From 8dc773296cf743af20b1174050431c29ba6a7427 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Mon, 14 Apr 2025 13:36:06 +0200 Subject: [PATCH 01/20] Clarify why SGX code specifies linkage/symbol names for certain statics Also update the symbol names as items have moved around a bit. The actual name isn't that important, it just needs to be unique. But for debugging it can be useful for it to point to the right place. --- library/std/src/sys/alloc/sgx.rs | 4 +++- library/std/src/sys/args/sgx.rs | 1 + library/std/src/sys/pal/sgx/abi/tls/mod.rs | 6 ++++-- library/std/src/sys/pal/sgx/os.rs | 6 ++++-- library/std/src/sys/pal/sgx/thread.rs | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/library/std/src/sys/alloc/sgx.rs b/library/std/src/sys/alloc/sgx.rs index f5c27688fbc8f..7a846e2376b9b 100644 --- a/library/std/src/sys/alloc/sgx.rs +++ b/library/std/src/sys/alloc/sgx.rs @@ -10,8 +10,10 @@ use crate::sys::pal::waitqueue::SpinMutex; // The current allocator here is the `dlmalloc` crate which we've got included // in the rust-lang/rust repository as a submodule. The crate is a port of // dlmalloc.c from C to Rust. +// +// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] -#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys5alloc3sgx8DLMALLOCE")] static DLMALLOC: SpinMutex> = SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {})); diff --git a/library/std/src/sys/args/sgx.rs b/library/std/src/sys/args/sgx.rs index efc4b79185227..0185a8a600094 100644 --- a/library/std/src/sys/args/sgx.rs +++ b/library/std/src/sys/args/sgx.rs @@ -8,6 +8,7 @@ use crate::sys::pal::abi::usercalls::raw::ByteBuffer; use crate::sys_common::FromInner; use crate::{fmt, slice}; +// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] #[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")] static ARGS: AtomicUsize = AtomicUsize::new(0); diff --git a/library/std/src/sys/pal/sgx/abi/tls/mod.rs b/library/std/src/sys/pal/sgx/abi/tls/mod.rs index 8e2b271f1c970..f082d94614b4d 100644 --- a/library/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/library/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -11,15 +11,17 @@ const USIZE_BITS: usize = 64; const TLS_KEYS: usize = 128; // Same as POSIX minimum const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS; +// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] -#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_KEY_IN_USEE")] static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT; macro_rules! dup { ((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* )); (() $($val:tt)*) => ([$($val),*]) } +// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] -#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_DESTRUCTORE")] static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0))); unsafe extern "C" { diff --git a/library/std/src/sys/pal/sgx/os.rs b/library/std/src/sys/pal/sgx/os.rs index b1ec2afd764e6..010634cf31063 100644 --- a/library/std/src/sys/pal/sgx/os.rs +++ b/library/std/src/sys/pal/sgx/os.rs @@ -73,11 +73,13 @@ pub fn current_exe() -> io::Result { unsupported() } +// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] -#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os3ENVE")] static ENV: AtomicUsize = AtomicUsize::new(0); +// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] -#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os8ENV_INITE")] static ENV_INIT: Once = Once::new(); type EnvStore = Mutex>; diff --git a/library/std/src/sys/pal/sgx/thread.rs b/library/std/src/sys/pal/sgx/thread.rs index b6932df431f42..219ef1b7a9897 100644 --- a/library/std/src/sys/pal/sgx/thread.rs +++ b/library/std/src/sys/pal/sgx/thread.rs @@ -45,8 +45,9 @@ mod task_queue { } } + // Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests #[cfg_attr(test, linkage = "available_externally")] - #[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")] + #[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx6thread10TASK_QUEUEE")] static TASK_QUEUE: Mutex> = Mutex::new(Vec::new()); pub(super) fn lock() -> MutexGuard<'static, Vec> { From a86df238d3f21ccb6ec25080bcc24b1f9153ea63 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sat, 19 Apr 2025 16:46:06 +0800 Subject: [PATCH 02/20] tests: rework `amdgpu-require-explicit-cpu.rs` - Reworked the test as a *centralized* version of checking that certain targets correctly require `-C target-cpu` being specified. - Document test intention. - Move `amdgpu-require-explicit-cpu.rs` under new dir `tests/ui/target-cpu/` - No other ui subdir really fits this "requires `-Ctarget-cpu`" check. --- tests/ui/amdgpu-require-explicit-cpu.rs | 18 --------- .../explicit-target-cpu.amdgcn_nocpu.stderr} | 0 .../explicit-target-cpu.avr_nocpu.stderr | 4 ++ tests/ui/target-cpu/explicit-target-cpu.rs | 37 +++++++++++++++++++ 4 files changed, 41 insertions(+), 18 deletions(-) delete mode 100644 tests/ui/amdgpu-require-explicit-cpu.rs rename tests/ui/{amdgpu-require-explicit-cpu.nocpu.stderr => target-cpu/explicit-target-cpu.amdgcn_nocpu.stderr} (100%) create mode 100644 tests/ui/target-cpu/explicit-target-cpu.avr_nocpu.stderr create mode 100644 tests/ui/target-cpu/explicit-target-cpu.rs diff --git a/tests/ui/amdgpu-require-explicit-cpu.rs b/tests/ui/amdgpu-require-explicit-cpu.rs deleted file mode 100644 index d40cb97977d94..0000000000000 --- a/tests/ui/amdgpu-require-explicit-cpu.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ revisions: nocpu cpu -//@ no-prefer-dynamic -//@ compile-flags: --crate-type=cdylib --target=amdgcn-amd-amdhsa -//@ needs-llvm-components: amdgpu -//@ needs-rust-lld -//@[nocpu] build-fail -//@[cpu] compile-flags: -Ctarget-cpu=gfx900 -//@[cpu] build-pass - -#![feature(no_core, lang_items)] -#![no_core] - -#[lang="sized"] -trait Sized {} - -pub fn foo() {} - -//[nocpu]~? ERROR target requires explicitly specifying a cpu with `-C target-cpu` diff --git a/tests/ui/amdgpu-require-explicit-cpu.nocpu.stderr b/tests/ui/target-cpu/explicit-target-cpu.amdgcn_nocpu.stderr similarity index 100% rename from tests/ui/amdgpu-require-explicit-cpu.nocpu.stderr rename to tests/ui/target-cpu/explicit-target-cpu.amdgcn_nocpu.stderr diff --git a/tests/ui/target-cpu/explicit-target-cpu.avr_nocpu.stderr b/tests/ui/target-cpu/explicit-target-cpu.avr_nocpu.stderr new file mode 100644 index 0000000000000..7480a8ed38f15 --- /dev/null +++ b/tests/ui/target-cpu/explicit-target-cpu.avr_nocpu.stderr @@ -0,0 +1,4 @@ +error: target requires explicitly specifying a cpu with `-C target-cpu` + +error: aborting due to 1 previous error + diff --git a/tests/ui/target-cpu/explicit-target-cpu.rs b/tests/ui/target-cpu/explicit-target-cpu.rs new file mode 100644 index 0000000000000..cd4c2384bc1df --- /dev/null +++ b/tests/ui/target-cpu/explicit-target-cpu.rs @@ -0,0 +1,37 @@ +//! Check that certain target *requires* the user to specify a target CPU via `-C target-cpu`. + +//@ revisions: amdgcn_nocpu amdgcn_cpu + +//@[amdgcn_nocpu] compile-flags: --target=amdgcn-amd-amdhsa +//@[amdgcn_nocpu] needs-llvm-components: amdgpu +//@[amdgcn_nocpu] build-fail + +//@[amdgcn_cpu] compile-flags: --target=amdgcn-amd-amdhsa +//@[amdgcn_cpu] needs-llvm-components: amdgpu +//@[amdgcn_cpu] compile-flags: -Ctarget-cpu=gfx900 +//@[amdgcn_cpu] build-pass + +//@ revisions: avr_nocpu avr_cpu + +//@[avr_nocpu] compile-flags: --target=avr-none +//@[avr_nocpu] needs-llvm-components: avr +//@[avr_nocpu] build-fail + +//@[avr_cpu] compile-flags: --target=avr-none +//@[avr_cpu] needs-llvm-components: avr +//@[avr_cpu] compile-flags: -Ctarget-cpu=atmega328p +//@[avr_cpu] build-pass + +#![crate_type = "rlib"] + +// FIXME(#140038): this can't use `minicore` yet because `minicore` doesn't currently propagate the +// `-C target-cpu` for targets that *require* a `target-cpu` being specified. +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized {} + +pub fn foo() {} + +//[amdgcn_nocpu,avr_nocpu]~? ERROR target requires explicitly specifying a cpu with `-C target-cpu` From 40b73322b93bf1627a7cb58aec5a7fe019af1f66 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sat, 19 Apr 2025 17:05:05 +0800 Subject: [PATCH 03/20] tests: adjust some `augmented-assignment*` tests - `tests/ui/augmented-assignment-feature-gate-cross.rs`: - This was *originally* to feature-gate overloaded OpAssign cross-crate, but now let's keep it as a smoke test. - Renamed as `augmented-assignment-cross-crate.rs`. - Relocated under `tests/ui/binop/`. - `tests/ui/augmented-assignments.rs`: - Documented test intent. - Moved under `tests/ui/borrowck/`. - `tests/ui/augmented-assignment-rpass.rs`: - Renamed to drop the `-rpass` suffix, since this was leftover from when `run-pass` test suite was a thing. - Moved under `tests/ui/binop/`. --- .../augmented-assignment.rs} | 0 .../augmented-assignments-cross-crate.rs} | 2 ++ tests/ui/{ => binop}/auxiliary/augmented_assignments.rs | 0 tests/ui/{ => borrowck}/augmented-assignments.rs | 3 +++ tests/ui/{ => borrowck}/augmented-assignments.stderr | 4 ++-- 5 files changed, 7 insertions(+), 2 deletions(-) rename tests/ui/{augmented-assignments-rpass.rs => binop/augmented-assignment.rs} (100%) rename tests/ui/{augmented-assignments-feature-gate-cross.rs => binop/augmented-assignments-cross-crate.rs} (72%) rename tests/ui/{ => binop}/auxiliary/augmented_assignments.rs (100%) rename tests/ui/{ => borrowck}/augmented-assignments.rs (83%) rename tests/ui/{ => borrowck}/augmented-assignments.stderr (88%) diff --git a/tests/ui/augmented-assignments-rpass.rs b/tests/ui/binop/augmented-assignment.rs similarity index 100% rename from tests/ui/augmented-assignments-rpass.rs rename to tests/ui/binop/augmented-assignment.rs diff --git a/tests/ui/augmented-assignments-feature-gate-cross.rs b/tests/ui/binop/augmented-assignments-cross-crate.rs similarity index 72% rename from tests/ui/augmented-assignments-feature-gate-cross.rs rename to tests/ui/binop/augmented-assignments-cross-crate.rs index d402d20061779..6dbb03509884d 100644 --- a/tests/ui/augmented-assignments-feature-gate-cross.rs +++ b/tests/ui/binop/augmented-assignments-cross-crate.rs @@ -1,3 +1,5 @@ +//! Smoke test for overloaded compound assignments cross-crate. + //@ run-pass //@ aux-build:augmented_assignments.rs diff --git a/tests/ui/auxiliary/augmented_assignments.rs b/tests/ui/binop/auxiliary/augmented_assignments.rs similarity index 100% rename from tests/ui/auxiliary/augmented_assignments.rs rename to tests/ui/binop/auxiliary/augmented_assignments.rs diff --git a/tests/ui/augmented-assignments.rs b/tests/ui/borrowck/augmented-assignments.rs similarity index 83% rename from tests/ui/augmented-assignments.rs rename to tests/ui/borrowck/augmented-assignments.rs index 35ab2d454f7b7..d717dcc7935ed 100644 --- a/tests/ui/augmented-assignments.rs +++ b/tests/ui/borrowck/augmented-assignments.rs @@ -1,3 +1,6 @@ +//! Check that overloaded compound assignment operators respect usual borrowck rules and emit +//! reasonable diagnostics. + use std::ops::AddAssign; #[derive(Clone)] diff --git a/tests/ui/augmented-assignments.stderr b/tests/ui/borrowck/augmented-assignments.stderr similarity index 88% rename from tests/ui/augmented-assignments.stderr rename to tests/ui/borrowck/augmented-assignments.stderr index a4b75cbf6e8fc..4b945cd998a14 100644 --- a/tests/ui/augmented-assignments.stderr +++ b/tests/ui/borrowck/augmented-assignments.stderr @@ -1,5 +1,5 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/augmented-assignments.rs:17:5 + --> $DIR/augmented-assignments.rs:20:5 | LL | let mut x = Int(1); | ----- binding `x` declared here @@ -10,7 +10,7 @@ LL | x; | ^ move out of `x` occurs here error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/augmented-assignments.rs:24:5 + --> $DIR/augmented-assignments.rs:27:5 | LL | y | ^ cannot borrow as mutable From b47fe51610fbe0d8d983f3ace0682044a1a450c3 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sat, 19 Apr 2025 17:29:31 +0800 Subject: [PATCH 04/20] tests: adjust `tests/ui/auto-instantiate.rs` - Reformat the test. - Document test intention. - Move test under `tests/ui/inference/`. --- tests/ui/auto-instantiate.rs | 13 ------------ tests/ui/inference/auto-instantiate.rs | 28 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) delete mode 100644 tests/ui/auto-instantiate.rs create mode 100644 tests/ui/inference/auto-instantiate.rs diff --git a/tests/ui/auto-instantiate.rs b/tests/ui/auto-instantiate.rs deleted file mode 100644 index 73ad5d701e182..0000000000000 --- a/tests/ui/auto-instantiate.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#[derive(Debug)] -struct Pair { a: T, b: U } -struct Triple { x: isize, y: isize, z: isize } - -fn f(x: T, y: U) -> Pair { return Pair {a: x, b: y}; } - -pub fn main() { - println!("{}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x); - println!("{}", f(5, 6).a); -} diff --git a/tests/ui/inference/auto-instantiate.rs b/tests/ui/inference/auto-instantiate.rs new file mode 100644 index 0000000000000..bf43330a0b77c --- /dev/null +++ b/tests/ui/inference/auto-instantiate.rs @@ -0,0 +1,28 @@ +//! Check that type parameters in generic function arg position and in "nested" return type position +//! can be inferred on an invocation of the generic function. +//! +//! See . + +//@ run-pass + +#![allow(dead_code)] +#[derive(Debug)] +struct Pair { + a: T, + b: U, +} + +struct Triple { + x: isize, + y: isize, + z: isize, +} + +fn f(x: T, y: U) -> Pair { + return Pair { a: x, b: y }; +} + +pub fn main() { + println!("{}", f(Triple {x: 3, y: 4, z: 5}, 4).a.x); + println!("{}", f(5, 6).a); +} From 6be60e83b5660f45fc26d75e43b6745e3a2d0ee9 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 19 Apr 2025 17:51:41 +0200 Subject: [PATCH 05/20] needed a stronger pause --- src/doc/rustc-dev-guide/src/tests/ui.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md index 7c4e2a0fdae74..f7857ae690343 100644 --- a/src/doc/rustc-dev-guide/src/tests/ui.md +++ b/src/doc/rustc-dev-guide/src/tests/ui.md @@ -337,7 +337,8 @@ possible, including `//~?` annotations for diagnostics without span. If the compile time output is target dependent or too verbose, use directive `//@ dont-require-annotations: ` to make the line annotation checking -non-exhaustive, some of the compiler messages can stay uncovered by annotations in this mode. +non-exhaustive. +Some of the compiler messages can stay uncovered by annotations in this mode. For checking runtime output `//@ check-run-results` may be preferable. From d09b3c75de1d2a4f15c6537d402df60a98fe07c3 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 19 Apr 2025 17:57:56 +0200 Subject: [PATCH 06/20] fix grammar --- src/doc/rustc-dev-guide/src/tests/ui.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md index f7857ae690343..06b13a324ee70 100644 --- a/src/doc/rustc-dev-guide/src/tests/ui.md +++ b/src/doc/rustc-dev-guide/src/tests/ui.md @@ -333,7 +333,7 @@ fn main() { Use of `error-pattern` is not recommended in general. For strict testing of compile time output, try to use the line annotations `//~` as much as -possible, including `//~?` annotations for diagnostics without span. +possible, including `//~?` annotations for diagnostics without spans. If the compile time output is target dependent or too verbose, use directive `//@ dont-require-annotations: ` to make the line annotation checking From 48612702d937bc6e26ccc70496c0aade6fae493c Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 19 Apr 2025 17:56:23 +0200 Subject: [PATCH 07/20] improve readability by adding pauses --- src/doc/rustc-dev-guide/src/tests/ui.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md index 06b13a324ee70..6232c8bcc0a61 100644 --- a/src/doc/rustc-dev-guide/src/tests/ui.md +++ b/src/doc/rustc-dev-guide/src/tests/ui.md @@ -303,7 +303,7 @@ It should be preferred to using `error-pattern`, which is imprecise and non-exha ### `error-pattern` The `error-pattern` [directive](directives.md) can be used for runtime messages, which don't -have a specific span, or in exceptional cases for compile time messages. +have a specific span, or in exceptional cases, for compile time messages. Let's think about this test: @@ -316,7 +316,7 @@ fn main() { } ``` -We want to ensure this shows "index out of bounds" but we cannot use the `ERROR` +We want to ensure this shows "index out of bounds", but we cannot use the `ERROR` annotation since the runtime error doesn't have any span. Then it's time to use the `error-pattern` directive: @@ -340,12 +340,12 @@ If the compile time output is target dependent or too verbose, use directive non-exhaustive. Some of the compiler messages can stay uncovered by annotations in this mode. -For checking runtime output `//@ check-run-results` may be preferable. +For checking runtime output, `//@ check-run-results` may be preferable. Only use `error-pattern` if none of the above works. Line annotations `//~` are still checked in tests using `error-pattern`. -In exceptional cases use `//@ compile-flags: --error-format=human` to opt out of these checks. +In exceptional cases, use `//@ compile-flags: --error-format=human` to opt out of these checks. ### Diagnostic kinds (error levels) From ae4b6d6c65c32d41d8017b4e3765a8a1871e8519 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Apr 2025 21:06:52 +0200 Subject: [PATCH 08/20] Update docs for `AssocItems::filter_by_name_unhygienic` --- compiler/rustc_middle/src/ty/assoc.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 0c44fd2758d52..78b2e265b488c 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -246,6 +246,8 @@ impl AssocItems { } /// Returns an iterator over all associated items with the given name, ignoring hygiene. + /// + /// Panics if `name.is_empty()` returns `true`. pub fn filter_by_name_unhygienic( &self, name: Symbol, From e0437ec364017b11b5e63d1c09e3204029d8b497 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Apr 2025 21:07:24 +0200 Subject: [PATCH 09/20] Fix error when an intra doc link is trying to resolve an empty associated item --- src/librustdoc/passes/collect_intra_doc_links.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 297597b3deacc..36f5889dcf4ea 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -59,7 +59,12 @@ fn filter_assoc_items_by_name_and_namespace( ident: Ident, ns: Namespace, ) -> impl Iterator { - tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| { + let iter: Box> = if !ident.name.is_empty() { + Box::new(tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name)) + } else { + Box::new([].iter()) + }; + iter.filter(move |item| { item.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of) }) } From 88a5e1ef683673c7e1b16b399d745d01ad540a19 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 19 Apr 2025 21:10:40 +0200 Subject: [PATCH 10/20] Add regression test for #140026 --- .../rustdoc-ui/intra-doc/empty-associated-items.rs | 8 ++++++++ .../intra-doc/empty-associated-items.stderr | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/rustdoc-ui/intra-doc/empty-associated-items.rs create mode 100644 tests/rustdoc-ui/intra-doc/empty-associated-items.stderr diff --git a/tests/rustdoc-ui/intra-doc/empty-associated-items.rs b/tests/rustdoc-ui/intra-doc/empty-associated-items.rs new file mode 100644 index 0000000000000..ea94cb349ad29 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/empty-associated-items.rs @@ -0,0 +1,8 @@ +// This test ensures that an empty associated item will not crash rustdoc. +// This is a regression test for . + +#[deny(rustdoc::broken_intra_doc_links)] + +/// [`String::`] +//~^ ERROR +pub struct Foo; diff --git a/tests/rustdoc-ui/intra-doc/empty-associated-items.stderr b/tests/rustdoc-ui/intra-doc/empty-associated-items.stderr new file mode 100644 index 0000000000000..b0527916ab502 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/empty-associated-items.stderr @@ -0,0 +1,14 @@ +error: unresolved link to `String::` + --> $DIR/empty-associated-items.rs:6:7 + | +LL | /// [`String::`] + | ^^^^^^^^ the struct `String` has no field or associated item named `` + | +note: the lint level is defined here + --> $DIR/empty-associated-items.rs:4:8 + | +LL | #[deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + From df8a3d5f1d363c19e2fc82060aabb80a9cd94015 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 18 Dec 2024 22:05:27 +0100 Subject: [PATCH 11/20] stabilize `naked_functions` --- .../example/mini_core_hello_world.rs | 11 +- .../src/error_codes/E0787.md | 2 - compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/builtin_attrs.rs | 7 +- compiler/rustc_feature/src/unstable.rs | 2 - compiler/rustc_passes/src/check_attr.rs | 7 -- library/core/src/arch.rs | 2 +- .../src/compiler-flags/sanitizer.md | 2 - .../aarch64-naked-fn-no-bti-prolog.rs | 2 +- tests/assembly/naked-functions/aix.rs | 2 +- tests/assembly/naked-functions/wasm32.rs | 2 +- .../x86_64-naked-fn-no-cet-prolog.rs | 2 +- tests/auxiliary/minicore.rs | 1 - tests/codegen/cffi/c-variadic-naked.rs | 1 - tests/codegen/naked-asan.rs | 2 +- tests/codegen/naked-fn/aligned.rs | 2 +- tests/codegen/naked-fn/generics.rs | 1 - tests/codegen/naked-fn/instruction-set.rs | 2 +- .../naked-fn/min-function-alignment.rs | 2 +- tests/codegen/naked-fn/naked-functions.rs | 2 +- .../naked-symbol-visibility/a_rust_dylib.rs | 2 +- tests/ui/asm/naked-asm-outside-naked-fn.rs | 1 - .../ui/asm/naked-asm-outside-naked-fn.stderr | 6 +- tests/ui/asm/naked-functions-ffi.rs | 1 - tests/ui/asm/naked-functions-ffi.stderr | 4 +- tests/ui/asm/naked-functions-inline.rs | 1 - tests/ui/asm/naked-functions-inline.stderr | 8 +- .../ui/asm/naked-functions-instruction-set.rs | 2 +- tests/ui/asm/naked-functions-rustic-abi.rs | 2 +- .../ui/asm/naked-functions-target-feature.rs | 2 +- tests/ui/asm/naked-functions-testattrs.rs | 1 - tests/ui/asm/naked-functions-testattrs.stderr | 8 +- .../asm/naked-functions-unused.aarch64.stderr | 20 +-- tests/ui/asm/naked-functions-unused.rs | 1 - .../asm/naked-functions-unused.x86_64.stderr | 20 +-- tests/ui/asm/naked-functions.rs | 1 - tests/ui/asm/naked-functions.stderr | 50 ++++---- tests/ui/asm/naked-invalid-attr.rs | 4 +- tests/ui/asm/naked-invalid-attr.stderr | 17 ++- tests/ui/asm/naked-with-invalid-repr-attr.rs | 1 - .../asm/naked-with-invalid-repr-attr.stderr | 12 +- tests/ui/asm/named-asm-labels.rs | 2 - tests/ui/asm/named-asm-labels.stderr | 116 +++++++++--------- tests/ui/asm/simple_global_asm.rs | 1 - .../feature-gate-naked_functions.rs | 20 --- .../feature-gate-naked_functions.stderr | 75 ----------- ...feature-gate-naked_functions_rustic_abi.rs | 2 +- ...ure-gate-naked_functions_target_feature.rs | 2 - ...gate-naked_functions_target_feature.stderr | 2 +- tests/ui/lint/inline-exported.rs | 2 - tests/ui/lint/inline-exported.stderr | 8 +- .../rfc-2091-track-caller/error-with-naked.rs | 1 - .../error-with-naked.stderr | 8 +- 53 files changed, 165 insertions(+), 294 deletions(-) delete mode 100644 tests/ui/feature-gates/feature-gate-naked_functions.rs delete mode 100644 tests/ui/feature-gates/feature-gate-naked_functions.stderr diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs index 0b3a7281d5a06..93ca2e0e42188 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -1,13 +1,4 @@ -#![feature( - no_core, - lang_items, - never_type, - linkage, - extern_types, - naked_functions, - thread_local, - repr_simd -)] +#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)] #![no_core] #![allow(dead_code, non_camel_case_types, internal_features)] diff --git a/compiler/rustc_error_codes/src/error_codes/E0787.md b/compiler/rustc_error_codes/src/error_codes/E0787.md index 47b56ac17f4f5..b7f92c8feb587 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0787.md +++ b/compiler/rustc_error_codes/src/error_codes/E0787.md @@ -3,8 +3,6 @@ An unsupported naked function definition. Erroneous code example: ```compile_fail,E0787 -#![feature(naked_functions)] - #[unsafe(naked)] pub extern "C" fn f() -> u32 { 42 diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index fcc11dd3c1fd7..e3e4eefe5e10a 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -300,6 +300,8 @@ declare_features! ( /// Allows patterns with concurrent by-move and by-ref bindings. /// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref. (accepted, move_ref_pattern, "1.49.0", Some(68354)), + /// Allows using `#[naked]` on functions. + (accepted, naked_functions, "CURRENT_RUSTC_VERSION", Some(90957)), /// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]` (accepted, native_link_modifiers, "1.61.0", Some(81490)), /// Allows specifying the bundle link modifier diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 713e460e507f4..0233f7a72e882 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -443,6 +443,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ungated!(unsafe(Edition2024) no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No), ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, EncodeCrossCrate::No), ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, EncodeCrossCrate::Yes), + ungated!(unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No), // Limits: ungated!( @@ -515,12 +516,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // Unstable attributes: // ========================================================================== - // Linking: - gated!( - unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, - naked_functions, experimental!(naked) - ), - // Testing: gated!( test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index e09ae3c12394d..cbc121e3632a6 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -563,8 +563,6 @@ declare_features! ( (unstable, must_not_suspend, "1.57.0", Some(83310)), /// Allows `mut ref` and `mut ref mut` identifier patterns. (incomplete, mut_ref, "1.79.0", Some(123076)), - /// Allows using `#[naked]` on functions. - (unstable, naked_functions, "1.9.0", Some(90957)), /// Allows using `#[naked]` on `extern "Rust"` functions. (unstable, naked_functions_rustic_abi, "CURRENT_RUSTC_VERSION", Some(138997)), /// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions. diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index cbe5058b55191..cfc71a412bea2 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -690,13 +690,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } } - // FIXME(#80564): We permit struct fields, match arms and macro defs to have an - // `#[naked]` attribute with just a lint, because we previously - // erroneously allowed it and some crates used it accidentally, to be compatible - // with crates depending on them, we can't throw an error here. - Target::Field | Target::Arm | Target::MacroDef => { - self.inline_attr_str_error_with_macro_def(hir_id, attr, "naked") - } _ => { self.dcx().emit_err(errors::AttrShouldBeAppliedToFn { attr_span: attr.span(), diff --git a/library/core/src/arch.rs b/library/core/src/arch.rs index 81d828a971c80..f19fde2b4c733 100644 --- a/library/core/src/arch.rs +++ b/library/core/src/arch.rs @@ -32,7 +32,7 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) { /// /// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html /// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html -#[unstable(feature = "naked_functions", issue = "90957")] +#[stable(feature = "naked_functions", since = "CURRENT_RUSTC_VERSION")] #[rustc_builtin_macro] pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) { /* compiler built-in */ diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md index f2e1bb80cb263..2f9d4d22e5a85 100644 --- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md +++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md @@ -245,8 +245,6 @@ See the [Clang ControlFlowIntegrity documentation][clang-cfi] for more details. ## Example 1: Redirecting control flow using an indirect branch/call to an invalid destination ```rust,ignore (making doc tests pass cross-platform is hard) -#![feature(naked_functions)] - use std::arch::naked_asm; use std::mem; diff --git a/tests/assembly/naked-functions/aarch64-naked-fn-no-bti-prolog.rs b/tests/assembly/naked-functions/aarch64-naked-fn-no-bti-prolog.rs index 46acf7c6501a9..860ecc3cfcd04 100644 --- a/tests/assembly/naked-functions/aarch64-naked-fn-no-bti-prolog.rs +++ b/tests/assembly/naked-functions/aarch64-naked-fn-no-bti-prolog.rs @@ -4,7 +4,7 @@ //@ only-aarch64 #![crate_type = "lib"] -#![feature(naked_functions)] + use std::arch::naked_asm; // The problem at hand: Rust has adopted a fairly strict meaning for "naked functions", diff --git a/tests/assembly/naked-functions/aix.rs b/tests/assembly/naked-functions/aix.rs index 9aa9edc39e78b..57ff0e183bed5 100644 --- a/tests/assembly/naked-functions/aix.rs +++ b/tests/assembly/naked-functions/aix.rs @@ -9,7 +9,7 @@ //@[aix] needs-llvm-components: powerpc #![crate_type = "lib"] -#![feature(no_core, naked_functions, asm_experimental_arch, f128, linkage, fn_align)] +#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)] #![no_core] // tests that naked functions work for the `powerpc64-ibm-aix` target. diff --git a/tests/assembly/naked-functions/wasm32.rs b/tests/assembly/naked-functions/wasm32.rs index c114cb385be17..71e4d80764a3a 100644 --- a/tests/assembly/naked-functions/wasm32.rs +++ b/tests/assembly/naked-functions/wasm32.rs @@ -9,7 +9,7 @@ //@ [wasm32-wasip1] needs-llvm-components: webassembly #![crate_type = "lib"] -#![feature(no_core, naked_functions, asm_experimental_arch, f128, linkage, fn_align)] +#![feature(no_core, asm_experimental_arch, f128, linkage, fn_align)] #![no_core] extern crate minicore; diff --git a/tests/assembly/naked-functions/x86_64-naked-fn-no-cet-prolog.rs b/tests/assembly/naked-functions/x86_64-naked-fn-no-cet-prolog.rs index df6a2e91c51ea..81ee9b13b4eca 100644 --- a/tests/assembly/naked-functions/x86_64-naked-fn-no-cet-prolog.rs +++ b/tests/assembly/naked-functions/x86_64-naked-fn-no-cet-prolog.rs @@ -4,7 +4,7 @@ //@ only-x86_64 #![crate_type = "lib"] -#![feature(naked_functions)] + use std::arch::naked_asm; // The problem at hand: Rust has adopted a fairly strict meaning for "naked functions", diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index 03aa847650823..941c4abed4679 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -22,7 +22,6 @@ negative_impls, rustc_attrs, decl_macro, - naked_functions, f16, f128, asm_experimental_arch, diff --git a/tests/codegen/cffi/c-variadic-naked.rs b/tests/codegen/cffi/c-variadic-naked.rs index 05d48e52dc006..5843628b6330a 100644 --- a/tests/codegen/cffi/c-variadic-naked.rs +++ b/tests/codegen/cffi/c-variadic-naked.rs @@ -5,7 +5,6 @@ #![crate_type = "lib"] #![feature(c_variadic)] -#![feature(naked_functions)] #![no_std] #[unsafe(naked)] diff --git a/tests/codegen/naked-asan.rs b/tests/codegen/naked-asan.rs index 52b3e709cd35c..223c41b15bb35 100644 --- a/tests/codegen/naked-asan.rs +++ b/tests/codegen/naked-asan.rs @@ -6,7 +6,7 @@ #![crate_type = "lib"] #![no_std] -#![feature(abi_x86_interrupt, naked_functions)] +#![feature(abi_x86_interrupt)] pub fn caller() { page_fault_handler(1, 2); diff --git a/tests/codegen/naked-fn/aligned.rs b/tests/codegen/naked-fn/aligned.rs index 6183461fedaec..47ef779f1b217 100644 --- a/tests/codegen/naked-fn/aligned.rs +++ b/tests/codegen/naked-fn/aligned.rs @@ -3,7 +3,7 @@ //@ ignore-arm no "ret" mnemonic #![crate_type = "lib"] -#![feature(naked_functions, fn_align)] +#![feature(fn_align)] use std::arch::naked_asm; // CHECK: .balign 16 diff --git a/tests/codegen/naked-fn/generics.rs b/tests/codegen/naked-fn/generics.rs index 4427586777168..865be00d91ee4 100644 --- a/tests/codegen/naked-fn/generics.rs +++ b/tests/codegen/naked-fn/generics.rs @@ -2,7 +2,6 @@ //@ only-x86_64 #![crate_type = "lib"] -#![feature(naked_functions, asm_const)] use std::arch::naked_asm; diff --git a/tests/codegen/naked-fn/instruction-set.rs b/tests/codegen/naked-fn/instruction-set.rs index 2ccd47d645858..67560c5aba758 100644 --- a/tests/codegen/naked-fn/instruction-set.rs +++ b/tests/codegen/naked-fn/instruction-set.rs @@ -6,7 +6,7 @@ //@ [thumb-mode] needs-llvm-components: arm #![crate_type = "lib"] -#![feature(no_core, lang_items, rustc_attrs, naked_functions)] +#![feature(no_core, lang_items, rustc_attrs)] #![no_core] extern crate minicore; diff --git a/tests/codegen/naked-fn/min-function-alignment.rs b/tests/codegen/naked-fn/min-function-alignment.rs index 4a9142288248b..1d778be8c90dc 100644 --- a/tests/codegen/naked-fn/min-function-alignment.rs +++ b/tests/codegen/naked-fn/min-function-alignment.rs @@ -2,7 +2,7 @@ //@ needs-asm-support //@ ignore-arm no "ret" mnemonic -#![feature(naked_functions, fn_align)] +#![feature(fn_align)] #![crate_type = "lib"] // functions without explicit alignment use the global minimum diff --git a/tests/codegen/naked-fn/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs index 1bcdd6de373e5..344af6eb42fa8 100644 --- a/tests/codegen/naked-fn/naked-functions.rs +++ b/tests/codegen/naked-fn/naked-functions.rs @@ -13,7 +13,7 @@ //@[thumb] needs-llvm-components: arm #![crate_type = "lib"] -#![feature(no_core, lang_items, rustc_attrs, naked_functions)] +#![feature(no_core, lang_items, rustc_attrs)] #![no_core] extern crate minicore; diff --git a/tests/run-make/naked-symbol-visibility/a_rust_dylib.rs b/tests/run-make/naked-symbol-visibility/a_rust_dylib.rs index ae75519525363..ce787f83ade6d 100644 --- a/tests/run-make/naked-symbol-visibility/a_rust_dylib.rs +++ b/tests/run-make/naked-symbol-visibility/a_rust_dylib.rs @@ -1,4 +1,4 @@ -#![feature(naked_functions, linkage)] +#![feature(linkage)] #![crate_type = "dylib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-asm-outside-naked-fn.rs b/tests/ui/asm/naked-asm-outside-naked-fn.rs index a7680cc63ae03..0a15b21f4d014 100644 --- a/tests/ui/asm/naked-asm-outside-naked-fn.rs +++ b/tests/ui/asm/naked-asm-outside-naked-fn.rs @@ -3,7 +3,6 @@ //@ ignore-nvptx64 //@ ignore-spirv -#![feature(naked_functions)] #![crate_type = "lib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-asm-outside-naked-fn.stderr b/tests/ui/asm/naked-asm-outside-naked-fn.stderr index 85a50a49fecfc..2cebaa9ea285d 100644 --- a/tests/ui/asm/naked-asm-outside-naked-fn.stderr +++ b/tests/ui/asm/naked-asm-outside-naked-fn.stderr @@ -1,17 +1,17 @@ error: the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` - --> $DIR/naked-asm-outside-naked-fn.rs:21:5 + --> $DIR/naked-asm-outside-naked-fn.rs:20:5 | LL | naked_asm!("") | ^^^^^^^^^^^^^^ error: the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` - --> $DIR/naked-asm-outside-naked-fn.rs:26:9 + --> $DIR/naked-asm-outside-naked-fn.rs:25:9 | LL | (|| naked_asm!(""))() | ^^^^^^^^^^^^^^ error: the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` - --> $DIR/naked-asm-outside-naked-fn.rs:32:9 + --> $DIR/naked-asm-outside-naked-fn.rs:31:9 | LL | naked_asm!(""); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/naked-functions-ffi.rs b/tests/ui/asm/naked-functions-ffi.rs index 8fd0da01d72a7..565c440022db3 100644 --- a/tests/ui/asm/naked-functions-ffi.rs +++ b/tests/ui/asm/naked-functions-ffi.rs @@ -1,6 +1,5 @@ //@ check-pass //@ needs-asm-support -#![feature(naked_functions)] #![crate_type = "lib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-functions-ffi.stderr b/tests/ui/asm/naked-functions-ffi.stderr index 908881b194999..9df6185498ed6 100644 --- a/tests/ui/asm/naked-functions-ffi.stderr +++ b/tests/ui/asm/naked-functions-ffi.stderr @@ -1,5 +1,5 @@ warning: `extern` fn uses type `char`, which is not FFI-safe - --> $DIR/naked-functions-ffi.rs:9:28 + --> $DIR/naked-functions-ffi.rs:8:28 | LL | pub extern "C" fn naked(p: char) -> u128 { | ^^^^ not FFI-safe @@ -9,7 +9,7 @@ LL | pub extern "C" fn naked(p: char) -> u128 { = note: `#[warn(improper_ctypes_definitions)]` on by default warning: `extern` fn uses type `u128`, which is not FFI-safe - --> $DIR/naked-functions-ffi.rs:9:37 + --> $DIR/naked-functions-ffi.rs:8:37 | LL | pub extern "C" fn naked(p: char) -> u128 { | ^^^^ not FFI-safe diff --git a/tests/ui/asm/naked-functions-inline.rs b/tests/ui/asm/naked-functions-inline.rs index 261401be64517..93741f26275bd 100644 --- a/tests/ui/asm/naked-functions-inline.rs +++ b/tests/ui/asm/naked-functions-inline.rs @@ -1,5 +1,4 @@ //@ needs-asm-support -#![feature(naked_functions)] #![crate_type = "lib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-functions-inline.stderr b/tests/ui/asm/naked-functions-inline.stderr index 6df5b08ae8534..07d5f3bc49a94 100644 --- a/tests/ui/asm/naked-functions-inline.stderr +++ b/tests/ui/asm/naked-functions-inline.stderr @@ -1,5 +1,5 @@ error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:13:1 + --> $DIR/naked-functions-inline.rs:12:1 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here @@ -7,7 +7,7 @@ LL | #[inline] | ^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:20:1 + --> $DIR/naked-functions-inline.rs:19:1 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here @@ -15,7 +15,7 @@ LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:27:1 + --> $DIR/naked-functions-inline.rs:26:1 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here @@ -23,7 +23,7 @@ LL | #[inline(never)] | ^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:34:19 + --> $DIR/naked-functions-inline.rs:33:19 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here diff --git a/tests/ui/asm/naked-functions-instruction-set.rs b/tests/ui/asm/naked-functions-instruction-set.rs index 6fd34b035edd0..69927a56aabb3 100644 --- a/tests/ui/asm/naked-functions-instruction-set.rs +++ b/tests/ui/asm/naked-functions-instruction-set.rs @@ -5,7 +5,7 @@ //@ build-pass #![crate_type = "lib"] -#![feature(no_core, naked_functions)] +#![feature(no_core)] #![no_core] extern crate minicore; diff --git a/tests/ui/asm/naked-functions-rustic-abi.rs b/tests/ui/asm/naked-functions-rustic-abi.rs index 99b8d2e19fe40..d9c1147482881 100644 --- a/tests/ui/asm/naked-functions-rustic-abi.rs +++ b/tests/ui/asm/naked-functions-rustic-abi.rs @@ -6,7 +6,7 @@ //@ build-pass //@ needs-asm-support -#![feature(naked_functions, naked_functions_rustic_abi, rust_cold_cc)] +#![feature(naked_functions_rustic_abi, rust_cold_cc)] #![crate_type = "lib"] use std::arch::{asm, naked_asm}; diff --git a/tests/ui/asm/naked-functions-target-feature.rs b/tests/ui/asm/naked-functions-target-feature.rs index d8dc2104c76e1..57ad79b1c315c 100644 --- a/tests/ui/asm/naked-functions-target-feature.rs +++ b/tests/ui/asm/naked-functions-target-feature.rs @@ -1,7 +1,7 @@ //@ build-pass //@ needs-asm-support -#![feature(naked_functions, naked_functions_target_feature)] +#![feature(naked_functions_target_feature)] #![crate_type = "lib"] use std::arch::{asm, naked_asm}; diff --git a/tests/ui/asm/naked-functions-testattrs.rs b/tests/ui/asm/naked-functions-testattrs.rs index c8539e8064088..6dc14a6840ecb 100644 --- a/tests/ui/asm/naked-functions-testattrs.rs +++ b/tests/ui/asm/naked-functions-testattrs.rs @@ -1,7 +1,6 @@ //@ needs-asm-support //@ compile-flags: --test -#![feature(naked_functions)] #![feature(test)] #![crate_type = "lib"] diff --git a/tests/ui/asm/naked-functions-testattrs.stderr b/tests/ui/asm/naked-functions-testattrs.stderr index ad2041ec118b9..8aab2f04ee29e 100644 --- a/tests/ui/asm/naked-functions-testattrs.stderr +++ b/tests/ui/asm/naked-functions-testattrs.stderr @@ -1,5 +1,5 @@ error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:11:1 + --> $DIR/naked-functions-testattrs.rs:10:1 | LL | #[test] | ------- function marked with testing attribute here @@ -7,7 +7,7 @@ LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ `#[unsafe(naked)]` is incompatible with testing attributes error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:19:1 + --> $DIR/naked-functions-testattrs.rs:18:1 | LL | #[test] | ------- function marked with testing attribute here @@ -15,7 +15,7 @@ LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ `#[unsafe(naked)]` is incompatible with testing attributes error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:27:1 + --> $DIR/naked-functions-testattrs.rs:26:1 | LL | #[test] | ------- function marked with testing attribute here @@ -23,7 +23,7 @@ LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ `#[unsafe(naked)]` is incompatible with testing attributes error[E0736]: cannot use `#[unsafe(naked)]` with testing attributes - --> $DIR/naked-functions-testattrs.rs:34:1 + --> $DIR/naked-functions-testattrs.rs:33:1 | LL | #[bench] | -------- function marked with testing attribute here diff --git a/tests/ui/asm/naked-functions-unused.aarch64.stderr b/tests/ui/asm/naked-functions-unused.aarch64.stderr index ea63ced1aab04..bfb2923b0b8d6 100644 --- a/tests/ui/asm/naked-functions-unused.aarch64.stderr +++ b/tests/ui/asm/naked-functions-unused.aarch64.stderr @@ -1,5 +1,5 @@ error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:17:32 + --> $DIR/naked-functions-unused.rs:16:32 | LL | pub extern "C" fn function(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` @@ -12,55 +12,55 @@ LL | #![deny(unused)] = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:17:42 + --> $DIR/naked-functions-unused.rs:16:42 | LL | pub extern "C" fn function(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:28:38 + --> $DIR/naked-functions-unused.rs:27:38 | LL | pub extern "C" fn associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:28:48 + --> $DIR/naked-functions-unused.rs:27:48 | LL | pub extern "C" fn associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:36:41 + --> $DIR/naked-functions-unused.rs:35:41 | LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:36:51 + --> $DIR/naked-functions-unused.rs:35:51 | LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:46:40 + --> $DIR/naked-functions-unused.rs:45:40 | LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:46:50 + --> $DIR/naked-functions-unused.rs:45:50 | LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:54:43 + --> $DIR/naked-functions-unused.rs:53:43 | LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:54:53 + --> $DIR/naked-functions-unused.rs:53:53 | LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` diff --git a/tests/ui/asm/naked-functions-unused.rs b/tests/ui/asm/naked-functions-unused.rs index 67c05984be71c..945ab1a40ad0c 100644 --- a/tests/ui/asm/naked-functions-unused.rs +++ b/tests/ui/asm/naked-functions-unused.rs @@ -3,7 +3,6 @@ //@[x86_64] only-x86_64 //@[aarch64] only-aarch64 #![deny(unused)] -#![feature(naked_functions)] #![crate_type = "lib"] pub trait Trait { diff --git a/tests/ui/asm/naked-functions-unused.x86_64.stderr b/tests/ui/asm/naked-functions-unused.x86_64.stderr index ea63ced1aab04..bfb2923b0b8d6 100644 --- a/tests/ui/asm/naked-functions-unused.x86_64.stderr +++ b/tests/ui/asm/naked-functions-unused.x86_64.stderr @@ -1,5 +1,5 @@ error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:17:32 + --> $DIR/naked-functions-unused.rs:16:32 | LL | pub extern "C" fn function(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` @@ -12,55 +12,55 @@ LL | #![deny(unused)] = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:17:42 + --> $DIR/naked-functions-unused.rs:16:42 | LL | pub extern "C" fn function(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:28:38 + --> $DIR/naked-functions-unused.rs:27:38 | LL | pub extern "C" fn associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:28:48 + --> $DIR/naked-functions-unused.rs:27:48 | LL | pub extern "C" fn associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:36:41 + --> $DIR/naked-functions-unused.rs:35:41 | LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:36:51 + --> $DIR/naked-functions-unused.rs:35:51 | LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:46:40 + --> $DIR/naked-functions-unused.rs:45:40 | LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:46:50 + --> $DIR/naked-functions-unused.rs:45:50 | LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` error: unused variable: `a` - --> $DIR/naked-functions-unused.rs:54:43 + --> $DIR/naked-functions-unused.rs:53:43 | LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` error: unused variable: `b` - --> $DIR/naked-functions-unused.rs:54:53 + --> $DIR/naked-functions-unused.rs:53:53 | LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs index b433c1b5389c4..1eeb716e98a1f 100644 --- a/tests/ui/asm/naked-functions.rs +++ b/tests/ui/asm/naked-functions.rs @@ -2,7 +2,6 @@ //@ ignore-nvptx64 //@ ignore-spirv -#![feature(naked_functions)] #![feature(asm_unwind, linkage)] #![crate_type = "lib"] diff --git a/tests/ui/asm/naked-functions.stderr b/tests/ui/asm/naked-functions.stderr index 2b67c3aecd73c..b94a09bb92ed9 100644 --- a/tests/ui/asm/naked-functions.stderr +++ b/tests/ui/asm/naked-functions.stderr @@ -1,107 +1,107 @@ error: the `in` operand cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:47:29 + --> $DIR/naked-functions.rs:46:29 | LL | naked_asm!("/* {0} */", in(reg) a) | ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it error: the `in` operand cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:68:10 + --> $DIR/naked-functions.rs:67:10 | LL | in(reg) a, | ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it error: the `noreturn` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:88:28 + --> $DIR/naked-functions.rs:87:28 | LL | naked_asm!("", options(noreturn)); | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly error: the `nomem` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:105:28 + --> $DIR/naked-functions.rs:104:28 | LL | naked_asm!("", options(nomem, preserves_flags)); | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly error: the `preserves_flags` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:105:35 + --> $DIR/naked-functions.rs:104:35 | LL | naked_asm!("", options(nomem, preserves_flags)); | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly error: the `readonly` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:112:28 + --> $DIR/naked-functions.rs:111:28 | LL | naked_asm!("", options(readonly, nostack), options(pure)); | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly error: the `nostack` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:112:38 + --> $DIR/naked-functions.rs:111:38 | LL | naked_asm!("", options(readonly, nostack), options(pure)); | ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly error: the `pure` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:112:56 + --> $DIR/naked-functions.rs:111:56 | LL | naked_asm!("", options(readonly, nostack), options(pure)); | ^^^^ the `pure` option is not meaningful for global-scoped inline assembly error: the `may_unwind` option cannot be used with `naked_asm!` - --> $DIR/naked-functions.rs:120:28 + --> $DIR/naked-functions.rs:119:28 | LL | naked_asm!("", options(may_unwind)); | ^^^^^^^^^^ the `may_unwind` option is not meaningful for global-scoped inline assembly error: this is a user specified error - --> $DIR/naked-functions.rs:151:5 + --> $DIR/naked-functions.rs:150:5 | LL | compile_error!("this is a user specified error") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this is a user specified error - --> $DIR/naked-functions.rs:157:5 + --> $DIR/naked-functions.rs:156:5 | LL | compile_error!("this is a user specified error"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/naked-functions.rs:164:16 + --> $DIR/naked-functions.rs:163:16 | LL | naked_asm!(invalid_syntax) | ^^^^^^^^^^^^^^ error[E0787]: the `asm!` macro is not allowed in naked functions - --> $DIR/naked-functions.rs:13:14 + --> $DIR/naked-functions.rs:12:14 | LL | unsafe { asm!("", options(raw)) }; | ^^^^^^^^^^^^^^^^^^^^^^ consider using the `naked_asm!` macro instead error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:25:5 + --> $DIR/naked-functions.rs:24:5 | LL | mut a: u32, | ^^^^^ error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:27:5 + --> $DIR/naked-functions.rs:26:5 | LL | &b: &i32, | ^^ error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:29:6 + --> $DIR/naked-functions.rs:28:6 | LL | (None | Some(_)): Option>, | ^^^^^^^^^^^^^^ error: patterns not allowed in naked function parameters - --> $DIR/naked-functions.rs:31:5 + --> $DIR/naked-functions.rs:30:5 | LL | P { x, y }: P, | ^^^^^^^^^^ error: referencing function parameters is not allowed in naked functions - --> $DIR/naked-functions.rs:40:5 + --> $DIR/naked-functions.rs:39:5 | LL | a + 1 | ^ @@ -109,7 +109,7 @@ LL | a + 1 = help: follow the calling convention in asm block to use parameters error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:38:1 + --> $DIR/naked-functions.rs:37:1 | LL | pub extern "C" fn inc(a: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | a + 1 | ----- not allowed in naked functions error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:52:1 + --> $DIR/naked-functions.rs:51:1 | LL | pub extern "C" fn inc_closure(a: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | (|| a + 1)() | ------------ not allowed in naked functions error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:58:1 + --> $DIR/naked-functions.rs:57:1 | LL | pub extern "C" fn unsupported_operands() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,13 +144,13 @@ LL | let mut e = 0usize; | ------------------- not allowed in naked functions error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:80:1 + --> $DIR/naked-functions.rs:79:1 | LL | pub extern "C" fn missing_assembly() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:85:1 + --> $DIR/naked-functions.rs:84:1 | LL | pub extern "C" fn too_many_asm_blocks() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -159,7 +159,7 @@ LL | naked_asm!(""); | -------------- multiple `naked_asm!` invocations are not allowed in naked functions error: referencing function parameters is not allowed in naked functions - --> $DIR/naked-functions.rs:97:11 + --> $DIR/naked-functions.rs:96:11 | LL | *&y | ^ @@ -167,7 +167,7 @@ LL | *&y = help: follow the calling convention in asm block to use parameters error[E0787]: naked functions must contain a single `naked_asm!` invocation - --> $DIR/naked-functions.rs:95:5 + --> $DIR/naked-functions.rs:94:5 | LL | pub extern "C" fn inner(y: usize) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/naked-invalid-attr.rs b/tests/ui/asm/naked-invalid-attr.rs index 6c5fdbe74d82a..c3a3131ee463c 100644 --- a/tests/ui/asm/naked-invalid-attr.rs +++ b/tests/ui/asm/naked-invalid-attr.rs @@ -1,7 +1,6 @@ -// Checks that #[unsafe(naked)] attribute can be placed on function definitions only. +// Checks that the #[unsafe(naked)] attribute can be placed on function definitions only. // //@ needs-asm-support -#![feature(naked_functions)] #![unsafe(naked)] //~ ERROR should be applied to a function definition use std::arch::naked_asm; @@ -14,6 +13,7 @@ extern "C" { #[unsafe(naked)] //~ ERROR should be applied to a function definition #[repr(C)] struct S { + #[unsafe(naked)] //~ ERROR should be applied to a function definition a: u32, b: u32, } diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr index 6e2746b568437..81d30e6475d95 100644 --- a/tests/ui/asm/naked-invalid-attr.stderr +++ b/tests/ui/asm/naked-invalid-attr.stderr @@ -1,15 +1,24 @@ error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:14:1 + --> $DIR/naked-invalid-attr.rs:13:1 | LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ LL | #[repr(C)] LL | / struct S { +LL | | #[unsafe(naked)] LL | | a: u32, LL | | b: u32, LL | | } | |_- not a function definition +error: attribute should be applied to a function definition + --> $DIR/naked-invalid-attr.rs:16:5 + | +LL | #[unsafe(naked)] + | ^^^^^^^^^^^^^^^^ +LL | a: u32, + | ------ not a function definition + error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:51:5 | @@ -27,7 +36,7 @@ LL | extern "C" fn invoke(&self); | ---------------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:10:5 + --> $DIR/naked-invalid-attr.rs:9:5 | LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ @@ -35,10 +44,10 @@ LL | fn f(); | ------- not a function definition error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:5:1 + --> $DIR/naked-invalid-attr.rs:4:1 | LL | #![unsafe(naked)] | ^^^^^^^^^^^^^^^^^ cannot be applied to crates -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.rs b/tests/ui/asm/naked-with-invalid-repr-attr.rs index c9f335ea9506a..96eed70dc5504 100644 --- a/tests/ui/asm/naked-with-invalid-repr-attr.rs +++ b/tests/ui/asm/naked-with-invalid-repr-attr.rs @@ -1,5 +1,4 @@ //@ needs-asm-support -#![feature(naked_functions)] #![feature(fn_align)] #![crate_type = "lib"] use std::arch::naked_asm; diff --git a/tests/ui/asm/naked-with-invalid-repr-attr.stderr b/tests/ui/asm/naked-with-invalid-repr-attr.stderr index 219e32473beaa..f173a39e5bf6d 100644 --- a/tests/ui/asm/naked-with-invalid-repr-attr.stderr +++ b/tests/ui/asm/naked-with-invalid-repr-attr.stderr @@ -1,5 +1,5 @@ error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:7:8 + --> $DIR/naked-with-invalid-repr-attr.rs:6:8 | LL | #[repr(C)] | ^ @@ -11,7 +11,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:15:8 + --> $DIR/naked-with-invalid-repr-attr.rs:14:8 | LL | #[repr(transparent)] | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:23:19 + --> $DIR/naked-with-invalid-repr-attr.rs:22:19 | LL | #[repr(align(16), C)] | ^ @@ -35,7 +35,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/naked-with-invalid-repr-attr.rs:32:8 + --> $DIR/naked-with-invalid-repr-attr.rs:31:8 | LL | #[repr(C, packed)] | ^ @@ -48,7 +48,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct or union - --> $DIR/naked-with-invalid-repr-attr.rs:32:11 + --> $DIR/naked-with-invalid-repr-attr.rs:31:11 | LL | #[repr(C, packed)] | ^^^^^^ @@ -61,7 +61,7 @@ LL | | } | |_- not a struct or union error[E0517]: attribute should be applied to an enum - --> $DIR/naked-with-invalid-repr-attr.rs:42:8 + --> $DIR/naked-with-invalid-repr-attr.rs:41:8 | LL | #[repr(u8)] | ^^ diff --git a/tests/ui/asm/named-asm-labels.rs b/tests/ui/asm/named-asm-labels.rs index d5c194452d75b..996fb82a944f2 100644 --- a/tests/ui/asm/named-asm-labels.rs +++ b/tests/ui/asm/named-asm-labels.rs @@ -10,8 +10,6 @@ // which causes less readable LLVM errors and in the worst cases causes ICEs // or segfaults based on system dependent behavior and codegen flags. -#![feature(naked_functions)] - use std::arch::{asm, global_asm, naked_asm}; #[no_mangle] diff --git a/tests/ui/asm/named-asm-labels.stderr b/tests/ui/asm/named-asm-labels.stderr index 0120d4948d51c..cd7e7a08c1d29 100644 --- a/tests/ui/asm/named-asm-labels.stderr +++ b/tests/ui/asm/named-asm-labels.stderr @@ -1,5 +1,5 @@ error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:23:15 + --> $DIR/named-asm-labels.rs:21:15 | LL | asm!("bar: nop"); | ^^^ @@ -9,7 +9,7 @@ LL | asm!("bar: nop"); = note: `#[deny(named_asm_labels)]` on by default error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:26:15 + --> $DIR/named-asm-labels.rs:24:15 | LL | asm!("abcd:"); | ^^^^ @@ -18,7 +18,7 @@ LL | asm!("abcd:"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:29:15 + --> $DIR/named-asm-labels.rs:27:15 | LL | asm!("foo: bar1: nop"); | ^^^ @@ -27,7 +27,7 @@ LL | asm!("foo: bar1: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:29:20 + --> $DIR/named-asm-labels.rs:27:20 | LL | asm!("foo: bar1: nop"); | ^^^^ @@ -36,7 +36,7 @@ LL | asm!("foo: bar1: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:34:15 + --> $DIR/named-asm-labels.rs:32:15 | LL | asm!("foo1: nop", "nop"); | ^^^^ @@ -45,7 +45,7 @@ LL | asm!("foo1: nop", "nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:35:15 + --> $DIR/named-asm-labels.rs:33:15 | LL | asm!("foo2: foo3: nop", "nop"); | ^^^^ @@ -54,7 +54,7 @@ LL | asm!("foo2: foo3: nop", "nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:35:21 + --> $DIR/named-asm-labels.rs:33:21 | LL | asm!("foo2: foo3: nop", "nop"); | ^^^^ @@ -63,7 +63,7 @@ LL | asm!("foo2: foo3: nop", "nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:38:22 + --> $DIR/named-asm-labels.rs:36:22 | LL | asm!("nop", "foo4: nop"); | ^^^^ @@ -72,7 +72,7 @@ LL | asm!("nop", "foo4: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:39:15 + --> $DIR/named-asm-labels.rs:37:15 | LL | asm!("foo5: nop", "foo6: nop"); | ^^^^ @@ -81,7 +81,7 @@ LL | asm!("foo5: nop", "foo6: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:39:28 + --> $DIR/named-asm-labels.rs:37:28 | LL | asm!("foo5: nop", "foo6: nop"); | ^^^^ @@ -90,7 +90,7 @@ LL | asm!("foo5: nop", "foo6: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:44:15 + --> $DIR/named-asm-labels.rs:42:15 | LL | asm!("foo7: nop; foo8: nop"); | ^^^^ @@ -99,7 +99,7 @@ LL | asm!("foo7: nop; foo8: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:44:26 + --> $DIR/named-asm-labels.rs:42:26 | LL | asm!("foo7: nop; foo8: nop"); | ^^^^ @@ -108,7 +108,7 @@ LL | asm!("foo7: nop; foo8: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:47:15 + --> $DIR/named-asm-labels.rs:45:15 | LL | asm!("foo9: nop; nop"); | ^^^^ @@ -117,7 +117,7 @@ LL | asm!("foo9: nop; nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:48:20 + --> $DIR/named-asm-labels.rs:46:20 | LL | asm!("nop; foo10: nop"); | ^^^^^ @@ -126,7 +126,7 @@ LL | asm!("nop; foo10: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:51:15 + --> $DIR/named-asm-labels.rs:49:15 | LL | asm!("bar2: nop\n bar3: nop"); | ^^^^ @@ -135,7 +135,7 @@ LL | asm!("bar2: nop\n bar3: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:51:27 + --> $DIR/named-asm-labels.rs:49:27 | LL | asm!("bar2: nop\n bar3: nop"); | ^^^^ @@ -144,7 +144,7 @@ LL | asm!("bar2: nop\n bar3: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:54:15 + --> $DIR/named-asm-labels.rs:52:15 | LL | asm!("bar4: nop\n nop"); | ^^^^ @@ -153,7 +153,7 @@ LL | asm!("bar4: nop\n nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:55:21 + --> $DIR/named-asm-labels.rs:53:21 | LL | asm!("nop\n bar5: nop"); | ^^^^ @@ -162,7 +162,7 @@ LL | asm!("nop\n bar5: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:56:21 + --> $DIR/named-asm-labels.rs:54:21 | LL | asm!("nop\n bar6: bar7: nop"); | ^^^^ @@ -171,7 +171,7 @@ LL | asm!("nop\n bar6: bar7: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:56:27 + --> $DIR/named-asm-labels.rs:54:27 | LL | asm!("nop\n bar6: bar7: nop"); | ^^^^ @@ -180,7 +180,7 @@ LL | asm!("nop\n bar6: bar7: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:63:13 + --> $DIR/named-asm-labels.rs:61:13 | LL | blah2: nop | ^^^^^ @@ -189,7 +189,7 @@ LL | blah2: nop = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:64:13 + --> $DIR/named-asm-labels.rs:62:13 | LL | blah3: nop | ^^^^^ @@ -198,7 +198,7 @@ LL | blah3: nop = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:73:19 + --> $DIR/named-asm-labels.rs:71:19 | LL | nop ; blah4: nop | ^^^^^ @@ -207,7 +207,7 @@ LL | nop ; blah4: nop = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:87:15 + --> $DIR/named-asm-labels.rs:85:15 | LL | asm!("blah1: 2bar: nop"); | ^^^^^ @@ -216,7 +216,7 @@ LL | asm!("blah1: 2bar: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:90:15 + --> $DIR/named-asm-labels.rs:88:15 | LL | asm!("def: def: nop"); | ^^^ @@ -225,7 +225,7 @@ LL | asm!("def: def: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:90:15 + --> $DIR/named-asm-labels.rs:88:15 | LL | asm!("def: def: nop"); | ^^^ @@ -235,7 +235,7 @@ LL | asm!("def: def: nop"); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:93:15 + --> $DIR/named-asm-labels.rs:91:15 | LL | asm!("def: nop\ndef: nop"); | ^^^ @@ -244,7 +244,7 @@ LL | asm!("def: nop\ndef: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:93:15 + --> $DIR/named-asm-labels.rs:91:15 | LL | asm!("def: nop\ndef: nop"); | ^^^ @@ -254,7 +254,7 @@ LL | asm!("def: nop\ndef: nop"); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:96:15 + --> $DIR/named-asm-labels.rs:94:15 | LL | asm!("def: nop; def: nop"); | ^^^ @@ -263,7 +263,7 @@ LL | asm!("def: nop; def: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:96:15 + --> $DIR/named-asm-labels.rs:94:15 | LL | asm!("def: nop; def: nop"); | ^^^ @@ -273,7 +273,7 @@ LL | asm!("def: nop; def: nop"); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:106:15 + --> $DIR/named-asm-labels.rs:104:15 | LL | asm!("fooo\u{003A} nop"); | ^^^^^^^^^^^^^^^^ @@ -282,7 +282,7 @@ LL | asm!("fooo\u{003A} nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:107:15 + --> $DIR/named-asm-labels.rs:105:15 | LL | asm!("foooo\x3A nop"); | ^^^^^^^^^^^^^ @@ -291,7 +291,7 @@ LL | asm!("foooo\x3A nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:110:15 + --> $DIR/named-asm-labels.rs:108:15 | LL | asm!("fooooo:\u{000A} nop"); | ^^^^^^ @@ -300,7 +300,7 @@ LL | asm!("fooooo:\u{000A} nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:111:15 + --> $DIR/named-asm-labels.rs:109:15 | LL | asm!("foooooo:\x0A nop"); | ^^^^^^^ @@ -309,7 +309,7 @@ LL | asm!("foooooo:\x0A nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:115:14 + --> $DIR/named-asm-labels.rs:113:14 | LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -319,7 +319,7 @@ LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70"); = note: the label may be declared in the expansion of a macro error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:123:13 + --> $DIR/named-asm-labels.rs:121:13 | LL | ab: nop // ab: does foo | ^^ @@ -328,7 +328,7 @@ LL | ab: nop // ab: does foo = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:144:19 + --> $DIR/named-asm-labels.rs:142:19 | LL | asm!("test_{}: nop", in(reg) 10); | ^^^^^^^ @@ -338,7 +338,7 @@ LL | asm!("test_{}: nop", in(reg) 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:146:15 + --> $DIR/named-asm-labels.rs:144:15 | LL | asm!("test_{}: nop", const 10); | ^^^^^^^ @@ -348,7 +348,7 @@ LL | asm!("test_{}: nop", const 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:147:15 + --> $DIR/named-asm-labels.rs:145:15 | LL | asm!("test_{}: nop", sym main); | ^^^^^^^ @@ -358,7 +358,7 @@ LL | asm!("test_{}: nop", sym main); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:148:15 + --> $DIR/named-asm-labels.rs:146:15 | LL | asm!("{}_test: nop", const 10); | ^^^^^^^ @@ -368,7 +368,7 @@ LL | asm!("{}_test: nop", const 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:149:15 + --> $DIR/named-asm-labels.rs:147:15 | LL | asm!("test_{}_test: nop", const 10); | ^^^^^^^^^^^^ @@ -378,7 +378,7 @@ LL | asm!("test_{}_test: nop", const 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:150:15 + --> $DIR/named-asm-labels.rs:148:15 | LL | asm!("{}: nop", const 10); | ^^ @@ -388,7 +388,7 @@ LL | asm!("{}: nop", const 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:152:15 + --> $DIR/named-asm-labels.rs:150:15 | LL | asm!("{uwu}: nop", uwu = const 10); | ^^^^^ @@ -398,7 +398,7 @@ LL | asm!("{uwu}: nop", uwu = const 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:153:15 + --> $DIR/named-asm-labels.rs:151:15 | LL | asm!("{0}: nop", const 10); | ^^^ @@ -408,7 +408,7 @@ LL | asm!("{0}: nop", const 10); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:154:15 + --> $DIR/named-asm-labels.rs:152:15 | LL | asm!("{1}: nop", "/* {0} */", const 10, const 20); | ^^^ @@ -418,7 +418,7 @@ LL | asm!("{1}: nop", "/* {0} */", const 10, const 20); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:157:14 + --> $DIR/named-asm-labels.rs:155:14 | LL | asm!(include_str!("named-asm-labels.s")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -428,7 +428,7 @@ LL | asm!(include_str!("named-asm-labels.s")); = note: the label may be declared in the expansion of a macro error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:157:14 + --> $DIR/named-asm-labels.rs:155:14 | LL | asm!(include_str!("named-asm-labels.s")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -439,7 +439,7 @@ LL | asm!(include_str!("named-asm-labels.s")); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:157:14 + --> $DIR/named-asm-labels.rs:155:14 | LL | asm!(include_str!("named-asm-labels.s")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -450,7 +450,7 @@ LL | asm!(include_str!("named-asm-labels.s")); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:157:14 + --> $DIR/named-asm-labels.rs:155:14 | LL | asm!(include_str!("named-asm-labels.s")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -461,7 +461,7 @@ LL | asm!(include_str!("named-asm-labels.s")); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:171:19 + --> $DIR/named-asm-labels.rs:169:19 | LL | asm!("warned: nop"); | ^^^^^^ @@ -469,13 +469,13 @@ LL | asm!("warned: nop"); = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information note: the lint level is defined here - --> $DIR/named-asm-labels.rs:169:16 + --> $DIR/named-asm-labels.rs:167:16 | LL | #[warn(named_asm_labels)] | ^^^^^^^^^^^^^^^^ error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:180:17 + --> $DIR/named-asm-labels.rs:178:17 | LL | naked_asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1) | ^^^^^ @@ -484,7 +484,7 @@ LL | naked_asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1) = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:187:20 + --> $DIR/named-asm-labels.rs:185:20 | LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } | ^^^^^ @@ -493,7 +493,7 @@ LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noret = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:195:17 + --> $DIR/named-asm-labels.rs:193:17 | LL | naked_asm!(".Laaa: nop; ret;") | ^^^^^ @@ -502,7 +502,7 @@ LL | naked_asm!(".Laaa: nop; ret;") = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:205:21 + --> $DIR/named-asm-labels.rs:203:21 | LL | naked_asm!(".Lbbb: nop; ret;") | ^^^^^ @@ -511,7 +511,7 @@ LL | naked_asm!(".Lbbb: nop; ret;") = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:214:15 + --> $DIR/named-asm-labels.rs:212:15 | LL | asm!("closure1: nop"); | ^^^^^^^^ @@ -520,7 +520,7 @@ LL | asm!("closure1: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:218:15 + --> $DIR/named-asm-labels.rs:216:15 | LL | asm!("closure2: nop"); | ^^^^^^^^ @@ -529,7 +529,7 @@ LL | asm!("closure2: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:228:19 + --> $DIR/named-asm-labels.rs:226:19 | LL | asm!("closure3: nop"); | ^^^^^^^^ diff --git a/tests/ui/asm/simple_global_asm.rs b/tests/ui/asm/simple_global_asm.rs index 9b193b3e44ce6..68b0b83858e18 100644 --- a/tests/ui/asm/simple_global_asm.rs +++ b/tests/ui/asm/simple_global_asm.rs @@ -1,7 +1,6 @@ //@ run-pass //@ needs-asm-support -#![feature(naked_functions)] #![allow(dead_code)] #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] diff --git a/tests/ui/feature-gates/feature-gate-naked_functions.rs b/tests/ui/feature-gates/feature-gate-naked_functions.rs deleted file mode 100644 index d940decd561e9..0000000000000 --- a/tests/ui/feature-gates/feature-gate-naked_functions.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ needs-asm-support - -use std::arch::naked_asm; -//~^ ERROR use of unstable library feature `naked_functions` - -#[naked] //~ ERROR unsafe attribute used without unsafe -//~^ ERROR the `#[naked]` attribute is an experimental feature -extern "C" fn naked() { - naked_asm!("") - //~^ ERROR use of unstable library feature `naked_functions` -} - -#[naked] //~ ERROR unsafe attribute used without unsafe -//~^ ERROR the `#[naked]` attribute is an experimental feature -extern "C" fn naked_2() -> isize { - naked_asm!("") - //~^ ERROR use of unstable library feature `naked_functions` -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-naked_functions.stderr b/tests/ui/feature-gates/feature-gate-naked_functions.stderr deleted file mode 100644 index ea765db7d946e..0000000000000 --- a/tests/ui/feature-gates/feature-gate-naked_functions.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0658]: use of unstable library feature `naked_functions` - --> $DIR/feature-gate-naked_functions.rs:9:5 - | -LL | naked_asm!("") - | ^^^^^^^^^ - | - = note: see issue #90957 for more information - = help: add `#![feature(naked_functions)]` 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[E0658]: use of unstable library feature `naked_functions` - --> $DIR/feature-gate-naked_functions.rs:16:5 - | -LL | naked_asm!("") - | ^^^^^^^^^ - | - = note: see issue #90957 for more information - = help: add `#![feature(naked_functions)]` 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: unsafe attribute used without unsafe - --> $DIR/feature-gate-naked_functions.rs:6:3 - | -LL | #[naked] - | ^^^^^ usage of unsafe attribute - | -help: wrap the attribute in `unsafe(...)` - | -LL | #[unsafe(naked)] - | +++++++ + - -error: unsafe attribute used without unsafe - --> $DIR/feature-gate-naked_functions.rs:13:3 - | -LL | #[naked] - | ^^^^^ usage of unsafe attribute - | -help: wrap the attribute in `unsafe(...)` - | -LL | #[unsafe(naked)] - | +++++++ + - -error[E0658]: the `#[naked]` attribute is an experimental feature - --> $DIR/feature-gate-naked_functions.rs:6:1 - | -LL | #[naked] - | ^^^^^^^^ - | - = note: see issue #90957 for more information - = help: add `#![feature(naked_functions)]` 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[E0658]: the `#[naked]` attribute is an experimental feature - --> $DIR/feature-gate-naked_functions.rs:13:1 - | -LL | #[naked] - | ^^^^^^^^ - | - = note: see issue #90957 for more information - = help: add `#![feature(naked_functions)]` 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[E0658]: use of unstable library feature `naked_functions` - --> $DIR/feature-gate-naked_functions.rs:3:5 - | -LL | use std::arch::naked_asm; - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #90957 for more information - = help: add `#![feature(naked_functions)]` 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: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-naked_functions_rustic_abi.rs b/tests/ui/feature-gates/feature-gate-naked_functions_rustic_abi.rs index cc5b4f0e88b42..d16c6ccd4c331 100644 --- a/tests/ui/feature-gates/feature-gate-naked_functions_rustic_abi.rs +++ b/tests/ui/feature-gates/feature-gate-naked_functions_rustic_abi.rs @@ -1,7 +1,7 @@ //@ needs-asm-support //@ only-x86_64 -#![feature(naked_functions, rust_cold_cc)] +#![feature(rust_cold_cc)] use std::arch::naked_asm; diff --git a/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.rs b/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.rs index b2e102f1db4b6..1fee3e7dcd1a9 100644 --- a/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.rs +++ b/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.rs @@ -1,8 +1,6 @@ //@ needs-asm-support //@ only-x86_64 -#![feature(naked_functions)] - use std::arch::naked_asm; #[unsafe(naked)] diff --git a/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr b/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr index b0592d08046f5..8e601a14753bb 100644 --- a/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr +++ b/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr @@ -1,5 +1,5 @@ error[E0658]: `#[target_feature(/* ... */)]` is currently unstable on `#[naked]` functions - --> $DIR/feature-gate-naked_functions_target_feature.rs:9:1 + --> $DIR/feature-gate-naked_functions_target_feature.rs:7:1 | LL | #[target_feature(enable = "avx2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/inline-exported.rs b/tests/ui/lint/inline-exported.rs index 69e322ef513ae..6a23cd58236ff 100644 --- a/tests/ui/lint/inline-exported.rs +++ b/tests/ui/lint/inline-exported.rs @@ -2,9 +2,7 @@ //! because `#[inline]` is ignored for such functions. #![crate_type = "lib"] - #![feature(linkage)] -#![feature(naked_functions)] #![deny(unused_attributes)] #[inline] diff --git a/tests/ui/lint/inline-exported.stderr b/tests/ui/lint/inline-exported.stderr index dcf63cc4090e4..05a2bda24067e 100644 --- a/tests/ui/lint/inline-exported.stderr +++ b/tests/ui/lint/inline-exported.stderr @@ -1,18 +1,18 @@ error: `#[inline]` is ignored on externally exported functions - --> $DIR/inline-exported.rs:10:1 + --> $DIR/inline-exported.rs:8:1 | LL | #[inline] | ^^^^^^^^^ | = help: externally exported functions are functions with `#[no_mangle]`, `#[export_name]`, or `#[linkage]` note: the lint level is defined here - --> $DIR/inline-exported.rs:8:9 + --> $DIR/inline-exported.rs:6:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: `#[inline]` is ignored on externally exported functions - --> $DIR/inline-exported.rs:15:1 + --> $DIR/inline-exported.rs:13:1 | LL | #[inline] | ^^^^^^^^^ @@ -20,7 +20,7 @@ LL | #[inline] = help: externally exported functions are functions with `#[no_mangle]`, `#[export_name]`, or `#[linkage]` error: `#[inline]` is ignored on externally exported functions - --> $DIR/inline-exported.rs:20:1 + --> $DIR/inline-exported.rs:18:1 | LL | #[inline] | ^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs index ce6d10bf33cbd..a4baf1fe4b97d 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs @@ -1,5 +1,4 @@ //@ needs-asm-support -#![feature(naked_functions)] use std::arch::naked_asm; diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr index f89d94b67d806..d3cafbc635086 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr @@ -1,5 +1,5 @@ error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/error-with-naked.rs:6:1 + --> $DIR/error-with-naked.rs:5:1 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[unsafe(naked)]` @@ -8,7 +8,7 @@ LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/error-with-naked.rs:18:5 + --> $DIR/error-with-naked.rs:17:5 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[unsafe(naked)]` @@ -17,13 +17,13 @@ LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/error-with-naked.rs:6:1 + --> $DIR/error-with-naked.rs:5:1 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/error-with-naked.rs:18:5 + --> $DIR/error-with-naked.rs:17:5 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ From c7e976eb1e4ba7590efd19a29a6a1eba23eb352a Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Sun, 20 Apr 2025 11:28:16 +0000 Subject: [PATCH 12/20] rustdoc-json: Improve test for auto-trait impls --- tests/rustdoc-json/impls/auto.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/rustdoc-json/impls/auto.rs b/tests/rustdoc-json/impls/auto.rs index ce47d1be690f7..5440301f96501 100644 --- a/tests/rustdoc-json/impls/auto.rs +++ b/tests/rustdoc-json/impls/auto.rs @@ -17,6 +17,8 @@ impl Foo { // Testing spans, so all tests below code //@ is "$.index[?(@.docs=='has span')].span.begin" "[13, 1]" //@ is "$.index[?(@.docs=='has span')].span.end" "[15, 2]" -// FIXME: this doesn't work due to https://github.com/freestrings/jsonpath/issues/91 -// is "$.index[?(@.inner.impl.is_synthetic==true)].span" null +//@ is "$.index[?(@.docs=='has span')].inner.impl.is_synthetic" false +//@ is "$.index[?(@.inner.impl.is_synthetic==true)].span" null +//@ is "$.index[?(@.inner.impl.is_synthetic==true)].inner.impl.for.resolved_path.path" '"Foo"' +//@ is "$.index[?(@.inner.impl.is_synthetic==true)].inner.impl.trait.path" '"Bar"' pub struct Foo; From fd4a093a4e9319fa1dc6603ea4ba5a5703ef5009 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Sun, 20 Apr 2025 11:34:49 +0000 Subject: [PATCH 13/20] jsondocck: Require command is at start of line --- src/tools/jsondocck/src/main.rs | 1 + tests/rustdoc-json/fns/return_type_alias.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index 79e419884c68e..65ad38da98b08 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -154,6 +154,7 @@ impl CommandKind { static LINE_PATTERN: LazyLock = LazyLock::new(|| { RegexBuilder::new( r#" + ^\s* //@\s+ (?P!?) (?P[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*) diff --git a/tests/rustdoc-json/fns/return_type_alias.rs b/tests/rustdoc-json/fns/return_type_alias.rs index 0aa1db47b7f91..c39abc7589458 100644 --- a/tests/rustdoc-json/fns/return_type_alias.rs +++ b/tests/rustdoc-json/fns/return_type_alias.rs @@ -1,6 +1,6 @@ // Regression test for -///@ set foo = "$.index[?(@.name=='Foo')].id" +//@ set foo = "$.index[?(@.name=='Foo')].id" pub type Foo = i32; //@ is "$.index[?(@.name=='demo')].inner.function.sig.output.resolved_path.id" $foo From 4c20d17365e7963a178e053dfb3525f4091cc39b Mon Sep 17 00:00:00 2001 From: xizheyin Date: Sun, 20 Apr 2025 19:39:09 +0800 Subject: [PATCH 14/20] Add ui test emit-output-types-without-args.rs Signed-off-by: xizheyin --- .../invalid-compile-flags/emit-output-types-without-args.rs | 1 + .../emit-output-types-without-args.stderr | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 tests/ui/invalid-compile-flags/emit-output-types-without-args.rs create mode 100644 tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs b/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs new file mode 100644 index 0000000000000..793931e99d9cf --- /dev/null +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs @@ -0,0 +1 @@ +//@ compile-flags: --emit diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr new file mode 100644 index 0000000000000..dad81dcb13c0d --- /dev/null +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr @@ -0,0 +1,6 @@ +error: Argument to option 'emit' missing + Usage: + --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] + Comma separated list of types of output for the + compiler to emit + From 6ea0fe5fc4558ed485cab1cd21c63a0e6cd35851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Sun, 20 Apr 2025 21:16:07 +0800 Subject: [PATCH 15/20] Update `libc` to 0.2.172 for std --- library/Cargo.lock | 4 ++-- library/std/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index e4f1c4ec96a3a..ba5e54db95d16 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.171" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" dependencies = [ "rustc-std-workspace-core", ] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 917a470842ca9..c02efd997cfcc 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -35,7 +35,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false } addr2line = { version = "0.24.0", optional = true, default-features = false } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] -libc = { version = "0.2.171", default-features = false, features = [ +libc = { version = "0.2.172", default-features = false, features = [ 'rustc-dep-of-std', ], public = true } From 6033e9df02ecc6de27d840f3cab5e788f6b63441 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 20 Apr 2025 16:08:39 +0000 Subject: [PATCH 16/20] Don't compute name of associated item if it's an RPITIT --- .../errors/wrong_number_of_generic_args.rs | 14 +++++------ .../src/hir_ty_lowering/mod.rs | 6 ++--- .../dont-probe-missing-item-name-2.rs | 12 ++++++++++ .../dont-probe-missing-item-name-2.stderr | 24 +++++++++++++++++++ .../dont-probe-missing-item-name-3.rs | 11 +++++++++ .../dont-probe-missing-item-name-3.stderr | 15 ++++++++++++ 6 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs create mode 100644 tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr create mode 100644 tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs create mode 100644 tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr diff --git a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs index 526ee30209c7d..a3c8ce620b366 100644 --- a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs @@ -486,15 +486,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let items: &AssocItems = self.tcx.associated_items(self.def_id); items .in_definition_order() - .filter(|item| item.is_type()) .filter(|item| { - !self - .gen_args - .constraints - .iter() - .any(|constraint| constraint.ident.name == item.name()) + item.is_type() + && !item.is_impl_trait_in_trait() + && !self + .gen_args + .constraints + .iter() + .any(|constraint| constraint.ident.name == item.name()) }) - .filter(|item| !item.is_impl_trait_in_trait()) .map(|item| self.tcx.item_ident(item.def_id).to_string()) .collect() } else { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 7605c6c6a420a..22162b8b3649a 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -29,7 +29,7 @@ use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, struct_span_code_err, }; -use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res}; +use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::{self as hir, AnonConst, GenericArg, GenericArgs, HirId}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; @@ -1731,9 +1731,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { tcx.associated_items(*trait_def_id) .in_definition_order() .any(|i| { - i.namespace() == Namespace::TypeNS + i.is_type() + && !i.is_impl_trait_in_trait() && i.ident(tcx).normalize_to_macros_2_0() == assoc_ident - && i.is_type() }) // Consider only accessible traits && tcx.visibility(*trait_def_id) diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs new file mode 100644 index 0000000000000..e8329e3694d73 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs @@ -0,0 +1,12 @@ +trait Foo { + fn rpitit() -> impl Sized; +} + +// Ensure that we don't try to probe the name of the RPITIT when looking for +// fixes to suggest for the redundant generic below. + +fn test>() {} +//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied +//~| ERROR associated type `Assoc` not found for `Foo` + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr new file mode 100644 index 0000000000000..1058ef01f323f --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr @@ -0,0 +1,24 @@ +error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/dont-probe-missing-item-name-2.rs:8:12 + | +LL | fn test>() {} + | ^^^------------------ help: remove the unnecessary generics + | | + | expected 0 generic arguments + | +note: trait defined here, with 0 generic parameters + --> $DIR/dont-probe-missing-item-name-2.rs:1:7 + | +LL | trait Foo { + | ^^^ + +error[E0220]: associated type `Assoc` not found for `Foo` + --> $DIR/dont-probe-missing-item-name-2.rs:8:21 + | +LL | fn test>() {} + | ^^^^^ associated type `Assoc` not found + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0107, E0220. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs new file mode 100644 index 0000000000000..db39bb354379a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs @@ -0,0 +1,11 @@ +trait Trait { + fn method() -> impl Sized; +} + +// Ensure that we don't try to probe the name of the RPITIT when looking for +// fixes to suggest for the missing associated type's trait path below. + +fn foo() -> i32::Assoc {} +//~^ ERROR ambiguous associated type + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr new file mode 100644 index 0000000000000..f30d0228a3c86 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr @@ -0,0 +1,15 @@ +error[E0223]: ambiguous associated type + --> $DIR/dont-probe-missing-item-name-3.rs:8:13 + | +LL | fn foo() -> i32::Assoc {} + | ^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `Assoc` implemented for `i32`, you could use the fully-qualified path + | +LL - fn foo() -> i32::Assoc {} +LL + fn foo() -> ::Assoc {} + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0223`. From de9323973a4dd9e76fadd250c2ac13ecddb4374c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 19 Apr 2025 18:11:57 +0200 Subject: [PATCH 17/20] remove a couple clones --- compiler/rustc_builtin_macros/src/autodiff.rs | 10 ++++------ compiler/rustc_mir_build/src/builder/scope.rs | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/autodiff.rs b/compiler/rustc_builtin_macros/src/autodiff.rs index daebd516499bc..e60efdbefd92a 100644 --- a/compiler/rustc_builtin_macros/src/autodiff.rs +++ b/compiler/rustc_builtin_macros/src/autodiff.rs @@ -596,15 +596,14 @@ mod llvm_enzyme { } }; let arg = ty.kind.is_simple_path().unwrap(); - let sl: Vec = vec![arg, kw::Default]; - let tmp = ecx.def_site_path(&sl); + let tmp = ecx.def_site_path(&[arg, kw::Default]); let default_call_expr = ecx.expr_path(ecx.path(span, tmp)); let default_call_expr = ecx.expr_call(new_decl_span, default_call_expr, thin_vec![]); body.stmts.push(ecx.stmt_expr(default_call_expr)); return body; } - let mut exprs: P = primal_call.clone(); + let mut exprs: P = primal_call; let d_ret_ty = match d_sig.decl.output { FnRetTy::Ty(ref ty) => ty.clone(), FnRetTy::Default(span) => { @@ -622,7 +621,7 @@ mod llvm_enzyme { // type due to the Const return activity. exprs = ecx.expr_call(new_decl_span, bb_call_expr, thin_vec![exprs]); } else { - let q = QSelf { ty: d_ret_ty.clone(), path_span: span, position: 0 }; + let q = QSelf { ty: d_ret_ty, path_span: span, position: 0 }; let y = ExprKind::Path(Some(P(q)), ecx.path_ident(span, Ident::from_str("default"))); let default_call_expr = ecx.expr(span, y); @@ -640,8 +639,7 @@ mod llvm_enzyme { let mut exprs2 = thin_vec![exprs]; for arg in args.iter().skip(1) { let arg = arg.kind.is_simple_path().unwrap(); - let sl: Vec = vec![arg, kw::Default]; - let tmp = ecx.def_site_path(&sl); + let tmp = ecx.def_site_path(&[arg, kw::Default]); let default_call_expr = ecx.expr_path(ecx.path(span, tmp)); let default_call_expr = ecx.expr_call(new_decl_span, default_call_expr, thin_vec![]); diff --git a/compiler/rustc_mir_build/src/builder/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index e42336a1dbbcc..4e4b11b8fa6b2 100644 --- a/compiler/rustc_mir_build/src/builder/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -1530,7 +1530,7 @@ fn build_scope_drops<'tcx>( // path, then don't generate the drop. (We only take this into // account for non-unwind paths so as not to disturb the // caching mechanism.) - if scope.moved_locals.iter().any(|&o| o == local) { + if scope.moved_locals.contains(&local) { continue; } From 605af72f06181409e8755365176417d8a4b27ceb Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sun, 20 Apr 2025 17:25:17 +0000 Subject: [PATCH 18/20] build_helper: try to rename dir before delete --- Cargo.lock | 1 + src/bootstrap/Cargo.lock | 7 +++++++ src/build_helper/Cargo.toml | 1 + src/build_helper/src/fs/mod.rs | 27 ++++++++++++++++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 97a90a44a398e..b582177608135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -332,6 +332,7 @@ dependencies = [ name = "build_helper" version = "0.1.0" dependencies = [ + "fastrand", "serde", "serde_derive", ] diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 17ee4d610f958..be733b55b1206 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -82,6 +82,7 @@ dependencies = [ name = "build_helper" version = "0.1.0" dependencies = [ + "fastrand", "serde", "serde_derive", ] @@ -233,6 +234,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "fd-lock" version = "4.0.2" diff --git a/src/build_helper/Cargo.toml b/src/build_helper/Cargo.toml index 66894e1abc40e..802fbb754c02c 100644 --- a/src/build_helper/Cargo.toml +++ b/src/build_helper/Cargo.toml @@ -6,5 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +fastrand = "2.3.0" serde = "1" serde_derive = "1" diff --git a/src/build_helper/src/fs/mod.rs b/src/build_helper/src/fs/mod.rs index 123df76e6a2e9..babfd042f609c 100644 --- a/src/build_helper/src/fs/mod.rs +++ b/src/build_helper/src/fs/mod.rs @@ -1,4 +1,5 @@ //! Misc filesystem related helpers for use by bootstrap and tools. +use std::ffi::{OsStr, OsString}; use std::fs::Metadata; use std::path::Path; use std::{fs, io}; @@ -100,6 +101,30 @@ where pub fn remove_and_create_dir_all>(path: P) -> io::Result<()> { let path = path.as_ref(); - recursive_remove(path)?; + + // Attempt to rename the directory in case removing fails. + // We allow either the rename to fail or the remove to fail but not both. + let rm_path = rand_name(path.as_os_str()); + if fs::rename(path, &rm_path).is_err() { + // Rename failed, try to remove the original path + recursive_remove(&path)?; + } else { + // Rename succeeded, try to remove the renamed path + let _ = recursive_remove(&rm_path); + } fs::create_dir_all(path) } + +fn rand_name(prefix: &OsStr) -> OsString { + let mut name: OsString = prefix.into(); + name.push("-"); + let mut rand_suffix = [0; 8]; + for n in rand_suffix.iter_mut() { + *n = fastrand::alphanumeric() as u8; + } + // SAFETY: `fastrand::alphanumeric` only returns valid ascii. + // Since an `OsStr` is a superset of UTF-8, ascii must be a valid `OsStr`. + let ascii = unsafe { OsStr::from_encoded_bytes_unchecked(&rand_suffix) }; + name.push(ascii); + name +} From 49b62eeacc0b57c01464577c5f3437f2f29f9683 Mon Sep 17 00:00:00 2001 From: The rustc-dev-guide Cronjob Bot Date: Mon, 21 Apr 2025 04:03:02 +0000 Subject: [PATCH 19/20] Preparing for merge from rustc --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 67de4a9816552..dc52e0928cc4c 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -a7c39b68616668a45f0afd62849a1da7c8ad2516 +b8005bff3248cfc6e327faf4fa631ac49bb49ba9 From 6fe881c788ebb4d8126cdd603a89e08ca94b4bdb Mon Sep 17 00:00:00 2001 From: xizheyin Date: Sun, 20 Apr 2025 19:52:26 +0800 Subject: [PATCH 20/20] Construct OutputType using macro and print [=FILENAME] help info Signed-off-by: xizheyin --- compiler/rustc_session/src/config.rs | 310 +++++++++++------- .../dash-separated_something-extra.expected.d | 4 +- tests/run-make/rustc-help/help-v.diff | 2 +- tests/run-make/rustc-help/help-v.stdout | 14 +- tests/run-make/rustc-help/help.stdout | 14 +- .../emit-output-types-without-args.rs | 1 + .../emit-output-types-without-args.stderr | 15 +- 7 files changed, 238 insertions(+), 122 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ff7ea5bd71896..bc92b95ce7116 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -568,124 +568,205 @@ impl FromStr for SplitDwarfKind { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, HashStable_Generic)] -#[derive(Encodable, Decodable)] -pub enum OutputType { - /// This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode, - /// depending on the specific request type. - Bitcode, - /// This is the summary or index data part of the ThinLTO bitcode. - ThinLinkBitcode, - Assembly, - LlvmAssembly, - Mir, - Metadata, - Object, - Exe, - DepInfo, -} +macro_rules! define_output_types { + ( + $( + $(#[doc = $doc:expr])* + $Variant:ident => { + shorthand: $shorthand:expr, + extension: $extension:expr, + description: $description:expr, + default_filename: $default_filename:expr, + is_text: $is_text:expr, + compatible_with_cgus_and_single_output: $compatible:expr + } + ),* $(,)? + ) => { + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, HashStable_Generic)] + #[derive(Encodable, Decodable)] + pub enum OutputType { + $( + $(#[doc = $doc])* + $Variant, + )* + } -impl StableOrd for OutputType { - const CAN_USE_UNSTABLE_SORT: bool = true; - // Trivial C-Style enums have a stable sort order across compilation sessions. - const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); -} + impl StableOrd for OutputType { + const CAN_USE_UNSTABLE_SORT: bool = true; -impl ToStableHashKey for OutputType { - type KeyType = Self; + // Trivial C-Style enums have a stable sort order across compilation sessions. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); + } - fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType { - *self - } -} + impl ToStableHashKey for OutputType { + type KeyType = Self; -impl OutputType { - fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool { - match *self { - OutputType::Exe | OutputType::DepInfo | OutputType::Metadata => true, - OutputType::Bitcode - | OutputType::ThinLinkBitcode - | OutputType::Assembly - | OutputType::LlvmAssembly - | OutputType::Mir - | OutputType::Object => false, + fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType { + *self + } } - } - pub fn shorthand(&self) -> &'static str { - match *self { - OutputType::Bitcode => "llvm-bc", - OutputType::ThinLinkBitcode => "thin-link-bitcode", - OutputType::Assembly => "asm", - OutputType::LlvmAssembly => "llvm-ir", - OutputType::Mir => "mir", - OutputType::Object => "obj", - OutputType::Metadata => "metadata", - OutputType::Exe => "link", - OutputType::DepInfo => "dep-info", - } - } - - fn from_shorthand(shorthand: &str) -> Option { - Some(match shorthand { - "asm" => OutputType::Assembly, - "llvm-ir" => OutputType::LlvmAssembly, - "mir" => OutputType::Mir, - "llvm-bc" => OutputType::Bitcode, - "thin-link-bitcode" => OutputType::ThinLinkBitcode, - "obj" => OutputType::Object, - "metadata" => OutputType::Metadata, - "link" => OutputType::Exe, - "dep-info" => OutputType::DepInfo, - _ => return None, - }) - } - fn shorthands_display() -> String { - format!( - "`{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`, `{}`", - OutputType::Bitcode.shorthand(), - OutputType::ThinLinkBitcode.shorthand(), - OutputType::Assembly.shorthand(), - OutputType::LlvmAssembly.shorthand(), - OutputType::Mir.shorthand(), - OutputType::Object.shorthand(), - OutputType::Metadata.shorthand(), - OutputType::Exe.shorthand(), - OutputType::DepInfo.shorthand(), - ) - } + impl OutputType { + pub fn iter_all() -> impl Iterator { + static ALL_VARIANTS: &[OutputType] = &[ + $( + OutputType::$Variant, + )* + ]; + ALL_VARIANTS.iter().copied() + } + + fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool { + match *self { + $( + OutputType::$Variant => $compatible, + )* + } + } + + pub fn shorthand(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $shorthand, + )* + } + } + + fn from_shorthand(shorthand: &str) -> Option { + match shorthand { + $( + s if s == $shorthand => Some(OutputType::$Variant), + )* + _ => None, + } + } + + fn shorthands_display() -> String { + let shorthands = vec![ + $( + format!("`{}`", $shorthand), + )* + ]; + shorthands.join(", ") + } + + pub fn extension(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $extension, + )* + } + } + + pub fn is_text_output(&self) -> bool { + match *self { + $( + OutputType::$Variant => $is_text, + )* + } + } + + pub fn description(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $description, + )* + } + } + + pub fn default_filename(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $default_filename, + )* + } + } - pub fn extension(&self) -> &'static str { - match *self { - OutputType::Bitcode => "bc", - OutputType::ThinLinkBitcode => "indexing.o", - OutputType::Assembly => "s", - OutputType::LlvmAssembly => "ll", - OutputType::Mir => "mir", - OutputType::Object => "o", - OutputType::Metadata => "rmeta", - OutputType::DepInfo => "d", - OutputType::Exe => "", - } - } - pub fn is_text_output(&self) -> bool { - match *self { - OutputType::Assembly - | OutputType::LlvmAssembly - | OutputType::Mir - | OutputType::DepInfo => true, - OutputType::Bitcode - | OutputType::ThinLinkBitcode - | OutputType::Object - | OutputType::Metadata - | OutputType::Exe => false, } } } +define_output_types! { + Assembly => { + shorthand: "asm", + extension: "s", + description: "Generates a file with the crate's assembly code", + default_filename: "CRATE_NAME.s", + is_text: true, + compatible_with_cgus_and_single_output: false + }, + #[doc = "This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode,"] + #[doc = "depending on the specific request type."] + Bitcode => { + shorthand: "llvm-bc", + extension: "bc", + description: "Generates a binary file containing the LLVM bitcode", + default_filename: "CRATE_NAME.bc", + is_text: false, + compatible_with_cgus_and_single_output: false + }, + DepInfo => { + shorthand: "dep-info", + extension: "d", + description: "Generates a file with Makefile syntax that indicates all the source files that were loaded to generate the crate", + default_filename: "CRATE_NAME.d", + is_text: true, + compatible_with_cgus_and_single_output: true + }, + Exe => { + shorthand: "link", + extension: "", + description: "Generates the crates specified by --crate-type. This is the default if --emit is not specified", + default_filename: "(platform and crate-type dependent)", + is_text: false, + compatible_with_cgus_and_single_output: true + }, + LlvmAssembly => { + shorthand: "llvm-ir", + extension: "ll", + description: "Generates a file containing LLVM IR", + default_filename: "CRATE_NAME.ll", + is_text: true, + compatible_with_cgus_and_single_output: false + }, + Metadata => { + shorthand: "metadata", + extension: "rmeta", + description: "Generates a file containing metadata about the crate", + default_filename: "libCRATE_NAME.rmeta", + is_text: false, + compatible_with_cgus_and_single_output: true + }, + Mir => { + shorthand: "mir", + extension: "mir", + description: "Generates a file containing rustc's mid-level intermediate representation", + default_filename: "CRATE_NAME.mir", + is_text: true, + compatible_with_cgus_and_single_output: false + }, + Object => { + shorthand: "obj", + extension: "o", + description: "Generates a native object file", + default_filename: "CRATE_NAME.o", + is_text: false, + compatible_with_cgus_and_single_output: false + }, + #[doc = "This is the summary or index data part of the ThinLTO bitcode."] + ThinLinkBitcode => { + shorthand: "thin-link-bitcode", + extension: "indexing.o", + description: "Generates the ThinLTO summary as bitcode", + default_filename: "CRATE_NAME.indexing.o", + is_text: false, + compatible_with_cgus_and_single_output: false + }, +} + /// The type of diagnostics output to generate. #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub enum ErrorOutputType { @@ -1570,6 +1651,18 @@ static PRINT_HELP: LazyLock = LazyLock::new(|| { ) }); +static EMIT_HELP: LazyLock = LazyLock::new(|| { + let mut result = + String::from("Comma separated list of types of output for the compiler to emit.\n"); + result.push_str("Each TYPE has the default FILE name:\n"); + + for output in OutputType::iter_all() { + result.push_str(&format!("* {} - {}\n", output.shorthand(), output.default_filename())); + } + + result +}); + /// Returns all rustc command line options, including metadata for /// each option, such as whether the option is stable. pub fn rustc_optgroups() -> Vec { @@ -1616,14 +1709,7 @@ pub fn rustc_optgroups() -> Vec { make_crate_type_option(), opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", "NAME"), opt(Stable, Opt, "", "edition", &EDITION_STRING, EDITION_NAME_LIST), - opt( - Stable, - Multi, - "", - "emit", - "Comma separated list of types of output for the compiler to emit", - "[asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]", - ), + opt(Stable, Multi, "", "emit", &EMIT_HELP, "TYPE[=FILE]"), opt(Stable, Multi, "", "print", &PRINT_HELP, "INFO[=FILE]"), opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""), opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""), diff --git a/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d b/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d index 497d76b4ea12e..43e8f9185a301 100644 --- a/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d +++ b/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d @@ -1,5 +1,5 @@ -libdash_separated_something-extra.rmeta: dash-separated.rs - dash-separated_something-extra.d: dash-separated.rs +libdash_separated_something-extra.rmeta: dash-separated.rs + dash-separated.rs: diff --git a/tests/run-make/rustc-help/help-v.diff b/tests/run-make/rustc-help/help-v.diff index 30703f6424e7e..0ea79f3e55734 100644 --- a/tests/run-make/rustc-help/help-v.diff +++ b/tests/run-make/rustc-help/help-v.diff @@ -1,4 +1,4 @@ -@@ -53,10 +53,27 @@ +@@ -63,10 +63,27 @@ Set a codegen option -V, --version Print version info and exit -v, --verbose Use verbose output diff --git a/tests/run-make/rustc-help/help-v.stdout b/tests/run-make/rustc-help/help-v.stdout index 13af6e21060b5..744453d6e8569 100644 --- a/tests/run-make/rustc-help/help-v.stdout +++ b/tests/run-make/rustc-help/help-v.stdout @@ -26,9 +26,19 @@ Options: Specify which edition of the compiler to use when compiling code. The default is 2015 and the latest stable edition is 2024. - --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] + --emit TYPE[=FILE] Comma separated list of types of output for the - compiler to emit + compiler to emit. + Each TYPE has the default FILE name: + * asm - CRATE_NAME.s + * llvm-bc - CRATE_NAME.bc + * dep-info - CRATE_NAME.d + * link - (platform and crate-type dependent) + * llvm-ir - CRATE_NAME.ll + * metadata - libCRATE_NAME.rmeta + * mir - CRATE_NAME.mir + * obj - CRATE_NAME.o + * thin-link-bitcode - CRATE_NAME.indexing.o --print INFO[=FILE] Compiler information to print on stdout (or to a file) INFO may be one of diff --git a/tests/run-make/rustc-help/help.stdout b/tests/run-make/rustc-help/help.stdout index 62757d989eb3b..3043755207a64 100644 --- a/tests/run-make/rustc-help/help.stdout +++ b/tests/run-make/rustc-help/help.stdout @@ -26,9 +26,19 @@ Options: Specify which edition of the compiler to use when compiling code. The default is 2015 and the latest stable edition is 2024. - --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] + --emit TYPE[=FILE] Comma separated list of types of output for the - compiler to emit + compiler to emit. + Each TYPE has the default FILE name: + * asm - CRATE_NAME.s + * llvm-bc - CRATE_NAME.bc + * dep-info - CRATE_NAME.d + * link - (platform and crate-type dependent) + * llvm-ir - CRATE_NAME.ll + * metadata - libCRATE_NAME.rmeta + * mir - CRATE_NAME.mir + * obj - CRATE_NAME.o + * thin-link-bitcode - CRATE_NAME.indexing.o --print INFO[=FILE] Compiler information to print on stdout (or to a file) INFO may be one of diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs b/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs index 793931e99d9cf..a96eeb0a5ce08 100644 --- a/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs @@ -1 +1,2 @@ //@ compile-flags: --emit +//@ error-pattern: Argument to option 'emit' missing diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr index dad81dcb13c0d..669913b57653e 100644 --- a/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr @@ -1,6 +1,15 @@ error: Argument to option 'emit' missing Usage: - --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] - Comma separated list of types of output for the - compiler to emit + --emit TYPE[=FILE] Comma separated list of types of output for the + compiler to emit. + Each TYPE has the default FILE name: + * asm - CRATE_NAME.s + * llvm-bc - CRATE_NAME.bc + * dep-info - CRATE_NAME.d + * link - (platform and crate-type dependent) + * llvm-ir - CRATE_NAME.ll + * metadata - libCRATE_NAME.rmeta + * mir - CRATE_NAME.mir + * obj - CRATE_NAME.o + * thin-link-bitcode - CRATE_NAME.indexing.o