From f943606503b142b24edb2b20f77f1eb737fb9ed2 Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 20 Nov 2025 20:53:51 +0800 Subject: [PATCH 01/22] Fix unused_assignments false positives from macros --- compiler/rustc_mir_transform/src/liveness.rs | 5 +++++ tests/ui/liveness/auxiliary/aux_issue_147648.rs | 7 +++++++ .../liveness/unused-assignments-from-macro-147648.rs | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 tests/ui/liveness/auxiliary/aux_issue_147648.rs create mode 100644 tests/ui/liveness/unused-assignments-from-macro-147648.rs diff --git a/compiler/rustc_mir_transform/src/liveness.rs b/compiler/rustc_mir_transform/src/liveness.rs index f7dc703560245..d9dd7f9c5b195 100644 --- a/compiler/rustc_mir_transform/src/liveness.rs +++ b/compiler/rustc_mir_transform/src/liveness.rs @@ -72,6 +72,11 @@ pub(crate) fn check_liveness<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Den return DenseBitSet::new_empty(0); } + // Don't run unused pass for items generated by foreign macros + if tcx.def_span(parent).in_external_macro(tcx.sess.source_map()) { + return DenseBitSet::new_empty(0); + } + let mut body = &*tcx.mir_promoted(def_id).0.borrow(); let mut body_mem; diff --git a/tests/ui/liveness/auxiliary/aux_issue_147648.rs b/tests/ui/liveness/auxiliary/aux_issue_147648.rs new file mode 100644 index 0000000000000..ccb5ad6b8fc09 --- /dev/null +++ b/tests/ui/liveness/auxiliary/aux_issue_147648.rs @@ -0,0 +1,7 @@ +#[macro_export] +macro_rules! unused_assign { + ($x:ident) => { + let mut $x = 1; + $x = 2; + }; +} diff --git a/tests/ui/liveness/unused-assignments-from-macro-147648.rs b/tests/ui/liveness/unused-assignments-from-macro-147648.rs new file mode 100644 index 0000000000000..c32c281538b44 --- /dev/null +++ b/tests/ui/liveness/unused-assignments-from-macro-147648.rs @@ -0,0 +1,10 @@ +//@ check-pass +//@ aux-build:aux_issue_147648.rs + +#![deny(unused_assignments)] + +extern crate aux_issue_147648; + +fn main() { + aux_issue_147648::unused_assign!(y); +} From 7a9e0df26efe95fff61ceef2bc1860f0e61f5fa5 Mon Sep 17 00:00:00 2001 From: yukang Date: Sat, 29 Nov 2025 10:27:34 +0800 Subject: [PATCH 02/22] Fix span note for question mark expression --- .../traits/fulfillment_errors.rs | 32 ++++++++------- .../question-mark-result-err-mismatch.rs | 2 +- .../question-mark-result-err-mismatch.stderr | 2 +- tests/ui/traits/question-mark-span-144304.rs | 7 ++++ .../traits/question-mark-span-144304.stderr | 41 +++++++++++++++++++ 5 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 tests/ui/traits/question-mark-span-144304.rs create mode 100644 tests/ui/traits/question-mark-span-144304.stderr diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 8c867f842b89a..d96a1b0a8c0eb 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1229,7 +1229,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { chain.push((expr.span, prev_ty)); let mut prev = None; - for (span, err_ty) in chain.into_iter().rev() { + let mut iter = chain.into_iter().rev().peekable(); + while let Some((span, err_ty)) = iter.next() { + let is_last = iter.peek().is_none(); let err_ty = get_e_type(err_ty); let err_ty = match (err_ty, prev) { (Some(err_ty), Some(prev)) if !self.can_eq(obligation.param_env, err_ty, prev) => { @@ -1241,27 +1243,27 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { continue; } }; - if self + + let implements_from = self .infcx .type_implements_trait( self.tcx.get_diagnostic_item(sym::From).unwrap(), [self_ty, err_ty], obligation.param_env, ) - .must_apply_modulo_regions() - { - if !suggested { - let err_ty = self.tcx.short_string(err_ty, err.long_ty_path()); - err.span_label(span, format!("this has type `Result<_, {err_ty}>`")); - } + .must_apply_modulo_regions(); + + let err_ty_str = self.tcx.short_string(err_ty, err.long_ty_path()); + let label = if !implements_from && is_last { + format!( + "this can't be annotated with `?` because it has type `Result<_, {err_ty_str}>`" + ) } else { - let err_ty = self.tcx.short_string(err_ty, err.long_ty_path()); - err.span_label( - span, - format!( - "this can't be annotated with `?` because it has type `Result<_, {err_ty}>`", - ), - ); + format!("this has type `Result<_, {err_ty_str}>`") + }; + + if !suggested || !implements_from { + err.span_label(span, label); } prev = Some(err_ty); } diff --git a/tests/ui/traits/question-mark-result-err-mismatch.rs b/tests/ui/traits/question-mark-result-err-mismatch.rs index df1d5105a34a1..dfea4b93f46da 100644 --- a/tests/ui/traits/question-mark-result-err-mismatch.rs +++ b/tests/ui/traits/question-mark-result-err-mismatch.rs @@ -9,7 +9,7 @@ fn foo() -> Result { //~ NOTE expected `String` because of this }); let one = x .map(|s| ()) - .map_err(|e| { //~ NOTE this can't be annotated with `?` because it has type `Result<_, ()>` + .map_err(|e| { //~ NOTE this has type `Result<_, ()>` e; //~ HELP remove this semicolon }) .map(|()| "")?; //~ ERROR `?` couldn't convert the error to `String` diff --git a/tests/ui/traits/question-mark-result-err-mismatch.stderr b/tests/ui/traits/question-mark-result-err-mismatch.stderr index 0f83c9e73a314..be3f17cfc5274 100644 --- a/tests/ui/traits/question-mark-result-err-mismatch.stderr +++ b/tests/ui/traits/question-mark-result-err-mismatch.stderr @@ -9,7 +9,7 @@ LL | .map_err(|e| { LL | | e; | | - help: remove this semicolon LL | | }) - | |__________- this can't be annotated with `?` because it has type `Result<_, ()>` + | |__________- this has type `Result<_, ()>` LL | .map(|()| "")?; | ^ the trait `From<()>` is not implemented for `String` | diff --git a/tests/ui/traits/question-mark-span-144304.rs b/tests/ui/traits/question-mark-span-144304.rs new file mode 100644 index 0000000000000..2d5d45b3b9c26 --- /dev/null +++ b/tests/ui/traits/question-mark-span-144304.rs @@ -0,0 +1,7 @@ +fn f() -> Result<(), i32> { + Err("str").map_err(|e| e)?; //~ ERROR `?` couldn't convert the error to `i32` + Err("str").map_err(|e| e.to_string())?; //~ ERROR `?` couldn't convert the error to `i32` + Ok(()) +} + +fn main() {} diff --git a/tests/ui/traits/question-mark-span-144304.stderr b/tests/ui/traits/question-mark-span-144304.stderr new file mode 100644 index 0000000000000..a1aa805980bf5 --- /dev/null +++ b/tests/ui/traits/question-mark-span-144304.stderr @@ -0,0 +1,41 @@ +error[E0277]: `?` couldn't convert the error to `i32` + --> $DIR/question-mark-span-144304.rs:2:30 + | +LL | fn f() -> Result<(), i32> { + | --------------- expected `i32` because of this +LL | Err("str").map_err(|e| e)?; + | ---------- ^ the trait `From<&str>` is not implemented for `i32` + | | + | this has type `Result<_, &str>` + | + = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + = help: the following other types implement trait `From`: + `i32` implements `From` + `i32` implements `From` + `i32` implements `From` + `i32` implements `From` + `i32` implements `From` + +error[E0277]: `?` couldn't convert the error to `i32` + --> $DIR/question-mark-span-144304.rs:3:42 + | +LL | fn f() -> Result<(), i32> { + | --------------- expected `i32` because of this +LL | Err("str").map_err(|e| e)?; +LL | Err("str").map_err(|e| e.to_string())?; + | ---------- --------------------------^ the trait `From` is not implemented for `i32` + | | | + | | this can't be annotated with `?` because it has type `Result<_, String>` + | this has type `Result<_, &str>` + | + = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + = help: the following other types implement trait `From`: + `i32` implements `From` + `i32` implements `From` + `i32` implements `From` + `i32` implements `From` + `i32` implements `From` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. From 5009847d1461d2af722dc154a00614765a80ac16 Mon Sep 17 00:00:00 2001 From: joboet Date: Wed, 17 Sep 2025 17:24:25 +0200 Subject: [PATCH 03/22] std: don't call `current_os_id` from signal handler --- .../std/src/sys/pal/unix/stack_overflow.rs | 33 ++++++++++--------- .../pal/unix/stack_overflow/thread_info.rs | 10 ++++-- library/std/src/sys/thread/unix.rs | 9 +++-- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/library/std/src/sys/pal/unix/stack_overflow.rs b/library/std/src/sys/pal/unix/stack_overflow.rs index 226b6bce01b58..040fda75a5080 100644 --- a/library/std/src/sys/pal/unix/stack_overflow.rs +++ b/library/std/src/sys/pal/unix/stack_overflow.rs @@ -8,8 +8,8 @@ pub struct Handler { } impl Handler { - pub unsafe fn new(thread_name: Option>) -> Handler { - make_handler(false, thread_name) + pub unsafe fn new() -> Handler { + make_handler(false) } fn null() -> Handler { @@ -117,8 +117,15 @@ mod imp { if let Some(thread_info) = thread_info && thread_info.guard_page_range.contains(&fault_addr) { - let name = thread_info.thread_name.as_deref().unwrap_or(""); - let tid = crate::thread::current_os_id(); + // Hey you! Yes, you modifying the stack overflow message! + // Please make sure that all functions called here are + // actually async-signal-safe. If they're not, try retrieving + // the information beforehand and storing it in `ThreadInfo`. + // Thank you! + // - says Jonas after having had to watch his carefully + // written code get made unsound again. + let tid = thread_info.tid; + let name = thread_info.name.as_deref().unwrap_or(""); rtprintpanic!("\nthread '{name}' ({tid}) has overflowed its stack\n"); rtabort!("stack overflow"); } @@ -164,12 +171,12 @@ mod imp { if !NEED_ALTSTACK.load(Ordering::Relaxed) { // haven't set up our sigaltstack yet NEED_ALTSTACK.store(true, Ordering::Release); - let handler = unsafe { make_handler(true, None) }; + let handler = unsafe { make_handler(true) }; MAIN_ALTSTACK.store(handler.data, Ordering::Relaxed); mem::forget(handler); if let Some(guard_page_range) = guard_page_range.take() { - set_current_info(guard_page_range, Some(Box::from("main"))); + set_current_info(guard_page_range); } } @@ -240,14 +247,14 @@ mod imp { /// # Safety /// Mutates the alternate signal stack #[forbid(unsafe_op_in_unsafe_fn)] - pub unsafe fn make_handler(main_thread: bool, thread_name: Option>) -> Handler { + pub unsafe fn make_handler(main_thread: bool) -> Handler { if cfg!(panic = "immediate-abort") || !NEED_ALTSTACK.load(Ordering::Acquire) { return Handler::null(); } if !main_thread { if let Some(guard_page_range) = unsafe { current_guard() } { - set_current_info(guard_page_range, thread_name); + set_current_info(guard_page_range); } } @@ -633,10 +640,7 @@ mod imp { pub unsafe fn cleanup() {} - pub unsafe fn make_handler( - _main_thread: bool, - _thread_name: Option>, - ) -> super::Handler { + pub unsafe fn make_handler(_main_thread: bool) -> super::Handler { super::Handler::null() } @@ -720,10 +724,7 @@ mod imp { pub unsafe fn cleanup() {} - pub unsafe fn make_handler( - main_thread: bool, - _thread_name: Option>, - ) -> super::Handler { + pub unsafe fn make_handler(main_thread: bool) -> super::Handler { if !main_thread { reserve_stack(); } diff --git a/library/std/src/sys/pal/unix/stack_overflow/thread_info.rs b/library/std/src/sys/pal/unix/stack_overflow/thread_info.rs index e81429b98a6c7..42eb0cd9a61af 100644 --- a/library/std/src/sys/pal/unix/stack_overflow/thread_info.rs +++ b/library/std/src/sys/pal/unix/stack_overflow/thread_info.rs @@ -32,8 +32,9 @@ use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sys::os::errno_location; pub struct ThreadInfo { + pub tid: u64, + pub name: Option>, pub guard_page_range: Range, - pub thread_name: Option>, } static LOCK: Mutex<()> = Mutex::new(()); @@ -108,14 +109,17 @@ fn spin_lock_in_setup(this: usize) -> UnlockOnDrop { } } -pub fn set_current_info(guard_page_range: Range, thread_name: Option>) { +pub fn set_current_info(guard_page_range: Range) { + let tid = crate::thread::current_os_id(); + let name = crate::thread::with_current_name(|name| name.map(Box::from)); + let this = errno_location().addr(); let _lock_guard = LOCK.lock(); let _spin_guard = spin_lock_in_setup(this); // SAFETY: we own the spin lock, so `THREAD_INFO` cannot be aliased. let thread_info = unsafe { &mut *(&raw mut THREAD_INFO) }; - thread_info.insert(this, ThreadInfo { guard_page_range, thread_name }); + thread_info.insert(this, ThreadInfo { tid, name, guard_page_range }); } pub fn delete_current_info() { diff --git a/library/std/src/sys/thread/unix.rs b/library/std/src/sys/thread/unix.rs index d4c27097afd79..4adc94d0e5c9e 100644 --- a/library/std/src/sys/thread/unix.rs +++ b/library/std/src/sys/thread/unix.rs @@ -14,7 +14,7 @@ use crate::sys::weak::dlsym; #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto",))] use crate::sys::weak::weak; use crate::sys::{os, stack_overflow}; -use crate::thread::{ThreadInit, current}; +use crate::thread::ThreadInit; use crate::time::Duration; use crate::{cmp, io, ptr}; #[cfg(not(any( @@ -111,10 +111,9 @@ impl Thread { let init = Box::from_raw(data as *mut ThreadInit); let rust_start = init.init(); - // Set up our thread name and stack overflow handler which may get triggered - // if we run out of stack. - let thread = current(); - let _handler = stack_overflow::Handler::new(thread.name().map(Box::from)); + // Now that the thread information is set, set up our stack + // overflow handler. + let _handler = stack_overflow::Handler::new(); rust_start(); } From 95491661695dacdc3cd92c5d739695a15fe3cfea Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 1 Dec 2025 12:47:18 +0100 Subject: [PATCH 04/22] add test --- ...und-unsatisfied-item-bounds-mit-opt-ice.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs diff --git a/tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs b/tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs new file mode 100644 index 0000000000000..80eec709eecbc --- /dev/null +++ b/tests/ui/where-clauses/projection-bound-unsatisfied-item-bounds-mit-opt-ice.rs @@ -0,0 +1,25 @@ +//@ compile-flags: -Copt-level=3 --crate-type=rlib +//@ build-pass + +// A regression test for #149081. The environment of `size` and `align` +// currently means that the item bound of`T::Assoc` doesn't hold. This can +// result in normalization failures and ICE during MIR optimizations. +// +// This will no longer be an issue once #149283 is implemented. + +pub fn align, U>() -> usize { + std::mem::align_of::>() +} + +pub fn size, U>() -> usize { + std::mem::size_of::>() +} + +pub struct Wrapper { + assoc2: ::Assoc, + value: T, +} + +pub trait WithAssoc { + type Assoc: WithAssoc; +} From 02d84c8d23e3e5cf61ab0ce11cf756625b8180a8 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 1 Dec 2025 12:48:18 +0100 Subject: [PATCH 05/22] generic normalization errors to `TooGeneric` --- .../src/interpret/eval_context.rs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 0e4a98f0941ac..d23369caffa42 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -11,7 +11,9 @@ use rustc_middle::ty::layout::{ self, FnAbiError, FnAbiOf, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout, }; -use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypingEnv, Variance}; +use rustc_middle::ty::{ + self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingEnv, Variance, +}; use rustc_middle::{mir, span_bug}; use rustc_span::Span; use rustc_target::callconv::FnAbi; @@ -84,10 +86,31 @@ impl<'tcx, M: Machine<'tcx>> LayoutOfHelpers<'tcx> for InterpCx<'tcx, M> { #[inline] fn handle_layout_err( &self, - err: LayoutError<'tcx>, + mut err: LayoutError<'tcx>, _: Span, _: Ty<'tcx>, ) -> InterpErrorKind<'tcx> { + // FIXME(#149283): This is really hacky and is only used to hide type + // system bugs. We use it as a temporary fix for #149081. + // + // While it's expected that we sometimes get ambiguity errors when + // entering another generic environment while the current environment + // itself is still generic, we should never fail to entirely prove + // something. + match err { + LayoutError::NormalizationFailure(ty, _) => { + if ty.has_non_region_param() { + err = LayoutError::TooGeneric(ty); + } + } + + LayoutError::Unknown(_) + | LayoutError::SizeOverflow(_) + | LayoutError::InvalidSimd { .. } + | LayoutError::TooGeneric(_) + | LayoutError::ReferencesError(_) + | LayoutError::Cycle(_) => {} + } err_inval!(Layout(err)) } } @@ -112,7 +135,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { /// and allows wrapping the actual [LayoutOf::layout_of] with a tracing span. /// See [LayoutOf::layout_of] for the original documentation. #[inline(always)] - pub fn layout_of(&self, ty: Ty<'tcx>) -> >::LayoutOfResult { + pub fn layout_of(&self, ty: Ty<'tcx>) -> Result, InterpErrorKind<'tcx>> { let _trace = enter_trace_span!(M, layouting::layout_of, ty = ?ty.kind()); LayoutOf::layout_of(self, ty) } From 3f1aa0b47eb16ebf049436ca0d5a16ea250f45d7 Mon Sep 17 00:00:00 2001 From: quaternic <57393910+quaternic@users.noreply.github.com> Date: Mon, 1 Dec 2025 20:37:11 +0200 Subject: [PATCH 06/22] Additional test for uN::{gather,scatter}_bits --- library/coretests/tests/num/uint_macros.rs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/library/coretests/tests/num/uint_macros.rs b/library/coretests/tests/num/uint_macros.rs index 7f3e27e9c446c..6e746a6a2278d 100644 --- a/library/coretests/tests/num/uint_macros.rs +++ b/library/coretests/tests/num/uint_macros.rs @@ -387,6 +387,70 @@ macro_rules! uint_module { } } + #[cfg(not(miri))] // Miri is too slow + #[test] + fn test_lots_of_gather_scatter() { + // Generate a handful of bit patterns to use as inputs + let xs = { + let mut xs = vec![]; + let mut x: $T = !0; + let mut w = $T::BITS; + while w > 0 { + w >>= 1; + xs.push(x); + xs.push(!x); + x ^= x << w; + } + xs + }; + if $T::BITS == 8 { + assert_eq!(&xs, &[0xff, 0x00, 0x0f, 0xf0, 0x33, 0xcc, 0x55, 0xaa]); + } + + // `256 * BITS` masks + let sparse_masks = (i8::MIN..=i8::MAX) + .map(|i| (i as i128 as $T).rotate_right(4)) + .flat_map(|x| (0..$T::BITS).map(move |s| ((1 as $T) << s) ^ x)); + + for sparse in sparse_masks { + // Collect the set bits to sequential low bits + let dense = sparse.gather_bits(sparse); + let count = sparse.count_ones(); + assert_eq!(count, dense.count_ones()); + assert_eq!(count, dense.trailing_ones()); + + let mut t = sparse; + for k in 0..$T::BITS { + let x = ((1 as $T) << k).scatter_bits(sparse); + let y = t.isolate_lowest_one(); + assert_eq!(x, y); + t ^= y; + } + + let mut t = sparse; + for k in 0..count { + let y = t.isolate_lowest_one(); + let x = y.gather_bits(sparse); + assert_eq!(x, (1 as $T) << k); + t ^= y; + } + + for &x in &xs { + // Gather bits from `x & sparse` to `dense` + let dx = x.gather_bits(sparse); + assert_eq!(dx & !dense, 0); + + // Scatter bits from `x & dense` to `sparse` + let sx = x.scatter_bits(sparse); + assert_eq!(sx & !sparse, 0); + + // The other recovers the input (within the mask) + assert_eq!(dx.scatter_bits(sparse), x & sparse); + assert_eq!(sx.gather_bits(sparse), x & dense); + } + } + } + test_runtime_and_compiletime! { fn test_div_floor() { assert_eq_const_safe!($T: (8 as $T).div_floor(3), 2); From 79224797fb36d5823b04cc266c08db5089246d2d Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Tue, 2 Dec 2025 15:36:21 +0000 Subject: [PATCH 07/22] Regression tests for system register `ttbr0_el2` --- tests/ui/asm/aarch64/ttbr0_el2.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/ui/asm/aarch64/ttbr0_el2.rs diff --git a/tests/ui/asm/aarch64/ttbr0_el2.rs b/tests/ui/asm/aarch64/ttbr0_el2.rs new file mode 100644 index 0000000000000..a283d75c8fffd --- /dev/null +++ b/tests/ui/asm/aarch64/ttbr0_el2.rs @@ -0,0 +1,11 @@ +//! Regression test for #97724, recognising ttbr0_el2 as a valid armv8 system register +//@ only-aarch64 +//@ build-pass +use std::arch::asm; + +static PT: [u64; 512] = [0; 512]; +fn main() { + unsafe { + asm!("msr ttbr0_el2, {pt}", pt = in(reg) &PT as *const _ ); + } +} From 85b6c380d6afe9d1644816db8f2dc12c05fd1a5b Mon Sep 17 00:00:00 2001 From: joboet Date: Mon, 1 Dec 2025 13:14:48 +0100 Subject: [PATCH 08/22] remember the main thread ID before performing platform initialisation --- library/std/src/rt.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/std/src/rt.rs b/library/std/src/rt.rs index 2717b7b469cee..11c0a0b9daf7b 100644 --- a/library/std/src/rt.rs +++ b/library/std/src/rt.rs @@ -109,14 +109,14 @@ fn handle_rt_panic(e: Box) -> T { // `compiler/rustc_session/src/config/sigpipe.rs`. #[cfg_attr(test, allow(dead_code))] unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { + // Remember the main thread ID to give it the correct name. + // SAFETY: this is the only time and place where we call this function. + unsafe { main_thread::set(thread::current_id()) }; + #[cfg_attr(target_os = "teeos", allow(unused_unsafe))] unsafe { sys::init(argc, argv, sigpipe) }; - - // Remember the main thread ID to give it the correct name. - // SAFETY: this is the only time and place where we call this function. - unsafe { main_thread::set(thread::current_id()) }; } /// Clean up the thread-local runtime state. This *should* be run after all other From f4729f2c55c689e66b354b1e9b7f37710fff1562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 2 Dec 2025 19:15:38 +0100 Subject: [PATCH 09/22] build-manifest: generate MSI and MINGW arrays from rustc --- src/tools/build-manifest/build.rs | 18 +++++++++++++++++- src/tools/build-manifest/src/main.rs | 10 ---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/tools/build-manifest/build.rs b/src/tools/build-manifest/build.rs index c804921408a93..3ecfd30b8260d 100644 --- a/src/tools/build-manifest/build.rs +++ b/src/tools/build-manifest/build.rs @@ -60,7 +60,7 @@ fn main() { let mut output = String::new(); writeln!(output, "static HOSTS: &[&str] = &[").unwrap(); - for host in targets.hosts { + for host in &targets.hosts { writeln!(output, " {:?},", host).unwrap(); } writeln!(output, "];").unwrap(); @@ -71,6 +71,22 @@ fn main() { } writeln!(output, "];").unwrap(); + writeln!(output, "static MSI_INSTALLERS: &[&str] = &[").unwrap(); + for host in &targets.hosts { + if host.contains("-windows-") { + writeln!(output, " {:?},", host).unwrap(); + } + } + writeln!(output, "];").unwrap(); + + writeln!(output, "static MINGW: &[&str] = &[").unwrap(); + for host in targets.hosts { + if host.contains("-windows-gnu") { + writeln!(output, " {:?},", host).unwrap(); + } + } + writeln!(output, "];").unwrap(); + std::fs::write(PathBuf::from(std::env::var_os("OUT_DIR").unwrap()).join("targets.rs"), output) .unwrap(); } diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index d646d9102ba3e..42db12e5e1173 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -29,18 +29,8 @@ static DOCS_FALLBACK: &[(&str, &str)] = &[ ("", "x86_64-unknown-linux-gnu"), ]; -static MSI_INSTALLERS: &[&str] = &[ - "aarch64-pc-windows-msvc", - "i686-pc-windows-gnu", - "i686-pc-windows-msvc", - "x86_64-pc-windows-gnu", - "x86_64-pc-windows-msvc", -]; - static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin"]; -static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"]; - static NIGHTLY_ONLY_COMPONENTS: &[PkgType] = &[PkgType::Miri, PkgType::JsonDocs, PkgType::RustcCodegenCranelift]; From f8ca41755924f992aa760a4dcb7bf79baea9028b Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Tue, 2 Dec 2025 00:38:13 +0000 Subject: [PATCH 10/22] reword error for invalid range patterns For half-open ranges, specifies that the upper bound cannot be the minimum. Also specify that this only applies to range patterns and not also expressions. --- compiler/rustc_mir_build/messages.ftl | 6 ++-- compiler/rustc_mir_build/src/errors.rs | 7 +++++ .../rustc_mir_build/src/thir/pattern/mod.rs | 3 ++ tests/ui/error-codes/E0030-teach.rs | 2 +- tests/ui/error-codes/E0030-teach.stderr | 2 +- tests/ui/error-codes/E0030.rs | 2 +- tests/ui/error-codes/E0030.stderr | 2 +- .../half-open-range-pats-thir-lower-empty.rs | 30 +++++++++---------- ...lf-open-range-pats-thir-lower-empty.stderr | 30 +++++++++---------- tests/ui/loop-match/invalid.rs | 2 +- tests/ui/loop-match/invalid.stderr | 2 +- tests/ui/match/match-range-fail-2.rs | 6 ++-- tests/ui/match/match-range-fail-2.stderr | 6 ++-- tests/ui/match/validate-range-endpoints.rs | 2 +- .../ui/match/validate-range-endpoints.stderr | 2 +- 15 files changed, 58 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index f65b99d5f99f0..8b0c38dd3b536 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -250,11 +250,11 @@ mir_build_loop_match_unsupported_type = .note = only integers, floats, bool, char, and enums without fields are supported mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper = - lower range bound must be less than or equal to upper + lower bound for range pattern must be less than or equal to upper bound .label = lower bound larger than upper bound .teach_note = When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. -mir_build_lower_range_bound_must_be_less_than_upper = lower range bound must be less than upper +mir_build_lower_range_bound_must_be_less_than_upper = lower bound for range pattern must be less than upper bound mir_build_more_information = for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html @@ -506,6 +506,8 @@ mir_build_unused_unsafe = unnecessary `unsafe` block mir_build_unused_unsafe_enclosing_block_label = because it's nested under this `unsafe` block +mir_build_upper_range_bound_cannot_be_min = exclusive upper bound for a range bound cannot be the minimum + mir_build_variant_defined_here = not covered mir_build_wrap_suggestion = consider wrapping the function body in an unsafe block diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 3d9753d72da58..64e2bb3207c87 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -776,6 +776,13 @@ pub(crate) struct LowerRangeBoundMustBeLessThanUpper { pub(crate) span: Span, } +#[derive(Diagnostic)] +#[diag(mir_build_upper_range_bound_cannot_be_min, code = E0579)] +pub(crate) struct UpperRangeBoundCannotBeMin { + #[primary_span] + pub(crate) span: Span, +} + #[derive(LintDiagnostic)] #[diag(mir_build_leading_irrefutable_let_patterns)] #[note] diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 8531c5f39f84f..02e6f8d6ce717 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -273,6 +273,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { teach: self.tcx.sess.teach(E0030), }) } + RangeEnd::Excluded if lo_expr.is_none() => { + self.tcx.dcx().emit_err(UpperRangeBoundCannotBeMin { span }) + } RangeEnd::Excluded => { self.tcx.dcx().emit_err(LowerRangeBoundMustBeLessThanUpper { span }) } diff --git a/tests/ui/error-codes/E0030-teach.rs b/tests/ui/error-codes/E0030-teach.rs index e1f887139e3d4..56736e69f1b00 100644 --- a/tests/ui/error-codes/E0030-teach.rs +++ b/tests/ui/error-codes/E0030-teach.rs @@ -3,6 +3,6 @@ fn main() { match 5u32 { 1000 ..= 5 => {} - //~^ ERROR lower range bound must be less than or equal to upper + //~^ ERROR lower bound for range pattern must be less than or equal to upper bound } } diff --git a/tests/ui/error-codes/E0030-teach.stderr b/tests/ui/error-codes/E0030-teach.stderr index 36200d2b86afa..50c7d1eee1f4e 100644 --- a/tests/ui/error-codes/E0030-teach.stderr +++ b/tests/ui/error-codes/E0030-teach.stderr @@ -1,4 +1,4 @@ -error[E0030]: lower range bound must be less than or equal to upper +error[E0030]: lower bound for range pattern must be less than or equal to upper bound --> $DIR/E0030-teach.rs:5:9 | LL | 1000 ..= 5 => {} diff --git a/tests/ui/error-codes/E0030.rs b/tests/ui/error-codes/E0030.rs index 58d856b7c9d23..d861360532b51 100644 --- a/tests/ui/error-codes/E0030.rs +++ b/tests/ui/error-codes/E0030.rs @@ -1,6 +1,6 @@ fn main() { match 5u32 { 1000 ..= 5 => {} - //~^ ERROR lower range bound must be less than or equal to upper + //~^ ERROR lower bound for range pattern must be less than or equal to upper bound } } diff --git a/tests/ui/error-codes/E0030.stderr b/tests/ui/error-codes/E0030.stderr index 4e9378dfe1dc4..f5190f5330d70 100644 --- a/tests/ui/error-codes/E0030.stderr +++ b/tests/ui/error-codes/E0030.stderr @@ -1,4 +1,4 @@ -error[E0030]: lower range bound must be less than or equal to upper +error[E0030]: lower bound for range pattern must be less than or equal to upper bound --> $DIR/E0030.rs:3:9 | LL | 1000 ..= 5 => {} diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs index 6a0115de01605..6b7306e865739 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs @@ -9,36 +9,36 @@ macro_rules! m { fn main() { m!(0, ..u8::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..u16::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..u32::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..u64::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..u128::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..i8::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..i16::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..i32::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..i64::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0, ..i128::MIN); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0f16, ..f16::NEG_INFINITY); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0f32, ..f32::NEG_INFINITY); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0f64, ..f64::NEG_INFINITY); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!(0f128, ..f128::NEG_INFINITY); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum m!('a', ..'\u{0}'); - //~^ ERROR lower range bound must be less than upper + //~^ ERROR exclusive upper bound for a range bound cannot be the minimum } diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr index f414a6bfd1830..8be3c81876de9 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr @@ -1,88 +1,88 @@ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:11:11 | LL | m!(0, ..u8::MIN); | ^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:13:11 | LL | m!(0, ..u16::MIN); | ^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | LL | m!(0, ..u32::MIN); | ^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:17:11 | LL | m!(0, ..u64::MIN); | ^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:19:11 | LL | m!(0, ..u128::MIN); | ^^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:22:11 | LL | m!(0, ..i8::MIN); | ^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | LL | m!(0, ..i16::MIN); | ^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:26:11 | LL | m!(0, ..i32::MIN); | ^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | LL | m!(0, ..i64::MIN); | ^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:30:11 | LL | m!(0, ..i128::MIN); | ^^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:33:14 | LL | m!(0f16, ..f16::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:35:14 | LL | m!(0f32, ..f32::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:14 | LL | m!(0f64, ..f64::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:39:15 | LL | m!(0f128, ..f128::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^ -error[E0579]: lower range bound must be less than upper +error[E0579]: exclusive upper bound for a range bound cannot be the minimum --> $DIR/half-open-range-pats-thir-lower-empty.rs:42:13 | LL | m!('a', ..'\u{0}'); diff --git a/tests/ui/loop-match/invalid.rs b/tests/ui/loop-match/invalid.rs index 08eaf832f56d0..31712485040fc 100644 --- a/tests/ui/loop-match/invalid.rs +++ b/tests/ui/loop-match/invalid.rs @@ -202,7 +202,7 @@ fn invalid_range_pattern(state: f32) { break 'blk 2.5; } 4.0..3.0 => { - //~^ ERROR lower range bound must be less than upper + //~^ ERROR lower bound for range pattern must be less than upper bound todo!() } } diff --git a/tests/ui/loop-match/invalid.stderr b/tests/ui/loop-match/invalid.stderr index 9e9796a2ea794..82539ed17430d 100644 --- a/tests/ui/loop-match/invalid.stderr +++ b/tests/ui/loop-match/invalid.stderr @@ -121,7 +121,7 @@ LL ~ State::A => State::B, LL ~ State::B | State::C => todo!(), | -error[E0579]: lower range bound must be less than upper +error[E0579]: lower bound for range pattern must be less than upper bound --> $DIR/invalid.rs:204:17 | LL | 4.0..3.0 => { diff --git a/tests/ui/match/match-range-fail-2.rs b/tests/ui/match/match-range-fail-2.rs index 524e84323e7cd..7b65ef049e4e5 100644 --- a/tests/ui/match/match-range-fail-2.rs +++ b/tests/ui/match/match-range-fail-2.rs @@ -1,19 +1,19 @@ fn main() { match 5 { 6 ..= 1 => { } - //~^ ERROR lower range bound must be less than or equal to upper + //~^ ERROR lower bound for range pattern must be less than or equal to upper bound _ => { } }; match 5 { 0 .. 0 => { } - //~^ ERROR lower range bound must be less than upper + //~^ ERROR lower bound for range pattern must be less than upper bound _ => { } }; match 5u64 { 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } - //~^ ERROR lower range bound must be less than or equal to upper + //~^ ERROR lower bound for range pattern must be less than or equal to upper bound _ => { } }; } diff --git a/tests/ui/match/match-range-fail-2.stderr b/tests/ui/match/match-range-fail-2.stderr index 8bad2e6e1470f..41bb85da95053 100644 --- a/tests/ui/match/match-range-fail-2.stderr +++ b/tests/ui/match/match-range-fail-2.stderr @@ -1,16 +1,16 @@ -error[E0030]: lower range bound must be less than or equal to upper +error[E0030]: lower bound for range pattern must be less than or equal to upper bound --> $DIR/match-range-fail-2.rs:3:9 | LL | 6 ..= 1 => { } | ^^^^^^^ lower bound larger than upper bound -error[E0579]: lower range bound must be less than upper +error[E0579]: lower bound for range pattern must be less than upper bound --> $DIR/match-range-fail-2.rs:9:9 | LL | 0 .. 0 => { } | ^^^^^^ -error[E0030]: lower range bound must be less than or equal to upper +error[E0030]: lower bound for range pattern must be less than or equal to upper bound --> $DIR/match-range-fail-2.rs:15:9 | LL | 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } diff --git a/tests/ui/match/validate-range-endpoints.rs b/tests/ui/match/validate-range-endpoints.rs index 678cedf016b9e..71a54eb374fce 100644 --- a/tests/ui/match/validate-range-endpoints.rs +++ b/tests/ui/match/validate-range-endpoints.rs @@ -15,7 +15,7 @@ fn main() { // There isn't really a way to detect these 1..=TOO_BIG => {} - //~^ ERROR lower range bound must be less than or equal to upper + //~^ ERROR lower bound for range pattern must be less than or equal to upper bound _ => {} } diff --git a/tests/ui/match/validate-range-endpoints.stderr b/tests/ui/match/validate-range-endpoints.stderr index 6a8a81a1cc645..345629ee41a5e 100644 --- a/tests/ui/match/validate-range-endpoints.stderr +++ b/tests/ui/match/validate-range-endpoints.stderr @@ -10,7 +10,7 @@ error: literal out of range for `u8` LL | 1..=256 => {} | ^^^ this value does not fit into the type `u8` whose range is `0..=255` -error[E0030]: lower range bound must be less than or equal to upper +error[E0030]: lower bound for range pattern must be less than or equal to upper bound --> $DIR/validate-range-endpoints.rs:17:9 | LL | 1..=TOO_BIG => {} From 3d31636f89764a2f6fec0caf33dabfd4341d52c0 Mon Sep 17 00:00:00 2001 From: beetrees Date: Fri, 4 Jul 2025 17:44:15 +0100 Subject: [PATCH 11/22] Rework `c_variadic` --- .../rustc_codegen_ssa/src/traits/intrinsic.rs | 4 +- library/core/src/ffi/mod.rs | 2 +- library/core/src/ffi/va_list.rs | 183 ++++--------- library/core/src/intrinsics/mod.rs | 8 +- library/std/src/ffi/mod.rs | 2 +- .../src/directives/directive_names.rs | 1 + tests/auxiliary/rust_test_helpers.c | 4 + tests/codegen-llvm/cffi/c-variadic-copy.rs | 4 +- tests/codegen-llvm/cffi/c-variadic-opt.rs | 8 +- tests/codegen-llvm/cffi/c-variadic.rs | 12 +- .../c-link-to-rust-va-list-fn/checkrust.rs | 15 +- tests/ui/abi/variadic-ffi.rs | 32 ++- .../pass-by-value-abi.aarch64.stderr | 80 ++++++ tests/ui/c-variadic/pass-by-value-abi.rs | 46 ++++ .../c-variadic/pass-by-value-abi.win.stderr | 83 ++++++ .../pass-by-value-abi.x86_64.stderr | 240 ++++++++++++++++++ tests/ui/c-variadic/variadic-ffi-4.rs | 19 +- tests/ui/c-variadic/variadic-ffi-4.stderr | 121 ++------- .../macro-dotdotdot-may-not-begin-a-type.rs | 2 +- .../variadic-ffi-semantic-restrictions.rs | 6 +- .../variadic-ffi-semantic-restrictions.stderr | 6 +- tests/ui/thir-print/c-variadic.stdout | 4 +- 22 files changed, 591 insertions(+), 291 deletions(-) create mode 100644 tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr create mode 100644 tests/ui/c-variadic/pass-by-value-abi.rs create mode 100644 tests/ui/c-variadic/pass-by-value-abi.win.stderr create mode 100644 tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr diff --git a/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs b/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs index c5ecf43046c74..187e4b90656ab 100644 --- a/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/traits/intrinsic.rs @@ -36,10 +36,10 @@ pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes { vtable_byte_offset: u64, typeid: Self::Metadata, ) -> Self::Value; - /// Trait method used to inject `va_start` on the "spoofed" `VaListImpl` in + /// Trait method used to inject `va_start` on the "spoofed" `VaList` in /// Rust defined C-variadic functions. fn va_start(&mut self, val: Self::Value) -> Self::Value; - /// Trait method used to inject `va_end` on the "spoofed" `VaListImpl` before + /// Trait method used to inject `va_end` on the "spoofed" `VaList` before /// Rust defined C-variadic functions return. fn va_end(&mut self, val: Self::Value) -> Self::Value; } diff --git a/library/core/src/ffi/mod.rs b/library/core/src/ffi/mod.rs index 1356ca217c9a2..f1b928da7ef3c 100644 --- a/library/core/src/ffi/mod.rs +++ b/library/core/src/ffi/mod.rs @@ -28,7 +28,7 @@ pub mod c_str; issue = "44930", reason = "the `c_variadic` feature has not been properly tested on all supported platforms" )] -pub use self::va_list::{VaArgSafe, VaList, VaListImpl}; +pub use self::va_list::{VaArgSafe, VaList}; #[unstable( feature = "c_variadic", diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index 233a2ee3e484e..449e62ac00d3e 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -4,15 +4,15 @@ #[cfg(not(target_arch = "xtensa"))] use crate::ffi::c_void; -#[allow(unused_imports)] use crate::fmt; -use crate::intrinsics::{va_arg, va_copy, va_end}; -use crate::marker::{PhantomData, PhantomInvariantLifetime}; -use crate::ops::{Deref, DerefMut}; +use crate::intrinsics::{va_arg, va_copy}; +use crate::marker::PhantomCovariantLifetime; -// The name is WIP, using `VaListImpl` for now. -// // Most targets explicitly specify the layout of `va_list`, this layout is matched here. +// For `va_list`s which are single-element array in C (and therefore experience array-to-pointer +// decay when passed as arguments in C), the `VaList` struct is annotated with +// `#[rustc_pass_indirectly_in_non_rustic_abis]`. This ensures that the compiler uses the correct +// ABI for functions like `extern "C" fn takes_va_list(va: VaList<'_>)` by passing `va` indirectly. crate::cfg_select! { all( target_arch = "aarch64", @@ -27,66 +27,60 @@ crate::cfg_select! { /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf #[repr(C)] #[derive(Debug)] - #[lang = "va_list"] - pub struct VaListImpl<'f> { - stack: *mut c_void, - gr_top: *mut c_void, - vr_top: *mut c_void, + struct VaListInner { + stack: *const c_void, + gr_top: *const c_void, + vr_top: *const c_void, gr_offs: i32, vr_offs: i32, - _marker: PhantomInvariantLifetime<'f>, } } all(target_arch = "powerpc", not(target_os = "uefi"), not(windows)) => { /// PowerPC ABI implementation of a `va_list`. #[repr(C)] #[derive(Debug)] - #[lang = "va_list"] - pub struct VaListImpl<'f> { + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { gpr: u8, fpr: u8, reserved: u16, - overflow_arg_area: *mut c_void, - reg_save_area: *mut c_void, - _marker: PhantomInvariantLifetime<'f>, + overflow_arg_area: *const c_void, + reg_save_area: *const c_void, } } target_arch = "s390x" => { /// s390x ABI implementation of a `va_list`. #[repr(C)] #[derive(Debug)] - #[lang = "va_list"] - pub struct VaListImpl<'f> { + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { gpr: i64, fpr: i64, - overflow_arg_area: *mut c_void, - reg_save_area: *mut c_void, - _marker: PhantomInvariantLifetime<'f>, + overflow_arg_area: *const c_void, + reg_save_area: *const c_void, } } all(target_arch = "x86_64", not(target_os = "uefi"), not(windows)) => { /// x86_64 ABI implementation of a `va_list`. #[repr(C)] #[derive(Debug)] - #[lang = "va_list"] - pub struct VaListImpl<'f> { + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { gp_offset: i32, fp_offset: i32, - overflow_arg_area: *mut c_void, - reg_save_area: *mut c_void, - _marker: PhantomInvariantLifetime<'f>, + overflow_arg_area: *const c_void, + reg_save_area: *const c_void, } } target_arch = "xtensa" => { /// Xtensa ABI implementation of a `va_list`. #[repr(C)] #[derive(Debug)] - #[lang = "va_list"] - pub struct VaListImpl<'f> { - stk: *mut i32, - reg: *mut i32, + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { + stk: *const i32, + reg: *const i32, ndx: i32, - _marker: PhantomInvariantLifetime<'f>, } } @@ -95,94 +89,32 @@ crate::cfg_select! { // - apple aarch64 (see https://github.com/rust-lang/rust/pull/56599) // - windows // - uefi - // - any other target for which we don't specify the `VaListImpl` above + // - any other target for which we don't specify the `VaListInner` above // // In this implementation the `va_list` type is just an alias for an opaque pointer. // That pointer is probably just the next variadic argument on the caller's stack. _ => { /// Basic implementation of a `va_list`. #[repr(transparent)] - #[lang = "va_list"] - pub struct VaListImpl<'f> { - ptr: *mut c_void, - - // Invariant over `'f`, so each `VaListImpl<'f>` object is tied to - // the region of the function it's defined in - _marker: PhantomInvariantLifetime<'f>, - } - - impl<'f> fmt::Debug for VaListImpl<'f> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "va_list* {:p}", self.ptr) - } - } - } -} - -crate::cfg_select! { - all( - any( - target_arch = "aarch64", - target_arch = "powerpc", - target_arch = "s390x", - target_arch = "x86_64" - ), - not(target_arch = "xtensa"), - any(not(target_arch = "aarch64"), not(target_vendor = "apple")), - not(target_family = "wasm"), - not(target_os = "uefi"), - not(windows), - ) => { - /// A wrapper for a `va_list` - #[repr(transparent)] - #[derive(Debug)] - pub struct VaList<'a, 'f: 'a> { - inner: &'a mut VaListImpl<'f>, - _marker: PhantomData<&'a mut VaListImpl<'f>>, - } - - - impl<'f> VaListImpl<'f> { - /// Converts a [`VaListImpl`] into a [`VaList`] that is binary-compatible with C's `va_list`. - #[inline] - pub fn as_va_list<'a>(&'a mut self) -> VaList<'a, 'f> { - VaList { inner: self, _marker: PhantomData } - } - } - } - - _ => { - /// A wrapper for a `va_list` - #[repr(transparent)] #[derive(Debug)] - pub struct VaList<'a, 'f: 'a> { - inner: VaListImpl<'f>, - _marker: PhantomData<&'a mut VaListImpl<'f>>, - } - - impl<'f> VaListImpl<'f> { - /// Converts a [`VaListImpl`] into a [`VaList`] that is binary-compatible with C's `va_list`. - #[inline] - pub fn as_va_list<'a>(&'a mut self) -> VaList<'a, 'f> { - VaList { inner: VaListImpl { ..*self }, _marker: PhantomData } - } + struct VaListInner { + ptr: *const c_void, } } } -impl<'a, 'f: 'a> Deref for VaList<'a, 'f> { - type Target = VaListImpl<'f>; - - #[inline] - fn deref(&self) -> &VaListImpl<'f> { - &self.inner - } +/// A variable argument list, equivalent to `va_list` in C. +#[repr(transparent)] +#[lang = "va_list"] +pub struct VaList<'a> { + inner: VaListInner, + _marker: PhantomCovariantLifetime<'a>, } -impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> { - #[inline] - fn deref_mut(&mut self) -> &mut VaListImpl<'f> { - &mut self.inner +impl fmt::Debug for VaList<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // No need to include `_marker` in debug output. + f.debug_tuple("VaList").field(&self.inner).finish() } } @@ -203,7 +135,7 @@ mod sealed { impl Sealed for *const T {} } -/// Types that are valid to read using [`VaListImpl::arg`]. +/// Types that are valid to read using [`VaList::arg`]. /// /// # Safety /// @@ -238,7 +170,7 @@ unsafe impl VaArgSafe for f64 {} unsafe impl VaArgSafe for *mut T {} unsafe impl VaArgSafe for *const T {} -impl<'f> VaListImpl<'f> { +impl<'f> VaList<'f> { /// Advance to and read the next variable argument. /// /// # Safety @@ -258,27 +190,13 @@ impl<'f> VaListImpl<'f> { // SAFETY: the caller must uphold the safety contract for `va_arg`. unsafe { va_arg(self) } } - - /// Copies the `va_list` at the current location. - pub unsafe fn with_copy(&self, f: F) -> R - where - F: for<'copy> FnOnce(VaList<'copy, 'f>) -> R, - { - let mut ap = self.clone(); - let ret = f(ap.as_va_list()); - // SAFETY: the caller must uphold the safety contract for `va_end`. - unsafe { - va_end(&mut ap); - } - ret - } } -impl<'f> Clone for VaListImpl<'f> { +impl<'f> Clone for VaList<'f> { #[inline] fn clone(&self) -> Self { let mut dest = crate::mem::MaybeUninit::uninit(); - // SAFETY: we write to the `MaybeUninit`, thus it is initialized and `assume_init` is legal + // SAFETY: we write to the `MaybeUninit`, thus it is initialized and `assume_init` is legal. unsafe { va_copy(dest.as_mut_ptr(), self); dest.assume_init() @@ -286,18 +204,11 @@ impl<'f> Clone for VaListImpl<'f> { } } -impl<'f> Drop for VaListImpl<'f> { +impl<'f> Drop for VaList<'f> { fn drop(&mut self) { - // FIXME: this should call `va_end`, but there's no clean way to - // guarantee that `drop` always gets inlined into its caller, - // so the `va_end` would get directly called from the same function as - // the corresponding `va_copy`. `man va_end` states that C requires this, - // and LLVM basically follows the C semantics, so we need to make sure - // that `va_end` is always called from the same function as `va_copy`. - // For more details, see https://github.com/rust-lang/rust/pull/59625 - // and https://llvm.org/docs/LangRef.html#llvm-va-end-intrinsic. - // - // This works for now, since `va_end` is a no-op on all current LLVM targets. + // Rust requires that not calling `va_end` on a `va_list` does not cause undefined behaviour + // (as it is safe to leak values). As `va_end` is a no-op on all current LLVM targets, this + // destructor is empty. } } diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 2115c5c9a85d8..7571f4a1fc12f 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -54,7 +54,7 @@ )] #![allow(missing_docs)] -use crate::ffi::va_list::{VaArgSafe, VaListImpl}; +use crate::ffi::va_list::{VaArgSafe, VaList}; use crate::marker::{ConstParamTy, Destruct, DiscriminantKind, PointeeSized, Tuple}; use crate::{mem, ptr}; @@ -3447,7 +3447,7 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize /// #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); +pub unsafe fn va_copy<'f>(dest: *mut VaList<'f>, src: &VaList<'f>); /// Loads an argument of type `T` from the `va_list` `ap` and increment the /// argument `ap` points to. @@ -3465,7 +3465,7 @@ pub unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); /// #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn va_arg(ap: &mut VaListImpl<'_>) -> T; +pub unsafe fn va_arg(ap: &mut VaList<'_>) -> T; /// Destroy the arglist `ap` after initialization with `va_start` or `va_copy`. /// @@ -3475,4 +3475,4 @@ pub unsafe fn va_arg(ap: &mut VaListImpl<'_>) -> T; /// #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn va_end(ap: &mut VaListImpl<'_>); +pub unsafe fn va_end(ap: &mut VaList<'_>); diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs index f44e12d48addf..999bd5e63dc45 100644 --- a/library/std/src/ffi/mod.rs +++ b/library/std/src/ffi/mod.rs @@ -172,7 +172,7 @@ pub use core::ffi::c_void; all supported platforms", issue = "44930" )] -pub use core::ffi::{VaArgSafe, VaList, VaListImpl}; +pub use core::ffi::{VaArgSafe, VaList}; #[stable(feature = "core_ffi_c", since = "1.64.0")] pub use core::ffi::{ c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, diff --git a/src/tools/compiletest/src/directives/directive_names.rs b/src/tools/compiletest/src/directives/directive_names.rs index 7b1c0a18670d2..e9824edfef601 100644 --- a/src/tools/compiletest/src/directives/directive_names.rs +++ b/src/tools/compiletest/src/directives/directive_names.rs @@ -121,6 +121,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "ignore-thumbv8m.base-none-eabi", "ignore-thumbv8m.main-none-eabi", "ignore-tvos", + "ignore-uefi", "ignore-unix", "ignore-unknown", "ignore-uwp", diff --git a/tests/auxiliary/rust_test_helpers.c b/tests/auxiliary/rust_test_helpers.c index 34cc7fd5dfbed..cd10d6b98ca7b 100644 --- a/tests/auxiliary/rust_test_helpers.c +++ b/tests/auxiliary/rust_test_helpers.c @@ -314,6 +314,10 @@ double rust_interesting_average(uint64_t n, ...) { return sum; } +int32_t rust_va_list_next_i32(va_list* ap) { + return va_arg(*ap, int32_t); +} + int32_t rust_int8_to_int32(int8_t x) { return (int32_t)x; } diff --git a/tests/codegen-llvm/cffi/c-variadic-copy.rs b/tests/codegen-llvm/cffi/c-variadic-copy.rs index 4c61c4fcf68d3..0cbdcb4bbb85c 100644 --- a/tests/codegen-llvm/cffi/c-variadic-copy.rs +++ b/tests/codegen-llvm/cffi/c-variadic-copy.rs @@ -1,4 +1,4 @@ -// Tests that `VaListImpl::clone` gets inlined into a call to `llvm.va_copy` +// Tests that `VaList::clone` gets inlined into a call to `llvm.va_copy` #![crate_type = "lib"] #![feature(c_variadic)] @@ -12,5 +12,5 @@ extern "C" { pub unsafe extern "C" fn clone_variadic(ap: VaList) { let mut ap2 = ap.clone(); // CHECK: call void @llvm.va_copy - foreign_c_variadic_1(ap2.as_va_list(), 42i32); + foreign_c_variadic_1(ap2, 42i32); } diff --git a/tests/codegen-llvm/cffi/c-variadic-opt.rs b/tests/codegen-llvm/cffi/c-variadic-opt.rs index 7e544ee7f37da..3cc0c3e9f9bdd 100644 --- a/tests/codegen-llvm/cffi/c-variadic-opt.rs +++ b/tests/codegen-llvm/cffi/c-variadic-opt.rs @@ -10,21 +10,21 @@ extern "C" { } // Ensure that `va_start` and `va_end` are properly injected even -// when the "spoofed" `VaListImpl` is not used. +// when the "spoofed" `VaList` is not used. #[no_mangle] pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 { // CHECK: call void @llvm.va_start - vprintf(fmt, ap.as_va_list()) + vprintf(fmt, ap) // CHECK: call void @llvm.va_end } -// Check that `VaListImpl::clone` gets inlined into a direct call to `llvm.va_copy` +// Check that `VaList::clone` gets inlined into a direct call to `llvm.va_copy` #[no_mangle] pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 { // CHECK: call void @llvm.va_start let mut ap2 = ap.clone(); // CHECK: call void @llvm.va_copy - let res = vprintf(fmt, ap2.as_va_list()); + let res = vprintf(fmt, ap2); res // CHECK: call void @llvm.va_end } diff --git a/tests/codegen-llvm/cffi/c-variadic.rs b/tests/codegen-llvm/cffi/c-variadic.rs index 140d2f37f4693..3ce421eb4a5c2 100644 --- a/tests/codegen-llvm/cffi/c-variadic.rs +++ b/tests/codegen-llvm/cffi/c-variadic.rs @@ -1,6 +1,6 @@ //@ needs-unwind //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 -// +//@ min-llvm-version: 21 #![crate_type = "lib"] #![feature(c_variadic)] @@ -25,23 +25,23 @@ pub unsafe extern "C" fn use_foreign_c_variadic_0() { } // Ensure that we do not remove the `va_list` passed to the foreign function when -// removing the "spoofed" `VaListImpl` that is used by Rust defined C-variadics. +// removing the "spoofed" `VaList` that is used by Rust defined C-variadics. pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap) + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %0) foreign_c_variadic_1(ap); } pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42) + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %0, [[PARAM]] 42) foreign_c_variadic_1(ap, 42i32); } pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42) + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %0, [[PARAM]] 2, [[PARAM]] 42) foreign_c_variadic_1(ap, 2i32, 42i32); } pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) { - // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42, [[PARAM]] 0) + // CHECK: call void ({{.*}}, ...) @foreign_c_variadic_1({{.*}} %0, [[PARAM]] 2, [[PARAM]] 42, [[PARAM]] 0) foreign_c_variadic_1(ap, 2i32, 42i32, 0i32); } diff --git a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs index 63d8d713d6226..dd2d094709942 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs @@ -2,7 +2,7 @@ #![feature(c_variadic)] #![feature(cfg_select)] -use std::ffi::{CStr, CString, VaList, VaListImpl, c_char, c_double, c_int, c_long, c_longlong}; +use std::ffi::{CStr, CString, VaList, c_char, c_double, c_int, c_long, c_longlong}; macro_rules! continue_if { ($cond:expr) => { @@ -58,11 +58,8 @@ pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize { continue_if!(ap.arg::() == 16); continue_if!(ap.arg::() == 'A' as c_int); continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!")); - ap.with_copy( - |mut ap| { - if compare_c_str(ap.arg::<*const c_char>(), "Correct") { 0 } else { 0xff } - }, - ) + let mut ap = ap.clone(); + if compare_c_str(ap.arg::<*const c_char>(), "Correct") { 0 } else { 0xff } } #[unsafe(no_mangle)] @@ -153,8 +150,8 @@ pub unsafe extern "C" fn check_varargs_5(_: c_int, mut ap: ...) -> usize { unsafe extern "C" { fn test_variadic(_: c_int, ...) -> usize; fn test_va_list_by_value(_: VaList) -> usize; - fn test_va_list_by_pointer(_: *mut VaListImpl) -> usize; - fn test_va_list_by_pointer_pointer(_: *mut *mut VaListImpl) -> usize; + fn test_va_list_by_pointer(_: *mut VaList) -> usize; + fn test_va_list_by_pointer_pointer(_: *mut *mut VaList) -> usize; } #[unsafe(no_mangle)] @@ -165,7 +162,7 @@ extern "C" fn run_test_variadic() -> usize { #[unsafe(no_mangle)] extern "C" fn run_test_va_list_by_value() -> usize { unsafe extern "C" fn helper(mut ap: ...) -> usize { - unsafe { test_va_list_by_value(ap.as_va_list()) } + unsafe { test_va_list_by_value(ap) } } unsafe { helper(1 as c_longlong, 2 as c_int, 3 as c_longlong) } diff --git a/tests/ui/abi/variadic-ffi.rs b/tests/ui/abi/variadic-ffi.rs index dfdbff33264be..3ffa0bea0ecf8 100644 --- a/tests/ui/abi/variadic-ffi.rs +++ b/tests/ui/abi/variadic-ffi.rs @@ -10,37 +10,45 @@ extern "C" { fn rust_interesting_average(_: u64, ...) -> f64; fn rust_valist_interesting_average(_: u64, _: VaList) -> f64; + + fn rust_va_list_next_i32(_: *mut VaList<'_>) -> i32; } -pub unsafe extern "C" fn test_valist_forward(n: u64, mut ap: ...) -> f64 { - rust_valist_interesting_average(n, ap.as_va_list()) +pub unsafe extern "C" fn test_valist_forward(n: u64, ap: ...) -> f64 { + rust_valist_interesting_average(n, ap) } -pub unsafe extern "C-unwind" fn c_unwind_can_forward(n: u64, mut ap: ...) -> f64 { - rust_valist_interesting_average(n, ap.as_va_list()) +pub unsafe extern "C-unwind" fn c_unwind_can_forward(n: u64, ap: ...) -> f64 { + rust_valist_interesting_average(n, ap) } pub unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) { - let mut ap2 = ap.clone(); - assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 30); + let ap2 = ap.clone(); + assert_eq!(rust_valist_interesting_average(2, ap2) as i64, 30); // Advance one pair in the copy before checking let mut ap2 = ap.clone(); let _ = ap2.arg::(); let _ = ap2.arg::(); - assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 50); + assert_eq!(rust_valist_interesting_average(2, ap2) as i64, 50); // Advance one pair in the original let _ = ap.arg::(); let _ = ap.arg::(); - let mut ap2 = ap.clone(); - assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 50); + let ap2 = ap.clone(); + assert_eq!(rust_valist_interesting_average(2, ap2) as i64, 50); let mut ap2 = ap.clone(); let _ = ap2.arg::(); let _ = ap2.arg::(); - assert_eq!(rust_valist_interesting_average(2, ap2.as_va_list()) as i64, 70); + assert_eq!(rust_valist_interesting_average(2, ap2) as i64, 70); +} + +pub unsafe extern "C" fn test_ref(mut ap: ...) { + assert_eq!(rust_va_list_next_i32(&mut ap), 2); + assert_eq!(rust_va_list_next_i32(&mut ap), 4); + assert_eq!(rust_va_list_next_i32(&mut ap), 8); } pub fn main() { @@ -85,4 +93,8 @@ pub fn main() { unsafe { test_va_copy(4, 10i64, 10f64, 20i64, 20f64, 30i64, 30f64, 40i64, 40f64); } + + unsafe { + test_ref(2, 4, 8); + } } diff --git a/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr new file mode 100644 index 0000000000000..fe11c42886188 --- /dev/null +++ b/tests/ui/c-variadic/pass-by-value-abi.aarch64.stderr @@ -0,0 +1,80 @@ +error: fn_abi_of(take_va_list) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: VaList<'_>, + layout: Layout { + size: Size(32 bytes), + align: AbiAlign { + abi: Align(8 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: $OFFSETS, + memory_index: $MEMORY_INDEX, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(8 bytes), + randomization_seed: $SEED, + }, + }, + mode: Indirect { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef, + arg_ext: None, + pointee_size: Size(32 bytes), + pointee_align: Some( + Align(8 bytes), + ), + }, + meta_attrs: None, + on_stack: false, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: Align(1 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: C, + can_unwind: false, + } + --> $DIR/pass-by-value-abi.rs:26:1 + | +LL | pub extern "C" fn take_va_list(_: VaList<'_>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/c-variadic/pass-by-value-abi.rs b/tests/ui/c-variadic/pass-by-value-abi.rs new file mode 100644 index 0000000000000..b65442af24727 --- /dev/null +++ b/tests/ui/c-variadic/pass-by-value-abi.rs @@ -0,0 +1,46 @@ +//@ check-fail +//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" +//@ normalize-stderr: "valid_range: 0\.\.=\d+" -> "valid_range: 0..=$$MAX" +//@ normalize-stderr: "memory_index: \[[^\]]+\]" -> "memory_index: $$MEMORY_INDEX" +//@ normalize-stderr: "offsets: \[[^\]]+\]" -> "offsets: $$OFFSETS" +//@ revisions: x86_64 aarch64 win +//@ compile-flags: -O +//@ [x86_64] only-x86_64 +//@ [x86_64] ignore-windows +//@ [x86_64] ignore-uefi +//@ [aarch64] only-aarch64 +//@ [aarch64] ignore-windows +//@ [aarch64] ignore-apple +//@ [aarch64] ignore-uefi +// Windows dosen't use `#[rustc_pass_indirectly_in_non_rustic_abis]` and is tested in CI, so is here +// for comparison. +//@ [win] only-windows + +#![feature(rustc_attrs, c_variadic)] +#![crate_type = "lib"] + +// Can't use `minicore` here as this is testing the implementation in `core::ffi` specifically. +use std::ffi::VaList; + +#[rustc_abi(debug)] +pub extern "C" fn take_va_list(_: VaList<'_>) {} +//~^ ERROR fn_abi_of(take_va_list) = FnAbi { +//[x86_64]~^^ ERROR mode: Indirect { +//[x86_64]~^^^ ERROR on_stack: false, +//[aarch64]~^^^^ ERROR mode: Indirect { +//[aarch64]~^^^^^ ERROR on_stack: false, +//[win]~^^^^^^ ERROR mode: Direct( + +#[cfg(all(target_arch = "x86_64", not(windows)))] +#[rustc_abi(debug)] +pub extern "sysv64" fn take_va_list_sysv64(_: VaList<'_>) {} +//[x86_64]~^ ERROR fn_abi_of(take_va_list_sysv64) = FnAbi { +//[x86_64]~^^ ERROR mode: Indirect { +//[x86_64]~^^^ ERROR on_stack: false, + +#[cfg(all(target_arch = "x86_64", not(windows)))] +#[rustc_abi(debug)] +pub extern "win64" fn take_va_list_win64(_: VaList<'_>) {} +//[x86_64]~^ ERROR: fn_abi_of(take_va_list_win64) = FnAbi { +//[x86_64]~^^ ERROR mode: Indirect { +//[x86_64]~^^^ ERROR on_stack: false, diff --git a/tests/ui/c-variadic/pass-by-value-abi.win.stderr b/tests/ui/c-variadic/pass-by-value-abi.win.stderr new file mode 100644 index 0000000000000..e84430859e029 --- /dev/null +++ b/tests/ui/c-variadic/pass-by-value-abi.win.stderr @@ -0,0 +1,83 @@ +error: fn_abi_of(take_va_list) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: VaList<'_>, + layout: Layout { + size: Size(8 bytes), + align: AbiAlign { + abi: Align(8 bytes), + }, + backend_repr: Scalar( + Initialized { + value: Pointer( + AddressSpace( + 0, + ), + ), + valid_range: 0..=$MAX, + }, + ), + fields: Arbitrary { + offsets: $OFFSETS, + memory_index: $MEMORY_INDEX, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(8 bytes), + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: Align(1 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: C, + can_unwind: false, + } + --> $DIR/pass-by-value-abi.rs:26:1 + | +LL | pub extern "C" fn take_va_list(_: VaList<'_>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr new file mode 100644 index 0000000000000..73f1ccd5992a9 --- /dev/null +++ b/tests/ui/c-variadic/pass-by-value-abi.x86_64.stderr @@ -0,0 +1,240 @@ +error: fn_abi_of(take_va_list) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: VaList<'_>, + layout: Layout { + size: Size(24 bytes), + align: AbiAlign { + abi: Align(8 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: $OFFSETS, + memory_index: $MEMORY_INDEX, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(8 bytes), + randomization_seed: $SEED, + }, + }, + mode: Indirect { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef, + arg_ext: None, + pointee_size: Size(24 bytes), + pointee_align: Some( + Align(8 bytes), + ), + }, + meta_attrs: None, + on_stack: false, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: Align(1 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: C, + can_unwind: false, + } + --> $DIR/pass-by-value-abi.rs:26:1 + | +LL | pub extern "C" fn take_va_list(_: VaList<'_>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: fn_abi_of(take_va_list_sysv64) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: VaList<'_>, + layout: Layout { + size: Size(24 bytes), + align: AbiAlign { + abi: Align(8 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: $OFFSETS, + memory_index: $MEMORY_INDEX, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(8 bytes), + randomization_seed: $SEED, + }, + }, + mode: Indirect { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef, + arg_ext: None, + pointee_size: Size(24 bytes), + pointee_align: Some( + Align(8 bytes), + ), + }, + meta_attrs: None, + on_stack: false, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: Align(1 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: X86( + SysV64, + ), + can_unwind: false, + } + --> $DIR/pass-by-value-abi.rs:36:1 + | +LL | pub extern "sysv64" fn take_va_list_sysv64(_: VaList<'_>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: fn_abi_of(take_va_list_win64) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: VaList<'_>, + layout: Layout { + size: Size(24 bytes), + align: AbiAlign { + abi: Align(8 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: $OFFSETS, + memory_index: $MEMORY_INDEX, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(8 bytes), + randomization_seed: $SEED, + }, + }, + mode: Indirect { + attrs: ArgAttributes { + regular: CapturesAddress | NoAlias | NonNull | NoUndef, + arg_ext: None, + pointee_size: Size(24 bytes), + pointee_align: Some( + Align(8 bytes), + ), + }, + meta_attrs: None, + on_stack: false, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: Align(1 bytes), + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: X86( + Win64, + ), + can_unwind: false, + } + --> $DIR/pass-by-value-abi.rs:43:1 + | +LL | pub extern "win64" fn take_va_list_win64(_: VaList<'_>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/c-variadic/variadic-ffi-4.rs b/tests/ui/c-variadic/variadic-ffi-4.rs index 8064037942259..d9e2e617ce3a1 100644 --- a/tests/ui/c-variadic/variadic-ffi-4.rs +++ b/tests/ui/c-variadic/variadic-ffi-4.rs @@ -2,37 +2,30 @@ #![no_std] #![feature(c_variadic)] -use core::ffi::{VaList, VaListImpl}; +use core::ffi::VaList; -pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> { +pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaList<'f> { ap //~^ ERROR: lifetime may not live long enough - //~| ERROR: lifetime may not live long enough } -pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> { +pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> { ap //~ ERROR: lifetime may not live long enough } -pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) { - let _ = ap.with_copy(|ap| ap); //~ ERROR: lifetime may not live long enough -} - -pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) { *ap0 = ap1; //~^ ERROR: lifetime may not live long enough - //~| ERROR: lifetime may not live long enough } -pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { ap0 = &mut ap1; //~^ ERROR: `ap1` does not live long enough //~| ERROR: lifetime may not live long enough //~| ERROR: lifetime may not live long enough } -pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaList, mut ap1: ...) { *ap0 = ap1.clone(); //~^ ERROR: lifetime may not live long enough - //~| ERROR: lifetime may not live long enough } diff --git a/tests/ui/c-variadic/variadic-ffi-4.stderr b/tests/ui/c-variadic/variadic-ffi-4.stderr index fc9f8036083a6..a230bb6f5861e 100644 --- a/tests/ui/c-variadic/variadic-ffi-4.stderr +++ b/tests/ui/c-variadic/variadic-ffi-4.stderr @@ -1,113 +1,64 @@ error: lifetime may not live long enough --> $DIR/variadic-ffi-4.rs:8:5 | -LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> { - | -- -- has type `VaListImpl<'1>` - | | - | lifetime `'f` defined here -LL | ap - | ^^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'f` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance - -error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:8:5 - | -LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> { - | -- -- has type `VaListImpl<'1>` +LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaList<'f> { + | -- -- has type `VaList<'1>` | | | lifetime `'f` defined here LL | ap | ^^ function was supposed to return data with lifetime `'f` but it is returning data with lifetime `'1` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:14:5 + --> $DIR/variadic-ffi-4.rs:13:5 | -LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> { - | -- has type `VaListImpl<'1>` +LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> { + | -- has type `VaList<'1>` LL | ap | ^^ returning this value requires that `'1` must outlive `'static` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:18:31 + --> $DIR/variadic-ffi-4.rs:17:5 | -LL | let _ = ap.with_copy(|ap| ap); - | --- ^^ returning this value requires that `'1` must outlive `'2` - | | | - | | return type of closure is VaList<'2, '_> - | has type `VaList<'1, '_>` - -error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:22:5 - | -LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | ------- ------- has type `VaListImpl<'2>` +LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) { + | ------- ------- has type `VaList<'1>` | | - | has type `&mut VaListImpl<'1>` + | has type `&mut VaList<'2>` LL | *ap0 = ap1; | ^^^^ assignment requires that `'1` must outlive `'2` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance error: lifetime may not live long enough --> $DIR/variadic-ffi-4.rs:22:5 | -LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | ------- ------- has type `VaListImpl<'2>` +LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { + | ------- ------- has type `VaList<'2>` | | - | has type `&mut VaListImpl<'1>` -LL | *ap0 = ap1; - | ^^^^ assignment requires that `'2` must outlive `'1` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance - -error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:28:5 - | -LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | ------- ------- has type `VaListImpl<'2>` - | | - | has type `&mut VaListImpl<'1>` + | has type `&mut VaList<'1>` LL | ap0 = &mut ap1; | ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2` | - = note: requirement occurs because of a mutable reference to `VaListImpl<'_>` + = note: requirement occurs because of a mutable reference to `VaList<'_>` = note: mutable references are invariant over their type parameter = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:28:5 + --> $DIR/variadic-ffi-4.rs:22:5 | -LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | ------- ------- has type `VaListImpl<'2>` +LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { + | ------- ------- has type `VaList<'2>` | | - | has type `&mut VaListImpl<'1>` + | has type `&mut VaList<'1>` LL | ap0 = &mut ap1; | ^^^^^^^^^^^^^^ assignment requires that `'2` must outlive `'1` | - = note: requirement occurs because of a mutable reference to `VaListImpl<'_>` + = note: requirement occurs because of a mutable reference to `VaList<'_>` = note: mutable references are invariant over their type parameter = help: see for more information about variance error[E0597]: `ap1` does not live long enough - --> $DIR/variadic-ffi-4.rs:28:11 + --> $DIR/variadic-ffi-4.rs:22:11 | -LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | - ------- binding `ap1` declared here +LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) { + | - ------- binding `ap1` declared here | | | let's call the lifetime of this reference `'3` LL | ap0 = &mut ap1; @@ -120,33 +71,15 @@ LL | } | - `ap1` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:35:5 - | -LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | ------- ------- has type `VaListImpl<'2>` - | | - | has type `&mut VaListImpl<'1>` -LL | *ap0 = ap1.clone(); - | ^^^^ assignment requires that `'2` must outlive `'1` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance - -error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:35:12 + --> $DIR/variadic-ffi-4.rs:29:5 | -LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - | ------- ------- has type `VaListImpl<'2>` +LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaList, mut ap1: ...) { + | ------- ------- has type `VaList<'1>` | | - | has type `&mut VaListImpl<'1>` + | has type `&mut VaList<'2>` LL | *ap0 = ap1.clone(); - | ^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - | - = note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant - = note: the struct `VaListImpl<'f>` is invariant over the parameter `'f` - = help: see for more information about variance + | ^^^^ assignment requires that `'1` must outlive `'2` -error: aborting due to 11 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs b/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs index 8be99f22d2ee0..b29f6915ae3d6 100644 --- a/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs +++ b/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs @@ -1,4 +1,4 @@ -// A bare `...` represents `CVarArgs` (`VaListImpl<'_>`) in function argument type +// A bare `...` represents `CVarArgs` (`VaList<'_>`) in function argument type // position without being a proper type syntactically. // This test ensures that we do not regress certain MBE calls would we ever promote // `...` to a proper type syntactically. diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs index 025c0e3ecaca4..6f61425a8bd6c 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -32,12 +32,12 @@ extern "C" fn f3_3(_: ..., x: isize) {} const unsafe extern "C" fn f4_1(x: isize, _: ...) {} //~^ ERROR functions cannot be both `const` and C-variadic -//~| ERROR destructor of `VaListImpl<'_>` cannot be evaluated at compile-time +//~| ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time const extern "C" fn f4_2(x: isize, _: ...) {} //~^ ERROR functions cannot be both `const` and C-variadic //~| ERROR functions with a C variable argument list must be unsafe -//~| ERROR destructor of `VaListImpl<'_>` cannot be evaluated at compile-time +//~| ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time const extern "C" fn f4_3(_: ..., x: isize, _: ...) {} //~^ ERROR functions cannot be both `const` and C-variadic @@ -65,7 +65,7 @@ impl X { const fn i_f5(x: isize, _: ...) {} //~^ ERROR `...` is not supported for non-extern functions //~| ERROR functions cannot be both `const` and C-variadic - //~| ERROR destructor of `VaListImpl<'_>` cannot be evaluated at compile-time + //~| ERROR destructor of `VaList<'_>` cannot be evaluated at compile-time } trait T { diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr index 0e02d4434233e..318015737fa1b 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -236,7 +236,7 @@ error: `...` must be the last argument of a C-variadic function LL | fn t_f6(_: ..., x: isize); | ^^^^^^ -error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time +error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time --> $DIR/variadic-ffi-semantic-restrictions.rs:33:43 | LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} @@ -244,7 +244,7 @@ LL | const unsafe extern "C" fn f4_1(x: isize, _: ...) {} | | | the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time +error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time --> $DIR/variadic-ffi-semantic-restrictions.rs:37:36 | LL | const extern "C" fn f4_2(x: isize, _: ...) {} @@ -252,7 +252,7 @@ LL | const extern "C" fn f4_2(x: isize, _: ...) {} | | | the destructor for this type cannot be evaluated in constant functions -error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time +error[E0493]: destructor of `VaList<'_>` cannot be evaluated at compile-time --> $DIR/variadic-ffi-semantic-restrictions.rs:65:29 | LL | const fn i_f5(x: isize, _: ...) {} diff --git a/tests/ui/thir-print/c-variadic.stdout b/tests/ui/thir-print/c-variadic.stdout index d64b2b9aa9d1d..f1905e04f72bf 100644 --- a/tests/ui/thir-print/c-variadic.stdout +++ b/tests/ui/thir-print/c-variadic.stdout @@ -16,13 +16,13 @@ params: [ ) } Param { - ty: std::ffi::VaListImpl<'{erased}> + ty: std::ffi::VaList<'{erased}> ty_span: None self_kind: None hir_id: Some(HirId(DefId(0:3 ~ c_variadic[a5de]::foo).3)) param: Some( Pat: { - ty: std::ffi::VaListImpl<'{erased}> + ty: std::ffi::VaList<'{erased}> span: $DIR/c-variadic.rs:7:34: 7:37 (#0) kind: PatKind { Missing From 64151c2ab00fb89e36e8f772fc93422d19ebcc5a Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Tue, 4 Nov 2025 19:32:06 +0100 Subject: [PATCH 12/22] document `VaList` ABI for more targets --- library/core/src/ffi/va_list.rs | 57 ++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index 449e62ac00d3e..4c59ea0cc5328 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -8,11 +8,29 @@ use crate::fmt; use crate::intrinsics::{va_arg, va_copy}; use crate::marker::PhantomCovariantLifetime; -// Most targets explicitly specify the layout of `va_list`, this layout is matched here. -// For `va_list`s which are single-element array in C (and therefore experience array-to-pointer -// decay when passed as arguments in C), the `VaList` struct is annotated with -// `#[rustc_pass_indirectly_in_non_rustic_abis]`. This ensures that the compiler uses the correct -// ABI for functions like `extern "C" fn takes_va_list(va: VaList<'_>)` by passing `va` indirectly. +// There are currently three flavors of how a C `va_list` is implemented for +// targets that Rust supports: +// +// - `va_list` is an opaque pointer +// - `va_list` is a struct +// - `va_list` is a single-element array, containing a struct +// +// The opaque pointer approach is the simplest to implement: the pointer just +// points to an array of arguments on the caller's stack. +// +// The struct and single-element array variants are more complex, but +// potentially more efficient because the additional state makes it +// possible to pass variadic arguments via registers. +// +// The Rust `VaList` type is ABI-compatible with the C `va_list`. +// The struct and pointer cases straightforwardly map to their Rust equivalents, +// but the single-element array case is special: in C, this type is subject to +// array-to-pointer decay. +// +// The `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute is used to match +// the pointer decay behavior in Rust, while otherwise matching Rust semantics. +// This attribute ensures that the compiler uses the correct ABI for functions +// like `extern "C" fn takes_va_list(va: VaList<'_>)` by passing `va` indirectly. crate::cfg_select! { all( target_arch = "aarch64", @@ -20,8 +38,9 @@ crate::cfg_select! { not(target_os = "uefi"), not(windows), ) => { - /// AArch64 ABI implementation of a `va_list`. See the - /// [AArch64 Procedure Call Standard] for more details. + /// AArch64 ABI implementation of a `va_list`. + /// + /// See the [AArch64 Procedure Call Standard] for more details. /// /// [AArch64 Procedure Call Standard]: /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf @@ -37,6 +56,12 @@ crate::cfg_select! { } all(target_arch = "powerpc", not(target_os = "uefi"), not(windows)) => { /// PowerPC ABI implementation of a `va_list`. + /// + /// See the [LLVM source] and [GCC header] for more details. + /// + /// [LLVM source]: + /// https://github.com/llvm/llvm-project/blob/af9a4263a1a209953a1d339ef781a954e31268ff/llvm/lib/Target/PowerPC/PPCISelLowering.cpp#L4089-L4111 + /// [GCC header]: https://web.mit.edu/darwin/src/modules/gcc/gcc/ginclude/va-ppc.h #[repr(C)] #[derive(Debug)] #[rustc_pass_indirectly_in_non_rustic_abis] @@ -50,6 +75,11 @@ crate::cfg_select! { } target_arch = "s390x" => { /// s390x ABI implementation of a `va_list`. + /// + /// See the [S/390x ELF Application Binary Interface Supplement] for more details. + /// + /// [S/390x ELF Application Binary Interface Supplement]: + /// https://docs.google.com/gview?embedded=true&url=https://github.com/IBM/s390x-abi/releases/download/v1.7/lzsabi_s390x.pdf #[repr(C)] #[derive(Debug)] #[rustc_pass_indirectly_in_non_rustic_abis] @@ -61,7 +91,12 @@ crate::cfg_select! { } } all(target_arch = "x86_64", not(target_os = "uefi"), not(windows)) => { - /// x86_64 ABI implementation of a `va_list`. + /// x86_64 System V ABI implementation of a `va_list`. + /// + /// See the [System V AMD64 ABI] for more details. + /// + /// [System V AMD64 ABI]: + /// https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf #[repr(C)] #[derive(Debug)] #[rustc_pass_indirectly_in_non_rustic_abis] @@ -74,6 +109,11 @@ crate::cfg_select! { } target_arch = "xtensa" => { /// Xtensa ABI implementation of a `va_list`. + /// + /// See the [LLVM source] for more details. + /// + /// [LLVM source]: + /// https://github.com/llvm/llvm-project/blob/af9a4263a1a209953a1d339ef781a954e31268ff/llvm/lib/Target/Xtensa/XtensaISelLowering.cpp#L1211-L1215 #[repr(C)] #[derive(Debug)] #[rustc_pass_indirectly_in_non_rustic_abis] @@ -88,6 +128,7 @@ crate::cfg_select! { // // - apple aarch64 (see https://github.com/rust-lang/rust/pull/56599) // - windows + // - powerpc64 & powerpc64le // - uefi // - any other target for which we don't specify the `VaListInner` above // From f49eaecca9e231ffe0f290f31314be06ef5f8db2 Mon Sep 17 00:00:00 2001 From: quaternic <57393910+quaternic@users.noreply.github.com> Date: Wed, 3 Dec 2025 10:08:29 +0200 Subject: [PATCH 13/22] reorganize test contents and adjust generated inputs to reduce iterations --- library/coretests/tests/num/uint_macros.rs | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/library/coretests/tests/num/uint_macros.rs b/library/coretests/tests/num/uint_macros.rs index 6e746a6a2278d..72d500e575fa0 100644 --- a/library/coretests/tests/num/uint_macros.rs +++ b/library/coretests/tests/num/uint_macros.rs @@ -407,10 +407,10 @@ macro_rules! uint_module { assert_eq!(&xs, &[0xff, 0x00, 0x0f, 0xf0, 0x33, 0xcc, 0x55, 0xaa]); } - // `256 * BITS` masks + // `256 * (BITS / 5)` masks let sparse_masks = (i8::MIN..=i8::MAX) .map(|i| (i as i128 as $T).rotate_right(4)) - .flat_map(|x| (0..$T::BITS).map(move |s| ((1 as $T) << s) ^ x)); + .flat_map(|x| (0..$T::BITS).step_by(5).map(move |r| x.rotate_right(r))); for sparse in sparse_masks { // Collect the set bits to sequential low bits @@ -419,21 +419,19 @@ macro_rules! uint_module { assert_eq!(count, dense.count_ones()); assert_eq!(count, dense.trailing_ones()); + // Check that each bit is individually mapped correctly let mut t = sparse; - for k in 0..$T::BITS { - let x = ((1 as $T) << k).scatter_bits(sparse); - let y = t.isolate_lowest_one(); - assert_eq!(x, y); - t ^= y; - } - - let mut t = sparse; - for k in 0..count { - let y = t.isolate_lowest_one(); - let x = y.gather_bits(sparse); - assert_eq!(x, (1 as $T) << k); - t ^= y; + let mut bit = 1 as $T; + for _ in 0..count { + let lowest_one = t.isolate_lowest_one(); + assert_eq!(lowest_one, bit.scatter_bits(sparse)); + assert_eq!(bit, lowest_one.gather_bits(sparse)); + t ^= lowest_one; + bit <<= 1; } + // Other bits are ignored + assert_eq!(0, bit.wrapping_neg().scatter_bits(sparse)); + assert_eq!(0, (!sparse).gather_bits(sparse)); for &x in &xs { // Gather bits from `x & sparse` to `dense` From fc017dd1760fec2b02b2f3db0375bda58fbb608a Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 3 Dec 2025 01:36:20 +0100 Subject: [PATCH 14/22] c-variadic: bpf and spirv do not support c-variadic definitions --- compiler/rustc_ast_passes/messages.ftl | 2 ++ .../rustc_ast_passes/src/ast_validation.rs | 8 ++++++++ compiler/rustc_ast_passes/src/errors.rs | 8 ++++++++ compiler/rustc_target/src/spec/mod.rs | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index f03c7dd5b9d59..f1f734b855c14 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -80,6 +80,8 @@ ast_passes_c_variadic_must_be_unsafe = ast_passes_c_variadic_no_extern = `...` is not supported for non-extern functions .help = only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list +ast_passes_c_variadic_not_supported = the `{$target}` target does not support c-variadic functions + ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic .const = `const` because of this .variadic = C-variadic because of this diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index e57f8da26769b..42461bd5eb106 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -710,6 +710,14 @@ impl<'a> AstValidator<'a> { match fn_ctxt { FnCtxt::Foreign => return, FnCtxt::Free | FnCtxt::Assoc(_) => { + if !self.sess.target.arch.supports_c_variadic_definitions() { + self.dcx().emit_err(errors::CVariadicNotSupported { + variadic_span: variadic_param.span, + target: &*self.sess.target.llvm_target, + }); + return; + } + match sig.header.ext { Extern::Implicit(_) => { if !matches!(sig.header.safety, Safety::Unsafe(_)) { diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index c700ae517140c..bf9309614fe20 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -733,6 +733,14 @@ pub(crate) struct CoroutineAndCVariadic { pub variadic_span: Span, } +#[derive(Diagnostic)] +#[diag(ast_passes_c_variadic_not_supported)] +pub(crate) struct CVariadicNotSupported<'a> { + #[primary_span] + pub variadic_span: Span, + pub target: &'a str, +} + #[derive(Diagnostic)] #[diag(ast_passes_pattern_in_foreign, code = E0130)] // FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 2b1c7174fb15d..424026bdceab8 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1925,6 +1925,24 @@ impl Arch { Self::Other(name) => rustc_span::Symbol::intern(name), } } + + pub fn supports_c_variadic_definitions(&self) -> bool { + use Arch::*; + + match self { + // These targets just do not support c-variadic definitions. + Bpf | SpirV => false, + + // We don't know if the target supports c-variadic definitions, but we don't want + // to needlessly restrict custom target.json configurations. + Other(_) => true, + + AArch64 | AmdGpu | Arm | Arm64EC | Avr | CSky | Hexagon | LoongArch32 | LoongArch64 + | M68k | Mips | Mips32r6 | Mips64 | Mips64r6 | Msp430 | Nvptx64 | PowerPC + | PowerPC64 | PowerPC64LE | RiscV32 | RiscV64 | S390x | Sparc | Sparc64 | Wasm32 + | Wasm64 | X86 | X86_64 | Xtensa => true, + } + } } crate::target_spec_enum! { From b3bf3158ec32b1a2a957228bae36f1b7cfc3fa2a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:33:47 +0000 Subject: [PATCH 15/22] Disable native-lib for x check miri This reduces check times for miri from 2m15s to 20s. And reduces check times for miri with --compile-time-deps from 1m50s to 7s. This makes rust-analyzer start a lot faster after switching branches. --- src/bootstrap/src/core/build_steps/check.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index aebdc2a6a92a3..df82b7baa9f97 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -662,6 +662,7 @@ macro_rules! tool_check_step { $(, allow_features: $allow_features:expr )? // Features that should be enabled when checking $(, enable_features: [$($enable_features:expr),*] )? + $(, default_features: $default_features:expr )? $(, default: $default:literal )? $( , )? } @@ -708,8 +709,13 @@ macro_rules! tool_check_step { _value }; let extra_features: &[&str] = &[$($($enable_features),*)?]; + let default_features = { + let mut _value = true; + $( _value = $default_features; )? + _value + }; let mode: Mode = $mode; - run_tool_check_step(builder, compiler, target, $path, mode, allow_features, extra_features); + run_tool_check_step(builder, compiler, target, $path, mode, allow_features, extra_features, default_features); } fn metadata(&self) -> Option { @@ -720,6 +726,7 @@ macro_rules! tool_check_step { } /// Used by the implementation of `Step::run` in `tool_check_step!`. +#[allow(clippy::too_many_arguments)] fn run_tool_check_step( builder: &Builder<'_>, compiler: CompilerForCheck, @@ -728,6 +735,7 @@ fn run_tool_check_step( mode: Mode, allow_features: &str, extra_features: &[&str], + default_features: bool, ) { let display_name = path.rsplit('/').next().unwrap(); @@ -761,6 +769,10 @@ fn run_tool_check_step( cargo.arg("--all-targets"); } + if !default_features { + cargo.arg("--no-default-features"); + } + let stamp = BuildStamp::new(&builder.cargo_out(build_compiler, mode, target)) .with_prefix(&format!("{display_name}-check")); @@ -778,7 +790,12 @@ tool_check_step!(Rustdoc { // behavior, treat it as in-tree so that any new warnings in clippy will be // rejected. tool_check_step!(Clippy { path: "src/tools/clippy", mode: Mode::ToolRustcPrivate }); -tool_check_step!(Miri { path: "src/tools/miri", mode: Mode::ToolRustcPrivate }); +tool_check_step!(Miri { + path: "src/tools/miri", + mode: Mode::ToolRustcPrivate, + enable_features: ["stack-cache"], + default_features: false, +}); tool_check_step!(CargoMiri { path: "src/tools/miri/cargo-miri", mode: Mode::ToolRustcPrivate }); tool_check_step!(Rustfmt { path: "src/tools/rustfmt", mode: Mode::ToolRustcPrivate }); tool_check_step!(RustAnalyzer { From 46d8adeb616bcc2534d9a16ce8b3056ea12ea451 Mon Sep 17 00:00:00 2001 From: tiif Date: Fri, 21 Nov 2025 14:52:09 +0000 Subject: [PATCH 16/22] Use TypingEnv::fully_monomorphized for evaluating const without generic param path --- compiler/rustc_trait_selection/src/traits/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 6032bcacec6a4..01b7d354b4335 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -637,7 +637,7 @@ pub fn try_evaluate_const<'tcx>( // Since there is no generic parameter, we can just drop the environment // to prevent query cycle. - let typing_env = infcx.typing_env(ty::ParamEnv::empty()); + let typing_env = ty::TypingEnv::fully_monomorphized(); (uv.args, typing_env) } From af66b68f63ff869287a18f04486bc4ccf96ca6f9 Mon Sep 17 00:00:00 2001 From: tiif Date: Fri, 21 Nov 2025 15:02:06 +0000 Subject: [PATCH 17/22] refactor: make the match exhaustive --- compiler/rustc_trait_selection/src/traits/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 01b7d354b4335..3af90bde86e64 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -618,7 +618,7 @@ pub fn try_evaluate_const<'tcx>( (args, typing_env) } - _ => { + Some(ty::AnonConstKind::MCG) | Some(ty::AnonConstKind::NonTypeSystem) | None => { // We are only dealing with "truly" generic/uninferred constants here: // - GCEConsts have been handled separately // - Repeat expr count back compat consts have also been handled separately From 1864bf6a510a7e9df23777591f3389b6feb27e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Sat, 18 Oct 2025 11:25:13 +0200 Subject: [PATCH 18/22] ICE when applying test to crate root --- tests/crashes/114920.rs | 2 -- tests/ui/macros/test-on-crate-root.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 tests/crashes/114920.rs create mode 100644 tests/ui/macros/test-on-crate-root.rs diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs deleted file mode 100644 index 9aa7598e10fc3..0000000000000 --- a/tests/crashes/114920.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ known-bug: #114920 -#![core::prelude::v1::test] diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs new file mode 100644 index 0000000000000..80635a458902d --- /dev/null +++ b/tests/ui/macros/test-on-crate-root.rs @@ -0,0 +1,8 @@ +// ICE when applying `#![test]` to the crate root, +// though only when specified with a full path. `#![test]` is not enough. +// Fixes #114920 +#![core::prelude::v1::test] + + + +fn main() {} // not important to reproduce the issue From 9dd3caeebefbb36f90ea13e5ec4b37048067ca59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Sat, 18 Oct 2025 12:10:21 +0200 Subject: [PATCH 19/22] only discard items with `#[test]` on it when target is valid --- compiler/rustc_builtin_macros/src/test.rs | 20 +- .../ui/feature-gates/gating-of-test-attrs.rs | 48 +++ .../feature-gates/gating-of-test-attrs.stderr | 181 +++++++++++ .../issue-43106-gating-of-builtin-attrs.rs | 32 -- ...issue-43106-gating-of-builtin-attrs.stderr | 304 +++++++++--------- tests/ui/macros/attr-empty-expr.rs | 11 - tests/ui/macros/attr-empty-expr.stderr | 20 -- tests/ui/macros/issue-111749.rs | 4 +- tests/ui/macros/issue-111749.stderr | 16 +- tests/ui/macros/test-on-crate-root.rs | 3 +- tests/ui/macros/test-on-crate-root.stderr | 25 ++ 11 files changed, 431 insertions(+), 233 deletions(-) create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.rs create mode 100644 tests/ui/feature-gates/gating-of-test-attrs.stderr delete mode 100644 tests/ui/macros/attr-empty-expr.rs delete mode 100644 tests/ui/macros/attr-empty-expr.stderr create mode 100644 tests/ui/macros/test-on-crate-root.stderr diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 532539f893aed..8f6244e418fdb 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -34,10 +34,6 @@ pub(crate) fn expand_test_case( check_builtin_macro_attribute(ecx, meta_item, sym::test_case); warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case); - if !ecx.ecfg.should_test { - return vec![]; - } - let sp = ecx.with_def_site_ctxt(attr_sp); let (mut item, is_stmt) = match anno_item { Annotatable::Item(item) => (item, false), @@ -54,6 +50,10 @@ pub(crate) fn expand_test_case( } }; + if !ecx.ecfg.should_test { + return vec![]; + } + // `#[test_case]` is valid on functions, consts, and statics. Only modify // the item in those cases. match &mut item.kind { @@ -113,11 +113,6 @@ pub(crate) fn expand_test_or_bench( item: Annotatable, is_bench: bool, ) -> Vec { - // If we're not in test configuration, remove the annotated item - if !cx.ecfg.should_test { - return vec![]; - } - let (item, is_stmt) = match item { Annotatable::Item(i) => (i, false), Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true), @@ -136,6 +131,11 @@ pub(crate) fn expand_test_or_bench( }; }; + // If we're not in test configuration, remove the annotated item + if !cx.ecfg.should_test { + return vec![]; + } + if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) { cx.dcx().emit_err(errors::NakedFunctionTestingAttribute { testing_span: attr_sp, @@ -407,7 +407,7 @@ pub(crate) fn expand_test_or_bench( fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) { let dcx = cx.dcx(); - let msg = "the `#[test]` attribute may only be used on a non-associated function"; + let msg = "the `#[test]` attribute may only be used on a free function"; let level = match item.map(|i| &i.kind) { // These were a warning before #92959 and need to continue being that to avoid breaking // stable user code (#94508). diff --git a/tests/ui/feature-gates/gating-of-test-attrs.rs b/tests/ui/feature-gates/gating-of-test-attrs.rs new file mode 100644 index 0000000000000..22b0454e17410 --- /dev/null +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -0,0 +1,48 @@ +#![feature(test)] + +// test is a built-in macro, not a built-in attribute, but it kind of acts like both. +// check its target checking anyway here +#[test] +//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +mod test { + mod inner { #![test] } + //~^ ERROR inner macro attributes are unstable + //~| ERROR the `#[test]` attribute may only be used on a non-associated function + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + struct S; + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + type T = S; + + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + impl S { } +} + +// At time of unit test authorship, if compiling without `--test` then +// non-crate-level #[bench] attributes seem to be ignored. + +#[bench] +//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +mod bench { + mod inner { #![bench] } + //~^ ERROR inner macro attributes are unstable + //~| ERROR the `#[test]` attribute may only be used on a non-associated function + + #[bench] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + struct S; + + #[bench] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + type T = S; + + #[bench] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + impl S { } +} + +fn main() {} diff --git a/tests/ui/feature-gates/gating-of-test-attrs.stderr b/tests/ui/feature-gates/gating-of-test-attrs.stderr new file mode 100644 index 0000000000000..339a68f5d5e48 --- /dev/null +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -0,0 +1,181 @@ +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:5:1 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | / mod test { +LL | | mod inner { #![test] } +... | +LL | | impl S { } +LL | | } + | |_- expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error[E0658]: inner macro attributes are unstable + --> $DIR/gating-of-test-attrs.rs:8:20 + | +LL | mod inner { #![test] } + | ^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:8:17 + | +LL | mod inner { #![test] } + | ------------^^^^^^^^-- + | | | + | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - mod inner { #![test] } +LL + mod inner { #[cfg(test)] } + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:12:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct S; + | --------- expected a non-associated function, found a struct + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:16:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | type T = S; + | ----------- expected a non-associated function, found a type alias + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:20:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | impl S { } + | ---------- expected a non-associated function, found an implementation + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[test] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:28:1 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | / mod bench { +LL | | mod inner { #![bench] } +... | +LL | | impl S { } +LL | | } + | |_- expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error[E0658]: inner macro attributes are unstable + --> $DIR/gating-of-test-attrs.rs:31:20 + | +LL | mod inner { #![bench] } + | ^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:31:17 + | +LL | mod inner { #![bench] } + | ------------^^^^^^^^^-- + | | | + | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | expected a non-associated function, found a module + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - mod inner { #![bench] } +LL + mod inner { #[cfg(test)] } + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:35:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct S; + | --------- expected a non-associated function, found a struct + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:39:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | type T = S; + | ----------- expected a non-associated function, found a type alias + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/gating-of-test-attrs.rs:43:5 + | +LL | #[bench] + | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | impl S { } + | ---------- expected a non-associated function, found an implementation + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #[bench] +LL + #[cfg(test)] + | + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index 8d67bf37279df..5b32c5ca0dfa5 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -250,38 +250,6 @@ mod macro_export { //~| HELP remove the attribute } -// At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[test] attributes seem to be ignored. - -#[test] -mod test { mod inner { #![test] } - - fn f() { } - - struct S; - - type T = S; - - impl S { } -} - -// At time of unit test authorship, if compiling without `--test` then -// non-crate-level #[bench] attributes seem to be ignored. - -#[bench] -mod bench { - mod inner { #![bench] } - - #[bench] - struct S; - - #[bench] - type T = S; - - #[bench] - impl S { } -} - #[path = "3800"] mod path { mod inner { #![path="3800"] } diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index f7e8d9c7c4001..d8b1dc91acc4f 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -1,5 +1,5 @@ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | mod inner { #![macro_escape] } = help: try an outer attribute: `#[macro_use]` warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ @@ -187,7 +187,7 @@ LL | #[deny(x5100)] impl S { } | ^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | #![reexport_test_harness_main = "2900"] | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:739:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1 | LL | #[link(name = "x")] | ^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | | } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:865:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,7 @@ LL | #![crate_type = "0800"] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:857:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | #![feature(x0600)] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:914:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:882:1 | LL | #[no_main] | ^^^^^^^^^^ @@ -252,7 +252,7 @@ LL | #![no_main] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:938:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:906:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ @@ -279,13 +279,13 @@ LL | #![feature(rust1)] = note: `#[warn(stable_features)]` on by default warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:505:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:508:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -296,7 +296,7 @@ LL | #![reexport_test_harness_main = "2900"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,7 @@ LL | #![reexport_test_harness_main = "2900"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:516:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,7 @@ LL | #![reexport_test_harness_main = "2900"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:520:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | #![reexport_test_harness_main = "2900"] impl S { } | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:17 | LL | mod inner { #![link(name = "x")] } | ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block @@ -337,7 +337,7 @@ LL | mod inner { #![link(name = "x")] } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 | LL | #[link(name = "x")] fn f() { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -345,7 +345,7 @@ LL | #[link(name = "x")] fn f() { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5 | LL | #[link(name = "x")] struct S; | ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block @@ -353,7 +353,7 @@ LL | #[link(name = "x")] struct S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:760:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5 | LL | #[link(name = "x")] type T = S; | ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block @@ -361,7 +361,7 @@ LL | #[link(name = "x")] type T = S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5 | LL | #[link(name = "x")] impl S { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -369,7 +369,7 @@ LL | #[link(name = "x")] impl S { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:5 | LL | #[link(name = "x")] extern "Rust" {} | ^^^^^^^^^^^^^^^^^^^ @@ -377,13 +377,13 @@ LL | #[link(name = "x")] extern "Rust" {} = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:869:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:837:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -394,7 +394,7 @@ LL | #![crate_type = "0800"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:876:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:844:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL | #![crate_type = "0800"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:880:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,7 @@ LL | #![crate_type = "0800"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:884:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -427,13 +427,13 @@ LL | #![crate_type = "0800"] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:861:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:896:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:864:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ @@ -444,7 +444,7 @@ LL | #![feature(x0600)] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:900:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:868:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL | #![feature(x0600)] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:904:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ @@ -466,7 +466,7 @@ LL | #![feature(x0600)] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:908:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:876:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ @@ -477,13 +477,13 @@ LL | #![feature(x0600)] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:918:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:886:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:921:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ @@ -494,7 +494,7 @@ LL | #![no_main] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ @@ -505,7 +505,7 @@ LL | #![no_main] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:929:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:897:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ @@ -516,7 +516,7 @@ LL | #![no_main] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:901:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ @@ -527,13 +527,13 @@ LL | #![no_main] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:942:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:910:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:913:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ @@ -544,7 +544,7 @@ LL | #![no_builtins] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:917:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL | #![no_builtins] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:953:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:921:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ @@ -566,7 +566,7 @@ LL | #![no_builtins] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:957:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ @@ -667,7 +667,7 @@ LL | #[macro_export] impl S { } = help: `#[macro_export]` can only be applied to macro defs warning: `#[path]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:289:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:257:5 | LL | #[path = "3800"] fn f() { } | ^^^^^^^^^^^^^^^^ @@ -676,7 +676,7 @@ LL | #[path = "3800"] fn f() { } = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:295:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:263:5 | LL | #[path = "3800"] struct S; | ^^^^^^^^^^^^^^^^ @@ -685,7 +685,7 @@ LL | #[path = "3800"] struct S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:301:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:5 | LL | #[path = "3800"] type T = S; | ^^^^^^^^^^^^^^^^ @@ -694,7 +694,7 @@ LL | #[path = "3800"] type T = S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:307:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:275:5 | LL | #[path = "3800"] impl S { } | ^^^^^^^^^^^^^^^^ @@ -703,7 +703,7 @@ LL | #[path = "3800"] impl S { } = help: `#[path]` can only be applied to modules warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:314:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:282:1 | LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -712,7 +712,7 @@ LL | #[automatically_derived] = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:320:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:288:17 | LL | mod inner { #![automatically_derived] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,7 @@ LL | mod inner { #![automatically_derived] } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:294:5 | LL | #[automatically_derived] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -730,7 +730,7 @@ LL | #[automatically_derived] fn f() { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:300:5 | LL | #[automatically_derived] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -739,7 +739,7 @@ LL | #[automatically_derived] struct S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:338:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:306:5 | LL | #[automatically_derived] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -748,7 +748,7 @@ LL | #[automatically_derived] type T = S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:344:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:312:5 | LL | #[automatically_derived] trait W { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -757,7 +757,7 @@ LL | #[automatically_derived] trait W { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:350:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:318:5 | LL | #[automatically_derived] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -766,7 +766,7 @@ LL | #[automatically_derived] impl S { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:359:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:327:1 | LL | #[no_mangle] | ^^^^^^^^^^^^ @@ -775,7 +775,7 @@ LL | #[no_mangle] = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:333:17 | LL | mod inner { #![no_mangle] } | ^^^^^^^^^^^^^ @@ -784,7 +784,7 @@ LL | mod inner { #![no_mangle] } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:341:5 | LL | #[no_mangle] struct S; | ^^^^^^^^^^^^ @@ -793,7 +793,7 @@ LL | #[no_mangle] struct S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:347:5 | LL | #[no_mangle] type T = S; | ^^^^^^^^^^^^ @@ -802,7 +802,7 @@ LL | #[no_mangle] type T = S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:385:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:353:5 | LL | #[no_mangle] impl S { } | ^^^^^^^^^^^^ @@ -811,7 +811,7 @@ LL | #[no_mangle] impl S { } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on required trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:392:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:360:9 | LL | #[no_mangle] fn foo(); | ^^^^^^^^^^^^ @@ -820,7 +820,7 @@ LL | #[no_mangle] fn foo(); = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[no_mangle]` attribute cannot be used on provided trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:366:9 | LL | #[no_mangle] fn bar() {} | ^^^^^^^^^^^^ @@ -829,7 +829,7 @@ LL | #[no_mangle] fn bar() {} = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:374:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ @@ -838,7 +838,7 @@ LL | #[should_panic] = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:17 | LL | mod inner { #![should_panic] } | ^^^^^^^^^^^^^^^^ @@ -847,7 +847,7 @@ LL | mod inner { #![should_panic] } = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:388:5 | LL | #[should_panic] struct S; | ^^^^^^^^^^^^^^^ @@ -856,7 +856,7 @@ LL | #[should_panic] struct S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:394:5 | LL | #[should_panic] type T = S; | ^^^^^^^^^^^^^^^ @@ -865,7 +865,7 @@ LL | #[should_panic] type T = S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:400:5 | LL | #[should_panic] impl S { } | ^^^^^^^^^^^^^^^ @@ -874,7 +874,7 @@ LL | #[should_panic] impl S { } = help: `#[should_panic]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:439:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:407:1 | LL | #[ignore] | ^^^^^^^^^ @@ -883,7 +883,7 @@ LL | #[ignore] = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:445:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:413:17 | LL | mod inner { #![ignore] } | ^^^^^^^^^^ @@ -892,7 +892,7 @@ LL | mod inner { #![ignore] } = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:453:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:421:5 | LL | #[ignore] struct S; | ^^^^^^^^^ @@ -901,7 +901,7 @@ LL | #[ignore] struct S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:459:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:427:5 | LL | #[ignore] type T = S; | ^^^^^^^^^ @@ -910,7 +910,7 @@ LL | #[ignore] type T = S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:465:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5 | LL | #[ignore] impl S { } | ^^^^^^^^^ @@ -919,7 +919,7 @@ LL | #[ignore] impl S { } = help: `#[ignore]` can only be applied to functions warning: `#[no_implicit_prelude]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:444:5 | LL | #[no_implicit_prelude] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -928,7 +928,7 @@ LL | #[no_implicit_prelude] fn f() { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:482:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:450:5 | LL | #[no_implicit_prelude] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -937,7 +937,7 @@ LL | #[no_implicit_prelude] struct S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:456:5 | LL | #[no_implicit_prelude] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -946,7 +946,7 @@ LL | #[no_implicit_prelude] type T = S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:462:5 | LL | #[no_implicit_prelude] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -955,7 +955,7 @@ LL | #[no_implicit_prelude] impl S { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[macro_escape]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ @@ -964,7 +964,7 @@ LL | #[macro_escape] fn f() { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:507:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ @@ -973,7 +973,7 @@ LL | #[macro_escape] struct S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:513:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ @@ -982,7 +982,7 @@ LL | #[macro_escape] type T = S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:519:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ @@ -991,13 +991,13 @@ LL | #[macro_escape] impl S { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:558:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:1 | LL | #[no_std] | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:560:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:528:1 | LL | / mod no_std { LL | | @@ -1007,61 +1007,61 @@ LL | | } | |_^ warning: the `#![no_std]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:562:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:530:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:15 | LL | #[no_std] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:5 | LL | #[no_std] struct S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:15 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:15 | LL | #[no_std] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:15 | LL | #[no_std] impl S { } | ^^^^^^^^^^ warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:599:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:567:1 | LL | #[cold] | ^^^^^^^ @@ -1070,7 +1070,7 @@ LL | #[cold] = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:574:17 | LL | mod inner { #![cold] } | ^^^^^^^^ @@ -1079,7 +1079,7 @@ LL | mod inner { #![cold] } = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:582:5 | LL | #[cold] struct S; | ^^^^^^^ @@ -1088,7 +1088,7 @@ LL | #[cold] struct S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:588:5 | LL | #[cold] type T = S; | ^^^^^^^ @@ -1097,7 +1097,7 @@ LL | #[cold] type T = S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:594:5 | LL | #[cold] impl S { } | ^^^^^^^ @@ -1106,7 +1106,7 @@ LL | #[cold] impl S { } = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:633:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:1 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1115,7 +1115,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on foreign modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:607:5 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1124,7 +1124,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:17 | LL | mod inner { #![link_name="1900"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1133,7 +1133,7 @@ LL | mod inner { #![link_name="1900"] } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 | LL | #[link_name = "1900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1142,7 +1142,7 @@ LL | #[link_name = "1900"] fn f() { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 | LL | #[link_name = "1900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1151,7 +1151,7 @@ LL | #[link_name = "1900"] struct S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:5 | LL | #[link_name = "1900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1160,7 +1160,7 @@ LL | #[link_name = "1900"] type T = S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:670:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:5 | LL | #[link_name = "1900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1169,7 +1169,7 @@ LL | #[link_name = "1900"] impl S { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:645:1 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1178,7 +1178,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:17 | LL | mod inner { #![link_section="1800"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1187,7 +1187,7 @@ LL | mod inner { #![link_section="1800"] } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:659:5 | LL | #[link_section = "1800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1196,7 +1196,7 @@ LL | #[link_section = "1800"] struct S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:5 | LL | #[link_section = "1800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1205,7 +1205,7 @@ LL | #[link_section = "1800"] type T = S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:5 | LL | #[link_section = "1800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1214,7 +1214,7 @@ LL | #[link_section = "1800"] impl S { } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:709:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:5 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1223,7 +1223,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:1 | LL | #[must_use] | ^^^^^^^^^^^ @@ -1232,7 +1232,7 @@ LL | #[must_use] = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:795:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ @@ -1241,7 +1241,7 @@ LL | mod inner { #![must_use] } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:772:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ @@ -1250,7 +1250,7 @@ LL | #[must_use] type T = S; = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:777:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ @@ -1259,13 +1259,13 @@ LL | #[must_use] impl S { } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:785:1 | LL | / mod windows_subsystem { LL | | @@ -1275,67 +1275,67 @@ LL | | } | |_^ warning: the `#![windows_subsystem]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:787:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:38 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:38 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:5 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:38 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:5 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:38 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:841:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:811:1 | LL | / mod crate_name { LL | | @@ -1345,67 +1345,67 @@ LL | | } | |_^ warning: the `#![crate_name]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:845:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:28 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:28 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:28 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:28 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:962:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:930:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:932:1 | LL | / mod recursion_limit { LL | | @@ -1415,67 +1415,67 @@ LL | | } | |_^ warning: the `#![recursion_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:966:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:934:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:31 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:941:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:941:31 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:977:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:977:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:31 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:981:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:981:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:31 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:986:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:954:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:988:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:956:1 | LL | / mod type_length_limit { LL | | @@ -1485,55 +1485,55 @@ LL | | } | |_^ warning: the `#![type_length_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:990:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:958:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:993:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:993:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:33 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:997:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:965:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:997:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:965:33 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1001:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1001:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:33 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1005:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:1005:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:33 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^ diff --git a/tests/ui/macros/attr-empty-expr.rs b/tests/ui/macros/attr-empty-expr.rs deleted file mode 100644 index d4d1a3ee71e67..0000000000000 --- a/tests/ui/macros/attr-empty-expr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// AST-based macro attributes expanding to an empty expression produce an error and not ICE. - -#![feature(custom_test_frameworks)] -#![feature(stmt_expr_attributes)] -#![feature(test)] - -fn main() { - let _ = #[test] 0; //~ ERROR removing an expression is not supported in this position - let _ = #[bench] 1; //~ ERROR removing an expression is not supported in this position - let _ = #[test_case] 2; //~ ERROR removing an expression is not supported in this position -} diff --git a/tests/ui/macros/attr-empty-expr.stderr b/tests/ui/macros/attr-empty-expr.stderr deleted file mode 100644 index 53721053bcc08..0000000000000 --- a/tests/ui/macros/attr-empty-expr.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:8:13 - | -LL | let _ = #[test] 0; - | ^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:9:13 - | -LL | let _ = #[bench] 1; - | ^^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/attr-empty-expr.rs:10:13 - | -LL | let _ = #[test_case] 2; - | ^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/macros/issue-111749.rs b/tests/ui/macros/issue-111749.rs index 6c45e4e8cd719..779a854ea5824 100644 --- a/tests/ui/macros/issue-111749.rs +++ b/tests/ui/macros/issue-111749.rs @@ -5,8 +5,8 @@ macro_rules! cbor_map { } fn main() { - cbor_map! { #[test(test)] 4}; - //~^ ERROR removing an expression is not supported in this position + cbor_map! { #[test(test)] 4i32}; + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function //~| ERROR attribute must be of the form `#[test]` //~| WARNING this was previously accepted by the compiler but is being phased out } diff --git a/tests/ui/macros/issue-111749.stderr b/tests/ui/macros/issue-111749.stderr index ae953e042e094..3afdd0ad4baff 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -1,13 +1,19 @@ -error: removing an expression is not supported in this position +error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; - | ^^^^^^^^^^^^^ +LL | cbor_map! { #[test(test)] 4i32}; + | ^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - cbor_map! { #[test(test)] 4i32}; +LL + cbor_map! { #[cfg(test)] 4i32}; + | error: attribute must be of the form `#[test]` --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; +LL | cbor_map! { #[test(test)] 4i32}; | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -20,7 +26,7 @@ Future incompatibility report: Future breakage diagnostic: error: attribute must be of the form `#[test]` --> $DIR/issue-111749.rs:8:17 | -LL | cbor_map! { #[test(test)] 4}; +LL | cbor_map! { #[test(test)] 4i32}; | ^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs index 80635a458902d..abe08536b1d68 100644 --- a/tests/ui/macros/test-on-crate-root.rs +++ b/tests/ui/macros/test-on-crate-root.rs @@ -2,7 +2,8 @@ // though only when specified with a full path. `#![test]` is not enough. // Fixes #114920 #![core::prelude::v1::test] - +//~^ ERROR inner macro attributes are unstable +//~| ERROR the `#[test]` attribute may only be used on a non-associated function fn main() {} // not important to reproduce the issue diff --git a/tests/ui/macros/test-on-crate-root.stderr b/tests/ui/macros/test-on-crate-root.stderr new file mode 100644 index 0000000000000..5a5e0597284d3 --- /dev/null +++ b/tests/ui/macros/test-on-crate-root.stderr @@ -0,0 +1,25 @@ +error[E0658]: inner macro attributes are unstable + --> $DIR/test-on-crate-root.rs:3:4 + | +LL | #![core::prelude::v1::test] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54726 for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/test-on-crate-root.rs:3:1 + | +LL | #![core::prelude::v1::test] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL - #![core::prelude::v1::test] +LL + #[cfg(test)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. From 97d4d2154f4764a62710f2e2a0f3cd90b55adeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Sat, 18 Oct 2025 12:13:39 +0200 Subject: [PATCH 20/22] fixup name in diagnostics --- compiler/rustc_builtin_macros/src/test.rs | 21 ++++--- .../ui/feature-gates/gating-of-test-attrs.rs | 20 +++---- .../feature-gates/gating-of-test-attrs.stderr | 60 +++++-------------- tests/ui/macros/issue-111749.rs | 2 +- tests/ui/macros/issue-111749.stderr | 2 +- tests/ui/macros/test-on-crate-root.rs | 2 +- tests/ui/macros/test-on-crate-root.stderr | 6 +- tests/ui/test-attrs/issue-109816.rs | 2 +- tests/ui/test-attrs/issue-109816.stderr | 2 +- .../test-attr-non-associated-functions.rs | 4 +- .../test-attr-non-associated-functions.stderr | 4 +- tests/ui/test-attrs/test-on-not-fn.rs | 24 ++++---- tests/ui/test-attrs/test-on-not-fn.stderr | 24 ++++---- 13 files changed, 74 insertions(+), 99 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 8f6244e418fdb..f31ad4f591b1e 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -117,13 +117,13 @@ pub(crate) fn expand_test_or_bench( Annotatable::Item(i) => (i, false), Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true), other => { - not_testable_error(cx, attr_sp, None); + not_testable_error(cx, is_bench, attr_sp, None); return vec![other]; } }; let ast::ItemKind::Fn(fn_) = &item.kind else { - not_testable_error(cx, attr_sp, Some(&item)); + not_testable_error(cx, is_bench, attr_sp, Some(&item)); return if is_stmt { vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))] } else { @@ -405,9 +405,10 @@ pub(crate) fn expand_test_or_bench( } } -fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) { +fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Option<&ast::Item>) { let dcx = cx.dcx(); - let msg = "the `#[test]` attribute may only be used on a free function"; + let name = if is_bench { "bench" } else { "test" }; + let msg = format!("the `#[{name}]` attribute may only be used on a free function"); let level = match item.map(|i| &i.kind) { // These were a warning before #92959 and need to continue being that to avoid breaking // stable user code (#94508). @@ -426,12 +427,16 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) ), ); } - err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions") - .with_span_suggestion(attr_sp, + err.span_label(attr_sp, format!("the `#[{name}]` macro causes a function to be run as a test and has no effect on non-functions")); + + if !is_bench { + err.with_span_suggestion(attr_sp, "replace with conditional compilation to make the item only exist when tests are being run", "#[cfg(test)]", - Applicability::MaybeIncorrect) - .emit(); + Applicability::MaybeIncorrect).emit(); + } else { + err.emit(); + } } fn get_location_info(cx: &ExtCtxt<'_>, fn_: &ast::Fn) -> (Symbol, usize, usize, usize, usize) { diff --git a/tests/ui/feature-gates/gating-of-test-attrs.rs b/tests/ui/feature-gates/gating-of-test-attrs.rs index 22b0454e17410..3b07e2ad03c9f 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.rs +++ b/tests/ui/feature-gates/gating-of-test-attrs.rs @@ -3,22 +3,22 @@ // test is a built-in macro, not a built-in attribute, but it kind of acts like both. // check its target checking anyway here #[test] -//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +//~^ ERROR the `#[test]` attribute may only be used on a free function mod test { mod inner { #![test] } //~^ ERROR inner macro attributes are unstable - //~| ERROR the `#[test]` attribute may only be used on a non-associated function + //~| ERROR the `#[test]` attribute may only be used on a free function #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct S; #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function type T = S; #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function impl S { } } @@ -26,22 +26,22 @@ mod test { // non-crate-level #[bench] attributes seem to be ignored. #[bench] -//~^ ERROR the `#[test]` attribute may only be used on a non-associated function +//~^ ERROR the `#[bench]` attribute may only be used on a free function mod bench { mod inner { #![bench] } //~^ ERROR inner macro attributes are unstable - //~| ERROR the `#[test]` attribute may only be used on a non-associated function + //~| ERROR the `#[bench]` attribute may only be used on a free function #[bench] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[bench]` attribute may only be used on a free function struct S; #[bench] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[bench]` attribute may only be used on a free function type T = S; #[bench] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[bench]` attribute may only be used on a free function impl S { } } diff --git a/tests/ui/feature-gates/gating-of-test-attrs.stderr b/tests/ui/feature-gates/gating-of-test-attrs.stderr index 339a68f5d5e48..0f47ab85dc18e 100644 --- a/tests/ui/feature-gates/gating-of-test-attrs.stderr +++ b/tests/ui/feature-gates/gating-of-test-attrs.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:5:1 | LL | #[test] @@ -27,7 +27,7 @@ LL | mod inner { #![test] } = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:8:17 | LL | mod inner { #![test] } @@ -42,7 +42,7 @@ LL - mod inner { #![test] } LL + mod inner { #[cfg(test)] } | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:12:5 | LL | #[test] @@ -57,7 +57,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:16:5 | LL | #[test] @@ -72,7 +72,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:20:5 | LL | #[test] @@ -87,11 +87,11 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:28:1 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | / mod bench { LL | | mod inner { #![bench] } @@ -99,12 +99,6 @@ LL | | mod inner { #![bench] } LL | | impl S { } LL | | } | |_- expected a non-associated function, found a module - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | error[E0658]: inner macro attributes are unstable --> $DIR/gating-of-test-attrs.rs:31:20 @@ -116,65 +110,41 @@ LL | mod inner { #![bench] } = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:31:17 | LL | mod inner { #![bench] } | ------------^^^^^^^^^-- | | | - | | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | | the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions | expected a non-associated function, found a module - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - mod inner { #![bench] } -LL + mod inner { #[cfg(test)] } - | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:35:5 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | struct S; | --------- expected a non-associated function, found a struct - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:39:5 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | type T = S; | ----------- expected a non-associated function, found a type alias - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[bench]` attribute may only be used on a free function --> $DIR/gating-of-test-attrs.rs:43:5 | LL | #[bench] - | ^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions LL | LL | impl S { } | ---------- expected a non-associated function, found an implementation - | -help: replace with conditional compilation to make the item only exist when tests are being run - | -LL - #[bench] -LL + #[cfg(test)] - | error: aborting due to 12 previous errors diff --git a/tests/ui/macros/issue-111749.rs b/tests/ui/macros/issue-111749.rs index 779a854ea5824..e92b9e4ccff82 100644 --- a/tests/ui/macros/issue-111749.rs +++ b/tests/ui/macros/issue-111749.rs @@ -6,7 +6,7 @@ macro_rules! cbor_map { fn main() { cbor_map! { #[test(test)] 4i32}; - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function //~| ERROR attribute must be of the form `#[test]` //~| WARNING this was previously accepted by the compiler but is being phased out } diff --git a/tests/ui/macros/issue-111749.stderr b/tests/ui/macros/issue-111749.stderr index 3afdd0ad4baff..ead01f87eaec0 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-111749.rs:8:17 | LL | cbor_map! { #[test(test)] 4i32}; diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs index abe08536b1d68..0e0f3ec40976c 100644 --- a/tests/ui/macros/test-on-crate-root.rs +++ b/tests/ui/macros/test-on-crate-root.rs @@ -3,7 +3,7 @@ // Fixes #114920 #![core::prelude::v1::test] //~^ ERROR inner macro attributes are unstable -//~| ERROR the `#[test]` attribute may only be used on a non-associated function +//~| ERROR the `#[test]` attribute may only be used on a free function fn main() {} // not important to reproduce the issue diff --git a/tests/ui/macros/test-on-crate-root.stderr b/tests/ui/macros/test-on-crate-root.stderr index 5a5e0597284d3..d706d6ae6c5fa 100644 --- a/tests/ui/macros/test-on-crate-root.stderr +++ b/tests/ui/macros/test-on-crate-root.stderr @@ -1,5 +1,5 @@ error[E0658]: inner macro attributes are unstable - --> $DIR/test-on-crate-root.rs:3:4 + --> $DIR/test-on-crate-root.rs:4:4 | LL | #![core::prelude::v1::test] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,8 +8,8 @@ LL | #![core::prelude::v1::test] = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: the `#[test]` attribute may only be used on a non-associated function - --> $DIR/test-on-crate-root.rs:3:1 +error: the `#[test]` attribute may only be used on a free function + --> $DIR/test-on-crate-root.rs:4:1 | LL | #![core::prelude::v1::test] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions diff --git a/tests/ui/test-attrs/issue-109816.rs b/tests/ui/test-attrs/issue-109816.rs index 3cabf451c6635..c7caae67fefa6 100644 --- a/tests/ui/test-attrs/issue-109816.rs +++ b/tests/ui/test-attrs/issue-109816.rs @@ -2,6 +2,6 @@ fn align_offset_weird_strides() { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function struct A5(u32, u8); } diff --git a/tests/ui/test-attrs/issue-109816.stderr b/tests/ui/test-attrs/issue-109816.stderr index 433421fff1b57..270f4e0a66683 100644 --- a/tests/ui/test-attrs/issue-109816.stderr +++ b/tests/ui/test-attrs/issue-109816.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/issue-109816.rs:4:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.rs b/tests/ui/test-attrs/test-attr-non-associated-functions.rs index 1a4dfda090970..4bf337d0f1b3c 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.rs +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.rs @@ -4,12 +4,12 @@ struct A {} impl A { #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn new() -> A { A {} } #[test] - //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + //~^ ERROR the `#[test]` attribute may only be used on a free function fn recovery_witness() -> A { A {} } diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr index 0ede0cbb97f33..13914971b558a 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:6:5 | LL | #[test] @@ -10,7 +10,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-attr-non-associated-functions.rs:11:5 | LL | #[test] diff --git a/tests/ui/test-attrs/test-on-not-fn.rs b/tests/ui/test-attrs/test-on-not-fn.rs index deba26f24ca71..16e9cd8d5b8d7 100644 --- a/tests/ui/test-attrs/test-on-not-fn.rs +++ b/tests/ui/test-attrs/test-on-not-fn.rs @@ -1,9 +1,9 @@ //@ compile-flags: --test -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod test {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function mod loooooooooooooong_teeeeeeeeeest { /* this is a comment @@ -17,37 +17,37 @@ mod loooooooooooooong_teeeeeeeeeest { */ } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function extern "C" {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function trait Foo {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function impl Foo for i32 {} -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function const FOO: i32 = -1_i32; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function static BAR: u64 = 10_000_u64; -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function enum MyUnit { Unit, } -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function struct NewI32(i32); -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function union Spooky { x: i32, y: u32, } #[repr(C, align(64))] -#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function #[derive(Copy, Clone, Debug)] struct MoreAttrs { a: i32, @@ -58,7 +58,7 @@ macro_rules! foo { () => {}; } -#[test] //~ WARN: the `#[test]` attribute may only be used on a non-associated function +#[test] //~ WARN: the `#[test]` attribute may only be used on a free function foo!(); // make sure it doesn't erroneously trigger on a real test diff --git a/tests/ui/test-attrs/test-on-not-fn.stderr b/tests/ui/test-attrs/test-on-not-fn.stderr index a282db012540a..db8bed100a635 100644 --- a/tests/ui/test-attrs/test-on-not-fn.stderr +++ b/tests/ui/test-attrs/test-on-not-fn.stderr @@ -1,4 +1,4 @@ -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] @@ -12,7 +12,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:6:1 | LL | #[test] @@ -32,7 +32,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:20:1 | LL | #[test] @@ -46,7 +46,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:23:1 | LL | #[test] @@ -60,7 +60,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:26:1 | LL | #[test] @@ -74,7 +74,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:29:1 | LL | #[test] @@ -88,7 +88,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:32:1 | LL | #[test] @@ -102,7 +102,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:35:1 | LL | #[test] @@ -118,7 +118,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:40:1 | LL | #[test] @@ -132,7 +132,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:43:1 | LL | #[test] @@ -149,7 +149,7 @@ LL - #[test] LL + #[cfg(test)] | -error: the `#[test]` attribute may only be used on a non-associated function +error: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:50:1 | LL | #[test] @@ -167,7 +167,7 @@ LL - #[test] LL + #[cfg(test)] | -warning: the `#[test]` attribute may only be used on a non-associated function +warning: the `#[test]` attribute may only be used on a free function --> $DIR/test-on-not-fn.rs:61:1 | LL | #[test] From 8f8247812e9d4ff206eb4f90f26c7e7697e50c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Wed, 3 Dec 2025 17:01:37 +0100 Subject: [PATCH 21/22] address review comments --- .../issue-43106-gating-of-builtin-attrs.rs | 1 - ...issue-43106-gating-of-builtin-attrs.stderr | 402 +++++++++--------- tests/ui/macros/test-on-crate-root.rs | 9 +- tests/ui/macros/test-on-crate-root.stderr | 4 +- 4 files changed, 208 insertions(+), 208 deletions(-) diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index 5b32c5ca0dfa5..4b5420a2ff8b4 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -33,7 +33,6 @@ //@ check-pass -#![feature(test)] #![warn(unused_attributes, unknown_lints)] //~^ NOTE the lint level is defined here //~| NOTE the lint level is defined here diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index d8b1dc91acc4f..676372ad85e05 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -1,5 +1,5 @@ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -7,193 +7,193 @@ LL | mod inner { #![macro_escape] } = help: try an outer attribute: `#[macro_use]` warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:43:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:42:9 | LL | #![warn(x5400)] | ^^^^^ | note: the lint level is defined here - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:36:28 | LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:44:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:43:10 | LL | #![allow(x5300)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:45:11 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:44:11 | LL | #![forbid(x5200)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:45:9 | LL | #![deny(x5100)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:111:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:110:8 | LL | #[warn(x5400)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:114:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:113:25 | LL | mod inner { #![warn(x5400)] } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:117:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:116:12 | LL | #[warn(x5400)] fn f() { } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:120:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:119:12 | LL | #[warn(x5400)] struct S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:123:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:122:12 | LL | #[warn(x5400)] type T = S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:126:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:125:12 | LL | #[warn(x5400)] impl S { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:130:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:129:9 | LL | #[allow(x5300)] | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:133:26 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:132:26 | LL | mod inner { #![allow(x5300)] } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:136:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:135:13 | LL | #[allow(x5300)] fn f() { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:139:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:138:13 | LL | #[allow(x5300)] struct S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:142:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:141:13 | LL | #[allow(x5300)] type T = S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:145:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:144:13 | LL | #[allow(x5300)] impl S { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:149:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:148:10 | LL | #[forbid(x5200)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:152:27 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:151:27 | LL | mod inner { #![forbid(x5200)] } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:155:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:154:14 | LL | #[forbid(x5200)] fn f() { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:158:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:157:14 | LL | #[forbid(x5200)] struct S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:161:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:160:14 | LL | #[forbid(x5200)] type T = S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:164:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:163:14 | LL | #[forbid(x5200)] impl S { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:168:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:167:8 | LL | #[deny(x5100)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:171:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:170:25 | LL | mod inner { #![deny(x5100)] } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:174:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:173:12 | LL | #[deny(x5100)] fn f() { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:177:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:176:12 | LL | #[deny(x5100)] struct S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:180:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:179:12 | LL | #[deny(x5100)] type T = S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:183:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:182:12 | LL | #[deny(x5100)] impl S { } | ^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:468:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:36:9 | LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | #![reexport_test_harness_main = "2900"] | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:1 | LL | #[link(name = "x")] | ^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | | } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:832:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +230,7 @@ LL | #![crate_type = "0800"] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:857:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | #![feature(x0600)] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:882:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:881:1 | LL | #[no_main] | ^^^^^^^^^^ @@ -252,7 +252,7 @@ LL | #![no_main] | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:906:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:905:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | #![no_builtins] | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:71:1 | LL | #![link(name = "x")] | ^^^^^^^^^^^^^^^^^^^^ not an `extern` block @@ -271,7 +271,7 @@ LL | #![link(name = "x")] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:100:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:99:12 | LL | #![feature(rust1)] | ^^^^^ @@ -279,13 +279,13 @@ LL | #![feature(rust1)] = note: `#[warn(stable_features)]` on by default warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:472:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:475:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -296,7 +296,7 @@ LL | #![reexport_test_harness_main = "2900"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:479:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,7 @@ LL | #![reexport_test_harness_main = "2900"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:483:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,7 @@ LL | #![reexport_test_harness_main = "2900"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | #![reexport_test_harness_main = "2900"] impl S { } | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:17 | LL | mod inner { #![link(name = "x")] } | ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block @@ -337,7 +337,7 @@ LL | mod inner { #![link(name = "x")] } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:717:5 | LL | #[link(name = "x")] fn f() { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -345,7 +345,7 @@ LL | #[link(name = "x")] fn f() { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:722:5 | LL | #[link(name = "x")] struct S; | ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block @@ -353,7 +353,7 @@ LL | #[link(name = "x")] struct S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 | LL | #[link(name = "x")] type T = S; | ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block @@ -361,7 +361,7 @@ LL | #[link(name = "x")] type T = S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5 | LL | #[link(name = "x")] impl S { } | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block @@ -369,7 +369,7 @@ LL | #[link(name = "x")] impl S { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 | LL | #[link(name = "x")] extern "Rust" {} | ^^^^^^^^^^^^^^^^^^^ @@ -377,13 +377,13 @@ LL | #[link(name = "x")] extern "Rust" {} = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:837:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:836:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:839:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -394,7 +394,7 @@ LL | #![crate_type = "0800"] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:844:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL | #![crate_type = "0800"] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:848:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:847:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -416,7 +416,7 @@ LL | #![crate_type = "0800"] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:851:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -427,13 +427,13 @@ LL | #![crate_type = "0800"] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:861:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:864:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:863:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ @@ -444,7 +444,7 @@ LL | #![feature(x0600)] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:868:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:867:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL | #![feature(x0600)] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:872:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:871:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ @@ -466,7 +466,7 @@ LL | #![feature(x0600)] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:876:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:875:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ @@ -477,13 +477,13 @@ LL | #![feature(x0600)] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:886:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:885:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:888:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ @@ -494,7 +494,7 @@ LL | #![no_main] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:892:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ @@ -505,7 +505,7 @@ LL | #![no_main] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:897:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:896:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ @@ -516,7 +516,7 @@ LL | #![no_main] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:901:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:900:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ @@ -527,13 +527,13 @@ LL | #![no_main] impl S { } | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:910:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:909:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:913:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:912:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ @@ -544,7 +544,7 @@ LL | #![no_builtins] fn f() { } | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:917:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:916:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL | #![no_builtins] struct S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:921:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:920:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ @@ -566,7 +566,7 @@ LL | #![no_builtins] type T = S; | + warning: crate-level attribute should be an inner attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:924:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ @@ -577,7 +577,7 @@ LL | #![no_builtins] impl S { } | + warning: `#[macro_use]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:191:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:190:5 | LL | #[macro_use] fn f() { } | ^^^^^^^^^^^^ @@ -586,7 +586,7 @@ LL | #[macro_use] fn f() { } = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_use]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:197:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:196:5 | LL | #[macro_use] struct S; | ^^^^^^^^^^^^ @@ -595,7 +595,7 @@ LL | #[macro_use] struct S; = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:203:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:202:5 | LL | #[macro_use] type T = S; | ^^^^^^^^^^^^ @@ -604,7 +604,7 @@ LL | #[macro_use] type T = S; = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:209:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:208:5 | LL | #[macro_use] impl S { } | ^^^^^^^^^^^^ @@ -613,7 +613,7 @@ LL | #[macro_use] impl S { } = help: `#[macro_use]` can be applied to crates, extern crates, and modules warning: `#[macro_export]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:216:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:215:1 | LL | #[macro_export] | ^^^^^^^^^^^^^^^ @@ -622,7 +622,7 @@ LL | #[macro_export] = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:222:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:221:17 | LL | mod inner { #![macro_export] } | ^^^^^^^^^^^^^^^^ @@ -631,7 +631,7 @@ LL | mod inner { #![macro_export] } = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:228:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:227:5 | LL | #[macro_export] fn f() { } | ^^^^^^^^^^^^^^^ @@ -640,7 +640,7 @@ LL | #[macro_export] fn f() { } = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:234:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:233:5 | LL | #[macro_export] struct S; | ^^^^^^^^^^^^^^^ @@ -649,7 +649,7 @@ LL | #[macro_export] struct S; = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:240:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:239:5 | LL | #[macro_export] type T = S; | ^^^^^^^^^^^^^^^ @@ -658,7 +658,7 @@ LL | #[macro_export] type T = S; = help: `#[macro_export]` can only be applied to macro defs warning: `#[macro_export]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:246:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:245:5 | LL | #[macro_export] impl S { } | ^^^^^^^^^^^^^^^ @@ -667,7 +667,7 @@ LL | #[macro_export] impl S { } = help: `#[macro_export]` can only be applied to macro defs warning: `#[path]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:257:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:256:5 | LL | #[path = "3800"] fn f() { } | ^^^^^^^^^^^^^^^^ @@ -676,7 +676,7 @@ LL | #[path = "3800"] fn f() { } = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:263:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:262:5 | LL | #[path = "3800"] struct S; | ^^^^^^^^^^^^^^^^ @@ -685,7 +685,7 @@ LL | #[path = "3800"] struct S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:268:5 | LL | #[path = "3800"] type T = S; | ^^^^^^^^^^^^^^^^ @@ -694,7 +694,7 @@ LL | #[path = "3800"] type T = S; = help: `#[path]` can only be applied to modules warning: `#[path]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:275:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:274:5 | LL | #[path = "3800"] impl S { } | ^^^^^^^^^^^^^^^^ @@ -703,7 +703,7 @@ LL | #[path = "3800"] impl S { } = help: `#[path]` can only be applied to modules warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:282:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:281:1 | LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -712,7 +712,7 @@ LL | #[automatically_derived] = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:288:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:287:17 | LL | mod inner { #![automatically_derived] } | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -721,7 +721,7 @@ LL | mod inner { #![automatically_derived] } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:294:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:293:5 | LL | #[automatically_derived] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -730,7 +730,7 @@ LL | #[automatically_derived] fn f() { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:300:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:299:5 | LL | #[automatically_derived] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -739,7 +739,7 @@ LL | #[automatically_derived] struct S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:306:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:305:5 | LL | #[automatically_derived] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -748,7 +748,7 @@ LL | #[automatically_derived] type T = S; = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:312:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:311:5 | LL | #[automatically_derived] trait W { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -757,7 +757,7 @@ LL | #[automatically_derived] trait W { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[automatically_derived]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:318:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:317:5 | LL | #[automatically_derived] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -766,7 +766,7 @@ LL | #[automatically_derived] impl S { } = help: `#[automatically_derived]` can only be applied to trait impl blocks warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:327:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:1 | LL | #[no_mangle] | ^^^^^^^^^^^^ @@ -775,7 +775,7 @@ LL | #[no_mangle] = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:333:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:17 | LL | mod inner { #![no_mangle] } | ^^^^^^^^^^^^^ @@ -784,7 +784,7 @@ LL | mod inner { #![no_mangle] } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:341:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:340:5 | LL | #[no_mangle] struct S; | ^^^^^^^^^^^^ @@ -793,7 +793,7 @@ LL | #[no_mangle] struct S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:347:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:346:5 | LL | #[no_mangle] type T = S; | ^^^^^^^^^^^^ @@ -802,7 +802,7 @@ LL | #[no_mangle] type T = S; = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:353:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:352:5 | LL | #[no_mangle] impl S { } | ^^^^^^^^^^^^ @@ -811,7 +811,7 @@ LL | #[no_mangle] impl S { } = help: `#[no_mangle]` can be applied to functions and statics warning: `#[no_mangle]` attribute cannot be used on required trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:360:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:359:9 | LL | #[no_mangle] fn foo(); | ^^^^^^^^^^^^ @@ -820,7 +820,7 @@ LL | #[no_mangle] fn foo(); = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[no_mangle]` attribute cannot be used on provided trait methods - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:366:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:9 | LL | #[no_mangle] fn bar() {} | ^^^^^^^^^^^^ @@ -829,7 +829,7 @@ LL | #[no_mangle] fn bar() {} = help: `#[no_mangle]` can be applied to functions, inherent methods, statics, and trait methods in impl blocks warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:374:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ @@ -838,7 +838,7 @@ LL | #[should_panic] = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:17 | LL | mod inner { #![should_panic] } | ^^^^^^^^^^^^^^^^ @@ -847,7 +847,7 @@ LL | mod inner { #![should_panic] } = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:388:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:387:5 | LL | #[should_panic] struct S; | ^^^^^^^^^^^^^^^ @@ -856,7 +856,7 @@ LL | #[should_panic] struct S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:394:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:393:5 | LL | #[should_panic] type T = S; | ^^^^^^^^^^^^^^^ @@ -865,7 +865,7 @@ LL | #[should_panic] type T = S; = help: `#[should_panic]` can only be applied to functions warning: `#[should_panic]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:400:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:399:5 | LL | #[should_panic] impl S { } | ^^^^^^^^^^^^^^^ @@ -874,7 +874,7 @@ LL | #[should_panic] impl S { } = help: `#[should_panic]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:407:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:1 | LL | #[ignore] | ^^^^^^^^^ @@ -883,7 +883,7 @@ LL | #[ignore] = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:413:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:17 | LL | mod inner { #![ignore] } | ^^^^^^^^^^ @@ -892,7 +892,7 @@ LL | mod inner { #![ignore] } = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:421:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 | LL | #[ignore] struct S; | ^^^^^^^^^ @@ -901,7 +901,7 @@ LL | #[ignore] struct S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:427:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 | LL | #[ignore] type T = S; | ^^^^^^^^^ @@ -910,7 +910,7 @@ LL | #[ignore] type T = S; = help: `#[ignore]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 | LL | #[ignore] impl S { } | ^^^^^^^^^ @@ -919,7 +919,7 @@ LL | #[ignore] impl S { } = help: `#[ignore]` can only be applied to functions warning: `#[no_implicit_prelude]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:444:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:443:5 | LL | #[no_implicit_prelude] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -928,7 +928,7 @@ LL | #[no_implicit_prelude] fn f() { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:450:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:449:5 | LL | #[no_implicit_prelude] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -937,7 +937,7 @@ LL | #[no_implicit_prelude] struct S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:456:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:455:5 | LL | #[no_implicit_prelude] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -946,7 +946,7 @@ LL | #[no_implicit_prelude] type T = S; = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:462:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:461:5 | LL | #[no_implicit_prelude] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -955,7 +955,7 @@ LL | #[no_implicit_prelude] impl S { } = help: `#[no_implicit_prelude]` can be applied to crates and modules warning: `#[macro_escape]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:500:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ @@ -964,7 +964,7 @@ LL | #[macro_escape] fn f() { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:507:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:506:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ @@ -973,7 +973,7 @@ LL | #[macro_escape] struct S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:513:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ @@ -982,7 +982,7 @@ LL | #[macro_escape] type T = S; = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:519:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:518:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ @@ -991,13 +991,13 @@ LL | #[macro_escape] impl S { } = help: `#[macro_escape]` can be applied to crates, extern crates, and modules warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:525:1 | LL | #[no_std] | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:528:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:1 | LL | / mod no_std { LL | | @@ -1007,61 +1007,61 @@ LL | | } | |_^ warning: the `#![no_std]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:530:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:15 | LL | #[no_std] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5 | LL | #[no_std] struct S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:15 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:15 | LL | #[no_std] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_std]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:545:15 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:15 | LL | #[no_std] impl S { } | ^^^^^^^^^^ warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:567:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:566:1 | LL | #[cold] | ^^^^^^^ @@ -1070,7 +1070,7 @@ LL | #[cold] = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:574:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:17 | LL | mod inner { #![cold] } | ^^^^^^^^ @@ -1079,7 +1079,7 @@ LL | mod inner { #![cold] } = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:582:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:581:5 | LL | #[cold] struct S; | ^^^^^^^ @@ -1088,7 +1088,7 @@ LL | #[cold] struct S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:588:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:587:5 | LL | #[cold] type T = S; | ^^^^^^^ @@ -1097,7 +1097,7 @@ LL | #[cold] type T = S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:594:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:593:5 | LL | #[cold] impl S { } | ^^^^^^^ @@ -1106,7 +1106,7 @@ LL | #[cold] impl S { } = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:600:1 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1115,7 +1115,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on foreign modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:607:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:5 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1124,7 +1124,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:613:17 | LL | mod inner { #![link_name="1900"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1133,7 +1133,7 @@ LL | mod inner { #![link_name="1900"] } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:619:5 | LL | #[link_name = "1900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1142,7 +1142,7 @@ LL | #[link_name = "1900"] fn f() { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:625:5 | LL | #[link_name = "1900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1151,7 +1151,7 @@ LL | #[link_name = "1900"] struct S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:5 | LL | #[link_name = "1900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1160,7 +1160,7 @@ LL | #[link_name = "1900"] type T = S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:637:5 | LL | #[link_name = "1900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1169,7 +1169,7 @@ LL | #[link_name = "1900"] impl S { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:645:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:1 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1178,7 +1178,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:650:17 | LL | mod inner { #![link_section="1800"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1187,7 +1187,7 @@ LL | mod inner { #![link_section="1800"] } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:659:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5 | LL | #[link_section = "1800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1196,7 +1196,7 @@ LL | #[link_section = "1800"] struct S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 | LL | #[link_section = "1800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1205,7 +1205,7 @@ LL | #[link_section = "1800"] type T = S; = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:670:5 | LL | #[link_section = "1800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1214,7 +1214,7 @@ LL | #[link_section = "1800"] impl S { } = help: `#[link_section]` can be applied to functions and statics warning: `#[link_section]` attribute cannot be used on traits - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:5 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1223,7 +1223,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:1 | LL | #[must_use] | ^^^^^^^^^^^ @@ -1232,7 +1232,7 @@ LL | #[must_use] = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ @@ -1241,7 +1241,7 @@ LL | mod inner { #![must_use] } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:772:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ @@ -1250,7 +1250,7 @@ LL | #[must_use] type T = S; = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: `#[must_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:777:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ @@ -1259,13 +1259,13 @@ LL | #[must_use] impl S { } = help: `#[must_use]` can be applied to data types, functions, traits, and unions warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:783:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:785:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:784:1 | LL | / mod windows_subsystem { LL | | @@ -1275,67 +1275,67 @@ LL | | } | |_^ warning: the `#![windows_subsystem]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:787:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:38 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:793:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:793:38 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:5 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:38 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![windows_subsystem]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:5 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:802:38 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:38 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:811:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:810:1 | LL | / mod crate_name { LL | | @@ -1345,67 +1345,67 @@ LL | | } | |_^ warning: the `#![crate_name]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:812:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:815:28 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:819:28 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:823:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:823:28 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:28 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:930:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:929:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:932:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:931:1 | LL | / mod recursion_limit { LL | | @@ -1415,67 +1415,67 @@ LL | | } | |_^ warning: the `#![recursion_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:934:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:936:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:936:31 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:941:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:940:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:941:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:940:31 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:944:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:945:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:944:31 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:948:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:31 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:948:31 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:954:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:953:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:956:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:955:1 | LL | / mod type_length_limit { LL | | @@ -1485,61 +1485,61 @@ LL | | } | |_^ warning: the `#![type_length_limit]` attribute can only be used at the crate root - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:958:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:957:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:960:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this function - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:960:33 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:965:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this struct - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:965:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:964:33 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:968:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:969:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:968:33 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![type_length_limit]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:972:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: This attribute does not have an `!`, which means it is applied to this implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:973:33 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:972:33 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^ warning: `#[should_panic]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:50:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:49:1 | LL | #![should_panic] | ^^^^^^^^^^^^^^^^ @@ -1548,7 +1548,7 @@ LL | #![should_panic] = help: `#[should_panic]` can only be applied to functions warning: `#[ignore]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1 | LL | #![ignore] | ^^^^^^^^^^ @@ -1557,7 +1557,7 @@ LL | #![ignore] = help: `#[ignore]` can only be applied to functions warning: `#[proc_macro_derive]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:63:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 | LL | #![proc_macro_derive(Test)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1566,7 +1566,7 @@ LL | #![proc_macro_derive(Test)] = help: `#[proc_macro_derive]` can only be applied to functions warning: `#[cold]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:68:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:67:1 | LL | #![cold] | ^^^^^^^^ @@ -1575,7 +1575,7 @@ LL | #![cold] = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:74:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:73:1 | LL | #![link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -1584,7 +1584,7 @@ LL | #![link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:79:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:78:1 | LL | #![link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1593,7 +1593,7 @@ LL | #![link_section = "1800"] = help: `#[link_section]` can be applied to functions and statics warning: `#[must_use]` attribute cannot be used on crates - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:83:1 | LL | #![must_use] | ^^^^^^^^^^^^ diff --git a/tests/ui/macros/test-on-crate-root.rs b/tests/ui/macros/test-on-crate-root.rs index 0e0f3ec40976c..88d6ec40af840 100644 --- a/tests/ui/macros/test-on-crate-root.rs +++ b/tests/ui/macros/test-on-crate-root.rs @@ -1,9 +1,10 @@ -// ICE when applying `#![test]` to the crate root, -// though only when specified with a full path. `#![test]` is not enough. -// Fixes #114920 +// Regression test for rust-lang/rust#114920 +// +// Applying `#![test]` to the crate root used to ICE, +// when referring to the attribute with full path specifically. #![core::prelude::v1::test] //~^ ERROR inner macro attributes are unstable //~| ERROR the `#[test]` attribute may only be used on a free function -fn main() {} // not important to reproduce the issue +fn main() {} diff --git a/tests/ui/macros/test-on-crate-root.stderr b/tests/ui/macros/test-on-crate-root.stderr index d706d6ae6c5fa..750c510ecbca1 100644 --- a/tests/ui/macros/test-on-crate-root.stderr +++ b/tests/ui/macros/test-on-crate-root.stderr @@ -1,5 +1,5 @@ error[E0658]: inner macro attributes are unstable - --> $DIR/test-on-crate-root.rs:4:4 + --> $DIR/test-on-crate-root.rs:5:4 | LL | #![core::prelude::v1::test] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![core::prelude::v1::test] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: the `#[test]` attribute may only be used on a free function - --> $DIR/test-on-crate-root.rs:4:1 + --> $DIR/test-on-crate-root.rs:5:1 | LL | #![core::prelude::v1::test] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions From 876c1c9d317dfdd762a266855c2abbc0b75ae12f Mon Sep 17 00:00:00 2001 From: blyxyas Date: Tue, 2 Dec 2025 22:45:54 +0000 Subject: [PATCH 22/22] Unify my name in the mailmap --- .mailmap | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 6bae8038c6964..1118955016bd0 100644 --- a/.mailmap +++ b/.mailmap @@ -43,6 +43,7 @@ Andre Bogus Andre Bogus Andre Bogus Andrea Ciliberti + Andreas Gal Andreas Jonson Andrew Gauger @@ -87,7 +88,9 @@ bjorn3 <17426603+bjorn3@users.noreply.github.com> Björn Steinbrink blake2-ppc -blyxyas Alejandra González +Alejandra González blyxyas +Alejandra González blyxyas +Alejandra González Alejandra González boolean_coercion Boris Egorov bors bors[bot] <26634292+bors[bot]@users.noreply.github.com>