diff --git a/compiler/rustc_attr_data_structures/src/attributes.rs b/compiler/rustc_attr_data_structures/src/attributes.rs index 845e4d5e5d0fa..a0a50fd4b7c2c 100644 --- a/compiler/rustc_attr_data_structures/src/attributes.rs +++ b/compiler/rustc_attr_data_structures/src/attributes.rs @@ -130,24 +130,54 @@ impl Deprecation { } } -/// Represent parsed, *built in*, inert attributes. +/// Represents parsed *built-in* inert attributes. /// -/// That means attributes that are not actually ever expanded. -/// For more information on this, see the module docs on the [`rustc_attr_parsing`] crate. -/// They're instead used as markers, to guide the compilation process in various way in most every stage of the compiler. -/// These are kept around after the AST, into the HIR and further on. +/// ## Overview +/// These attributes are markers that guide the compilation process and are never expanded into other code. +/// They persist throughout the compilation phases, from AST to HIR and beyond. /// -/// The word "parsed" could be a little misleading here, because the parser already parses -/// attributes early on. However, the result, an [`ast::Attribute`] -/// is only parsed at a high level, still containing a token stream in many cases. That is -/// because the structure of the contents varies from attribute to attribute. -/// With a parsed attribute I mean that each attribute is processed individually into a -/// final structure, which on-site (the place where the attribute is useful for, think the -/// the place where `must_use` is checked) little to no extra parsing or validating needs to -/// happen. +/// ## Attribute Processing +/// While attributes are initially parsed by [`rustc_parse`] into [`ast::Attribute`], they still contain raw token streams +/// because different attributes have different internal structures. This enum represents the final, +/// fully parsed form of these attributes, where each variant contains contains all the information and +/// structure relevant for the specific attribute. /// -/// For more docs, look in [`rustc_attr_parsing`]. +/// Some attributes can be applied multiple times to the same item, and they are "collapsed" into a single +/// semantic attribute. For example: +/// ```rust +/// #[repr(C)] +/// #[repr(packed)] +/// struct S { } +/// ``` +/// This is equivalent to `#[repr(C, packed)]` and results in a single [`AttributeKind::Repr`] containing +/// both `C` and `packed` annotations. This collapsing happens during parsing and is reflected in the +/// data structures defined in this enum. /// +/// ## Usage +/// These parsed attributes are used throughout the compiler to: +/// - Control code generation (e.g., `#[repr]`) +/// - Mark API stability (`#[stable]`, `#[unstable]`) +/// - Provide documentation (`#[doc]`) +/// - Guide compiler behavior (e.g., `#[allow_internal_unstable]`) +/// +/// ## Note on Attribute Organization +/// Some attributes like `InlineAttr`, `OptimizeAttr`, and `InstructionSetAttr` are defined separately +/// from this enum because they are used in specific compiler phases (like code generation) and don't +/// need to persist throughout the entire compilation process. They are typically processed and +/// converted into their final form earlier in the compilation pipeline. +/// +/// For example: +/// - `InlineAttr` is used during code generation to control function inlining +/// - `OptimizeAttr` is used to control optimization levels +/// - `InstructionSetAttr` is used for target-specific code generation +/// +/// These attributes are handled by their respective compiler passes in the [`rustc_codegen_ssa`] crate +/// and don't need to be preserved in the same way as the attributes in this enum. +/// +/// For more details on attribute parsing, see the [`rustc_attr_parsing`] crate. +/// +/// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html +/// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html /// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html #[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] pub enum AttributeKind { diff --git a/compiler/rustc_attr_data_structures/src/lib.rs b/compiler/rustc_attr_data_structures/src/lib.rs index b0fc19d1cd7ba..f8355be09adfb 100644 --- a/compiler/rustc_attr_data_structures/src/lib.rs +++ b/compiler/rustc_attr_data_structures/src/lib.rs @@ -1,3 +1,7 @@ +//! Data structures for representing parsed attributes in the Rust compiler. +//! For detailed documentation about attribute processing, +//! see [rustc_attr_parsing](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html). + // tidy-alphabetical-start #![allow(internal_features)] #![doc(rust_logo)] diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 8fc83908efbcc..438313b6d1021 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1829,6 +1829,7 @@ pub(crate) fn linked_symbols( for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) || info.used + || info.rustc_std_internal_symbol { symbols.push(( symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum), diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 92b9b6e132e74..a7825d9c020d6 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -131,6 +131,9 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap, _: LocalCrate) -> DefIdMap( level: info.level, kind: SymbolExportKind::Text, used: info.used, + rustc_std_internal_symbol: info.rustc_std_internal_symbol, }, ) }) @@ -207,6 +212,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::C, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: false, }, )); } @@ -229,6 +235,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::Rust, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: true, }, )); } @@ -243,6 +250,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::Rust, kind: SymbolExportKind::Data, used: false, + rustc_std_internal_symbol: true, }, )) } @@ -262,6 +270,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::C, kind: SymbolExportKind::Data, used: false, + rustc_std_internal_symbol: false, }, ) })); @@ -287,6 +296,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::C, kind: SymbolExportKind::Data, used: false, + rustc_std_internal_symbol: false, }, ) })); @@ -304,6 +314,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::C, kind: SymbolExportKind::Data, used: true, + rustc_std_internal_symbol: false, }, )); } @@ -379,6 +390,8 @@ fn exported_symbols_provider_local<'tcx>( } } + // Note: These all set rustc_std_internal_symbol to false as generic functions must not + // be marked with this attribute and we are only handling generic functions here. match *mono_item { MonoItem::Fn(Instance { def: InstanceKind::Item(def), args }) => { let has_generics = args.non_erasable_generics().next().is_some(); @@ -394,6 +407,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::Rust, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: false, }, )); } @@ -416,6 +430,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::Rust, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: false, }, )); } @@ -432,6 +447,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::Rust, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: false, }, )); } @@ -442,6 +458,7 @@ fn exported_symbols_provider_local<'tcx>( level: SymbolExportLevel::Rust, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: false, }, )); } diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index a3d6c73ba8560..04e5d2486e25a 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -6,7 +6,7 @@ use std::time::{Duration, Instant}; use itertools::Itertools; use rustc_abi::FIRST_VARIANT; use rustc_ast as ast; -use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, AllocatorKind, global_fn_name}; +use rustc_ast::expand::allocator::AllocatorKind; use rustc_attr_data_structures::OptimizeAttr; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry}; @@ -1039,26 +1039,6 @@ impl CrateInfo { .collect::>(); symbols.sort_unstable_by(|a, b| a.0.cmp(&b.0)); linked_symbols.extend(symbols); - if tcx.allocator_kind(()).is_some() { - // At least one crate needs a global allocator. This crate may be placed - // after the crate that defines it in the linker order, in which case some - // linkers return an error. By adding the global allocator shim methods to - // the linked_symbols list, linking the generated symbols.o will ensure that - // circular dependencies involving the global allocator don't lead to linker - // errors. - linked_symbols.extend(ALLOCATOR_METHODS.iter().map(|method| { - ( - format!( - "{prefix}{}", - mangle_internal_symbol( - tcx, - global_fn_name(method.name).as_str() - ) - ), - SymbolExportKind::Text, - ) - })); - } }); } diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 73a21789c5d25..7d6e471e7e951 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -887,7 +887,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_legacy_const_generics, Normal, template!(List: "N"), ErrorFollowing, EncodeCrossCrate::Yes, ), - // Do not const-check this function's body. It will always get replaced during CTFE. + // Do not const-check this function's body. It will always get replaced during CTFE via `hook_special_const_fn`. rustc_attr!( rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes, "`#[rustc_do_not_const_check]` skips const-check for this function's body", diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index de19c10bc57c8..2c882b84c588d 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -1,7 +1,6 @@ //! Validates all used crates and extern libraries and loads their metadata use std::error::Error; -use std::ops::Fn; use std::path::Path; use std::str::FromStr; use std::time::Duration; @@ -276,12 +275,6 @@ impl CStore { .filter_map(|(cnum, data)| data.as_deref().map(|data| (cnum, data))) } - fn iter_crate_data_mut(&mut self) -> impl Iterator { - self.metas - .iter_enumerated_mut() - .filter_map(|(cnum, data)| data.as_deref_mut().map(|data| (cnum, data))) - } - fn push_dependencies_in_postorder(&self, deps: &mut IndexSet, cnum: CrateNum) { if !deps.contains(&cnum) { let data = self.get_crate_data(cnum); @@ -307,13 +300,6 @@ impl CStore { deps } - fn crate_dependencies_in_reverse_postorder( - &self, - cnum: CrateNum, - ) -> impl Iterator { - self.crate_dependencies_in_postorder(cnum).into_iter().rev() - } - pub(crate) fn injected_panic_runtime(&self) -> Option { self.injected_panic_runtime } @@ -966,47 +952,27 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { // If we need a panic runtime, we try to find an existing one here. At // the same time we perform some general validation of the DAG we've got // going such as ensuring everything has a compatible panic strategy. - // - // The logic for finding the panic runtime here is pretty much the same - // as the allocator case with the only addition that the panic strategy - // compilation mode also comes into play. - let desired_strategy = self.sess.panic_strategy(); - let mut runtime_found = false; let mut needs_panic_runtime = attr::contains_name(&krate.attrs, sym::needs_panic_runtime); - - let mut panic_runtimes = Vec::new(); - for (cnum, data) in self.cstore.iter_crate_data() { - needs_panic_runtime = needs_panic_runtime || data.needs_panic_runtime(); - if data.is_panic_runtime() { - // Inject a dependency from all #![needs_panic_runtime] to this - // #![panic_runtime] crate. - panic_runtimes.push(cnum); - runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit; - } - } - for cnum in panic_runtimes { - self.inject_dependency_if(cnum, "a panic runtime", &|data| data.needs_panic_runtime()); + for (_cnum, data) in self.cstore.iter_crate_data() { + needs_panic_runtime |= data.needs_panic_runtime(); } - // If an explicitly linked and matching panic runtime was found, or if - // we just don't need one at all, then we're done here and there's - // nothing else to do. - if !needs_panic_runtime || runtime_found { + // If we just don't need a panic runtime at all, then we're done here + // and there's nothing else to do. + if !needs_panic_runtime { return; } - // By this point we know that we (a) need a panic runtime and (b) no - // panic runtime was explicitly linked. Here we just load an appropriate - // default runtime for our panic strategy and then inject the - // dependencies. + // By this point we know that we need a panic runtime. Here we just load + // an appropriate default runtime for our panic strategy. // // We may resolve to an already loaded crate (as the crate may not have - // been explicitly linked prior to this) and we may re-inject - // dependencies again, but both of those situations are fine. + // been explicitly linked prior to this), but this is fine. // // Also note that we have yet to perform validation of the crate graph // in terms of everyone has a compatible panic runtime format, that's // performed later as part of the `dependency_format` module. + let desired_strategy = self.sess.panic_strategy(); let name = match desired_strategy { PanicStrategy::Unwind => sym::panic_unwind, PanicStrategy::Abort => sym::panic_abort, @@ -1031,7 +997,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { } self.cstore.injected_panic_runtime = Some(cnum); - self.inject_dependency_if(cnum, "a panic runtime", &|data| data.needs_panic_runtime()); } fn inject_profiler_runtime(&mut self) { @@ -1212,45 +1177,6 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> { } } - fn inject_dependency_if( - &mut self, - krate: CrateNum, - what: &str, - needs_dep: &dyn Fn(&CrateMetadata) -> bool, - ) { - // Don't perform this validation if the session has errors, as one of - // those errors may indicate a circular dependency which could cause - // this to stack overflow. - if self.dcx().has_errors().is_some() { - return; - } - - // Before we inject any dependencies, make sure we don't inject a - // circular dependency by validating that this crate doesn't - // transitively depend on any crates satisfying `needs_dep`. - for dep in self.cstore.crate_dependencies_in_reverse_postorder(krate) { - let data = self.cstore.get_crate_data(dep); - if needs_dep(&data) { - self.dcx().emit_err(errors::NoTransitiveNeedsDep { - crate_name: self.cstore.get_crate_data(krate).name(), - needs_crate_name: what, - deps_crate_name: data.name(), - }); - } - } - - // All crates satisfying `needs_dep` do not explicitly depend on the - // crate provided for this compile, but in order for this compilation to - // be successfully linked we need to inject a dependency (to order the - // crates on the command line correctly). - for (cnum, data) in self.cstore.iter_crate_data_mut() { - if needs_dep(data) { - info!("injecting a dep from {} to {}", cnum, krate); - data.add_dependency(krate); - } - } - } - fn report_unused_deps(&mut self, krate: &ast::Crate) { // Make a point span rather than covering the whole file let span = krate.spans.inner_span.shrink_to_lo(); diff --git a/compiler/rustc_metadata/src/dependency_format.rs b/compiler/rustc_metadata/src/dependency_format.rs index fcae33c73c9c0..f2f5afd84a09a 100644 --- a/compiler/rustc_metadata/src/dependency_format.rs +++ b/compiler/rustc_metadata/src/dependency_format.rs @@ -370,15 +370,15 @@ fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec) -> Option, list: &mut DependencyList, diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 1953eef81700b..70cd4e7efac74 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1868,10 +1868,6 @@ impl CrateMetadata { self.dependencies.iter().copied() } - pub(crate) fn add_dependency(&mut self, cnum: CrateNum) { - self.dependencies.push(cnum); - } - pub(crate) fn target_modifiers(&self) -> TargetModifiers { self.root.decode_target_modifiers(&self.blob).collect() } diff --git a/compiler/rustc_middle/src/middle/exported_symbols.rs b/compiler/rustc_middle/src/middle/exported_symbols.rs index 1d67d0fe3bbf4..4469a5532f95f 100644 --- a/compiler/rustc_middle/src/middle/exported_symbols.rs +++ b/compiler/rustc_middle/src/middle/exported_symbols.rs @@ -35,7 +35,10 @@ pub enum SymbolExportKind { pub struct SymbolExportInfo { pub level: SymbolExportLevel, pub kind: SymbolExportKind, + /// Was the symbol marked as `#[used(compiler)]` or `#[used(linker)]`? pub used: bool, + /// Was the symbol marked as `#[rustc_std_internal_symbol]`? + pub rustc_std_internal_symbol: bool, } #[derive(Eq, PartialEq, Debug, Copy, Clone, TyEncodable, TyDecodable, HashStable)] diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index 94cfd667ffae0..f1eedede8aab9 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -30,7 +30,7 @@ use crate::fmt; /// Files are compared as strings, not `Path`, which could be unexpected. /// See [`Location::file`]'s documentation for more discussion. #[lang = "panic_location"] -#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] #[stable(feature = "panic_hooks", since = "1.10.0")] pub struct Location<'a> { // Note: this filename will have exactly one nul byte at its end, but otherwise @@ -43,6 +43,17 @@ pub struct Location<'a> { col: u32, } +#[stable(feature = "panic_hooks", since = "1.10.0")] +impl fmt::Debug for Location<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Location") + .field("file", &self.file()) + .field("line", &self.line) + .field("column", &self.col) + .finish() + } +} + impl<'a> Location<'a> { /// Returns the source location of the caller of this function. If that function's caller is /// annotated then its call location will be returned, and so on up the stack to the first call diff --git a/library/coretests/tests/panic/location.rs b/library/coretests/tests/panic/location.rs index d20241d838001..5ce0b06e90e1a 100644 --- a/library/coretests/tests/panic/location.rs +++ b/library/coretests/tests/panic/location.rs @@ -29,3 +29,11 @@ fn location_const_column() { const COLUMN: u32 = CALLER.column(); assert_eq!(COLUMN, 40); } + +#[test] +fn location_debug() { + let f = format!("{:?}", Location::caller()); + assert!(f.contains(&format!("{:?}", file!()))); + assert!(f.contains("35")); + assert!(f.contains("29")); +} diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index ae7107938f363..7c2a43ef20745 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -93,7 +93,7 @@ backtrace = [ 'miniz_oxide/rustc-dep-of-std', ] -panic-unwind = ["panic_unwind"] +panic-unwind = ["dep:panic_unwind"] compiler-builtins-c = ["alloc/compiler-builtins-c"] compiler-builtins-mem = ["alloc/compiler-builtins-mem"] compiler-builtins-no-asm = ["alloc/compiler-builtins-no-asm"] diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0cd794fd3efbb..865ea620a283f 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -121,7 +121,7 @@ pub struct File { /// /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared -#[unstable(feature = "file_lock", issue = "130994")] +#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub enum TryLockError { /// The lock could not be acquired due to an I/O error on the file. The standard library will /// not return an [`ErrorKind::WouldBlock`] error inside [`TryLockError::Error`] @@ -366,10 +366,10 @@ pub fn write, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result inner(path.as_ref(), contents.as_ref()) } -#[unstable(feature = "file_lock", issue = "130994")] +#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] impl error::Error for TryLockError {} -#[unstable(feature = "file_lock", issue = "130994")] +#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for TryLockError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -379,7 +379,7 @@ impl fmt::Debug for TryLockError { } } -#[unstable(feature = "file_lock", issue = "130994")] +#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for TryLockError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -390,7 +390,7 @@ impl fmt::Display for TryLockError { } } -#[unstable(feature = "file_lock", issue = "130994")] +#[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] impl From for io::Error { fn from(err: TryLockError) -> io::Error { match err { @@ -713,7 +713,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -722,7 +721,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn lock(&self) -> io::Result<()> { self.inner.lock() } @@ -766,7 +765,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -775,7 +773,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn lock_shared(&self) -> io::Result<()> { self.inner.lock_shared() } @@ -824,7 +822,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::{File, TryLockError}; /// /// fn main() -> std::io::Result<()> { @@ -840,7 +837,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn try_lock(&self) -> Result<(), TryLockError> { self.inner.try_lock() } @@ -888,7 +885,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::{File, TryLockError}; /// /// fn main() -> std::io::Result<()> { @@ -905,7 +901,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn try_lock_shared(&self) -> Result<(), TryLockError> { self.inner.try_lock_shared() } @@ -933,7 +929,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -943,7 +938,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn unlock(&self) -> io::Result<()> { self.inner.unlock() } diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml index c149d513c32b4..3adc022497167 100644 --- a/library/sysroot/Cargo.toml +++ b/library/sysroot/Cargo.toml @@ -26,7 +26,7 @@ debug_typeid = ["std/debug_typeid"] llvm-libunwind = ["std/llvm-libunwind"] system-llvm-libunwind = ["std/system-llvm-libunwind"] optimize_for_size = ["std/optimize_for_size"] -panic-unwind = ["std/panic_unwind"] +panic-unwind = ["std/panic-unwind"] panic_immediate_abort = ["std/panic_immediate_abort"] profiler = ["dep:profiler_builtins"] std_detect_file_io = ["std/std_detect_file_io"] diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 0c8e66335609b..a6ca699e28241 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -44,6 +44,7 @@ dependencies = [ "fd-lock", "home", "ignore", + "insta", "junction", "libc", "object", @@ -158,6 +159,18 @@ dependencies = [ "cc", ] +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + [[package]] name = "cpufeatures" version = "0.2.15" @@ -218,6 +231,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "errno" version = "0.3.11" @@ -323,6 +342,17 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "insta" +version = "1.43.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "154934ea70c58054b556dd430b99a98c2a7ff5309ac9891597e339b5c28f4371" +dependencies = [ + "console", + "once_cell", + "similar", +] + [[package]] name = "itoa" version = "1.0.11" @@ -675,6 +705,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + [[package]] name = "smallvec" version = "1.13.2" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index b12b3dfc7b2a6..9785a306c9b1b 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -84,6 +84,7 @@ features = [ [dev-dependencies] pretty_assertions = "1.4" tempfile = "3.15.0" +insta = "1.43" # We care a lot about bootstrap's compile times, so don't include debuginfo for # dependencies, only bootstrap itself. diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index f9d7c811f600a..5ff999f01a954 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -200,6 +200,10 @@ please file issues on the [Rust issue tracker][rust-issue-tracker]. [rust-bootstrap-zulip]: https://rust-lang.zulipchat.com/#narrow/stream/t-infra.2Fbootstrap [rust-issue-tracker]: https://github.com/rust-lang/rust/issues +## Testing + +To run bootstrap tests, execute `x test bootstrap`. If you want to bless snapshot tests, then install `cargo-insta` (`cargo install cargo-insta`) and then run `cargo insta review --manifest-path src/bootstrap/Cargo.toml`. + ## Changelog Because we do not release bootstrap with versions, we also do not maintain CHANGELOG files. To diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index ebb926d81cef4..f9f82b800419b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2009,7 +2009,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the // Note that if we encounter `PATH` we make sure to append to our own `PATH` // rather than stomp over it. if !builder.config.dry_run() && target.is_msvc() { - for (k, v) in builder.cc.borrow()[&target].env() { + for (k, v) in builder.cc[&target].env() { if k != "PATH" { cmd.env(k, v); } @@ -2026,8 +2026,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the // address sanitizer enabled (e.g., ntdll.dll). cmd.env("ASAN_WIN_CONTINUE_ON_INTERCEPTION_FAILURE", "1"); // Add the address sanitizer runtime to the PATH - it is located next to cl.exe. - let asan_runtime_path = - builder.cc.borrow()[&target].path().parent().unwrap().to_path_buf(); + let asan_runtime_path = builder.cc[&target].path().parent().unwrap().to_path_buf(); let old_path = cmd .get_envs() .find_map(|(k, v)| (k == "PATH").then_some(v)) @@ -3059,6 +3058,8 @@ impl Step for Bootstrap { cargo .rustflag("-Cdebuginfo=2") .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) + // Needed for insta to correctly write pending snapshots to the right directories. + .env("INSTA_WORKSPACE_ROOT", &builder.src) .env("RUSTC_BOOTSTRAP", "1"); // bootstrap tests are racy on directory creation so just run them one at a time. diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index f64d67341cfe2..237efaefada39 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -1334,7 +1334,7 @@ impl Builder<'_> { if compiler.host.is_msvc() { let curpaths = env::var_os("PATH").unwrap_or_default(); let curpaths = env::split_paths(&curpaths).collect::>(); - for (k, v) in self.cc.borrow()[&compiler.host].env() { + for (k, v) in self.cc[&compiler.host].env() { if k != "PATH" { continue; } diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index c6cfdb69356c5..0e3c3aaee0ff7 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -278,9 +278,7 @@ impl Cargo { self.rustdocflags.arg(&arg); } - if !builder.config.dry_run() - && builder.cc.borrow()[&target].args().iter().any(|arg| arg == "-gz") - { + if !builder.config.dry_run() && builder.cc[&target].args().iter().any(|arg| arg == "-gz") { self.rustflags.arg("-Clink-arg=-gz"); } diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 887db683f7899..7433f0b0f3b44 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Debug, Write}; use std::hash::Hash; use std::ops::Deref; use std::path::{Path, PathBuf}; -use std::sync::LazyLock; +use std::sync::{LazyLock, OnceLock}; use std::time::{Duration, Instant}; use std::{env, fs}; @@ -60,6 +60,9 @@ pub struct Builder<'a> { /// to do. For example: with `./x check foo bar` we get `paths=["foo", /// "bar"]`. pub paths: Vec, + + /// Cached list of submodules from self.build.src. + submodule_paths_cache: OnceLock>, } impl Deref for Builder<'_> { @@ -687,7 +690,7 @@ impl<'a> ShouldRun<'a> { /// /// [`path`]: ShouldRun::path pub fn paths(mut self, paths: &[&str]) -> Self { - let submodules_paths = build_helper::util::parse_gitmodules(&self.builder.src); + let submodules_paths = self.builder.submodule_paths(); self.paths.insert(PathSet::Set( paths @@ -1180,6 +1183,7 @@ impl<'a> Builder<'a> { stack: RefCell::new(Vec::new()), time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), paths, + submodule_paths_cache: Default::default(), } } @@ -1510,6 +1514,19 @@ impl<'a> Builder<'a> { None } + /// Updates all submodules, and exits with an error if submodule + /// management is disabled and the submodule does not exist. + pub fn require_and_update_all_submodules(&self) { + for submodule in self.submodule_paths() { + self.require_submodule(submodule, None); + } + } + + /// Get all submodules from the src directory. + pub fn submodule_paths(&self) -> &[String] { + self.submodule_paths_cache.get_or_init(|| build_helper::util::parse_gitmodules(&self.src)) + } + /// Ensure that a given step is built, returning its output. This will /// cache the step, so it is safe (and good!) to call this as often as /// needed to ensure that all dependencies are built. diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index a26a96f2815e6..d07df7f4a841d 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -15,11 +15,12 @@ static TEST_TRIPLE_2: &str = "i686-unknown-hurd-gnu"; static TEST_TRIPLE_3: &str = "i686-unknown-netbsd"; fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config { - configure_with_args(&[cmd.to_owned()], host, target) + configure_with_args(&[cmd], host, target) } -fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config { - let mut config = Config::parse(Flags::parse(cmd)); +fn configure_with_args(cmd: &[&str], host: &[&str], target: &[&str]) -> Config { + let cmd = cmd.iter().copied().map(String::from).collect::>(); + let mut config = Config::parse(Flags::parse(&cmd)); // don't save toolstates config.save_toolstates = None; config.set_dry_run(DryRun::SelfCheck); @@ -67,7 +68,7 @@ fn run_build(paths: &[PathBuf], config: Config) -> Cache { fn check_cli(paths: [&str; N]) { run_build( &paths.map(PathBuf::from), - configure_with_args(&paths.map(String::from), &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]), + configure_with_args(&paths, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]), ); } @@ -1000,8 +1001,7 @@ mod sysroot_target_dirs { /// cg_gcc tests instead. #[test] fn test_test_compiler() { - let cmd = &["test", "compiler"].map(str::to_owned); - let config = configure_with_args(cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]); + let config = configure_with_args(&["test", "compiler"], &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]); let cache = run_build(&config.paths.clone(), config); let compiler = cache.contains::(); @@ -1034,8 +1034,7 @@ fn test_test_coverage() { // Print each test case so that if one fails, the most recently printed // case is the one that failed. println!("Testing case: {cmd:?}"); - let cmd = cmd.iter().copied().map(str::to_owned).collect::>(); - let config = configure_with_args(&cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]); + let config = configure_with_args(cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]); let mut cache = run_build(&config.paths.clone(), config); let modes = @@ -1207,8 +1206,7 @@ fn test_get_tool_rustc_compiler() { /// of `Any { .. }`. #[test] fn step_cycle_debug() { - let cmd = ["run", "cyclic-step"].map(str::to_owned); - let config = configure_with_args(&cmd, &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]); + let config = configure_with_args(&["run", "cyclic-step"], &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]); let err = panic::catch_unwind(|| run_build(&config.paths.clone(), config)).unwrap_err(); let err = err.downcast_ref::().unwrap().as_str(); @@ -1233,3 +1231,81 @@ fn any_debug() { // Downcasting to the underlying type should succeed. assert_eq!(x.downcast_ref::(), Some(&MyStruct { x: 7 })); } + +/// The staging tests use insta for snapshot testing. +/// See bootstrap's README on how to bless the snapshots. +mod staging { + use crate::core::builder::tests::{ + TEST_TRIPLE_1, configure, configure_with_args, render_steps, run_build, + }; + + #[test] + fn build_compiler_stage_1() { + let mut cache = run_build( + &["compiler".into()], + configure_with_args(&["build", "--stage", "1"], &[TEST_TRIPLE_1], &[TEST_TRIPLE_1]), + ); + let steps = cache.into_executed_steps(); + insta::assert_snapshot!(render_steps(&steps), @r" + [build] rustc 0 -> std 0 + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 0 -> rustc 1 + "); + } +} + +/// Renders the executed bootstrap steps for usage in snapshot tests with insta. +/// Only renders certain important steps. +/// Each value in `steps` should be a tuple of (Step, step output). +fn render_steps(steps: &[(Box, Box)]) -> String { + steps + .iter() + .filter_map(|(step, output)| { + // FIXME: implement an optional method on Step to produce metadata for test, instead + // of this downcasting + if let Some((rustc, output)) = downcast_step::(step, output) { + Some(format!( + "[build] {} -> {}", + render_compiler(rustc.build_compiler), + // FIXME: return the correct stage from the `Rustc` step, now it behaves weirdly + render_compiler(Compiler::new(rustc.build_compiler.stage + 1, rustc.target)), + )) + } else if let Some((std, output)) = downcast_step::(step, output) { + Some(format!( + "[build] {} -> std {} <{}>", + render_compiler(std.compiler), + std.compiler.stage, + std.target + )) + } else if let Some((llvm, output)) = downcast_step::(step, output) { + Some(format!("[build] llvm <{}>", llvm.target)) + } else { + None + } + }) + .map(|line| { + line.replace(TEST_TRIPLE_1, "target1") + .replace(TEST_TRIPLE_2, "target2") + .replace(TEST_TRIPLE_3, "target3") + }) + .collect::>() + .join("\n") +} + +fn downcast_step<'a, S: Step>( + step: &'a Box, + output: &'a Box, +) -> Option<(&'a S, &'a S::Output)> { + let Some(step) = step.downcast_ref::() else { + return None; + }; + let Some(output) = output.downcast_ref::() else { + return None; + }; + Some((step, output)) +} + +fn render_compiler(compiler: Compiler) -> String { + format!("rustc {} <{}>", compiler.stage, compiler.host) +} diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 7254c653a2dba..f1628f34ddabe 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -17,7 +17,7 @@ //! also check out the `src/bootstrap/README.md` file for more information. #![cfg_attr(test, allow(unused))] -use std::cell::{Cell, RefCell}; +use std::cell::Cell; use std::collections::{BTreeSet, HashMap, HashSet}; use std::fmt::Display; use std::path::{Path, PathBuf}; @@ -189,10 +189,12 @@ pub struct Build { // Runtime state filled in later on // C/C++ compilers and archiver for all targets - cc: RefCell>, - cxx: RefCell>, - ar: RefCell>, - ranlib: RefCell>, + cc: HashMap, + cxx: HashMap, + ar: HashMap, + ranlib: HashMap, + wasi_sdk_path: Option, + // Miscellaneous // allow bidirectional lookups: both name -> path and path -> name crates: HashMap, @@ -466,10 +468,11 @@ impl Build { enzyme_info, in_tree_llvm_info, in_tree_gcc_info, - cc: RefCell::new(HashMap::new()), - cxx: RefCell::new(HashMap::new()), - ar: RefCell::new(HashMap::new()), - ranlib: RefCell::new(HashMap::new()), + cc: HashMap::new(), + cxx: HashMap::new(), + ar: HashMap::new(), + ranlib: HashMap::new(), + wasi_sdk_path: env::var_os("WASI_SDK_PATH").map(PathBuf::from), crates: HashMap::new(), crate_paths: HashMap::new(), is_sudo, @@ -498,7 +501,7 @@ impl Build { } build.verbose(|| println!("finding compilers")); - utils::cc_detect::find(&build); + utils::cc_detect::fill_compilers(&mut build); // When running `setup`, the profile is about to change, so any requirements we have now may // be different on the next invocation. Don't check for them until the next time x.py is // run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing. @@ -593,14 +596,6 @@ impl Build { } } - /// Updates all submodules, and exits with an error if submodule - /// management is disabled and the submodule does not exist. - pub fn require_and_update_all_submodules(&self) { - for submodule in build_helper::util::parse_gitmodules(&self.src) { - self.require_submodule(submodule, None); - } - } - /// If any submodule has been initialized already, sync it unconditionally. /// This avoids contributors checking in a submodule change by accident. fn update_existing_submodules(&self) { @@ -1143,17 +1138,17 @@ impl Build { if self.config.dry_run() { return PathBuf::new(); } - self.cc.borrow()[&target].path().into() + self.cc[&target].path().into() } /// Returns the internal `cc::Tool` for the C compiler. fn cc_tool(&self, target: TargetSelection) -> Tool { - self.cc.borrow()[&target].clone() + self.cc[&target].clone() } /// Returns the internal `cc::Tool` for the C++ compiler. fn cxx_tool(&self, target: TargetSelection) -> Tool { - self.cxx.borrow()[&target].clone() + self.cxx[&target].clone() } /// Returns C flags that `cc-rs` thinks should be enabled for the @@ -1163,8 +1158,8 @@ impl Build { return Vec::new(); } let base = match c { - CLang::C => self.cc.borrow()[&target].clone(), - CLang::Cxx => self.cxx.borrow()[&target].clone(), + CLang::C => self.cc[&target].clone(), + CLang::Cxx => self.cxx[&target].clone(), }; // Filter out -O and /O (the optimization flags) that we picked up @@ -1217,7 +1212,7 @@ impl Build { if self.config.dry_run() { return None; } - self.ar.borrow().get(&target).cloned() + self.ar.get(&target).cloned() } /// Returns the path to the `ranlib` utility for the target specified. @@ -1225,7 +1220,7 @@ impl Build { if self.config.dry_run() { return None; } - self.ranlib.borrow().get(&target).cloned() + self.ranlib.get(&target).cloned() } /// Returns the path to the C++ compiler for the target specified. @@ -1233,7 +1228,7 @@ impl Build { if self.config.dry_run() { return Ok(PathBuf::new()); } - match self.cxx.borrow().get(&target) { + match self.cxx.get(&target) { Some(p) => Ok(p.path().into()), None => Err(format!("target `{target}` is not configured as a host, only as a target")), } @@ -1250,7 +1245,7 @@ impl Build { } else if target.contains("vxworks") { // need to use CXX compiler as linker to resolve the exception functions // that are only existed in CXX libraries - Some(self.cxx.borrow()[&target].path().into()) + Some(self.cxx[&target].path().into()) } else if !self.config.is_host_target(target) && helpers::use_host_linker(target) && !target.is_msvc() diff --git a/src/bootstrap/src/utils/build_stamp/tests.rs b/src/bootstrap/src/utils/build_stamp/tests.rs index 2d7d1f7124655..f150266159a25 100644 --- a/src/bootstrap/src/utils/build_stamp/tests.rs +++ b/src/bootstrap/src/utils/build_stamp/tests.rs @@ -1,32 +1,28 @@ use std::path::PathBuf; -use crate::{BuildStamp, Config, Flags}; +use tempfile::TempDir; -fn temp_dir() -> PathBuf { - let config = - Config::parse(Flags::parse(&["check".to_owned(), "--config=/does/not/exist".to_owned()])); - config.tempdir() -} +use crate::{BuildStamp, Config, Flags}; #[test] #[should_panic(expected = "prefix can not start or end with '.'")] fn test_with_invalid_prefix() { - let dir = temp_dir(); - BuildStamp::new(&dir).with_prefix(".invalid"); + let dir = TempDir::new().unwrap(); + BuildStamp::new(dir.path()).with_prefix(".invalid"); } #[test] #[should_panic(expected = "prefix can not start or end with '.'")] fn test_with_invalid_prefix2() { - let dir = temp_dir(); - BuildStamp::new(&dir).with_prefix("invalid."); + let dir = TempDir::new().unwrap(); + BuildStamp::new(dir.path()).with_prefix("invalid."); } #[test] fn test_is_up_to_date() { - let dir = temp_dir(); + let dir = TempDir::new().unwrap(); - let mut build_stamp = BuildStamp::new(&dir).add_stamp("v1.0.0"); + let mut build_stamp = BuildStamp::new(dir.path()).add_stamp("v1.0.0"); build_stamp.write().unwrap(); assert!( @@ -45,9 +41,9 @@ fn test_is_up_to_date() { #[test] fn test_with_prefix() { - let dir = temp_dir(); + let dir = TempDir::new().unwrap(); - let stamp = BuildStamp::new(&dir).add_stamp("v1.0.0"); + let stamp = BuildStamp::new(dir.path()).add_stamp("v1.0.0"); assert_eq!(stamp.path.file_name().unwrap(), ".stamp"); let stamp = stamp.with_prefix("test"); diff --git a/src/bootstrap/src/utils/cache.rs b/src/bootstrap/src/utils/cache.rs index 46eeffad88c38..0c7374709584c 100644 --- a/src/bootstrap/src/utils/cache.rs +++ b/src/bootstrap/src/utils/cache.rs @@ -17,6 +17,7 @@ use std::borrow::Borrow; use std::cell::RefCell; use std::cmp::Ordering; use std::collections::HashMap; +use std::fmt::Debug; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; use std::ops::Deref; @@ -208,25 +209,30 @@ pub static INTERNER: LazyLock = LazyLock::new(Interner::default); /// any type in its output. It is a write-once cache; values are never evicted, /// which means that references to the value can safely be returned from the /// `get()` method. -#[derive(Debug)] -pub struct Cache( - RefCell< +#[derive(Debug, Default)] +pub struct Cache { + cache: RefCell< HashMap< TypeId, Box, // actually a HashMap> >, >, -); + #[cfg(test)] + /// Contains steps in the same order in which they were executed + /// Useful for tests + /// Tuples (step, step output) + executed_steps: RefCell, Box)>>, +} impl Cache { /// Creates a new empty cache. pub fn new() -> Cache { - Cache(RefCell::new(HashMap::new())) + Cache::default() } /// Stores the result of a computation step in the cache. pub fn put(&self, step: S, value: S::Output) { - let mut cache = self.0.borrow_mut(); + let mut cache = self.cache.borrow_mut(); let type_id = TypeId::of::(); let stepcache = cache .entry(type_id) @@ -234,12 +240,20 @@ impl Cache { .downcast_mut::>() .expect("invalid type mapped"); assert!(!stepcache.contains_key(&step), "processing {step:?} a second time"); + + #[cfg(test)] + { + let step: Box = Box::new(step.clone()); + let output: Box = Box::new(value.clone()); + self.executed_steps.borrow_mut().push((step, output)); + } + stepcache.insert(step, value); } /// Retrieves a cached result for the given step, if available. pub fn get(&self, step: &S) -> Option { - let mut cache = self.0.borrow_mut(); + let mut cache = self.cache.borrow_mut(); let type_id = TypeId::of::(); let stepcache = cache .entry(type_id) @@ -252,8 +266,8 @@ impl Cache { #[cfg(test)] impl Cache { - pub fn all(&mut self) -> Vec<(S, S::Output)> { - let cache = self.0.get_mut(); + pub fn all(&mut self) -> Vec<(S, S::Output)> { + let cache = self.cache.get_mut(); let type_id = TypeId::of::(); let mut v = cache .remove(&type_id) @@ -265,7 +279,12 @@ impl Cache { } pub fn contains(&self) -> bool { - self.0.borrow().contains_key(&TypeId::of::()) + self.cache.borrow().contains_key(&TypeId::of::()) + } + + #[cfg(test)] + pub fn into_executed_steps(mut self) -> Vec<(Box, Box)> { + mem::take(&mut self.executed_steps.borrow_mut()) } } diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 851bb38074ef7..dcafeb80f90ca 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -61,8 +61,8 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { /// /// This function determines which targets need a C compiler (and, if needed, a C++ compiler) /// by combining the primary build target, host targets, and any additional targets. For -/// each target, it calls [`find_target`] to configure the necessary compiler tools. -pub fn find(build: &Build) { +/// each target, it calls [`fill_target_compiler`] to configure the necessary compiler tools. +pub fn fill_compilers(build: &mut Build) { let targets: HashSet<_> = match build.config.cmd { // We don't need to check cross targets for these commands. crate::Subcommand::Clean { .. } @@ -87,7 +87,7 @@ pub fn find(build: &Build) { }; for target in targets.into_iter() { - find_target(build, target); + fill_target_compiler(build, target); } } @@ -96,7 +96,7 @@ pub fn find(build: &Build) { /// This function uses both user-specified configuration (from `bootstrap.toml`) and auto-detection /// logic to determine the correct C/C++ compilers for the target. It also determines the appropriate /// archiver (`ar`) and sets up additional compilation flags (both handled and unhandled). -pub fn find_target(build: &Build, target: TargetSelection) { +pub fn fill_target_compiler(build: &mut Build, target: TargetSelection) { let mut cfg = new_cc_build(build, target); let config = build.config.target_config.get(&target); if let Some(cc) = config @@ -113,7 +113,7 @@ pub fn find_target(build: &Build, target: TargetSelection) { cfg.try_get_archiver().map(|c| PathBuf::from(c.get_program())).ok() }; - build.cc.borrow_mut().insert(target, compiler.clone()); + build.cc.insert(target, compiler.clone()); let mut cflags = build.cc_handled_clags(target, CLang::C); cflags.extend(build.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C)); @@ -135,7 +135,7 @@ pub fn find_target(build: &Build, target: TargetSelection) { // for VxWorks, record CXX compiler which will be used in lib.rs:linker() if cxx_configured || target.contains("vxworks") { let compiler = cfg.get_compiler(); - build.cxx.borrow_mut().insert(target, compiler); + build.cxx.insert(target, compiler); } build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target))); @@ -148,11 +148,11 @@ pub fn find_target(build: &Build, target: TargetSelection) { } if let Some(ar) = ar { build.verbose(|| println!("AR_{} = {ar:?}", target.triple)); - build.ar.borrow_mut().insert(target, ar); + build.ar.insert(target, ar); } if let Some(ranlib) = config.and_then(|c| c.ranlib.clone()) { - build.ranlib.borrow_mut().insert(target, ranlib); + build.ranlib.insert(target, ranlib); } } @@ -221,7 +221,10 @@ fn default_compiler( } t if t.contains("-wasi") => { - let root = PathBuf::from(std::env::var_os("WASI_SDK_PATH")?); + let root = build + .wasi_sdk_path + .as_ref() + .expect("WASI_SDK_PATH mut be configured for a -wasi target"); let compiler = match compiler { Language::C => format!("{t}-clang"), Language::CPlusPlus => format!("{t}-clang++"), diff --git a/src/bootstrap/src/utils/cc_detect/tests.rs b/src/bootstrap/src/utils/cc_detect/tests.rs index 1f50738959fbb..bed03c18aaad4 100644 --- a/src/bootstrap/src/utils/cc_detect/tests.rs +++ b/src/bootstrap/src/utils/cc_detect/tests.rs @@ -77,11 +77,11 @@ fn test_new_cc_build() { #[test] fn test_default_compiler_wasi() { - let build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) }); + let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) }); let target = TargetSelection::from_user("wasm32-wasi"); let wasi_sdk = PathBuf::from("/wasi-sdk"); - // SAFETY: bootstrap tests run on a single thread - unsafe { env::set_var("WASI_SDK_PATH", &wasi_sdk) }; + build.wasi_sdk_path = Some(wasi_sdk.clone()); + let mut cfg = cc::Build::new(); if let Some(result) = default_compiler(&mut cfg, Language::C, target.clone(), &build) { let expected = { @@ -94,10 +94,6 @@ fn test_default_compiler_wasi() { "default_compiler should return a compiler path for wasi target when WASI_SDK_PATH is set" ); } - // SAFETY: bootstrap tests run on a single thread - unsafe { - env::remove_var("WASI_SDK_PATH"); - } } #[test] @@ -119,18 +115,14 @@ fn test_find_target_with_config() { target_config.ar = Some(PathBuf::from("dummy-ar")); target_config.ranlib = Some(PathBuf::from("dummy-ranlib")); build.config.target_config.insert(target.clone(), target_config); - find_target(&build, target.clone()); - let binding = build.cc.borrow(); - let cc_tool = binding.get(&target).unwrap(); + fill_target_compiler(&mut build, target.clone()); + let cc_tool = build.cc.get(&target).unwrap(); assert_eq!(cc_tool.path(), &PathBuf::from("dummy-cc")); - let binding = build.cxx.borrow(); - let cxx_tool = binding.get(&target).unwrap(); + let cxx_tool = build.cxx.get(&target).unwrap(); assert_eq!(cxx_tool.path(), &PathBuf::from("dummy-cxx")); - let binding = build.ar.borrow(); - let ar = binding.get(&target).unwrap(); + let ar = build.ar.get(&target).unwrap(); assert_eq!(ar, &PathBuf::from("dummy-ar")); - let binding = build.ranlib.borrow(); - let ranlib = binding.get(&target).unwrap(); + let ranlib = build.ranlib.get(&target).unwrap(); assert_eq!(ranlib, &PathBuf::from("dummy-ranlib")); } @@ -139,12 +131,12 @@ fn test_find_target_without_config() { let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["build".to_owned()])) }); let target = TargetSelection::from_user("x86_64-unknown-linux-gnu"); build.config.target_config.clear(); - find_target(&build, target.clone()); - assert!(build.cc.borrow().contains_key(&target)); + fill_target_compiler(&mut build, target.clone()); + assert!(build.cc.contains_key(&target)); if !target.triple.contains("vxworks") { - assert!(build.cxx.borrow().contains_key(&target)); + assert!(build.cxx.contains_key(&target)); } - assert!(build.ar.borrow().contains_key(&target)); + assert!(build.ar.contains_key(&target)); } #[test] @@ -154,8 +146,8 @@ fn test_find() { let target2 = TargetSelection::from_user("x86_64-unknown-openbsd"); build.targets.push(target1.clone()); build.hosts.push(target2.clone()); - find(&build); + fill_compilers(&mut build); for t in build.hosts.iter().chain(build.targets.iter()).chain(iter::once(&build.host_target)) { - assert!(build.cc.borrow().contains_key(t), "CC not set for target {}", t.triple); + assert!(build.cc.contains_key(t), "CC not set for target {}", t.triple); } } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 8b2f2dd431e17..f4be22f1e649e 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -98,7 +98,7 @@ pub fn is_dylib(path: &Path) -> bool { /// Return the path to the containing submodule if available. pub fn submodule_path_of(builder: &Builder<'_>, path: &str) -> Option { - let submodule_paths = build_helper::util::parse_gitmodules(&builder.src); + let submodule_paths = builder.submodule_paths(); submodule_paths.iter().find_map(|submodule_path| { if path.starts_with(submodule_path) { Some(submodule_path.to_string()) } else { None } }) diff --git a/src/bootstrap/src/utils/shared_helpers.rs b/src/bootstrap/src/utils/shared_helpers.rs index 561af34a4478b..9c6b4a7615d81 100644 --- a/src/bootstrap/src/utils/shared_helpers.rs +++ b/src/bootstrap/src/utils/shared_helpers.rs @@ -6,6 +6,9 @@ #![allow(dead_code)] +#[cfg(test)] +mod tests; + use std::env; use std::ffi::OsString; use std::fs::OpenOptions; diff --git a/src/bootstrap/src/utils/tests/shared_helpers_tests.rs b/src/bootstrap/src/utils/shared_helpers/tests.rs similarity index 73% rename from src/bootstrap/src/utils/tests/shared_helpers_tests.rs rename to src/bootstrap/src/utils/shared_helpers/tests.rs index 6c47e7f24387e..559e9f70abd2f 100644 --- a/src/bootstrap/src/utils/tests/shared_helpers_tests.rs +++ b/src/bootstrap/src/utils/shared_helpers/tests.rs @@ -1,10 +1,3 @@ -//! The `shared_helpers` module can't have its own tests submodule, because -//! that would cause problems for the shim binaries that include it via -//! `#[path]`, so instead those unit tests live here. -//! -//! To prevent tidy from complaining about this file not being named `tests.rs`, -//! it lives inside a submodule directory named `tests`. - use crate::utils::shared_helpers::parse_value_from_args; #[test] diff --git a/src/bootstrap/src/utils/tests/mod.rs b/src/bootstrap/src/utils/tests/mod.rs index 73d55db994cc0..73c500f6e3691 100644 --- a/src/bootstrap/src/utils/tests/mod.rs +++ b/src/bootstrap/src/utils/tests/mod.rs @@ -1,2 +1,3 @@ +//! This module contains shared utilities for bootstrap tests. + pub mod git; -mod shared_helpers_tests; diff --git a/src/build_helper/src/util.rs b/src/build_helper/src/util.rs index 72c05c4c48abf..80dd6813d136e 100644 --- a/src/build_helper/src/util.rs +++ b/src/build_helper/src/util.rs @@ -2,7 +2,6 @@ use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; use std::process::Command; -use std::sync::OnceLock; /// Invokes `build_helper::util::detail_exit` with `cfg!(test)` /// @@ -51,25 +50,20 @@ pub fn try_run(cmd: &mut Command, print_cmd_on_fail: bool) -> Result<(), ()> { } /// Returns the submodule paths from the `.gitmodules` file in the given directory. -pub fn parse_gitmodules(target_dir: &Path) -> &[String] { - static SUBMODULES_PATHS: OnceLock> = OnceLock::new(); +pub fn parse_gitmodules(target_dir: &Path) -> Vec { let gitmodules = target_dir.join(".gitmodules"); assert!(gitmodules.exists(), "'{}' file is missing.", gitmodules.display()); - let init_submodules_paths = || { - let file = File::open(gitmodules).unwrap(); + let file = File::open(gitmodules).unwrap(); - let mut submodules_paths = vec![]; - for line in BufReader::new(file).lines().map_while(Result::ok) { - let line = line.trim(); - if line.starts_with("path") { - let actual_path = line.split(' ').last().expect("Couldn't get value of path"); - submodules_paths.push(actual_path.to_owned()); - } + let mut submodules_paths = vec![]; + for line in BufReader::new(file).lines().map_while(Result::ok) { + let line = line.trim(); + if line.starts_with("path") { + let actual_path = line.split(' ').last().expect("Couldn't get value of path"); + submodules_paths.push(actual_path.to_owned()); } + } - submodules_paths - }; - - SUBMODULES_PATHS.get_or_init(|| init_submodules_paths()) + submodules_paths } diff --git a/src/tools/miri/cargo-miri/src/setup.rs b/src/tools/miri/cargo-miri/src/setup.rs index b9b58c04f9e4a..e399f66fbc9cd 100644 --- a/src/tools/miri/cargo-miri/src/setup.rs +++ b/src/tools/miri/cargo-miri/src/setup.rs @@ -83,7 +83,7 @@ pub fn setup( SysrootConfig::NoStd } else { SysrootConfig::WithStd { - std_features: ["panic_unwind", "backtrace"].into_iter().map(Into::into).collect(), + std_features: ["panic-unwind", "backtrace"].into_iter().map(Into::into).collect(), } }; let cargo_cmd = { diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index d4ba7fbd6a479..72057f812f962 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -295,6 +295,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls { level: SymbolExportLevel::C, kind: SymbolExportKind::Text, used: false, + rustc_std_internal_symbol: false, }, )) } else { diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 344e12e9fa349..048ed81a816f8 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -16,7 +16,7 @@ #![feature(unqualified_local_imports)] #![feature(derive_coerce_pointee)] #![feature(arbitrary_self_types)] -#![feature(file_lock)] +#![cfg_attr(bootstrap, feature(file_lock))] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index 2f30827c9336b..9d5725773e647 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -2,7 +2,6 @@ #![feature(io_error_more)] #![feature(io_error_uncategorized)] -#![feature(file_lock)] use std::collections::BTreeMap; use std::ffi::OsString; diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs index 543ac0619dd3e..385c98ef87784 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs @@ -486,7 +486,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_legacy_const_generics, Normal, template!(List: "N"), ErrorFollowing, INTERNAL_UNSTABLE ), - // Do not const-check this function's body. It will always get replaced during CTFE. + // Do not const-check this function's body. It will always get replaced during CTFE via `hook_special_const_fn`. rustc_attr!( rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE ), diff --git a/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs b/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs index ba887b3d791d1..8824a498306e4 100644 --- a/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs +++ b/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std // ignore-tidy-linelength // Check that the `CURRENT_RUSTC_VERSION` placeholder is correctly replaced by the current diff --git a/tests/run-make/allow-warnings-cmdline-stability/rmake.rs b/tests/run-make/allow-warnings-cmdline-stability/rmake.rs index 22a31266176b4..66ca3eb3383bd 100644 --- a/tests/run-make/allow-warnings-cmdline-stability/rmake.rs +++ b/tests/run-make/allow-warnings-cmdline-stability/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std // Test that `-Awarnings` suppresses warnings for unstable APIs. use run_make_support::rustc; diff --git a/tests/run-make/artifact-incr-cache-no-obj/rmake.rs b/tests/run-make/artifact-incr-cache-no-obj/rmake.rs index d5bc46dff4706..8395b38f6125a 100644 --- a/tests/run-make/artifact-incr-cache-no-obj/rmake.rs +++ b/tests/run-make/artifact-incr-cache-no-obj/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // emitting an object file is not necessary if user didn't ask for one // // This test is similar to run-make/artifact-incr-cache but it doesn't diff --git a/tests/run-make/artifact-incr-cache/rmake.rs b/tests/run-make/artifact-incr-cache/rmake.rs index b4b63313cfc40..670c851e1e007 100644 --- a/tests/run-make/artifact-incr-cache/rmake.rs +++ b/tests/run-make/artifact-incr-cache/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // rustc should be able to emit required files (asm, llvm-*, etc) during incremental // compilation on the first pass by running the code gen as well as on subsequent runs - // extracting them from the cache diff --git a/tests/run-make/bin-emit-no-symbols/rmake.rs b/tests/run-make/bin-emit-no-symbols/rmake.rs index 5586e53c05084..2faeb20025bb7 100644 --- a/tests/run-make/bin-emit-no-symbols/rmake.rs +++ b/tests/run-make/bin-emit-no-symbols/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When setting the crate type as a "bin" (in app.rs), // this could cause a bug where some symbols would not be // emitted in the object files. This has been fixed, and diff --git a/tests/run-make/box-struct-no-segfault/rmake.rs b/tests/run-make/box-struct-no-segfault/rmake.rs index 1bbefd03541a2..06dcf61e9ccd8 100644 --- a/tests/run-make/box-struct-no-segfault/rmake.rs +++ b/tests/run-make/box-struct-no-segfault/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // The crate "foo" tied to this test executes a very specific function, // which involves boxing an instance of the struct Foo. However, // this once caused a segmentation fault in cargo release builds due to an LLVM diff --git a/tests/run-make/checksum-freshness/rmake.rs b/tests/run-make/checksum-freshness/rmake.rs index 071db6b145b51..60e4f81269b17 100644 --- a/tests/run-make/checksum-freshness/rmake.rs +++ b/tests/run-make/checksum-freshness/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{rfs, rustc}; fn main() { diff --git a/tests/run-make/compiler-lookup-paths-2/rmake.rs b/tests/run-make/compiler-lookup-paths-2/rmake.rs index 99efb157b5378..5401787b9bf98 100644 --- a/tests/run-make/compiler-lookup-paths-2/rmake.rs +++ b/tests/run-make/compiler-lookup-paths-2/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test checks that extern crate declarations in Cargo without a corresponding declaration // in the manifest of a dependency are NOT allowed. The last rustc call does it anyways, which // should result in a compilation failure. diff --git a/tests/run-make/compiler-lookup-paths/rmake.rs b/tests/run-make/compiler-lookup-paths/rmake.rs index 3ffa6e0592f0c..0e00f9b340019 100644 --- a/tests/run-make/compiler-lookup-paths/rmake.rs +++ b/tests/run-make/compiler-lookup-paths/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Since #19941, rustc can accept specifications on its library search paths. // This test runs Rust programs with varied library dependencies, expecting them // to succeed or fail depending on the situation. diff --git a/tests/run-make/const-trait-stable-toolchain/rmake.rs b/tests/run-make/const-trait-stable-toolchain/rmake.rs index 241de11ed59ca..09a7c27a1064a 100644 --- a/tests/run-make/const-trait-stable-toolchain/rmake.rs +++ b/tests/run-make/const-trait-stable-toolchain/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Test output of const super trait errors in both stable and nightly. // We don't want to provide suggestions on stable that only make sense in nightly. diff --git a/tests/run-make/crate-circular-deps-link/rmake.rs b/tests/run-make/crate-circular-deps-link/rmake.rs index 7cc28ac93e148..6771fdec7e8a9 100644 --- a/tests/run-make/crate-circular-deps-link/rmake.rs +++ b/tests/run-make/crate-circular-deps-link/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Test that previously triggered a linker failure with root cause // similar to one found in the issue #69368. // diff --git a/tests/run-make/cross-lang-lto-upstream-rlibs/rmake.rs b/tests/run-make/cross-lang-lto-upstream-rlibs/rmake.rs index f0b8fa75bee3e..7fb0f6903974c 100644 --- a/tests/run-make/cross-lang-lto-upstream-rlibs/rmake.rs +++ b/tests/run-make/cross-lang-lto-upstream-rlibs/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When using the flag -C linker-plugin-lto, static libraries could lose their upstream object // files during compilation. This bug was fixed in #53031, and this test compiles a staticlib // dependent on upstream, checking that the upstream object file still exists after no LTO and diff --git a/tests/run-make/cross-lang-lto/rmake.rs b/tests/run-make/cross-lang-lto/rmake.rs index 50d37460d8dbb..8773070b1a9e7 100644 --- a/tests/run-make/cross-lang-lto/rmake.rs +++ b/tests/run-make/cross-lang-lto/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test checks that the object files we generate are actually // LLVM bitcode files (as used by linker LTO plugins) when compiling with // -Clinker-plugin-lto. diff --git a/tests/run-make/debugger-visualizer-dep-info/rmake.rs b/tests/run-make/debugger-visualizer-dep-info/rmake.rs index f5cf39157ac65..95a095e49d842 100644 --- a/tests/run-make/debugger-visualizer-dep-info/rmake.rs +++ b/tests/run-make/debugger-visualizer-dep-info/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test checks that files referenced via #[debugger_visualizer] are // included in `--emit dep-info` output. // See https://github.com/rust-lang/rust/pull/111641 diff --git a/tests/run-make/dep-info/rmake.rs b/tests/run-make/dep-info/rmake.rs index 508569b7671c1..8cef6e87f7cfb 100644 --- a/tests/run-make/dep-info/rmake.rs +++ b/tests/run-make/dep-info/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This is a simple smoke test for rustc's `--emit dep-info` feature. It prints out // information about dependencies in a Makefile-compatible format, as a `.d` file. // Note that this test does not check that the `.d` file is Makefile-compatible. diff --git a/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs b/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs index 32c4cf3389647..5bc0a0c9519fd 100644 --- a/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs +++ b/tests/run-make/diagnostics-traits-from-duplicate-crates/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Non-regression test for issue #132920 where multiple versions of the same crate are present in // the dependency graph, and an unexpected error in a dependent crate caused an ICE in the // unsatisfied bounds diagnostics for traits present in multiple crate versions. diff --git a/tests/run-make/doctests-merge/rmake.rs b/tests/run-make/doctests-merge/rmake.rs index a88b050c50fa8..8236997d72d71 100644 --- a/tests/run-make/doctests-merge/rmake.rs +++ b/tests/run-make/doctests-merge/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use std::path::Path; use run_make_support::{cwd, diff, rustc, rustdoc}; diff --git a/tests/run-make/doctests-runtool/rmake.rs b/tests/run-make/doctests-runtool/rmake.rs index 817001c514b52..aaba417491028 100644 --- a/tests/run-make/doctests-runtool/rmake.rs +++ b/tests/run-make/doctests-runtool/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Tests behavior of rustdoc `--test-runtool`. use std::path::PathBuf; diff --git a/tests/run-make/dump-mono-stats/rmake.rs b/tests/run-make/dump-mono-stats/rmake.rs index f4142e0a31c3e..8ebc5758d9d79 100644 --- a/tests/run-make/dump-mono-stats/rmake.rs +++ b/tests/run-make/dump-mono-stats/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // A flag named dump-mono-stats was added to the compiler in 2022, which // collects stats on instantiation of items and their associated costs. // This test checks that the output stat file exists, and that it contains diff --git a/tests/run-make/duplicate-output-flavors/rmake.rs b/tests/run-make/duplicate-output-flavors/rmake.rs index 09545228807bc..f07339aceb92b 100644 --- a/tests/run-make/duplicate-output-flavors/rmake.rs +++ b/tests/run-make/duplicate-output-flavors/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::rustc; fn main() { diff --git a/tests/run-make/embed-metadata/rmake.rs b/tests/run-make/embed-metadata/rmake.rs index acefb18648440..a41716d15429c 100644 --- a/tests/run-make/embed-metadata/rmake.rs +++ b/tests/run-make/embed-metadata/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Tests the -Zembed-metadata compiler flag. // Tracking issue: https://github.com/rust-lang/rust/issues/139165 diff --git a/tests/run-make/embed-source-dwarf/rmake.rs b/tests/run-make/embed-source-dwarf/rmake.rs index 550c8b9b3c903..99fad359054b6 100644 --- a/tests/run-make/embed-source-dwarf/rmake.rs +++ b/tests/run-make/embed-source-dwarf/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std //@ ignore-windows //@ ignore-apple diff --git a/tests/run-make/emit-named-files/rmake.rs b/tests/run-make/emit-named-files/rmake.rs index 1570e1adc2561..b482fb3268b9e 100644 --- a/tests/run-make/emit-named-files/rmake.rs +++ b/tests/run-make/emit-named-files/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use std::path::Path; use run_make_support::{rfs, rustc}; diff --git a/tests/run-make/emit-path-unhashed/rmake.rs b/tests/run-make/emit-path-unhashed/rmake.rs index a97153e37dd9c..5d5256621ceaf 100644 --- a/tests/run-make/emit-path-unhashed/rmake.rs +++ b/tests/run-make/emit-path-unhashed/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Specifying how rustc outputs a file can be done in different ways, such as // the output flag or the KIND=NAME syntax. However, some of these methods used // to result in different hashes on output files even though they yielded the diff --git a/tests/run-make/emit-stack-sizes/rmake.rs b/tests/run-make/emit-stack-sizes/rmake.rs index 53cc9ee5943f8..886e875cfae8c 100644 --- a/tests/run-make/emit-stack-sizes/rmake.rs +++ b/tests/run-make/emit-stack-sizes/rmake.rs @@ -6,6 +6,7 @@ // this diagnostics information should be located. // See https://github.com/rust-lang/rust/pull/51946 +//@ needs-target-std //@ ignore-windows //@ ignore-apple // Reason: this feature only works when the output object format is ELF. diff --git a/tests/run-make/emit-to-stdout/rmake.rs b/tests/run-make/emit-to-stdout/rmake.rs index a9a3796731b4b..19c15b72fe475 100644 --- a/tests/run-make/emit-to-stdout/rmake.rs +++ b/tests/run-make/emit-to-stdout/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std //! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout //! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`) //! being written this way will result in an error if stdout is a tty. diff --git a/tests/run-make/env-dep-info/rmake.rs b/tests/run-make/env-dep-info/rmake.rs index 5b51a5476f491..97006a632057a 100644 --- a/tests/run-make/env-dep-info/rmake.rs +++ b/tests/run-make/env-dep-info/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Inside dep-info emit files, #71858 made it so all accessed environment // variables are usefully printed. This test checks that this feature works // as intended by checking if the environment variables used in compilation diff --git a/tests/run-make/error-found-staticlib-instead-crate/rmake.rs b/tests/run-make/error-found-staticlib-instead-crate/rmake.rs index 8c707092b7e44..15f09c83e2007 100644 --- a/tests/run-make/error-found-staticlib-instead-crate/rmake.rs +++ b/tests/run-make/error-found-staticlib-instead-crate/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When rustc is looking for a crate but is given a staticlib instead, // the error message should be helpful and indicate precisely the cause // of the compilation failure. diff --git a/tests/run-make/exit-code/rmake.rs b/tests/run-make/exit-code/rmake.rs index d3dcc04428cb6..5fdf920b55a69 100644 --- a/tests/run-make/exit-code/rmake.rs +++ b/tests/run-make/exit-code/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Test that we exit with the correct exit code for successful / unsuccessful / ICE compilations use run_make_support::{rustc, rustdoc}; diff --git a/tests/run-make/export/disambiguator/rmake.rs b/tests/run-make/export/disambiguator/rmake.rs index 743db1933fb4e..f855e42d08ee8 100644 --- a/tests/run-make/export/disambiguator/rmake.rs +++ b/tests/run-make/export/disambiguator/rmake.rs @@ -1,12 +1,7 @@ +//@ needs-target-std use run_make_support::rustc; fn main() { - rustc() - .env("RUSTC_FORCE_RUSTC_VERSION", "1") - .input("libr.rs") - .run(); - rustc() - .env("RUSTC_FORCE_RUSTC_VERSION", "2") - .input("app.rs") - .run(); + rustc().env("RUSTC_FORCE_RUSTC_VERSION", "1").input("libr.rs").run(); + rustc().env("RUSTC_FORCE_RUSTC_VERSION", "2").input("app.rs").run(); } diff --git a/tests/run-make/export/extern-opt/rmake.rs b/tests/run-make/export/extern-opt/rmake.rs index 821e2eb214919..a2f9ba28c2f5c 100644 --- a/tests/run-make/export/extern-opt/rmake.rs +++ b/tests/run-make/export/extern-opt/rmake.rs @@ -1,10 +1,8 @@ -use run_make_support::{rustc, dynamic_lib_name}; +//@ needs-target-std +use run_make_support::{dynamic_lib_name, rustc}; fn main() { - rustc() - .env("RUSTC_FORCE_RUSTC_VERSION", "1") - .input("libr.rs") - .run(); + rustc().env("RUSTC_FORCE_RUSTC_VERSION", "1").input("libr.rs").run(); rustc() .env("RUSTC_FORCE_RUSTC_VERSION", "2") diff --git a/tests/run-make/export/simple/rmake.rs b/tests/run-make/export/simple/rmake.rs index 743db1933fb4e..f855e42d08ee8 100644 --- a/tests/run-make/export/simple/rmake.rs +++ b/tests/run-make/export/simple/rmake.rs @@ -1,12 +1,7 @@ +//@ needs-target-std use run_make_support::rustc; fn main() { - rustc() - .env("RUSTC_FORCE_RUSTC_VERSION", "1") - .input("libr.rs") - .run(); - rustc() - .env("RUSTC_FORCE_RUSTC_VERSION", "2") - .input("app.rs") - .run(); + rustc().env("RUSTC_FORCE_RUSTC_VERSION", "1").input("libr.rs").run(); + rustc().env("RUSTC_FORCE_RUSTC_VERSION", "2").input("app.rs").run(); } diff --git a/tests/run-make/extern-diff-internal-name/rmake.rs b/tests/run-make/extern-diff-internal-name/rmake.rs index 1a7f34d65bc2a..1bae8decb0528 100644 --- a/tests/run-make/extern-diff-internal-name/rmake.rs +++ b/tests/run-make/extern-diff-internal-name/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In the following scenario: // 1. The crate foo, is referenced multiple times // 2. --extern foo=./path/to/libbar.rlib is specified to rustc diff --git a/tests/run-make/extern-flag-fun/rmake.rs b/tests/run-make/extern-flag-fun/rmake.rs index c1825f6bbb888..181a76b7cfa0c 100644 --- a/tests/run-make/extern-flag-fun/rmake.rs +++ b/tests/run-make/extern-flag-fun/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // The --extern flag can override the default crate search of // the compiler and directly fetch a given path. There are a few rules // to follow: for example, there can't be more than one rlib, the crates must diff --git a/tests/run-make/extern-flag-rename-transitive/rmake.rs b/tests/run-make/extern-flag-rename-transitive/rmake.rs index 0090d487f03d6..c5bff7bbb696a 100644 --- a/tests/run-make/extern-flag-rename-transitive/rmake.rs +++ b/tests/run-make/extern-flag-rename-transitive/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In this test, baz.rs is looking for an extern crate "a" which // does not exist, and can only run through the --extern rustc flag // defining that the "a" crate is in fact just "foo". This test diff --git a/tests/run-make/extern-multiple-copies/rmake.rs b/tests/run-make/extern-multiple-copies/rmake.rs index 8b67e6d9facfc..d9d769d178c37 100644 --- a/tests/run-make/extern-multiple-copies/rmake.rs +++ b/tests/run-make/extern-multiple-copies/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In this test, the rust library foo1 exists in two different locations, but only one // is required by the --extern flag. This test checks that the copy is ignored (as --extern // demands fetching only the original instance of foo1) and that no error is emitted, resulting diff --git a/tests/run-make/extern-multiple-copies2/rmake.rs b/tests/run-make/extern-multiple-copies2/rmake.rs index 59913bfa42bb5..4188d5bdc182f 100644 --- a/tests/run-make/extern-multiple-copies2/rmake.rs +++ b/tests/run-make/extern-multiple-copies2/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Almost identical to `extern-multiple-copies`, but with a variation in the --extern calls // and the addition of #[macro_use] in the rust code files, which used to break --extern // until #33625. diff --git a/tests/run-make/ice-static-mir/rmake.rs b/tests/run-make/ice-static-mir/rmake.rs index 2d4ffa379b62b..b6a04bf877e7f 100644 --- a/tests/run-make/ice-static-mir/rmake.rs +++ b/tests/run-make/ice-static-mir/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Trying to access mid-level internal representation (MIR) in statics // used to cause an internal compiler error (ICE), now handled as a proper // error since #100211. This test checks that the correct error is printed diff --git a/tests/run-make/include-all-symbols-linking/rmake.rs b/tests/run-make/include-all-symbols-linking/rmake.rs index bab510fb5be3c..4f85ee179f5f6 100644 --- a/tests/run-make/include-all-symbols-linking/rmake.rs +++ b/tests/run-make/include-all-symbols-linking/rmake.rs @@ -7,6 +7,7 @@ // See https://github.com/rust-lang/rust/pull/95604 // See https://github.com/rust-lang/rust/issues/47384 +//@ needs-target-std //@ ignore-wasm differences in object file formats causes errors in the llvm_objdump step. //@ ignore-windows differences in object file formats causes errors in the llvm_objdump step. diff --git a/tests/run-make/include-bytes-deps/rmake.rs b/tests/run-make/include-bytes-deps/rmake.rs index ea371ddae5675..2938f334243f1 100644 --- a/tests/run-make/include-bytes-deps/rmake.rs +++ b/tests/run-make/include-bytes-deps/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // include_bytes! and include_str! in `main.rs` // should register the included file as of #24423, // and this test checks that this is still the case. diff --git a/tests/run-make/incremental-debugger-visualizer/rmake.rs b/tests/run-make/incremental-debugger-visualizer/rmake.rs index 07c920cc04a6f..3a4fc1d179294 100644 --- a/tests/run-make/incremental-debugger-visualizer/rmake.rs +++ b/tests/run-make/incremental-debugger-visualizer/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test ensures that changes to files referenced via #[debugger_visualizer] // (in this case, foo.py and foo.natvis) are picked up when compiling incrementally. // See https://github.com/rust-lang/rust/pull/111641 diff --git a/tests/run-make/inline-always-many-cgu/rmake.rs b/tests/run-make/inline-always-many-cgu/rmake.rs index 678b949bc700d..18068578dd04e 100644 --- a/tests/run-make/inline-always-many-cgu/rmake.rs +++ b/tests/run-make/inline-always-many-cgu/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use std::ffi::OsStr; use run_make_support::regex::Regex; diff --git a/tests/run-make/invalid-so/rmake.rs b/tests/run-make/invalid-so/rmake.rs index 754c53a49b924..ee886b5ee3a6d 100644 --- a/tests/run-make/invalid-so/rmake.rs +++ b/tests/run-make/invalid-so/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When a fake library was given to the compiler, it would // result in an obscure and unhelpful error message. This test // creates a false "foo" dylib, and checks that the standard error diff --git a/tests/run-make/invalid-staticlib/rmake.rs b/tests/run-make/invalid-staticlib/rmake.rs index ba9e07dd07b8f..4844bff329aca 100644 --- a/tests/run-make/invalid-staticlib/rmake.rs +++ b/tests/run-make/invalid-staticlib/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // If the static library provided is not valid (in this test, // created as an empty file), // rustc should print a normal error message and not throw diff --git a/tests/run-make/invalid-symlink-search-path/rmake.rs b/tests/run-make/invalid-symlink-search-path/rmake.rs index 7b7e7c7944219..4eb6e6f770694 100644 --- a/tests/run-make/invalid-symlink-search-path/rmake.rs +++ b/tests/run-make/invalid-symlink-search-path/rmake.rs @@ -5,6 +5,7 @@ // // See https://github.com/rust-lang/rust/issues/26006 +//@ needs-target-std //@ needs-symlink //Reason: symlink requires elevated permission in Windows diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-env-var/rmake.rs index db44debb319eb..c5b9dca33a940 100644 --- a/tests/run-make/invalid-tmpdir-env-var/rmake.rs +++ b/tests/run-make/invalid-tmpdir-env-var/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When the TMP (on Windows) or TMPDIR (on Unix) variable is set to an invalid // or non-existing directory, this used to cause an internal compiler error (ICE). After the // addition of proper error handling in #28430, this test checks that the expected message is diff --git a/tests/run-make/issue-107495-archive-permissions/rmake.rs b/tests/run-make/issue-107495-archive-permissions/rmake.rs index 87d4faaa77a2e..80474ba32c2ed 100644 --- a/tests/run-make/issue-107495-archive-permissions/rmake.rs +++ b/tests/run-make/issue-107495-archive-permissions/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::Path; diff --git a/tests/run-make/issue-125484-used-dependencies/rmake.rs b/tests/run-make/issue-125484-used-dependencies/rmake.rs index bc0a18de66e7e..afcea34783f9a 100644 --- a/tests/run-make/issue-125484-used-dependencies/rmake.rs +++ b/tests/run-make/issue-125484-used-dependencies/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Non-regression test for issues #125474, #125484, #125646, with the repro taken from #125484. Some // queries use "used dependencies" while others use "speculatively loaded dependencies", and an // indexing ICE appeared in some cases when these were unexpectedly used in the same context. diff --git a/tests/run-make/json-error-no-offset/rmake.rs b/tests/run-make/json-error-no-offset/rmake.rs index 629d9c4c16e44..3f45778ca04a1 100644 --- a/tests/run-make/json-error-no-offset/rmake.rs +++ b/tests/run-make/json-error-no-offset/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // The byte positions in json format error logging used to have a small, difficult // to predict offset. This was changed to be the top of the file every time in #42973, // and this test checks that the measurements appearing in the standard error are correct. diff --git a/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs b/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs index 0c5e12055e815..af42911502e08 100644 --- a/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs +++ b/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Inside a library, implementing a trait for another trait // with a lifetime used to cause an internal compiler error (ICE). // This test checks that this bug does not make a resurgence - diff --git a/tests/run-make/link-arg/rmake.rs b/tests/run-make/link-arg/rmake.rs index c0bf8d972af73..bfceaae0dba6f 100644 --- a/tests/run-make/link-arg/rmake.rs +++ b/tests/run-make/link-arg/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In 2016, the rustc flag "-C link-arg" was introduced - it can be repeatedly used // to add single arguments to the linker. This test passes 2 arguments to the linker using it, // then checks that the compiler's output contains the arguments passed to it. diff --git a/tests/run-make/link-args-order/rmake.rs b/tests/run-make/link-args-order/rmake.rs index fe0d02926eff4..a4591ea3949e0 100644 --- a/tests/run-make/link-args-order/rmake.rs +++ b/tests/run-make/link-args-order/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Passing linker arguments to the compiler used to be lost or reordered in a messy way // as they were passed further to the linker. This was fixed in #70665, and this test // checks that linker arguments remain intact and in the order they were originally passed in. diff --git a/tests/run-make/link-dedup/rmake.rs b/tests/run-make/link-dedup/rmake.rs index f38603dee8cbb..0148817f98784 100644 --- a/tests/run-make/link-dedup/rmake.rs +++ b/tests/run-make/link-dedup/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When native libraries are passed to the linker, there used to be an annoyance // where multiple instances of the same library in a row would cause duplication in // outputs. This has been fixed, and this test checks that it stays fixed. diff --git a/tests/run-make/linker-warning/rmake.rs b/tests/run-make/linker-warning/rmake.rs index bc21739fefc6e..eb1bbbff8ef01 100644 --- a/tests/run-make/linker-warning/rmake.rs +++ b/tests/run-make/linker-warning/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{Rustc, diff, regex, rustc}; fn run_rustc() -> Rustc { diff --git a/tests/run-make/llvm-outputs/rmake.rs b/tests/run-make/llvm-outputs/rmake.rs index 2ce31b260a164..dabae38c141c9 100644 --- a/tests/run-make/llvm-outputs/rmake.rs +++ b/tests/run-make/llvm-outputs/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std // test that directories get created when emitting llvm bitcode and IR use std::path::PathBuf; diff --git a/tests/run-make/lto-avoid-object-duplication/rmake.rs b/tests/run-make/lto-avoid-object-duplication/rmake.rs index b0e7494cb5132..394aed2b881f9 100644 --- a/tests/run-make/lto-avoid-object-duplication/rmake.rs +++ b/tests/run-make/lto-avoid-object-duplication/rmake.rs @@ -8,6 +8,7 @@ // This test makes sure that functions defined in the upstream crates do not // appear twice in the final staticlib when listing all the symbols from it. +//@ needs-target-std //@ ignore-windows // Reason: `llvm-objdump`'s output looks different on windows than on other platforms. // Only checking on Unix platforms should suffice. diff --git a/tests/run-make/manual-crate-name/rmake.rs b/tests/run-make/manual-crate-name/rmake.rs index 9f480ec6b6af2..ead3b669e2da8 100644 --- a/tests/run-make/manual-crate-name/rmake.rs +++ b/tests/run-make/manual-crate-name/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{path, rustc}; fn main() { diff --git a/tests/run-make/many-crates-but-no-match/rmake.rs b/tests/run-make/many-crates-but-no-match/rmake.rs index 938ffce6a036c..449b6e2908d06 100644 --- a/tests/run-make/many-crates-but-no-match/rmake.rs +++ b/tests/run-make/many-crates-but-no-match/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // An extended version of the ui/changing-crates.rs test, this test puts // multiple mismatching crates into the search path of crateC (A2 and A3) // and checks that the standard error contains helpful messages to indicate diff --git a/tests/run-make/metadata-dep-info/rmake.rs b/tests/run-make/metadata-dep-info/rmake.rs index f4bb3ea63fb16..82fa4c014e177 100644 --- a/tests/run-make/metadata-dep-info/rmake.rs +++ b/tests/run-make/metadata-dep-info/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Emitting dep-info alongside metadata would present subtle discrepancies // in the output file, such as the filename transforming underscores_ into hyphens-. // After the fix in #114750, this test checks that the emitted files are identical diff --git a/tests/run-make/metadata-only-crate-no-ice/rmake.rs b/tests/run-make/metadata-only-crate-no-ice/rmake.rs index e6f852fca413a..2e771d8793330 100644 --- a/tests/run-make/metadata-only-crate-no-ice/rmake.rs +++ b/tests/run-make/metadata-only-crate-no-ice/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In a dependency hierarchy, metadata-only crates could cause an Internal // Compiler Error (ICE) due to a compiler bug - not correctly fetching sources for // metadata-only crates. This test is a minimal reproduction of a program that triggered diff --git a/tests/run-make/missing-crate-dependency/rmake.rs b/tests/run-make/missing-crate-dependency/rmake.rs index dae77032f7d4a..7abdd11c50988 100644 --- a/tests/run-make/missing-crate-dependency/rmake.rs +++ b/tests/run-make/missing-crate-dependency/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // A simple smoke test to check that rustc fails compilation // and outputs a helpful message when a dependency is missing // in a dependency chain. diff --git a/tests/run-make/multiple-emits/rmake.rs b/tests/run-make/multiple-emits/rmake.rs index 8a5eb1d9d856a..d8a008660c063 100644 --- a/tests/run-make/multiple-emits/rmake.rs +++ b/tests/run-make/multiple-emits/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{path, rustc}; fn main() { diff --git a/tests/run-make/native-lib-alt-naming/rmake.rs b/tests/run-make/native-lib-alt-naming/rmake.rs index d1ea0fc868767..a1dc002533f5f 100644 --- a/tests/run-make/native-lib-alt-naming/rmake.rs +++ b/tests/run-make/native-lib-alt-naming/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // On MSVC the alternative naming format for static libraries (`libfoo.a`) is accepted in addition // to the default format (`foo.lib`). diff --git a/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs b/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs index 6868cb368ccc3..e06be13d9b95c 100644 --- a/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs +++ b/tests/run-make/native-link-modifier-verbatim-linker/rmake.rs @@ -3,6 +3,7 @@ // This test is the same as native-link-modifier-rustc, but without rlibs. // See https://github.com/rust-lang/rust/issues/99425 +//@ needs-target-std //@ ignore-apple // Reason: linking fails due to the unusual ".ext" staticlib name. diff --git a/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs b/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs index 703b8a80ef3ed..d885df9e79eb4 100644 --- a/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs +++ b/tests/run-make/native-link-modifier-verbatim-rustc/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // `verbatim` is a native link modifier that forces rustc to only accept libraries with // a specified name. This test checks that this modifier works as intended. // This test is the same as native-link-modifier-linker, but with rlibs. diff --git a/tests/run-make/no-builtins-attribute/rmake.rs b/tests/run-make/no-builtins-attribute/rmake.rs index 7182c65a2c59e..038958f19ed9d 100644 --- a/tests/run-make/no-builtins-attribute/rmake.rs +++ b/tests/run-make/no-builtins-attribute/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // `no_builtins` is an attribute related to LLVM's optimizations. In order to ensure that it has an // effect on link-time optimizations (LTO), it should be added to function declarations in a crate. // This test uses the `llvm-filecheck` tool to determine that this attribute is successfully diff --git a/tests/run-make/no-builtins-lto/rmake.rs b/tests/run-make/no-builtins-lto/rmake.rs index 56fdfde42f04d..a1d9dc43e713d 100644 --- a/tests/run-make/no-builtins-lto/rmake.rs +++ b/tests/run-make/no-builtins-lto/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // The rlib produced by a no_builtins crate should be explicitly linked // during compilation, and as a result be present in the linker arguments. // See the comments inside this file for more details. diff --git a/tests/run-make/non-unicode-env/rmake.rs b/tests/run-make/non-unicode-env/rmake.rs index d708192908c1c..b7a3c51db5bfd 100644 --- a/tests/run-make/non-unicode-env/rmake.rs +++ b/tests/run-make/non-unicode-env/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{rfs, rustc}; fn main() { diff --git a/tests/run-make/non-unicode-in-incremental-dir/rmake.rs b/tests/run-make/non-unicode-in-incremental-dir/rmake.rs index 42bd4b1b79990..5c437a3fe00c0 100644 --- a/tests/run-make/non-unicode-in-incremental-dir/rmake.rs +++ b/tests/run-make/non-unicode-in-incremental-dir/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{rfs, rustc}; fn main() { diff --git a/tests/run-make/notify-all-emit-artifacts/rmake.rs b/tests/run-make/notify-all-emit-artifacts/rmake.rs index 321eda489410e..5896cffefcce4 100644 --- a/tests/run-make/notify-all-emit-artifacts/rmake.rs +++ b/tests/run-make/notify-all-emit-artifacts/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // rust should produce artifact notifications about files it was asked to --emit. // // It should work in incremental mode both on the first pass where files are generated as well diff --git a/tests/run-make/optimization-remarks-dir/rmake.rs b/tests/run-make/optimization-remarks-dir/rmake.rs index afcb8c3e3ebdb..df656302d789c 100644 --- a/tests/run-make/optimization-remarks-dir/rmake.rs +++ b/tests/run-make/optimization-remarks-dir/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In this test, the function `bar` has #[inline(never)] and the function `foo` // does not. This test outputs LLVM optimization remarks twice - first for all // functions (including `bar`, and the `inline` mention), and then for only `foo` diff --git a/tests/run-make/overwrite-input/rmake.rs b/tests/run-make/overwrite-input/rmake.rs index b87a7c7e0a851..bdf7860caa8a0 100644 --- a/tests/run-make/overwrite-input/rmake.rs +++ b/tests/run-make/overwrite-input/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // An attempt to set the output `-o` into a directory or a file we cannot write into should indeed // be an error; but not an ICE (Internal Compiler Error). This test attempts both and checks // that the standard error matches what is expected. diff --git a/tests/run-make/parallel-rustc-no-overwrite/rmake.rs b/tests/run-make/parallel-rustc-no-overwrite/rmake.rs index aa38eb664cf5e..f7531ab4bf697 100644 --- a/tests/run-make/parallel-rustc-no-overwrite/rmake.rs +++ b/tests/run-make/parallel-rustc-no-overwrite/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When two instances of rustc are invoked in parallel, they // can conflict on their temporary files and overwrite each others', // leading to unsuccessful compilation. The -Z temps-dir flag adds diff --git a/tests/run-make/pass-linker-flags-from-dep/rmake.rs b/tests/run-make/pass-linker-flags-from-dep/rmake.rs index 4b8e0486e1427..1cd55468737dd 100644 --- a/tests/run-make/pass-linker-flags-from-dep/rmake.rs +++ b/tests/run-make/pass-linker-flags-from-dep/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // A similar test to pass-linker-flags, testing that the `-l link-arg` flag // respects the order relative to other `-l` flags, but this time, the flags // are passed on the compilation of a dependency. This test checks that the diff --git a/tests/run-make/pass-linker-flags/rmake.rs b/tests/run-make/pass-linker-flags/rmake.rs index de69567a6e60c..a44da7b32ff85 100644 --- a/tests/run-make/pass-linker-flags/rmake.rs +++ b/tests/run-make/pass-linker-flags/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test checks the proper function of `-l link-arg=NAME`, which, unlike // -C link-arg, is supposed to guarantee that the order relative to other -l // options will be respected. In this test, compilation fails (because none of the diff --git a/tests/run-make/pgo-gen-no-imp-symbols/rmake.rs b/tests/run-make/pgo-gen-no-imp-symbols/rmake.rs index 85ade7885ce7e..db25eab104a84 100644 --- a/tests/run-make/pgo-gen-no-imp-symbols/rmake.rs +++ b/tests/run-make/pgo-gen-no-imp-symbols/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // LLVM's profiling instrumentation adds a few symbols that are used by the profiler runtime. // Since these show up as globals in the LLVM IR, the compiler generates dllimport-related // __imp_ stubs for them. This can lead to linker errors because the instrumentation diff --git a/tests/run-make/pretty-print-with-dep-file/rmake.rs b/tests/run-make/pretty-print-with-dep-file/rmake.rs index 24ae6bc24560a..e473854a12ea5 100644 --- a/tests/run-make/pretty-print-with-dep-file/rmake.rs +++ b/tests/run-make/pretty-print-with-dep-file/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Passing --emit=dep-info to the Rust compiler should create a .d file... // but it failed to do so in Rust 1.69.0 when combined with -Z unpretty=expanded // due to a bug. This test checks that -Z unpretty=expanded does not prevent the diff --git a/tests/run-make/proc-macro-three-crates/rmake.rs b/tests/run-make/proc-macro-three-crates/rmake.rs index d3735540fdd47..e5a3385acbc5c 100644 --- a/tests/run-make/proc-macro-three-crates/rmake.rs +++ b/tests/run-make/proc-macro-three-crates/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // A compiler bug caused the following issue: // If a crate A depends on crate B, and crate B // depends on crate C, and crate C contains a procedural diff --git a/tests/run-make/remap-path-prefix-dwarf/rmake.rs b/tests/run-make/remap-path-prefix-dwarf/rmake.rs index 3d6ca014fc2a5..3b88fca0bb7f8 100644 --- a/tests/run-make/remap-path-prefix-dwarf/rmake.rs +++ b/tests/run-make/remap-path-prefix-dwarf/rmake.rs @@ -4,6 +4,7 @@ // It tests several cases, each of them has a detailed description attached to it. // See https://github.com/rust-lang/rust/pull/96867 +//@ needs-target-std //@ ignore-windows // Reason: the remap path prefix is not printed in the dwarf dump. diff --git a/tests/run-make/remap-path-prefix/rmake.rs b/tests/run-make/remap-path-prefix/rmake.rs index b4f7f4769b5ba..b75ca9e796ace 100644 --- a/tests/run-make/remap-path-prefix/rmake.rs +++ b/tests/run-make/remap-path-prefix/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Generating metadata alongside remap-path-prefix would fail to actually remap the path // in the metadata. After this was fixed in #85344, this test checks that "auxiliary" is being // successfully remapped to "/the/aux" in the rmeta files. diff --git a/tests/run-make/repr128-dwarf/rmake.rs b/tests/run-make/repr128-dwarf/rmake.rs index 8227c51516fa5..1372d2bcc4658 100644 --- a/tests/run-make/repr128-dwarf/rmake.rs +++ b/tests/run-make/repr128-dwarf/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std //@ ignore-windows // This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums. diff --git a/tests/run-make/reproducible-build-2/rmake.rs b/tests/run-make/reproducible-build-2/rmake.rs index 8b5825cad3026..0e1781dbfbe46 100644 --- a/tests/run-make/reproducible-build-2/rmake.rs +++ b/tests/run-make/reproducible-build-2/rmake.rs @@ -6,6 +6,7 @@ // Outputs should be identical. // See https://github.com/rust-lang/rust/issues/34902 +//@ needs-target-std //@ ignore-windows // Reasons: // 1. The object files are reproducible, but their paths are not, which causes diff --git a/tests/run-make/resolve-rename/rmake.rs b/tests/run-make/resolve-rename/rmake.rs index 21ec7f8527475..8afdaadbfde17 100644 --- a/tests/run-make/resolve-rename/rmake.rs +++ b/tests/run-make/resolve-rename/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // If a library is compiled with -C extra-filename, the rust compiler // will take this into account when searching for libraries. However, // if that library is then renamed, the rust compiler should fall back diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs index 5a1460963b64d..70d1ead85b5d2 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs +++ b/tests/run-make/rlib-format-packed-bundled-libs-2/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // `-Z packed_bundled_libs` is an unstable rustc flag that makes the compiler // only require a native library and no supplementary object files to compile. // This test simply checks that this flag can be passed alongside verbatim syntax diff --git a/tests/run-make/rustc-macro-dep-files/rmake.rs b/tests/run-make/rustc-macro-dep-files/rmake.rs index bc02a04c9b8f1..eb4771fea7a6f 100644 --- a/tests/run-make/rustc-macro-dep-files/rmake.rs +++ b/tests/run-make/rustc-macro-dep-files/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // --emit dep-info used to print all macro-generated code it could // find as if it was part of a nonexistent file named "proc-macro source", // which is not a valid path. After this was fixed in #36776, this test checks diff --git a/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs b/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs index e9c54fa392237..8996ff184c900 100644 --- a/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std #[path = "../rustdoc-scrape-examples-remap/scrape.rs"] mod scrape; diff --git a/tests/run-make/rustdoc-scrape-examples-multiple/rmake.rs b/tests/run-make/rustdoc-scrape-examples-multiple/rmake.rs index e9c54fa392237..8996ff184c900 100644 --- a/tests/run-make/rustdoc-scrape-examples-multiple/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-multiple/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std #[path = "../rustdoc-scrape-examples-remap/scrape.rs"] mod scrape; diff --git a/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs b/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs index e9c54fa392237..8996ff184c900 100644 --- a/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std #[path = "../rustdoc-scrape-examples-remap/scrape.rs"] mod scrape; diff --git a/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs b/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs index 4e3b895aef0c4..ead3920c76132 100644 --- a/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std mod scrape; fn main() { diff --git a/tests/run-make/rustdoc-scrape-examples-test/rmake.rs b/tests/run-make/rustdoc-scrape-examples-test/rmake.rs index f96ba113ff730..0868507c4ae5b 100644 --- a/tests/run-make/rustdoc-scrape-examples-test/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-test/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std #[path = "../rustdoc-scrape-examples-remap/scrape.rs"] mod scrape; diff --git a/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs b/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs index e9c54fa392237..8996ff184c900 100644 --- a/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std #[path = "../rustdoc-scrape-examples-remap/scrape.rs"] mod scrape; diff --git a/tests/run-make/rustdoc-with-short-out-dir-option/rmake.rs b/tests/run-make/rustdoc-with-short-out-dir-option/rmake.rs index 4a8896cc975bb..49df3bedc8496 100644 --- a/tests/run-make/rustdoc-with-short-out-dir-option/rmake.rs +++ b/tests/run-make/rustdoc-with-short-out-dir-option/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std use run_make_support::{htmldocck, rustdoc}; fn main() { diff --git a/tests/run-make/share-generics-dylib/rmake.rs b/tests/run-make/share-generics-dylib/rmake.rs index e0e647fe19955..2d52cd43db753 100644 --- a/tests/run-make/share-generics-dylib/rmake.rs +++ b/tests/run-make/share-generics-dylib/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test makes sure all generic instances get re-exported from Rust dylibs for use by // `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`) // which both provide an instance of `Cell::set`. There is `instance_user_dylib` which is diff --git a/tests/run-make/short-ice/rmake.rs b/tests/run-make/short-ice/rmake.rs index 81403931c783e..8377954f46726 100644 --- a/tests/run-make/short-ice/rmake.rs +++ b/tests/run-make/short-ice/rmake.rs @@ -4,6 +4,7 @@ // was shortened down to an appropriate length. // See https://github.com/rust-lang/rust/issues/107910 +//@ needs-target-std //@ ignore-windows // Reason: the assert_eq! on line 32 fails, as error output on Windows is different. diff --git a/tests/run-make/stable-symbol-names/rmake.rs b/tests/run-make/stable-symbol-names/rmake.rs index 402f411c7f5e6..dacee1a9a3ee8 100644 --- a/tests/run-make/stable-symbol-names/rmake.rs +++ b/tests/run-make/stable-symbol-names/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // A typo in rustc caused generic symbol names to be non-deterministic - // that is, it was possible to compile the same file twice with no changes // and get outputs with different symbol names. diff --git a/tests/run-make/staticlib-blank-lib/rmake.rs b/tests/run-make/staticlib-blank-lib/rmake.rs index 11a85d102aadb..1ab527b61689d 100644 --- a/tests/run-make/staticlib-blank-lib/rmake.rs +++ b/tests/run-make/staticlib-blank-lib/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // In this test, the static library foo is made blank, which used to cause // a compilation error. As the compiler now returns Ok upon encountering a blank // staticlib as of #12379, this test checks that compilation is successful despite diff --git a/tests/run-make/staticlib-broken-bitcode/rmake.rs b/tests/run-make/staticlib-broken-bitcode/rmake.rs index 17d17c1f0f5e8..ab406d3217616 100644 --- a/tests/run-make/staticlib-broken-bitcode/rmake.rs +++ b/tests/run-make/staticlib-broken-bitcode/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Regression test for https://github.com/rust-lang/rust/issues/128955#issuecomment-2657811196 // which checks that rustc can read an archive containing LLVM bitcode with a // newer version from the one rustc links against. diff --git a/tests/run-make/staticlib-thin-archive/rmake.rs b/tests/run-make/staticlib-thin-archive/rmake.rs index 955c50da2011c..1fb56ac053810 100644 --- a/tests/run-make/staticlib-thin-archive/rmake.rs +++ b/tests/run-make/staticlib-thin-archive/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Regression test for https://github.com/rust-lang/rust/issues/107407 which // checks that rustc can read thin archive. Before the object crate added thin // archive support rustc would add emit object files to the staticlib and after diff --git a/tests/run-make/stdin-rustc/rmake.rs b/tests/run-make/stdin-rustc/rmake.rs index 2d634dd455eb2..318d569a76051 100644 --- a/tests/run-make/stdin-rustc/rmake.rs +++ b/tests/run-make/stdin-rustc/rmake.rs @@ -1,3 +1,4 @@ +//@ needs-target-std //! This test checks rustc `-` (stdin) support use std::path::PathBuf; diff --git a/tests/run-make/symbol-visibility/rmake.rs b/tests/run-make/symbol-visibility/rmake.rs index ec936bc3b07fa..0175158d08b81 100644 --- a/tests/run-make/symbol-visibility/rmake.rs +++ b/tests/run-make/symbol-visibility/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Dynamic libraries on Rust used to export a very high amount of symbols, // going as far as filling the output with mangled names and generic function // names. After the rework of #38117, this test checks that no mangled Rust symbols diff --git a/tests/run-make/symbols-include-type-name/rmake.rs b/tests/run-make/symbols-include-type-name/rmake.rs index 746c7486bf0c0..3b46050e6620e 100644 --- a/tests/run-make/symbols-include-type-name/rmake.rs +++ b/tests/run-make/symbols-include-type-name/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Method names used to be obfuscated when exported into symbols, // leaving only an obscure ``. After the fix in #30328, // this test checks that method names are successfully saved in the symbol list. diff --git a/tests/run-make/track-path-dep-info/rmake.rs b/tests/run-make/track-path-dep-info/rmake.rs index 9b21644c41bc5..4b98a1b48d5fa 100644 --- a/tests/run-make/track-path-dep-info/rmake.rs +++ b/tests/run-make/track-path-dep-info/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test checks the functionality of `tracked_path::path`, a procedural macro // feature that adds a dependency to another file inside the procmacro. In this case, // the text file is added through this method, and the test checks that the compilation diff --git a/tests/run-make/type-mismatch-same-crate-name/rmake.rs b/tests/run-make/type-mismatch-same-crate-name/rmake.rs index ecf80d88d51c1..b095027071f1c 100644 --- a/tests/run-make/type-mismatch-same-crate-name/rmake.rs +++ b/tests/run-make/type-mismatch-same-crate-name/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // When a compilation failure deals with seemingly identical types, some helpful // errors should be printed. // The main use case of this error is when there are two crates diff --git a/tests/run-make/unknown-mod-stdin/rmake.rs b/tests/run-make/unknown-mod-stdin/rmake.rs index 6be3119c0fd15..101711b0d2c70 100644 --- a/tests/run-make/unknown-mod-stdin/rmake.rs +++ b/tests/run-make/unknown-mod-stdin/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // Rustc displays a compilation error when it finds a `mod` (module) // statement referencing a file that does not exist. However, a bug from 2019 // caused invalid `mod` statements to silently insert empty inline modules diff --git a/tests/run-make/unstable-feature-usage-metrics-incremental/rmake.rs b/tests/run-make/unstable-feature-usage-metrics-incremental/rmake.rs index 7e070d80c7933..a7215ca9d50bc 100644 --- a/tests/run-make/unstable-feature-usage-metrics-incremental/rmake.rs +++ b/tests/run-make/unstable-feature-usage-metrics-incremental/rmake.rs @@ -10,6 +10,7 @@ //! - forked from dump-ice-to-disk test, which has flakeyness issues on i686-mingw, I'm assuming //! those will be present in this test as well on the same platform +//@ needs-target-std //@ ignore-windows //FIXME(#128911): still flakey on i686-mingw. diff --git a/tests/run-make/unstable-feature-usage-metrics/rmake.rs b/tests/run-make/unstable-feature-usage-metrics/rmake.rs index 2183e28e89abe..dbe078bf468a5 100644 --- a/tests/run-make/unstable-feature-usage-metrics/rmake.rs +++ b/tests/run-make/unstable-feature-usage-metrics/rmake.rs @@ -10,6 +10,7 @@ //! - forked from dump-ice-to-disk test, which has flakeyness issues on i686-mingw, I'm assuming //! those will be present in this test as well on the same platform +//@ needs-target-std //@ ignore-windows //FIXME(#128911): still flakey on i686-mingw. diff --git a/tests/run-make/use-suggestions-rust-2018/rmake.rs b/tests/run-make/use-suggestions-rust-2018/rmake.rs index 52c694da75e9a..4d2163e7cc4bd 100644 --- a/tests/run-make/use-suggestions-rust-2018/rmake.rs +++ b/tests/run-make/use-suggestions-rust-2018/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // The compilation error caused by calling on an unimported crate // should have a suggestion to write, say, crate::bar::Foo instead // of just bar::Foo. However, this suggestion used to only appear for diff --git a/tests/run-make/used/rmake.rs b/tests/run-make/used/rmake.rs index 39f36b2eea8f6..daed69c1b3857 100644 --- a/tests/run-make/used/rmake.rs +++ b/tests/run-make/used/rmake.rs @@ -1,3 +1,5 @@ +//@ needs-target-std +// // This test ensures that the compiler is keeping static variables, even if not referenced // by another part of the program, in the output object file. // diff --git a/tests/ui/panic-runtime/auxiliary/depends.rs b/tests/ui/panic-runtime/auxiliary/depends.rs deleted file mode 100644 index 7a35619b68133..0000000000000 --- a/tests/ui/panic-runtime/auxiliary/depends.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] -#![panic_runtime] -#![no_std] - -extern crate needs_panic_runtime; diff --git a/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs b/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs deleted file mode 100644 index fbafee0c24177..0000000000000 --- a/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ no-prefer-dynamic - -#![feature(needs_panic_runtime)] -#![crate_type = "rlib"] -#![needs_panic_runtime] -#![no_std] diff --git a/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs deleted file mode 100644 index eb00c071702c3..0000000000000 --- a/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ dont-check-compiler-stderr -//@ aux-build:needs-panic-runtime.rs -//@ aux-build:depends.rs - -extern crate depends; - -fn main() {} - -//~? ERROR the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime`