提交 7637fd58 编写于 作者: B bors

Auto merge of #83503 - Dylan-DPC:rollup-mqvjfav, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #83055 ([rustdoc] Don't document stripped items in JSON renderer.)
 - #83437 (Refactor #82270 as lint instead of an error)
 - #83444 (Fix bootstrap tests on beta)
 - #83456 (Add docs for Vec::from functions)
 - #83463 (ExitStatusExt: Fix missing word in two docs messages)
 - #83470 (Fix patch note about #80653 not mentioning nested nor recursive)
 - #83485 (Mark asm tests as requiring LLVM 10.0.1)
 - #83486 (Don't ICE when using `#[global_alloc]` on a non-item statement)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
......@@ -1219,6 +1219,12 @@ dependencies = [
"rustc-std-workspace-core",
]
[[package]]
name = "fs-err"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcd1163ae48bda72a20ae26d66a04d3094135cadab911cff418ae5e33f253431"
[[package]]
name = "fs_extra"
version = "1.1.0"
......@@ -1748,6 +1754,7 @@ checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5"
name = "jsondocck"
version = "0.1.0"
dependencies = [
"fs-err",
"getopts",
"jsonpath_lib",
"lazy_static",
......
......@@ -87,7 +87,7 @@ Cargo
Rustdoc
-------
- [Rustdoc will now include documentation for methods available from `Deref` traits.][80653]
- [Rustdoc will now include documentation for methods available from _nested_ `Deref` traits.][80653]
- [You can now provide a `--default-theme` flag which sets the default theme to use for
documentation.][79642]
......
......@@ -7,11 +7,10 @@
use rustc_expand::base::{self, *};
use rustc_parse::parser::Parser;
use rustc_parse_format as parse;
use rustc_span::{
symbol::{kw, sym, Symbol},
BytePos,
};
use rustc_session::lint;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{InnerSpan, Span};
use rustc_target::asm::InlineAsmArch;
struct AsmArgs {
templates: Vec<P<ast::Expr>>,
......@@ -402,8 +401,6 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast
let mut line_spans = Vec::with_capacity(args.templates.len());
let mut curarg = 0;
let default_dialect = ecx.sess.inline_asm_dialect();
for template_expr in args.templates.into_iter() {
if !template.is_empty() {
template.push(ast::InlineAsmTemplatePiece::String("\n".to_string()));
......@@ -430,56 +427,36 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast
let template_str = &template_str.as_str();
let template_snippet = ecx.source_map().span_to_snippet(template_sp).ok();
if let Some(snippet) = &template_snippet {
let snippet = snippet.trim_matches('"');
match default_dialect {
ast::LlvmAsmDialect::Intel => {
if let Some(span) = check_syntax_directive(snippet, ".intel_syntax") {
let span = template_span.from_inner(span);
let mut err = ecx.struct_span_err(span, "intel syntax is the default syntax on this target, and trying to use this directive may cause issues");
err.span_suggestion(
span,
"remove this assembler directive",
"".to_string(),
Applicability::MachineApplicable,
);
err.emit();
}
if let Some(span) = check_syntax_directive(snippet, ".att_syntax") {
let span = template_span.from_inner(span);
let mut err = ecx.struct_span_err(span, "using the .att_syntax directive may cause issues, use the att_syntax option instead");
let asm_end = sp.hi() - BytePos(2);
let suggestions = vec![
(span, "".to_string()),
(
Span::new(asm_end, asm_end, sp.ctxt()),
", options(att_syntax)".to_string(),
),
];
err.multipart_suggestion(
"remove the assembler directive and replace it with options(att_syntax)",
suggestions,
Applicability::MachineApplicable,
);
err.emit();
if let Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) = ecx.sess.asm_arch {
let find_span = |needle: &str| -> Span {
if let Some(snippet) = &template_snippet {
if let Some(pos) = snippet.find(needle) {
let end = pos
+ &snippet[pos..]
.find(|c| matches!(c, '\n' | ';' | '\\' | '"'))
.unwrap_or(snippet[pos..].len() - 1);
let inner = InnerSpan::new(pos, end);
return template_sp.from_inner(inner);
}
}
ast::LlvmAsmDialect::Att => {
if let Some(span) = check_syntax_directive(snippet, ".att_syntax") {
let span = template_span.from_inner(span);
let mut err = ecx.struct_span_err(span, "att syntax is the default syntax on this target, and trying to use this directive may cause issues");
err.span_suggestion(
span,
"remove this assembler directive",
"".to_string(),
Applicability::MachineApplicable,
);
err.emit();
}
template_sp
};
// Use of .intel_syntax is ignored
}
if template_str.contains(".intel_syntax") {
ecx.parse_sess().buffer_lint(
lint::builtin::BAD_ASM_STYLE,
find_span(".intel_syntax"),
ecx.resolver.lint_node_id(ecx.current_expansion.id),
"avoid using `.intel_syntax`, Intel syntax is the default",
);
}
if template_str.contains(".att_syntax") {
ecx.parse_sess().buffer_lint(
lint::builtin::BAD_ASM_STYLE,
find_span(".att_syntax"),
ecx.resolver.lint_node_id(ecx.current_expansion.id),
"avoid using `.att_syntax`, prefer using `options(att_syntax)` instead",
);
}
}
......@@ -690,15 +667,3 @@ pub fn expand_asm<'cx>(
}
}
}
fn check_syntax_directive<S: AsRef<str>>(piece: S, syntax: &str) -> Option<InnerSpan> {
let piece = piece.as_ref();
if let Some(idx) = piece.find(syntax) {
let end =
idx + &piece[idx..].find(|c| matches!(c, '\n' | ';')).unwrap_or(piece[idx..].len());
// Offset by one because these represent the span with the " removed
Some(InnerSpan::new(idx + 1, end + 1))
} else {
None
}
}
......@@ -14,31 +14,31 @@ pub fn expand(
ecx: &mut ExtCtxt<'_>,
_span: Span,
meta_item: &ast::MetaItem,
mut item: Annotatable,
item: Annotatable,
) -> Vec<Annotatable> {
check_builtin_macro_attribute(ecx, meta_item, sym::global_allocator);
let not_static = |item: Annotatable| {
let orig_item = item.clone();
let not_static = || {
ecx.sess.parse_sess.span_diagnostic.span_err(item.span(), "allocators must be statics");
vec![item]
vec![orig_item.clone()]
};
let orig_item = item.clone();
let mut is_stmt = false;
// Allow using `#[global_allocator]` on an item statement
if let Annotatable::Stmt(stmt) = &item {
if let StmtKind::Item(item_) = &stmt.kind {
item = Annotatable::Item(item_.clone());
is_stmt = true;
}
}
let item = match item {
// FIXME - if we get deref patterns, use them to reduce duplication here
let (item, is_stmt) = match &item {
Annotatable::Item(item) => match item.kind {
ItemKind::Static(..) => item,
_ => return not_static(Annotatable::Item(item)),
ItemKind::Static(..) => (item, false),
_ => return not_static(),
},
Annotatable::Stmt(stmt) => match &stmt.kind {
StmtKind::Item(item_) => match item_.kind {
ItemKind::Static(..) => (item_, true),
_ => return not_static(),
},
_ => return not_static(),
},
_ => return not_static(item),
_ => return not_static(),
};
// Generate a bunch of new items using the AllocFnFactory
......
......@@ -2486,6 +2486,52 @@
"using only a subset of a register for inline asm inputs",
}
declare_lint! {
/// The `bad_asm_style` lint detects the use of the `.intel_syntax` and
/// `.att_syntax` directives.
///
/// ### Example
///
/// ```rust,ignore (fails on system llvm)
/// #![feature(asm)]
///
/// fn main() {
/// #[cfg(target_arch="x86_64")]
/// unsafe {
/// asm!(
/// ".att_syntax",
/// "movl {0}, {0}", in(reg) 0usize
/// );
/// }
/// }
/// ```
///
/// This will produce:
///
/// ```text
/// warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
/// --> test.rs:7:14
/// |
/// 7 | ".att_syntax",
/// | ^^^^^^^^^^^
/// 8 | "movq {0}, {0}", out(reg) _,
/// 9 | );
/// | - help: add option: `, options(att_syntax)`
/// |
/// = note: `#[warn(bad_asm_style)]` on by default
/// ```
///
/// ### Explanation
///
/// On x86, `asm!` uses the intel assembly syntax by default. While this
/// can be switched using assembler directives like `.att_syntax`, using the
/// `att_syntax` option is recomended instead because it will also properly
/// prefix register placeholders with `%` as required by AT&T syntax.
pub BAD_ASM_STYLE,
Warn,
"incorrect use of inline assembly",
}
declare_lint! {
/// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
/// functions without an explicit unsafe block.
......
......@@ -793,13 +793,6 @@ pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool {
}
}
pub fn inline_asm_dialect(&self) -> rustc_ast::LlvmAsmDialect {
match self.asm_arch {
Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) => rustc_ast::LlvmAsmDialect::Intel,
_ => rustc_ast::LlvmAsmDialect::Att,
}
}
pub fn relocation_model(&self) -> RelocModel {
self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model)
}
......
......@@ -2712,6 +2712,13 @@ fn as_mut(&mut self) -> &mut [T] {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Clone> From<&[T]> for Vec<T> {
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
///
/// # Examples
///
/// ```
/// assert_eq!(Vec::from(&[1, 2, 3][..]), vec![1, 2, 3]);
/// ```
#[cfg(not(test))]
fn from(s: &[T]) -> Vec<T> {
s.to_vec()
......@@ -2724,6 +2731,13 @@ fn from(s: &[T]) -> Vec<T> {
#[stable(feature = "vec_from_mut", since = "1.19.0")]
impl<T: Clone> From<&mut [T]> for Vec<T> {
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
///
/// # Examples
///
/// ```
/// assert_eq!(Vec::from(&mut [1, 2, 3][..]), vec![1, 2, 3]);
/// ```
#[cfg(not(test))]
fn from(s: &mut [T]) -> Vec<T> {
s.to_vec()
......@@ -2740,6 +2754,13 @@ fn from(s: &mut [T]) -> Vec<T> {
fn from(s: [T; N]) -> Vec<T> {
<[T]>::into_vec(box s)
}
/// Allocate a `Vec<T>` and move `s`'s items into it.
///
/// # Examples
///
/// ```
/// assert_eq!(Vec::from([1, 2, 3]), vec![1, 2, 3]);
/// ```
#[cfg(test)]
fn from(s: [T; N]) -> Vec<T> {
crate::slice::into_vec(box s)
......@@ -2751,6 +2772,20 @@ impl<'a, T> From<Cow<'a, [T]>> for Vec<T>
where
[T]: ToOwned<Owned = Vec<T>>,
{
/// Convert a clone-on-write slice into a vector.
///
/// If `s` already owns a `Vec<T>`, it will be returned directly.
/// If `s` is borrowing a slice, a new `Vec<T>` will be allocated and
/// filled by cloning `s`'s items into it.
///
/// # Examples
///
/// ```
/// # use std::borrow::Cow;
/// let o: Cow<[i32]> = Cow::Owned(vec![1, 2, 3]);
/// let b: Cow<[i32]> = Cow::Borrowed(&[1, 2, 3]);
/// assert_eq!(Vec::from(o), Vec::from(b));
/// ```
fn from(s: Cow<'a, [T]>) -> Vec<T> {
s.into_owned()
}
......@@ -2760,6 +2795,15 @@ fn from(s: Cow<'a, [T]>) -> Vec<T> {
#[cfg(not(test))]
#[stable(feature = "vec_from_box", since = "1.18.0")]
impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> {
/// Convert a boxed slice into a vector by transferring ownership of
/// the existing heap allocation.
///
/// # Examples
///
/// ```
/// let b: Box<[i32]> = vec![1, 2, 3].into_boxed_slice();
/// assert_eq!(Vec::from(b), vec![1, 2, 3]);
/// ```
fn from(s: Box<[T], A>) -> Self {
let len = s.len();
Self { buf: RawVec::from_box(s), len }
......@@ -2770,6 +2814,16 @@ fn from(s: Box<[T], A>) -> Self {
#[cfg(not(test))]
#[stable(feature = "box_from_vec", since = "1.20.0")]
impl<T, A: Allocator> From<Vec<T, A>> for Box<[T], A> {
/// Convert a vector into a boxed slice.
///
/// If `v` has excess capacity, its items will be moved into a
/// newly-allocated buffer with exactly the right capacity.
///
/// # Examples
///
/// ```
/// assert_eq!(Box::from(vec![1, 2, 3]), vec![1, 2, 3].into_boxed_slice());
/// ```
fn from(v: Vec<T, A>) -> Self {
v.into_boxed_slice()
}
......@@ -2777,6 +2831,13 @@ fn from(v: Vec<T, A>) -> Self {
#[stable(feature = "rust1", since = "1.0.0")]
impl From<&str> for Vec<u8> {
/// Allocate a `Vec<u8>` and fill it with a UTF-8 string.
///
/// # Examples
///
/// ```
/// assert_eq!(Vec::from("123"), vec![b'1', b'2', b'3']);
/// ```
fn from(s: &str) -> Vec<u8> {
From::from(s.as_bytes())
}
......
......@@ -227,14 +227,14 @@ pub trait ExitStatusExt: Sealed {
/// If the process was stopped by a signal, returns that signal.
///
/// In other words, if `WIFSTOPPED`, this returns `WSTOPSIG`. This is only possible if the status came from
/// a `wait` system call which was passed `WUNTRACED`, was then converted into an `ExitStatus`.
/// a `wait` system call which was passed `WUNTRACED`, and was then converted into an `ExitStatus`.
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
fn stopped_signal(&self) -> Option<i32>;
/// Whether the process was continued from a stopped status.
///
/// Ie, `WIFCONTINUED`. This is only possible if the status came from a `wait` system call
/// which was passed `WCONTINUED`, was then converted into an `ExitStatus`.
/// which was passed `WCONTINUED`, and was then converted into an `ExitStatus`.
#[unstable(feature = "unix_process_wait_more", issue = "80695")]
fn continued(&self) -> bool;
......
......@@ -585,8 +585,11 @@ fn test_docs() {
rustfix_coverage: false,
pass: None,
};
// Make sure rustfmt binary not being found isn't an error.
config.channel = "beta".to_string();
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]);
let a = TargetSelection::from_user("A");
......
......@@ -13,6 +13,11 @@
/// Gives a description of the renderer. Used for performance profiling.
fn descr() -> &'static str;
/// Whether to call `item` recursivly for modules
///
/// This is true for html, and false for json. See #80664
const RUN_ON_MODULE: bool;
/// Sets up any state required for the renderer. When this is called the cache has already been
/// populated.
fn init(
......@@ -68,7 +73,7 @@ fn after_krate(
let unknown = Symbol::intern("<unknown item>");
while let Some((mut cx, item)) = work.pop() {
if item.is_mod() {
if item.is_mod() && T::RUN_ON_MODULE {
// modules are special because they add a namespace. We also need to
// recurse into the items of the module as well.
let name = item.name.as_ref().unwrap().to_string();
......
......@@ -290,6 +290,8 @@ fn descr() -> &'static str {
"html"
}
const RUN_ON_MODULE: bool = true;
fn init(
mut krate: clean::Crate,
options: RenderOptions,
......
......@@ -198,7 +198,8 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>, name: &Option<Sy
bounds: g.into_iter().map(|x| x.into_tcx(tcx)).collect(),
default: t.map(|x| x.into_tcx(tcx)),
},
StrippedItem(inner) => from_clean_item_kind(*inner, tcx, name),
// `convert_item` early returns `None` for striped items
StrippedItem(_) => unreachable!(),
PrimitiveItem(_) | KeywordItem(_) => {
panic!("{:?} is not supported for JSON output", item)
}
......
......@@ -129,6 +129,8 @@ fn descr() -> &'static str {
"json"
}
const RUN_ON_MODULE: bool = false;
fn init(
krate: clean::Crate,
options: RenderOptions,
......@@ -169,8 +171,10 @@ fn item(&mut self, item: clean::Item) -> Result<(), Error> {
e.impls = self.get_impls(id)
}
let removed = self.index.borrow_mut().insert(from_def_id(id), new_item.clone());
// FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check
// to make sure the items are unique.
// to make sure the items are unique. The main place this happens is when an item, is
// reexported in more than one place. See `rustdoc-json/reexport/in_root_and_mod`
if let Some(old_item) = removed {
assert_eq!(old_item, new_item);
}
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target aarch64-unknown-linux-gnu
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target armv7-unknown-linux-gnueabihf
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target armv7-unknown-linux-gnueabihf
// compile-flags: -C target-feature=+neon
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon
......
// no-system-llvm
// min-llvm-version: 10.0.1
// revisions: mips32 mips64
// assembly-output: emit-asm
//[mips32] compile-flags: --target mips-unknown-linux-gnu
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target nvptx64-nvidia-cuda
// compile-flags: --crate-type cdylib
......
// no-system-llvm
// min-llvm-version: 10.0.1
// revisions: riscv64 riscv32
// assembly-output: emit-asm
//[riscv64] compile-flags: --target riscv64imac-unknown-none-elf
......
// no-system-llvm
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target wasm32-unknown-unknown
// compile-flags: --crate-type cdylib
......
// no-system-llvm
// min-llvm-version: 10.0.1
// revisions: x86_64 i686
// assembly-output: emit-asm
// compile-flags: -O
......
// no-system-llvm
// min-llvm-version: 10.0.1
// revisions: x86_64 i686
// assembly-output: emit-asm
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
......
//
// no-system-llvm
// min-llvm-version: 10.0.1
// compile-flags: -O
#![crate_type="lib"]
......
#![feature(no_core)]
#![no_core]
mod foo {
// @set foo_id = in_root_and_mod.json "$.index[*][?(@.name=='Foo')].id"
pub struct Foo;
}
// @has - "$.index[*][?(@.name=='in_root_and_mod')].inner.items[*]" $foo_id
pub use foo::Foo;
pub mod bar {
// @has - "$.index[*][?(@.name=='bar')].inner.items[*]" $foo_id
pub use crate::foo::Foo;
}
#![feature(no_core)]
#![no_core]
pub mod foo {
// @set bar_id = in_root_and_mod_pub.json "$.index[*][?(@.name=='Bar')].id"
// @has - "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id
pub struct Bar;
}
// @set root_import_id = - "$.index[*][?(@.inner.source=='foo::Bar')].id"
// @is - "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id
// @has - "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id
pub use foo::Bar;
pub mod baz {
// @set baz_import_id = - "$.index[*][?(@.inner.source=='crate::foo::Bar')].id"
// @is - "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id
// @has - "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id
pub use crate::foo::Bar;
}
// edition:2018
#![no_core]
#![feature(no_core)]
// @!has rename_private.json "$.index[*][?(@.name=='inner')]"
mod inner {
// @!has - "$.index[*][?(@.name=='Public')]"
pub struct Public;
}
// @set newname_id = - "$.index[*][?(@.name=='NewName')].id"
// @is - "$.index[*][?(@.name=='NewName')].kind" \"struct\"
// @has - "$.index[*][?(@.name=='rename_private')].inner.items[*]" $newname_id
pub use inner::Public as NewName;
// no-system-llvm
// min-llvm-version: 10.0.1
// only-x86_64
// run-pass
......
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues
--> $DIR/inline-syntax.rs:23:15
error: unknown directive
--> $DIR/inline-syntax.rs:22:15
|
LL | asm!(".intel_syntax noprefix", "nop");
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | .intel_syntax noprefix
| ^
error: unknown directive
--> $DIR/inline-syntax.rs:25:15
|
LL | asm!(".intel_syntax aaa noprefix", "nop");
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | .intel_syntax aaa noprefix
| ^
error: unknown directive
--> $DIR/inline-syntax.rs:28:15
|
LL | asm!(".att_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | .att_syntax noprefix
| ^
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues
--> $DIR/inline-syntax.rs:26:15
error: unknown directive
--> $DIR/inline-syntax.rs:31:15
|
LL | asm!(".att_syntax bbb noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | .att_syntax bbb noprefix
| ^
error: unknown directive
--> $DIR/inline-syntax.rs:34:15
|
LL | asm!(".intel_syntax noprefix; nop");
| ^
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | .intel_syntax noprefix; nop
| ^
error: unknown directive
--> $DIR/inline-syntax.rs:40:13
|
LL | .intel_syntax noprefix
| ^
|
note: instantiated into assembly here
--> <inline asm>:2:13
|
LL | .intel_syntax noprefix
| ^
error: aborting due to 2 previous errors
error: aborting due to 6 previous errors
// needs-llvm-components: arm
// revisions: x86_64 arm
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
//[x86_64] check-pass
//[arm] compile-flags: --target armv7-unknown-linux-gnueabihf
//[arm] build-fail
#![feature(no_core, lang_items, rustc_attrs)]
#![crate_type = "rlib"]
#![no_core]
#[rustc_builtin_macro]
......@@ -14,26 +17,30 @@
#[lang = "sized"]
trait Sized {}
fn main() {
pub fn main() {
unsafe {
asm!(".intel_syntax noprefix", "nop");
//[x86_64]~^ ERROR intel syntax is the default syntax on this target
//[x86_64]~^ WARN avoid using `.intel_syntax`
//[arm]~^^ ERROR unknown directive
asm!(".intel_syntax aaa noprefix", "nop");
//[x86_64]~^ ERROR intel syntax is the default syntax on this target
//[x86_64]~^ WARN avoid using `.intel_syntax`
//[arm]~^^ ERROR unknown directive
asm!(".att_syntax noprefix", "nop");
//[x86_64]~^ ERROR using the .att_syntax directive may cause issues
//[arm]~^^ att syntax is the default syntax on this target
//[x86_64]~^ WARN avoid using `.att_syntax`
//[arm]~^^ ERROR unknown directive
asm!(".att_syntax bbb noprefix", "nop");
//[x86_64]~^ ERROR using the .att_syntax directive may cause issues
//[arm]~^^ att syntax is the default syntax on this target
//[x86_64]~^ WARN avoid using `.att_syntax`
//[arm]~^^ ERROR unknown directive
asm!(".intel_syntax noprefix; nop");
//[x86_64]~^ ERROR intel syntax is the default syntax on this target
//[x86_64]~^ WARN avoid using `.intel_syntax`
//[arm]~^^ ERROR unknown directive
asm!(
r"
.intel_syntax noprefix
nop"
);
//[x86_64]~^^^ ERROR intel syntax is the default syntax on this target
//[x86_64]~^^^ WARN avoid using `.intel_syntax`
//[arm]~^^^^ ERROR unknown directive
}
}
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
--> $DIR/inline-syntax.rs:19:15
warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:22:15
|
LL | asm!(".intel_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(bad_asm_style)]` on by default
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
--> $DIR/inline-syntax.rs:21:15
warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:25:15
|
LL | asm!(".intel_syntax aaa noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: using the .att_syntax directive may cause issues, use the att_syntax option instead
--> $DIR/inline-syntax.rs:23:15
warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
--> $DIR/inline-syntax.rs:28:15
|
LL | asm!(".att_syntax noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^
|
help: remove the assembler directive and replace it with options(att_syntax)
|
LL | asm!("", "nop", options(att_syntax));
| -- ^^^^^^^^^^^^^^^^^^^^^
error: using the .att_syntax directive may cause issues, use the att_syntax option instead
--> $DIR/inline-syntax.rs:26:15
warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
--> $DIR/inline-syntax.rs:31:15
|
LL | asm!(".att_syntax bbb noprefix", "nop");
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove the assembler directive and replace it with options(att_syntax)
|
LL | asm!("", "nop", options(att_syntax));
| -- ^^^^^^^^^^^^^^^^^^^^^
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
--> $DIR/inline-syntax.rs:29:15
warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:34:15
|
LL | asm!(".intel_syntax noprefix; nop");
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
| ^^^^^^^^^^^^^^^^^^^^^^
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
--> $DIR/inline-syntax.rs:34:14
warning: avoid using `.intel_syntax`, Intel syntax is the default
--> $DIR/inline-syntax.rs:40:13
|
LL | .intel_syntax noprefix
| ______________^
LL | | nop"
| |_ help: remove this assembler directive
LL | .intel_syntax noprefix
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors
warning: 6 warnings emitted
// no-system-llvm
// min-llvm-version: 10.0.1
// only-x86_64
// build-fail
......
// no-system-llvm
// min-llvm-version: 10.0.1
// only-x86_64
// only-linux
// run-pass
......
// Regression test for issue #83469
// Ensures that we recover from `#[global_alloc]` on an invalid
// stmt without an ICE
fn outer() {
#[global_allocator]
fn inner() {} //~ ERROR allocators must be statics
}
fn main() {}
error: allocators must be statics
--> $DIR/issue-83469-global-alloc-invalid-stmt.rs:7:5
|
LL | fn inner() {}
| ^^^^^^^^^^^^^
error: aborting due to previous error
......@@ -12,3 +12,4 @@ lazy_static = "1.4"
shlex = "0.1"
serde = "1.0"
serde_json = "1.0"
fs-err = "2.5.0"
use crate::error::CkError;
use serde_json::Value;
use std::collections::HashMap;
use std::io;
use std::path::{Path, PathBuf};
use std::{fs, io};
use fs_err as fs;
#[derive(Debug)]
pub struct Cache {
......@@ -31,7 +33,11 @@ fn resolve_path(&mut self, path: &String) -> PathBuf {
self.last_path = Some(resolve.clone());
resolve
} else {
self.last_path.as_ref().unwrap().clone()
self.last_path
.as_ref()
// FIXME: Point to a line number
.expect("No last path set. Make sure to specify a full path before using `-`")
.clone()
}
}
......
......@@ -239,7 +239,20 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> {
let val = cache.get_value(&command.args[0])?;
let results = select(&val, &command.args[1]).unwrap();
let pat = string_to_value(&command.args[2], cache);
results.len() == 1 && results[0] == pat.as_ref()
let is = results.len() == 1 && results[0] == pat.as_ref();
if !command.negated && !is {
return Err(CkError::FailedCheck(
format!(
"{} matched to {:?}, but expected {:?}",
&command.args[1],
results,
pat.as_ref()
),
command,
));
} else {
is
}
}
CommandKind::Set => {
// @set <name> = <path> <jsonpath>
......@@ -299,7 +312,10 @@ fn check_command(command: Command, cache: &mut Cache) -> Result<(), CkError> {
fn string_to_value<'a>(s: &str, cache: &'a Cache) -> Cow<'a, Value> {
if s.starts_with("$") {
Cow::Borrowed(&cache.variables[&s[1..]])
Cow::Borrowed(&cache.variables.get(&s[1..]).unwrap_or_else(|| {
// FIXME(adotinthevoid): Show line number
panic!("No variable: `{}`. Current state: `{:?}`", &s[1..], cache.variables)
}))
} else {
Cow::Owned(serde_json::from_str(s).unwrap())
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册