From 24ce341185d929e0c3f14cce73ce7aac9ede0bf8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 2 Jun 2024 16:43:29 +0200 Subject: [PATCH 01/15] from_ref, from_mut: clarify domain of quantification --- library/core/src/ptr/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 8e3447d0b1b..f1a1b1a4149 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -777,8 +777,8 @@ where /// Convert a reference to a raw pointer. /// -/// This is equivalent to `r as *const T`, but is a bit safer since it will never silently change -/// type or mutability, in particular if the code is refactored. +/// For `r: &T`, `from_ref(r)` is equivalent to `r as *const T`, but is a bit safer since it will +/// never silently change type or mutability, in particular if the code is refactored. #[inline(always)] #[must_use] #[stable(feature = "ptr_from_ref", since = "1.76.0")] @@ -791,8 +791,8 @@ pub const fn from_ref(r: &T) -> *const T { /// Convert a mutable reference to a raw pointer. /// -/// This is equivalent to `r as *mut T`, but is a bit safer since it will never silently change -/// type or mutability, in particular if the code is refactored. +/// For `r: &mut T`, `from_mut(r)` is equivalent to `r as *mut T`, but is a bit safer since it will +/// never silently change type or mutability, in particular if the code is refactored. #[inline(always)] #[must_use] #[stable(feature = "ptr_from_ref", since = "1.76.0")] From 64e7337be596cb12aa8c7f593a1fe5d17ab089ca Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 4 Jun 2024 07:37:24 +0200 Subject: [PATCH 02/15] more explicitly state the basic rules of working with the obtained raw pointers --- library/core/src/ptr/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index f1a1b1a4149..c6af6617bab 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -779,6 +779,15 @@ where /// /// For `r: &T`, `from_ref(r)` is equivalent to `r as *const T`, but is a bit safer since it will /// never silently change type or mutability, in particular if the code is refactored. +/// +/// The caller must ensure that the pointee outlives the pointer this function returns, or else it +/// will end up pointing to garbage. +/// +/// The caller must also ensure that the memory the pointer (non-transitively) points to is never +/// written to (except inside an `UnsafeCell`) using this pointer or any pointer derived from it. If +/// you need to mutate the pointee, use [`from_mut`]`. Specifically, to turn a mutable reference `m: +/// &mut T` into `*const T`, prefer `from_mut(m).cast_const()` to obtain a pointer that can later be +/// used for mutation. #[inline(always)] #[must_use] #[stable(feature = "ptr_from_ref", since = "1.76.0")] @@ -791,6 +800,9 @@ pub const fn from_ref(r: &T) -> *const T { /// Convert a mutable reference to a raw pointer. /// +/// The caller must ensure that the pointee outlives the pointer this function returns, or else it +/// will end up pointing to garbage. +/// /// For `r: &mut T`, `from_mut(r)` is equivalent to `r as *mut T`, but is a bit safer since it will /// never silently change type or mutability, in particular if the code is refactored. #[inline(always)] From 05b7f282e8a883005237833f3bbc972072111e74 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 6 Jun 2024 08:04:34 +0200 Subject: [PATCH 03/15] less garbage, more examples --- library/alloc/src/vec/mod.rs | 4 +- library/core/src/ptr/mod.rs | 82 ++++++++++++++++++++++++++++++++--- library/core/src/slice/mod.rs | 4 +- 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index aa9b632cbed..7ecc8855dbc 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1276,7 +1276,7 @@ impl Vec { /// valid for zero sized reads if the vector didn't allocate. /// /// The caller must ensure that the vector outlives the pointer this - /// function returns, or else it will end up pointing to garbage. + /// function returns, or else it will end up dangling. /// Modifying the vector may cause its buffer to be reallocated, /// which would also make any pointers to it invalid. /// @@ -1336,7 +1336,7 @@ impl Vec { /// raw pointer valid for zero sized reads if the vector didn't allocate. /// /// The caller must ensure that the vector outlives the pointer this - /// function returns, or else it will end up pointing to garbage. + /// function returns, or else it will end up dangling. /// Modifying the vector may cause its buffer to be reallocated, /// which would also make any pointers to it invalid. /// diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index c6af6617bab..0a20b3c04c8 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -777,17 +777,51 @@ where /// Convert a reference to a raw pointer. /// -/// For `r: &T`, `from_ref(r)` is equivalent to `r as *const T`, but is a bit safer since it will -/// never silently change type or mutability, in particular if the code is refactored. +/// For `r: &T`, `from_ref(r)` is equivalent to `r as *const T` (except for the caveat noted below), +/// but is a bit safer since it will never silently change type or mutability, in particular if the +/// code is refactored. /// /// The caller must ensure that the pointee outlives the pointer this function returns, or else it -/// will end up pointing to garbage. +/// will end up dangling. /// /// The caller must also ensure that the memory the pointer (non-transitively) points to is never /// written to (except inside an `UnsafeCell`) using this pointer or any pointer derived from it. If /// you need to mutate the pointee, use [`from_mut`]`. Specifically, to turn a mutable reference `m: /// &mut T` into `*const T`, prefer `from_mut(m).cast_const()` to obtain a pointer that can later be /// used for mutation. +/// +/// ## Interaction with lifetime extension +/// +/// Note that this has subtle interactions with the rules for lifetime extension of temporaries in +/// tail expressions. This code is valid, albeit in a non-obvious way: +/// ```rust +/// # type T = i32; +/// # fn foo() -> T { 42 } +/// // The temporary holding the return value of `foo` has its lifetime extended, +/// // because the surrounding expression involves no function call. +/// let p = &foo() as *const T; +/// unsafe { p.read() }; +/// ``` +/// Naively replacing the cast with `from_ref` is not valid: +/// ```rust,no_run +/// # use std::ptr; +/// # type T = i32; +/// # fn foo() -> T { 42 } +/// // The temporary holding the return value of `foo` does *not* have its lifetime extended, +/// // because the surrounding expression involves no function call. +/// let p = ptr::from_ref(&foo()); +/// unsafe { p.read() }; // UB! Reading from a dangling pointer ⚠️ +/// ``` +/// The recommended way to write this code is to avoid relying on lifetime extension +/// when raw pointers are involved: +/// ```rust +/// # use std::ptr; +/// # type T = i32; +/// # fn foo() -> T { 42 } +/// let x = foo(); +/// let p = ptr::from_ref(&x); +/// unsafe { p.read() }; +/// ``` #[inline(always)] #[must_use] #[stable(feature = "ptr_from_ref", since = "1.76.0")] @@ -800,11 +834,45 @@ pub const fn from_ref(r: &T) -> *const T { /// Convert a mutable reference to a raw pointer. /// -/// The caller must ensure that the pointee outlives the pointer this function returns, or else it -/// will end up pointing to garbage. +/// For `r: &mut T`, `from_mut(r)` is equivalent to `r as *mut T` (except for the caveat noted +/// below), but is a bit safer since it will never silently change type or mutability, in particular +/// if the code is refactored. /// -/// For `r: &mut T`, `from_mut(r)` is equivalent to `r as *mut T`, but is a bit safer since it will -/// never silently change type or mutability, in particular if the code is refactored. +/// The caller must ensure that the pointee outlives the pointer this function returns, or else it +/// will end up dangling. +/// +/// ## Interaction with lifetime extension +/// +/// Note that this has subtle interactions with the rules for lifetime extension of temporaries in +/// tail expressions. This code is valid, albeit in a non-obvious way: +/// ```rust +/// # type T = i32; +/// # fn foo() -> T { 42 } +/// // The temporary holding the return value of `foo` has its lifetime extended, +/// // because the surrounding expression involves no function call. +/// let p = &mut foo() as *mut T; +/// unsafe { p.write(T::default()) }; +/// ``` +/// Naively replacing the cast with `from_mut` is not valid: +/// ```rust,no_run +/// # use std::ptr; +/// # type T = i32; +/// # fn foo() -> T { 42 } +/// // The temporary holding the return value of `foo` does *not* have its lifetime extended, +/// // because the surrounding expression involves no function call. +/// let p = ptr::from_mut(&mut foo()); +/// unsafe { p.write(T::default()) }; // UB! Writing to a dangling pointer ⚠️ +/// ``` +/// The recommended way to write this code is to avoid relying on lifetime extension +/// when raw pointers are involved: +/// ```rust +/// # use std::ptr; +/// # type T = i32; +/// # fn foo() -> T { 42 } +/// let mut x = foo(); +/// let p = ptr::from_mut(&mut x); +/// unsafe { p.write(T::default()) }; +/// ``` #[inline(always)] #[must_use] #[stable(feature = "ptr_from_ref", since = "1.76.0")] diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 503107c7480..8ada77c34b3 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -731,7 +731,7 @@ impl [T] { /// Returns a raw pointer to the slice's buffer. /// /// The caller must ensure that the slice outlives the pointer this - /// function returns, or else it will end up pointing to garbage. + /// function returns, or else it will end up dangling. /// /// The caller must also ensure that the memory the pointer (non-transitively) points to /// is never written to (except inside an `UnsafeCell`) using this pointer or any pointer @@ -766,7 +766,7 @@ impl [T] { /// Returns an unsafe mutable pointer to the slice's buffer. /// /// The caller must ensure that the slice outlives the pointer this - /// function returns, or else it will end up pointing to garbage. + /// function returns, or else it will end up dangling. /// /// Modifying the container referenced by this slice may cause its buffer /// to be reallocated, which would also make any pointers to it invalid. From d3858f7465a711852e162b42e7cb2a2a53cf1e83 Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 25 Jul 2024 10:05:31 +0200 Subject: [PATCH 04/15] improve error message when `global_asm!` uses `asm!` options --- compiler/rustc_ast/src/ast.rs | 5 ++ compiler/rustc_builtin_macros/messages.ftl | 4 ++ compiler/rustc_builtin_macros/src/asm.rs | 61 +++++++++++++------- compiler/rustc_builtin_macros/src/errors.rs | 11 ++++ compiler/rustc_parse/src/parser/mod.rs | 7 ++- compiler/rustc_passes/src/naked_functions.rs | 5 +- tests/ui/asm/parse-error.rs | 10 +++- tests/ui/asm/parse-error.stderr | 58 ++++++++++++------- tests/ui/asm/x86_64/bad-options.rs | 12 ++-- tests/ui/asm/x86_64/bad-options.stderr | 24 ++++---- 10 files changed, 128 insertions(+), 69 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 411fc8311a0..1c917651e27 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2265,6 +2265,11 @@ bitflags::bitflags! { } impl InlineAsmOptions { + pub const COUNT: usize = Self::all().bits().count_ones() as usize; + + pub const GLOBAL_OPTIONS: Self = Self::ATT_SYNTAX.union(Self::RAW); + pub const NAKED_OPTIONS: Self = Self::ATT_SYNTAX.union(Self::RAW).union(Self::NORETURN); + pub fn human_readable_names(&self) -> Vec<&'static str> { let mut options = vec![]; diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index b56bfa98357..876f3c2b135 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -199,6 +199,10 @@ builtin_macros_format_use_positional = consider using a positional formatting ar builtin_macros_global_asm_clobber_abi = `clobber_abi` cannot be used with `global_asm!` +builtin_macros_global_asm_unsupported_option = the `{$symbol}` option cannot be used with `global_asm!` + .label = the `{$symbol}` option is not meaningful for global-scoped inline assembly + .suggestion = remove this option + builtin_macros_invalid_crate_attribute = invalid crate attribute builtin_macros_multiple_default_attrs = multiple `#[default]` attributes diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index dd0f9aaf221..96fc40ed1eb 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -310,6 +310,16 @@ fn err_duplicate_option(p: &Parser<'_>, symbol: Symbol, span: Span) { p.dcx().emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span }); } +/// Report an invalid option error. +/// +/// This function must be called immediately after the option token is parsed. +/// Otherwise, the suggestion will be incorrect. +fn err_unsupported_option(p: &Parser<'_>, symbol: Symbol, span: Span) { + // Tool-only output + let full_span = if p.token.kind == token::Comma { span.to(p.token.span) } else { span }; + p.dcx().emit_err(errors::GlobalAsmUnsupportedOption { span, symbol, full_span }); +} + /// Try to set the provided option in the provided `AsmArgs`. /// If it is already set, report a duplicate option error. /// @@ -318,13 +328,16 @@ fn err_duplicate_option(p: &Parser<'_>, symbol: Symbol, span: Span) { fn try_set_option<'a>( p: &Parser<'a>, args: &mut AsmArgs, + is_global_asm: bool, symbol: Symbol, option: ast::InlineAsmOptions, ) { - if !args.options.contains(option) { - args.options |= option; - } else { + if is_global_asm && !ast::InlineAsmOptions::GLOBAL_OPTIONS.contains(option) { + err_unsupported_option(p, symbol, p.prev_token.span); + } else if args.options.contains(option) { err_duplicate_option(p, symbol, p.prev_token.span); + } else { + args.options |= option; } } @@ -338,25 +351,29 @@ fn parse_options<'a>( p.expect(&token::OpenDelim(Delimiter::Parenthesis))?; while !p.eat(&token::CloseDelim(Delimiter::Parenthesis)) { - if !is_global_asm && p.eat_keyword(sym::pure) { - try_set_option(p, args, sym::pure, ast::InlineAsmOptions::PURE); - } else if !is_global_asm && p.eat_keyword(sym::nomem) { - try_set_option(p, args, sym::nomem, ast::InlineAsmOptions::NOMEM); - } else if !is_global_asm && p.eat_keyword(sym::readonly) { - try_set_option(p, args, sym::readonly, ast::InlineAsmOptions::READONLY); - } else if !is_global_asm && p.eat_keyword(sym::preserves_flags) { - try_set_option(p, args, sym::preserves_flags, ast::InlineAsmOptions::PRESERVES_FLAGS); - } else if !is_global_asm && p.eat_keyword(sym::noreturn) { - try_set_option(p, args, sym::noreturn, ast::InlineAsmOptions::NORETURN); - } else if !is_global_asm && p.eat_keyword(sym::nostack) { - try_set_option(p, args, sym::nostack, ast::InlineAsmOptions::NOSTACK); - } else if !is_global_asm && p.eat_keyword(sym::may_unwind) { - try_set_option(p, args, kw::Raw, ast::InlineAsmOptions::MAY_UNWIND); - } else if p.eat_keyword(sym::att_syntax) { - try_set_option(p, args, sym::att_syntax, ast::InlineAsmOptions::ATT_SYNTAX); - } else if p.eat_keyword(kw::Raw) { - try_set_option(p, args, kw::Raw, ast::InlineAsmOptions::RAW); - } else { + const OPTIONS: [(Symbol, ast::InlineAsmOptions); ast::InlineAsmOptions::COUNT] = [ + (sym::pure, ast::InlineAsmOptions::PURE), + (sym::nomem, ast::InlineAsmOptions::NOMEM), + (sym::readonly, ast::InlineAsmOptions::READONLY), + (sym::preserves_flags, ast::InlineAsmOptions::PRESERVES_FLAGS), + (sym::noreturn, ast::InlineAsmOptions::NORETURN), + (sym::nostack, ast::InlineAsmOptions::NOSTACK), + (sym::may_unwind, ast::InlineAsmOptions::MAY_UNWIND), + (sym::att_syntax, ast::InlineAsmOptions::ATT_SYNTAX), + (kw::Raw, ast::InlineAsmOptions::RAW), + ]; + + 'blk: { + for (symbol, option) in OPTIONS { + let expect = + !is_global_asm || ast::InlineAsmOptions::GLOBAL_OPTIONS.contains(option); + + if if expect { p.eat_keyword(symbol) } else { p.eat_keyword_noexpect(symbol) } { + try_set_option(p, args, is_global_asm, symbol, option); + break 'blk; + } + } + return p.unexpected(); } diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index 49d640436c2..2e6bdae14a8 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -845,6 +845,17 @@ pub(crate) struct AsmOptAlreadyprovided { pub(crate) full_span: Span, } +#[derive(Diagnostic)] +#[diag(builtin_macros_global_asm_unsupported_option)] +pub(crate) struct GlobalAsmUnsupportedOption { + #[primary_span] + #[label] + pub(crate) span: Span, + pub(crate) symbol: Symbol, + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] + pub(crate) full_span: Span, +} + #[derive(Diagnostic)] #[diag(builtin_macros_test_runner_invalid)] pub(crate) struct TestRunnerInvalid { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 7326b9ec51f..e7240869a39 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -599,7 +599,7 @@ impl<'a> Parser<'a> { /// If the next token is the given keyword, eats it and returns `true`. /// Otherwise, returns `false`. An expectation is also added for diagnostics purposes. - // Public for rustfmt usage. + // Public for rustc_builtin_macros and rustfmt usage. #[inline] pub fn eat_keyword(&mut self, kw: Symbol) -> bool { if self.check_keyword(kw) { @@ -631,8 +631,11 @@ impl<'a> Parser<'a> { false } + /// If the next token is the given keyword, eats it and returns `true`. + /// Otherwise, returns `false`. No expectation is added. + // Public for rustc_builtin_macros usage. #[inline] - fn eat_keyword_noexpect(&mut self, kw: Symbol) -> bool { + pub fn eat_keyword_noexpect(&mut self, kw: Symbol) -> bool { if self.token.is_keyword(kw) { self.bump(); true diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index dbbf802c920..4c5089b8676 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -244,10 +244,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> { self.tcx.dcx().emit_err(NakedFunctionsOperands { unsupported_operands }); } - let supported_options = - InlineAsmOptions::RAW | InlineAsmOptions::NORETURN | InlineAsmOptions::ATT_SYNTAX; - let unsupported_options = asm.options.difference(supported_options); - + let unsupported_options = asm.options.difference(InlineAsmOptions::NAKED_OPTIONS); if !unsupported_options.is_empty() { self.tcx.dcx().emit_err(NakedFunctionsAsmOptions { span, diff --git a/tests/ui/asm/parse-error.rs b/tests/ui/asm/parse-error.rs index a0251c6763b..9dec3a1c394 100644 --- a/tests/ui/asm/parse-error.rs +++ b/tests/ui/asm/parse-error.rs @@ -111,11 +111,15 @@ global_asm!("{}", const); global_asm!("{}", const(reg) FOO); //~^ ERROR expected one of global_asm!("", options(FOO)); -//~^ ERROR expected one of +//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` +global_asm!("", options(FOO,)); +//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` global_asm!("", options(nomem FOO)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR expected one of `)` or `,`, found `FOO` global_asm!("", options(nomem, FOO)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` global_asm!("{}", options(), const FOO); global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr index 1999cd09aa3..e9ecd712bc3 100644 --- a/tests/ui/asm/parse-error.stderr +++ b/tests/ui/asm/parse-error.stderr @@ -264,62 +264,80 @@ error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` --> $DIR/parse-error.rs:115:25 | -LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` +LL | global_asm!("", options(FOO,)); + | ^^^ expected one of `)`, `att_syntax`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/parse-error.rs:117:25 | +LL | global_asm!("", options(nomem FOO)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: expected one of `)` or `,`, found `FOO` + --> $DIR/parse-error.rs:117:31 + | +LL | global_asm!("", options(nomem FOO)); + | ^^^ expected one of `)` or `,` + +error: the `nomem` option cannot be used with `global_asm!` + --> $DIR/parse-error.rs:120:25 + | LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` + --> $DIR/parse-error.rs:120:32 + | +LL | global_asm!("", options(nomem, FOO)); + | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected string literal - --> $DIR/parse-error.rs:120:29 + --> $DIR/parse-error.rs:124:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:122:33 + --> $DIR/parse-error.rs:126:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:124:34 + --> $DIR/parse-error.rs:128:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:126:19 + --> $DIR/parse-error.rs:130:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:128:28 + --> $DIR/parse-error.rs:132:28 | LL | global_asm!("", options(), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:130:30 + --> $DIR/parse-error.rs:134:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:132:17 + --> $DIR/parse-error.rs:136:17 | LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:134:35 + --> $DIR/parse-error.rs:138:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -327,7 +345,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:134:35 + --> $DIR/parse-error.rs:138:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -335,19 +353,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:137:28 + --> $DIR/parse-error.rs:141:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:139:30 + --> $DIR/parse-error.rs:143:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:141:13 + --> $DIR/parse-error.rs:145:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ @@ -355,7 +373,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:143:20 + --> $DIR/parse-error.rs:147:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ @@ -363,7 +381,7 @@ LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:145:19 + --> $DIR/parse-error.rs:149:19 | LL | global_asm!("{}", label {}); | ^^^^^^^^ expected operand, options, or additional template string @@ -423,6 +441,6 @@ help: consider using `const` instead of `let` LL | const bar: /* Type */ = 0; | ~~~~~ ++++++++++++ -error: aborting due to 64 previous errors +error: aborting due to 67 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/x86_64/bad-options.rs b/tests/ui/asm/x86_64/bad-options.rs index f9cc13cfc5a..6424a1b1d42 100644 --- a/tests/ui/asm/x86_64/bad-options.rs +++ b/tests/ui/asm/x86_64/bad-options.rs @@ -33,14 +33,14 @@ fn main() { } global_asm!("", options(nomem)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("", options(readonly)); -//~^ ERROR expected one of +//~^ ERROR the `readonly` option cannot be used with `global_asm!` global_asm!("", options(noreturn)); -//~^ ERROR expected one of +//~^ ERROR the `noreturn` option cannot be used with `global_asm!` global_asm!("", options(pure)); -//~^ ERROR expected one of +//~^ ERROR the `pure` option cannot be used with `global_asm!` global_asm!("", options(nostack)); -//~^ ERROR expected one of +//~^ ERROR the `nostack` option cannot be used with `global_asm!` global_asm!("", options(preserves_flags)); -//~^ ERROR expected one of +//~^ ERROR the `preserves_flags` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/x86_64/bad-options.stderr b/tests/ui/asm/x86_64/bad-options.stderr index aa167e7913c..366eb7cb90f 100644 --- a/tests/ui/asm/x86_64/bad-options.stderr +++ b/tests/ui/asm/x86_64/bad-options.stderr @@ -51,41 +51,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C"), clobber_abi("C")); | | clobber_abi | generic outputs -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:35:25 | LL | global_asm!("", options(nomem)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `readonly` +error: the `readonly` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:37:25 | LL | global_asm!("", options(readonly)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn` +error: the `noreturn` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:39:25 | LL | global_asm!("", options(noreturn)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `pure` +error: the `pure` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:41:25 | LL | global_asm!("", options(pure)); - | ^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^ the `pure` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `nostack` +error: the `nostack` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:43:25 | LL | global_asm!("", options(nostack)); - | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` +error: the `preserves_flags` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:45:25 | LL | global_asm!("", options(preserves_flags)); - | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly error: invalid ABI for `clobber_abi` --> $DIR/bad-options.rs:24:18 From 73fde1701762e82227cd9fe588b06ee15719d252 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 26 Jul 2024 00:08:22 +0200 Subject: [PATCH 05/15] refactor the `if if` --- compiler/rustc_builtin_macros/src/asm.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 96fc40ed1eb..218529b9ed7 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -365,10 +365,14 @@ fn parse_options<'a>( 'blk: { for (symbol, option) in OPTIONS { - let expect = - !is_global_asm || ast::InlineAsmOptions::GLOBAL_OPTIONS.contains(option); + let kw_matched = + if !is_global_asm || ast::InlineAsmOptions::GLOBAL_OPTIONS.contains(option) { + p.eat_keyword(symbol) + } else { + p.eat_keyword_noexpect(symbol) + }; - if if expect { p.eat_keyword(symbol) } else { p.eat_keyword_noexpect(symbol) } { + if kw_matched { try_set_option(p, args, is_global_asm, symbol, option); break 'blk; } From 8859da0bf2f1f3d447ce1939647e88a0302afb99 Mon Sep 17 00:00:00 2001 From: Folkert Date: Fri, 26 Jul 2024 00:20:59 +0200 Subject: [PATCH 06/15] add `run-rustfix` test for machine-applicable suggestion --- tests/ui/asm/unsupported-option.fixed | 10 ++++++++++ tests/ui/asm/unsupported-option.rs | 10 ++++++++++ tests/ui/asm/unsupported-option.stderr | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/ui/asm/unsupported-option.fixed create mode 100644 tests/ui/asm/unsupported-option.rs create mode 100644 tests/ui/asm/unsupported-option.stderr diff --git a/tests/ui/asm/unsupported-option.fixed b/tests/ui/asm/unsupported-option.fixed new file mode 100644 index 00000000000..c2ff13bbc55 --- /dev/null +++ b/tests/ui/asm/unsupported-option.fixed @@ -0,0 +1,10 @@ +//@ run-rustfix + +use std::arch::global_asm; + +fn main() {} + +global_asm!("", options(att_syntax, raw)); +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR the `readonly` option cannot be used with `global_asm!` +//~| ERROR the `noreturn` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/unsupported-option.rs b/tests/ui/asm/unsupported-option.rs new file mode 100644 index 00000000000..672aedf230c --- /dev/null +++ b/tests/ui/asm/unsupported-option.rs @@ -0,0 +1,10 @@ +//@ run-rustfix + +use std::arch::global_asm; + +fn main() {} + +global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR the `readonly` option cannot be used with `global_asm!` +//~| ERROR the `noreturn` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/unsupported-option.stderr b/tests/ui/asm/unsupported-option.stderr new file mode 100644 index 00000000000..c040b0364d7 --- /dev/null +++ b/tests/ui/asm/unsupported-option.stderr @@ -0,0 +1,20 @@ +error: the `nomem` option cannot be used with `global_asm!` + --> $DIR/unsupported-option.rs:7:37 + | +LL | global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: the `readonly` option cannot be used with `global_asm!` + --> $DIR/unsupported-option.rs:7:44 + | +LL | global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly + +error: the `noreturn` option cannot be used with `global_asm!` + --> $DIR/unsupported-option.rs:7:54 + | +LL | global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly + +error: aborting due to 3 previous errors + From e7eae5370e304fb1534c1964852a6c127f1f09f8 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 26 Jul 2024 13:56:02 -0400 Subject: [PATCH 07/15] Remove logic to suggest clone of function output --- .../src/diagnostics/conflict_errors.rs | 31 ------------------- .../associated-types-outlives.stderr | 10 ++++-- tests/ui/variance/variance-issue-20533.stderr | 10 ++++-- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 2d9bc45ebc8..a5635344b4a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1306,37 +1306,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { // result of `foo(...)` won't help. break 'outer; } - - // We're suggesting `.clone()` on an borrowed value. See if the expression we have - // is an argument to a function or method call, and try to suggest cloning the - // *result* of the call, instead of the argument. This is closest to what people - // would actually be looking for in most cases, with maybe the exception of things - // like `fn(T) -> T`, but even then it is reasonable. - let typeck_results = self.infcx.tcx.typeck(self.mir_def_id()); - let mut prev = expr; - while let hir::Node::Expr(parent) = self.infcx.tcx.parent_hir_node(prev.hir_id) { - if let hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) = parent.kind - && let Some(call_ty) = typeck_results.node_type_opt(parent.hir_id) - && let call_ty = call_ty.peel_refs() - && (!call_ty - .walk() - .any(|t| matches!(t.unpack(), ty::GenericArgKind::Lifetime(_))) - || if let ty::Alias(ty::Projection, _) = call_ty.kind() { - // FIXME: this isn't quite right with lifetimes on assoc types, - // but ignore for now. We will only suggest cloning if - // `::Assoc: Clone`, which should keep false positives - // down to a managable ammount. - true - } else { - false - }) - && self.implements_clone(call_ty) - && self.suggest_cloning_inner(err, call_ty, parent) - { - return; - } - prev = parent; - } } } let ty = ty.peel_refs(); diff --git a/tests/ui/associated-types/associated-types-outlives.stderr b/tests/ui/associated-types/associated-types-outlives.stderr index c97af672c33..1164869bf19 100644 --- a/tests/ui/associated-types/associated-types-outlives.stderr +++ b/tests/ui/associated-types/associated-types-outlives.stderr @@ -11,10 +11,14 @@ LL | drop(x); LL | return f(y); | - borrow later used here | -help: consider cloning the value if the performance cost is acceptable +help: if `T` implemented `Clone`, you could clone the value + --> $DIR/associated-types-outlives.rs:17:21 | -LL | 's: loop { y = denormalise(&x).clone(); break } - | ++++++++ +LL | pub fn free_and_use Foo<'a>, + | ^ consider constraining this type parameter with `Clone` +... +LL | 's: loop { y = denormalise(&x); break } + | -- you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/variance/variance-issue-20533.stderr b/tests/ui/variance/variance-issue-20533.stderr index 03cada07a9e..0a810b7222e 100644 --- a/tests/ui/variance/variance-issue-20533.stderr +++ b/tests/ui/variance/variance-issue-20533.stderr @@ -73,10 +73,14 @@ LL | drop(a); LL | drop(x); | - borrow later used here | -help: consider cloning the value if the performance cost is acceptable +note: if `AffineU32` implemented `Clone`, you could clone the value + --> $DIR/variance-issue-20533.rs:26:1 | -LL | let x = bat(&a).clone(); - | ++++++++ +LL | struct AffineU32(u32); + | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = bat(&a); + | -- you could clone this value error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:59:14 From 50d127e6ecb83f267fe35321eb14e536b959bb1d Mon Sep 17 00:00:00 2001 From: Rain Date: Sat, 27 Jul 2024 02:06:58 +0000 Subject: [PATCH 08/15] [illumos/solaris] set MSG_NOSIGNAL while writing to sockets Both these platforms have MSG_NOSIGNAL available, and we should set it for socket writes in the event that the SIGPIPE handler has been reset to SIG_DFL (i.e. terminate the process). I've verified via a quick program at https://github.com/sunshowers/msg-nosignal-test/ that even when the SIGPIPE handler is reset to SIG_DFL, writes to closed sockets now error out with EPIPE. (Under ordinary circumstances UDP writes won't cause MSG_NOSIGNAL.) --- library/std/src/os/unix/net/datagram.rs | 4 ++++ library/std/src/sys_common/net.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/library/std/src/os/unix/net/datagram.rs b/library/std/src/os/unix/net/datagram.rs index b29f9099a11..f58f9b4d9ab 100644 --- a/library/std/src/os/unix/net/datagram.rs +++ b/library/std/src/os/unix/net/datagram.rs @@ -20,6 +20,8 @@ use crate::{fmt, io}; target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", + target_os = "solaris", + target_os = "illumos", target_os = "haiku", target_os = "nto", ))] @@ -31,6 +33,8 @@ use libc::MSG_NOSIGNAL; target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", + target_os = "solaris", + target_os = "illumos", target_os = "haiku", target_os = "nto", )))] diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index 95ca67fc2e0..0a82b50ae1a 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -42,6 +42,7 @@ cfg_if::cfg_if! { target_os = "hurd", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", + target_os = "solaris", target_os = "illumos", target_os = "haiku", target_os = "nto"))] { use libc::MSG_NOSIGNAL; } else { From 9aed3843f2496f9cc8120560eb0da0c8db4588a3 Mon Sep 17 00:00:00 2001 From: DianQK Date: Sat, 27 Jul 2024 14:04:24 +0800 Subject: [PATCH 09/15] Delete `SimplifyArmIdentity` and `SimplifyBranchSame` tests --- tests/codegen/try_identity.rs | 34 ------ ...mplify_arm.id_try.SimplifyArmIdentity.diff | 89 --------------- ...implify_arm.id_try.SimplifyBranchSame.diff | 89 --------------- tests/mir-opt/simplify_arm.rs | 50 --------- tests/mir-opt/simplify_arm_identity.rs | 26 ----- tests/mir-opt/simplify_try_if_let.rs | 44 -------- ...t.{impl#0}-append.SimplifyArmIdentity.diff | 104 ------------------ 7 files changed, 436 deletions(-) delete mode 100644 tests/codegen/try_identity.rs delete mode 100644 tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff delete mode 100644 tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff delete mode 100644 tests/mir-opt/simplify_arm.rs delete mode 100644 tests/mir-opt/simplify_arm_identity.rs delete mode 100644 tests/mir-opt/simplify_try_if_let.rs delete mode 100644 tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff diff --git a/tests/codegen/try_identity.rs b/tests/codegen/try_identity.rs deleted file mode 100644 index 6a3a8a06e82..00000000000 --- a/tests/codegen/try_identity.rs +++ /dev/null @@ -1,34 +0,0 @@ -//@ compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts - -// Ensure that `x?` has no overhead on `Result` due to identity `match`es in lowering. -// This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`. - -#![crate_type = "lib"] - -type R = Result; - -// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, -// so the relevant desugar is copied inline in order to keep the test testing the same thing. -// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR -// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. -#[no_mangle] -pub fn try_identity(x: R) -> R { - // CHECK: start: - // FIXME(JakobDegen): Broken by deaggregation change CHECK-NOT\: br {{.*}} - // CHECK ret void - let y = match into_result(x) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(y) -} - -#[inline] -fn into_result(r: Result) -> Result { - r -} - -#[inline] -fn from_error(e: E) -> Result { - Err(e) -} diff --git a/tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff deleted file mode 100644 index cff9afc38f0..00000000000 --- a/tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ /dev/null @@ -1,89 +0,0 @@ -- // MIR for `id_try` before SimplifyArmIdentity -+ // MIR for `id_try` after SimplifyArmIdentity - - fn id_try(_1: Result) -> Result { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:+0:11: +0:12 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:+0:34: +0:49 - let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:48: +2:49 - let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:+5:8: +5:9 - scope 1 { - debug x => _2; // in scope 1 at $DIR/simplify-arm.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:+2:13: +2:14 - scope 5 (inlined >::from) { // at $DIR/simplify-arm.rs:37:37: 37:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::) { // at $DIR/simplify-arm.rs:37:26: 37:51 - debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:27:21: 27:22 - } - } - scope 3 { - debug v => _10; // in scope 3 at $DIR/simplify-arm.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify-arm.rs:36:19: 36:33 - debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:23:22: 23:23 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _4 = _1; // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _3 = move _4; // scope 4 at $DIR/simplify-arm.rs:24:5: 24:6 - StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:+1:13: +1:33 - } - - bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _2 = _10; // scope 3 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_10); // scope 0 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageLive(_11); // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - _11 = _2; // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _9 = _6; // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:+2:49: +2:50 - ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify-arm.rs:28:9: 28:10 - Deinit(_0); // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff deleted file mode 100644 index 9d38b93508c..00000000000 --- a/tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ /dev/null @@ -1,89 +0,0 @@ -- // MIR for `id_try` before SimplifyBranchSame -+ // MIR for `id_try` after SimplifyBranchSame - - fn id_try(_1: Result) -> Result { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:+0:11: +0:12 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:+0:34: +0:49 - let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:48: +2:49 - let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:+5:8: +5:9 - scope 1 { - debug x => _2; // in scope 1 at $DIR/simplify-arm.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:+2:13: +2:14 - scope 5 (inlined >::from) { // at $DIR/simplify-arm.rs:37:37: 37:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::) { // at $DIR/simplify-arm.rs:37:26: 37:51 - debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:27:21: 27:22 - } - } - scope 3 { - debug v => _10; // in scope 3 at $DIR/simplify-arm.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify-arm.rs:36:19: 36:33 - debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:23:22: 23:23 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _4 = _1; // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _3 = move _4; // scope 4 at $DIR/simplify-arm.rs:24:5: 24:6 - StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:+1:13: +1:33 - } - - bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _2 = _10; // scope 3 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_10); // scope 0 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageLive(_11); // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - _11 = _2; // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _9 = _6; // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:+2:49: +2:50 - ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify-arm.rs:28:9: 28:10 - Deinit(_0); // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/simplify_arm.rs b/tests/mir-opt/simplify_arm.rs deleted file mode 100644 index 5d9c31121dd..00000000000 --- a/tests/mir-opt/simplify_arm.rs +++ /dev/null @@ -1,50 +0,0 @@ -// skip-filecheck -//@ compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts -// EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff - -//@ ignore-test This pass is broken since deaggregation changed - -fn id(o: Option) -> Option { - match o { - Some(v) => Some(v), - None => None, - } -} - -fn id_result(r: Result) -> Result { - match r { - Ok(x) => Ok(x), - Err(y) => Err(y), - } -} - -fn into_result(r: Result) -> Result { - r -} - -fn from_error(e: E) -> Result { - Err(e) -} - -// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, -// so the relevant desugar is copied inline in order to keep the test testing the same thing. -// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR -// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. -fn id_try(r: Result) -> Result { - let x = match into_result(r) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(x) -} - -fn main() { - id(None); - id_result(Ok(4)); - id_try(Ok(4)); -} diff --git a/tests/mir-opt/simplify_arm_identity.rs b/tests/mir-opt/simplify_arm_identity.rs deleted file mode 100644 index 79395b312ac..00000000000 --- a/tests/mir-opt/simplify_arm_identity.rs +++ /dev/null @@ -1,26 +0,0 @@ -// skip-filecheck -// Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts. -// Regression test for issue #66856. -// -//@ compile-flags: -Zmir-opt-level=3 -// EMIT_MIR_FOR_EACH_BIT_WIDTH - -//@ ignore-test This pass is broken since deaggregation changed - -enum Src { - Foo(u8), - Bar, -} - -enum Dst { - Foo(u8), -} - -// EMIT_MIR simplify_arm_identity.main.SimplifyArmIdentity.diff -fn main() { - let e: Src = Src::Foo(0); - let _: Dst = match e { - Src::Foo(x) => Dst::Foo(x), - Src::Bar => Dst::Foo(0), - }; -} diff --git a/tests/mir-opt/simplify_try_if_let.rs b/tests/mir-opt/simplify_try_if_let.rs deleted file mode 100644 index 98df9a54abb..00000000000 --- a/tests/mir-opt/simplify_try_if_let.rs +++ /dev/null @@ -1,44 +0,0 @@ -// skip-filecheck -//@ compile-flags: -Zmir-opt-level=1 -Zunsound-mir-opts -//@ ignore-test -// FIXME: the pass is unsound and causes ICEs in the MIR validator - -// EMIT_MIR simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff - -use std::ptr::NonNull; - -pub struct LinkedList { - head: Option>, - tail: Option>, -} - -pub struct Node { - next: Option>, -} - -impl LinkedList { - pub fn new() -> Self { - Self { head: None, tail: None } - } - - pub fn append(&mut self, other: &mut Self) { - match self.tail { - None => {} - Some(mut tail) => { - // `as_mut` is okay here because we have exclusive access to the entirety - // of both lists. - if let Some(other_head) = other.head.take() { - unsafe { - tail.as_mut().next = Some(other_head); - } - } - } - } - } -} - -fn main() { - let mut one = LinkedList::new(); - let mut two = LinkedList::new(); - one.append(&mut two); -} diff --git a/tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff b/tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff deleted file mode 100644 index 11f6b533741..00000000000 --- a/tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff +++ /dev/null @@ -1,104 +0,0 @@ -- // MIR for `::append` before SimplifyArmIdentity -+ // MIR for `::append` after SimplifyArmIdentity - - fn ::append(_1: &mut LinkedList, _2: &mut LinkedList) -> () { - debug self => _1; // in scope 0 at $DIR/simplify_try_if_let.rs:20:19: 20:28 - debug other => _2; // in scope 0 at $DIR/simplify_try_if_let.rs:20:30: 20:35 - let mut _0: (); // return place in scope 0 at $DIR/simplify_try_if_let.rs:20:48: 20:48 - let mut _3: isize; // in scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17 - let mut _4: std::ptr::NonNull; // in scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - let mut _5: std::option::Option>; // in scope 0 at $DIR/simplify_try_if_let.rs:26:43: 26:60 - let mut _6: &mut std::option::Option>; // in scope 0 at $DIR/simplify_try_if_let.rs:26:43: 26:53 - let mut _7: isize; // in scope 0 at $DIR/simplify_try_if_let.rs:26:24: 26:40 - let mut _9: std::option::Option>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:46: 28:62 - let mut _10: std::ptr::NonNull; // in scope 0 at $DIR/simplify_try_if_let.rs:28:51: 28:61 - let mut _11: &mut Node; // in scope 0 at $DIR/simplify_try_if_let.rs:28:25: 28:38 - let mut _12: &mut std::ptr::NonNull; // in scope 0 at $DIR/simplify_try_if_let.rs:28:25: 28:29 - scope 1 { - debug tail => _4; // in scope 1 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - let _8: std::ptr::NonNull; // in scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - scope 2 { -- debug other_head => _8; // in scope 2 at $DIR/simplify_try_if_let.rs:26:29: 26:39 -+ debug other_head => ((_9 as Some).0: std::ptr::NonNull); // in scope 2 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - scope 3 { - } - } - } - - bb0: { - _3 = discriminant(((*_1).1: std::option::Option>)); // scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17 - switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17 - } - - bb1: { - StorageLive(_4); // scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - _4 = ((((*_1).1: std::option::Option>) as Some).0: std::ptr::NonNull); // scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - StorageLive(_5); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:60 - StorageLive(_6); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:53 - _6 = &mut ((*_2).0: std::option::Option>); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:53 - _5 = Option::>::take(move _6) -> bb4; // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:60 - // mir::Constant - // + span: $DIR/simplify_try_if_let.rs:26:54: 26:58 - // + literal: Const { ty: for<'r> fn(&'r mut std::option::Option>) -> std::option::Option> {std::option::Option::>::take}, val: Value(Scalar()) } - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify_try_if_let.rs:21:15: 21:24 - } - - bb3: { - _0 = const (); // scope 0 at $DIR/simplify_try_if_let.rs:22:21: 22:24 - goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10 - } - - bb4: { - StorageDead(_6); // scope 1 at $DIR/simplify_try_if_let.rs:26:59: 26:60 - _7 = discriminant(_5); // scope 1 at $DIR/simplify_try_if_let.rs:26:24: 26:40 - switchInt(move _7) -> [1_isize: bb6, otherwise: bb5]; // scope 1 at $DIR/simplify_try_if_let.rs:26:24: 26:40 - } - - bb5: { - _0 = const (); // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18 - goto -> bb8; // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18 - } - - bb6: { - StorageLive(_8); // scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - _8 = ((_5 as Some).0: std::ptr::NonNull); // scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - StorageLive(_9); // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 -- StorageLive(_10); // scope 3 at $DIR/simplify_try_if_let.rs:28:51: 28:61 -- _10 = _8; // scope 3 at $DIR/simplify_try_if_let.rs:28:51: 28:61 -- ((_9 as Some).0: std::ptr::NonNull) = move _10; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 -- discriminant(_9) = 1; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 -- StorageDead(_10); // scope 3 at $DIR/simplify_try_if_let.rs:28:61: 28:62 -+ _9 = move _5; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 - StorageLive(_11); // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:38 - StorageLive(_12); // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:29 - _12 = &mut _4; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:29 - _11 = NonNull::::as_mut(move _12) -> bb7; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:38 - // mir::Constant - // + span: $DIR/simplify_try_if_let.rs:28:30: 28:36 - // + literal: Const { ty: for<'r> unsafe fn(&'r mut std::ptr::NonNull) -> &'r mut Node {std::ptr::NonNull::::as_mut}, val: Value(Scalar()) } - } - - bb7: { - StorageDead(_12); // scope 3 at $DIR/simplify_try_if_let.rs:28:37: 28:38 - ((*_11).0: std::option::Option>) = move _9; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:62 - StorageDead(_9); // scope 3 at $DIR/simplify_try_if_let.rs:28:61: 28:62 - StorageDead(_11); // scope 3 at $DIR/simplify_try_if_let.rs:28:62: 28:63 - _0 = const (); // scope 3 at $DIR/simplify_try_if_let.rs:27:21: 29:22 - StorageDead(_8); // scope 1 at $DIR/simplify_try_if_let.rs:30:17: 30:18 - goto -> bb8; // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18 - } - - bb8: { - StorageDead(_5); // scope 1 at $DIR/simplify_try_if_let.rs:31:13: 31:14 - StorageDead(_4); // scope 0 at $DIR/simplify_try_if_let.rs:31:13: 31:14 - goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10 - } - - bb9: { - return; // scope 0 at $DIR/simplify_try_if_let.rs:33:6: 33:6 - } - } - From 1140750f6eff7ad09ea675cf48d66418a62bcdd5 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sat, 27 Jul 2024 11:05:03 +0300 Subject: [PATCH 10/15] update `rust.channel` documentation Signed-off-by: onur-ozkan --- config.example.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 8800c85db32..45faa66ec11 100644 --- a/config.example.toml +++ b/config.example.toml @@ -578,7 +578,10 @@ # The "channel" for the Rust build to produce. The stable/beta channels only # allow using stable features, whereas the nightly and dev channels allow using # nightly features -#channel = "dev" +# +# If using tarball sources, default value for `channel` is taken from the `src/ci/channel` file; +# otherwise, it's "dev". +#channel = if "is a tarball source" { content of `src/ci/channel` file } else { "dev" } # A descriptive string to be appended to `rustc --version` output, which is # also used in places like debuginfo `DW_AT_producer`. This may be useful for From 139a713dc0451589ef6bfb04451ab638065d7ca4 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sat, 27 Jul 2024 11:05:36 +0300 Subject: [PATCH 11/15] add change entry for `rust.channel` defaults Signed-off-by: onur-ozkan --- src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 879cc079c6b..b8f70fdf6a8 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -215,4 +215,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "Removed android-ndk r25b support in favor of android-ndk r26d.", }, + ChangeInfo { + change_id: 125181, + severity: ChangeSeverity::Warning, + summary: "For tarball sources, default value for `rust.channel` will be taken from `src/ci/channel` file.", + }, ]; From 015f5d6f76ed631885a661946d9751221ab9c6aa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 27 Jul 2024 12:12:16 +0200 Subject: [PATCH 12/15] Add rustdoc GUI test to check title with and without search --- tests/rustdoc-gui/search-title.goml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/rustdoc-gui/search-title.goml diff --git a/tests/rustdoc-gui/search-title.goml b/tests/rustdoc-gui/search-title.goml new file mode 100644 index 00000000000..95bc36af449 --- /dev/null +++ b/tests/rustdoc-gui/search-title.goml @@ -0,0 +1,24 @@ +// Checks that the search changes the title +include: "utils.goml" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" + +store-value: (title, "test_docs - Rust") +assert-document-property: {"title": |title|} + +write-into: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' +wait-for: "#crate-search" + +assert-document-property: {"title": '"test" Search - Rust'} + +set-property: (".search-input", {"value": "another one"}) +// To be SURE that the search will be run. +press-key: 'Enter' +wait-for: "#crate-search" + +assert-document-property: {"title": '"another one" Search - Rust'} + +press-key: "Escape" + +assert-document-property: {"title": |title|} From f305e188041b586fb162161f961298f1532fe83b Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 27 Jul 2024 15:08:11 +0200 Subject: [PATCH 13/15] Disable jump threading of float equality Jump threading stores values as `u128` (`ScalarInt`) and does its comparisons for equality as integer comparisons. This works great for integers. Sadly, not everything is an integer. Floats famously have wonky equality semantcs, with `NaN!=NaN` and `0.0 == -0.0`. This does not match our beautiful integer bitpattern equality and therefore causes things to go horribly wrong. While jump threading could be extended to support floats by remembering that they're floats in the value state and handling them properly, it's signficantly easier to just disable it for now. --- .../rustc_mir_transform/src/jump_threading.rs | 7 +++ ...ding.floats.JumpThreading.panic-abort.diff | 59 +++++++++++++++++++ ...ing.floats.JumpThreading.panic-unwind.diff | 59 +++++++++++++++++++ tests/mir-opt/jump_threading.rs | 12 ++++ 4 files changed, 137 insertions(+) create mode 100644 tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff create mode 100644 tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 2100f4b4a1a..96c52845a4a 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -509,6 +509,13 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { BinOp::Ne => ScalarInt::FALSE, _ => return None, }; + if value.const_.ty().is_floating_point() { + // Floating point equality does not follow bit-patterns. + // -0.0 and NaN both have special rules for equality, + // and therefore we cannot use integer comparisons for them. + // Avoid handling them, though this could be extended in the future. + return None; + } let value = value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()?; let conds = conditions.map(self.arena, |c| Condition { value, diff --git a/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff new file mode 100644 index 00000000000..6ca37e96d29 --- /dev/null +++ b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff @@ -0,0 +1,59 @@ +- // MIR for `floats` before JumpThreading ++ // MIR for `floats` after JumpThreading + + fn floats() -> u32 { + let mut _0: u32; + let _1: f64; + let mut _2: bool; + let mut _3: bool; + let mut _4: f64; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = const true; +- switchInt(move _2) -> [0: bb2, otherwise: bb1]; ++ goto -> bb1; + } + + bb1: { + _1 = const -0f64; + goto -> bb3; + } + + bb2: { + _1 = const 1f64; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + _4 = _1; + _3 = Eq(move _4, const 0f64); + switchInt(move _3) -> [0: bb5, otherwise: bb4]; + } + + bb4: { + StorageDead(_4); + _0 = const 0_u32; + goto -> bb6; + } + + bb5: { + StorageDead(_4); + _0 = const 1_u32; + goto -> bb6; + } + + bb6: { + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff new file mode 100644 index 00000000000..6ca37e96d29 --- /dev/null +++ b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff @@ -0,0 +1,59 @@ +- // MIR for `floats` before JumpThreading ++ // MIR for `floats` after JumpThreading + + fn floats() -> u32 { + let mut _0: u32; + let _1: f64; + let mut _2: bool; + let mut _3: bool; + let mut _4: f64; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = const true; +- switchInt(move _2) -> [0: bb2, otherwise: bb1]; ++ goto -> bb1; + } + + bb1: { + _1 = const -0f64; + goto -> bb3; + } + + bb2: { + _1 = const 1f64; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + _4 = _1; + _3 = Eq(move _4, const 0f64); + switchInt(move _3) -> [0: bb5, otherwise: bb4]; + } + + bb4: { + StorageDead(_4); + _0 = const 0_u32; + goto -> bb6; + } + + bb5: { + StorageDead(_4); + _0 = const 1_u32; + goto -> bb6; + } + + bb6: { + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index de290c1ef44..e5d8525dcac 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -521,6 +521,16 @@ fn aggregate_copy() -> u32 { if c == 2 { b.0 } else { 13 } } +fn floats() -> u32 { + // CHECK-LABEL: fn floats( + // CHECK: switchInt( + + // Test for issue #128243, where float equality was assumed to be bitwise. + // When adding float support, it must be ensured that this continues working properly. + let x = if true { -0.0 } else { 1.0 }; + if x == 0.0 { 0 } else { 1 } +} + fn main() { // CHECK-LABEL: fn main( too_complex(Ok(0)); @@ -535,6 +545,7 @@ fn main() { disappearing_bb(7); aggregate(7); assume(7, false); + floats(); } // EMIT_MIR jump_threading.too_complex.JumpThreading.diff @@ -550,3 +561,4 @@ fn main() { // EMIT_MIR jump_threading.aggregate.JumpThreading.diff // EMIT_MIR jump_threading.assume.JumpThreading.diff // EMIT_MIR jump_threading.aggregate_copy.JumpThreading.diff +// EMIT_MIR jump_threading.floats.JumpThreading.diff From 3e4ddc39b8c47895b9086908ca4e9577a2c28142 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 27 Jul 2024 19:08:00 +0200 Subject: [PATCH 14/15] update aarch64 asm tests --- tests/ui/asm/aarch64/bad-options.rs | 12 +++---- tests/ui/asm/aarch64/bad-options.stderr | 24 ++++++------- tests/ui/asm/aarch64/parse-error.rs | 2 ++ tests/ui/asm/aarch64/parse-error.stderr | 48 +++++++++++++++---------- tests/ui/asm/unsupported-option.fixed | 2 +- tests/ui/asm/unsupported-option.rs | 2 +- tests/ui/asm/unsupported-option.stderr | 18 +++++----- 7 files changed, 61 insertions(+), 47 deletions(-) diff --git a/tests/ui/asm/aarch64/bad-options.rs b/tests/ui/asm/aarch64/bad-options.rs index 33b77367a4f..9e721d55b2d 100644 --- a/tests/ui/asm/aarch64/bad-options.rs +++ b/tests/ui/asm/aarch64/bad-options.rs @@ -26,14 +26,14 @@ fn main() { } global_asm!("", options(nomem)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("", options(readonly)); -//~^ ERROR expected one of +//~^ ERROR the `readonly` option cannot be used with `global_asm!` global_asm!("", options(noreturn)); -//~^ ERROR expected one of +//~^ ERROR the `noreturn` option cannot be used with `global_asm!` global_asm!("", options(pure)); -//~^ ERROR expected one of +//~^ ERROR the `pure` option cannot be used with `global_asm!` global_asm!("", options(nostack)); -//~^ ERROR expected one of +//~^ ERROR the `nostack` option cannot be used with `global_asm!` global_asm!("", options(preserves_flags)); -//~^ ERROR expected one of +//~^ ERROR the `preserves_flags` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/aarch64/bad-options.stderr b/tests/ui/asm/aarch64/bad-options.stderr index 21bcc4a9c7b..54ab7cafa49 100644 --- a/tests/ui/asm/aarch64/bad-options.stderr +++ b/tests/ui/asm/aarch64/bad-options.stderr @@ -36,41 +36,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C")); | | | generic outputs -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:28:25 | LL | global_asm!("", options(nomem)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `readonly` +error: the `readonly` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:30:25 | LL | global_asm!("", options(readonly)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn` +error: the `noreturn` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:32:25 | LL | global_asm!("", options(noreturn)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `pure` +error: the `pure` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:34:25 | LL | global_asm!("", options(pure)); - | ^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^ the `pure` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `nostack` +error: the `nostack` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:36:25 | LL | global_asm!("", options(nostack)); - | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` +error: the `preserves_flags` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:38:25 | LL | global_asm!("", options(preserves_flags)); - | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly error: invalid ABI for `clobber_abi` --> $DIR/bad-options.rs:20:18 diff --git a/tests/ui/asm/aarch64/parse-error.rs b/tests/ui/asm/aarch64/parse-error.rs index fbb1e08df91..ac73bbf99c9 100644 --- a/tests/ui/asm/aarch64/parse-error.rs +++ b/tests/ui/asm/aarch64/parse-error.rs @@ -98,8 +98,10 @@ global_asm!("", options(FOO)); //~^ ERROR expected one of global_asm!("", options(nomem FOO)); //~^ ERROR expected one of +//~| ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("", options(nomem, FOO)); //~^ ERROR expected one of +//~| ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("{}", options(), const FOO); global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal diff --git a/tests/ui/asm/aarch64/parse-error.stderr b/tests/ui/asm/aarch64/parse-error.stderr index d21a8ab1f85..e2c798c798e 100644 --- a/tests/ui/asm/aarch64/parse-error.stderr +++ b/tests/ui/asm/aarch64/parse-error.stderr @@ -218,56 +218,68 @@ error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/parse-error.rs:99:25 | LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:101:25 +error: expected one of `)` or `,`, found `FOO` + --> $DIR/parse-error.rs:99:31 + | +LL | global_asm!("", options(nomem FOO)); + | ^^^ expected one of `)` or `,` + +error: the `nomem` option cannot be used with `global_asm!` + --> $DIR/parse-error.rs:102:25 | LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` + --> $DIR/parse-error.rs:102:32 + | +LL | global_asm!("", options(nomem, FOO)); + | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected string literal - --> $DIR/parse-error.rs:104:29 + --> $DIR/parse-error.rs:106:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:106:33 + --> $DIR/parse-error.rs:108:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:108:34 + --> $DIR/parse-error.rs:110:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:110:19 + --> $DIR/parse-error.rs:112:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:112:28 + --> $DIR/parse-error.rs:114:28 | LL | global_asm!("", options(), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:114:30 + --> $DIR/parse-error.rs:116:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:116:35 + --> $DIR/parse-error.rs:118:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -275,7 +287,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:116:35 + --> $DIR/parse-error.rs:118:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -283,19 +295,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:119:28 + --> $DIR/parse-error.rs:121:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:121:30 + --> $DIR/parse-error.rs:123:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:123:13 + --> $DIR/parse-error.rs:125:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ @@ -303,7 +315,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:125:20 + --> $DIR/parse-error.rs:127:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ @@ -398,6 +410,6 @@ help: consider using `const` instead of `let` LL | const bar: /* Type */ = 0; | ~~~~~ ++++++++++++ -error: aborting due to 57 previous errors +error: aborting due to 59 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/unsupported-option.fixed b/tests/ui/asm/unsupported-option.fixed index c2ff13bbc55..f0d5ddb39d6 100644 --- a/tests/ui/asm/unsupported-option.fixed +++ b/tests/ui/asm/unsupported-option.fixed @@ -4,7 +4,7 @@ use std::arch::global_asm; fn main() {} -global_asm!("", options(att_syntax, raw)); +global_asm!("", options( raw)); //~^ ERROR the `nomem` option cannot be used with `global_asm!` //~| ERROR the `readonly` option cannot be used with `global_asm!` //~| ERROR the `noreturn` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/unsupported-option.rs b/tests/ui/asm/unsupported-option.rs index 672aedf230c..a852dcc4edd 100644 --- a/tests/ui/asm/unsupported-option.rs +++ b/tests/ui/asm/unsupported-option.rs @@ -4,7 +4,7 @@ use std::arch::global_asm; fn main() {} -global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); +global_asm!("", options(nomem, readonly, noreturn, raw)); //~^ ERROR the `nomem` option cannot be used with `global_asm!` //~| ERROR the `readonly` option cannot be used with `global_asm!` //~| ERROR the `noreturn` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/unsupported-option.stderr b/tests/ui/asm/unsupported-option.stderr index c040b0364d7..1bcb98b8d49 100644 --- a/tests/ui/asm/unsupported-option.stderr +++ b/tests/ui/asm/unsupported-option.stderr @@ -1,20 +1,20 @@ error: the `nomem` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:7:37 + --> $DIR/unsupported-option.rs:7:25 | -LL | global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); - | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly +LL | global_asm!("", options(nomem, readonly, noreturn, raw)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly error: the `readonly` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:7:44 + --> $DIR/unsupported-option.rs:7:32 | -LL | global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); - | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly +LL | global_asm!("", options(nomem, readonly, noreturn, raw)); + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly error: the `noreturn` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:7:54 + --> $DIR/unsupported-option.rs:7:42 | -LL | global_asm!("", options(att_syntax, nomem, readonly, noreturn, raw)); - | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly +LL | global_asm!("", options(nomem, readonly, noreturn, raw)); + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly error: aborting due to 3 previous errors From 33b5ca99b7c61aa50ce1d973648bb610394576e8 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 27 Jul 2024 19:27:20 +0200 Subject: [PATCH 15/15] add `needs-asm-support` to `tests/ui/asm/unsupported-option.rs` --- tests/ui/asm/unsupported-option.fixed | 1 + tests/ui/asm/unsupported-option.rs | 1 + tests/ui/asm/unsupported-option.stderr | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/ui/asm/unsupported-option.fixed b/tests/ui/asm/unsupported-option.fixed index f0d5ddb39d6..d313d8028b6 100644 --- a/tests/ui/asm/unsupported-option.fixed +++ b/tests/ui/asm/unsupported-option.fixed @@ -1,3 +1,4 @@ +//@ needs-asm-support //@ run-rustfix use std::arch::global_asm; diff --git a/tests/ui/asm/unsupported-option.rs b/tests/ui/asm/unsupported-option.rs index a852dcc4edd..d75f8e7f569 100644 --- a/tests/ui/asm/unsupported-option.rs +++ b/tests/ui/asm/unsupported-option.rs @@ -1,3 +1,4 @@ +//@ needs-asm-support //@ run-rustfix use std::arch::global_asm; diff --git a/tests/ui/asm/unsupported-option.stderr b/tests/ui/asm/unsupported-option.stderr index 1bcb98b8d49..7a6927152b6 100644 --- a/tests/ui/asm/unsupported-option.stderr +++ b/tests/ui/asm/unsupported-option.stderr @@ -1,17 +1,17 @@ error: the `nomem` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:7:25 + --> $DIR/unsupported-option.rs:8:25 | LL | global_asm!("", options(nomem, readonly, noreturn, raw)); | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly error: the `readonly` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:7:32 + --> $DIR/unsupported-option.rs:8:32 | LL | global_asm!("", options(nomem, readonly, noreturn, raw)); | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly error: the `noreturn` option cannot be used with `global_asm!` - --> $DIR/unsupported-option.rs:7:42 + --> $DIR/unsupported-option.rs:8:42 | LL | global_asm!("", options(nomem, readonly, noreturn, raw)); | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly