From 50e61a1a667929d0db91132246e61c1a67ab07af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Fri, 25 Feb 2022 13:43:57 +0100 Subject: [PATCH 1/8] Add support for values() with --check-cfg --- compiler/rustc_interface/src/interface.rs | 3 +++ compiler/rustc_session/src/config.rs | 9 ++++++++- src/test/ui/check-cfg/empty-values.rs | 4 ++-- src/test/ui/check-cfg/empty-values.stderr | 2 -- 4 files changed, 13 insertions(+), 5 deletions(-) delete mode 100644 src/test/ui/check-cfg/empty-values.stderr diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 7f4a4ffadec14..e7563933c88ac 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -207,6 +207,9 @@ pub fn parse_check_cfg(specs: Vec) -> CheckCfg { "`values()` first argument must be a simple identifer" ); } + } else if args.is_empty() { + cfg.well_known_values = true; + continue 'specs; } } } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index f9b75690e375f..02cfdcf86f840 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1025,13 +1025,19 @@ pub fn to_crate_config(cfg: FxHashSet<(String, Option)>) -> CrateConfig pub struct CheckCfg { /// The set of all `names()`, if None no name checking is performed pub names_valid: Option>, + /// Is well known values activated + pub well_known_values: bool, /// The set of all `values()` pub values_valid: FxHashMap>, } impl Default for CheckCfg { fn default() -> Self { - CheckCfg { names_valid: Default::default(), values_valid: Default::default() } + CheckCfg { + names_valid: Default::default(), + values_valid: Default::default(), + well_known_values: false, + } } } @@ -1047,6 +1053,7 @@ impl CheckCfg { .iter() .map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect())) .collect(), + well_known_values: self.well_known_values, } } } diff --git a/src/test/ui/check-cfg/empty-values.rs b/src/test/ui/check-cfg/empty-values.rs index 38ef9e51c7a1f..5464846409ac9 100644 --- a/src/test/ui/check-cfg/empty-values.rs +++ b/src/test/ui/check-cfg/empty-values.rs @@ -1,6 +1,6 @@ -// Check that a an empty values() is rejected +// Check that a an empty values() pass // -// check-fail +// check-pass // compile-flags: --check-cfg=values() -Z unstable-options fn main() {} diff --git a/src/test/ui/check-cfg/empty-values.stderr b/src/test/ui/check-cfg/empty-values.stderr deleted file mode 100644 index 106d5b7b47f9b..0000000000000 --- a/src/test/ui/check-cfg/empty-values.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: invalid `--check-cfg` argument: `values()` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`) - From 42cb2ea296ca9ce4c2ec229bb0bb78cca13138dd Mon Sep 17 00:00:00 2001 From: JmPotato Date: Thu, 3 Mar 2022 14:24:47 +0800 Subject: [PATCH 2/8] Clean up the std library's #![feature]s Signed-off-by: JmPotato --- library/std/src/lib.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 10fec8e115245..4df5f2a8df4a5 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -212,7 +212,6 @@ #![needs_panic_runtime] // std may use features in a platform-specific way #![allow(unused_features)] -#![feature(rustc_allow_const_fn_unstable)] #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count))] #![cfg_attr( all(target_vendor = "fortanix", target_env = "sgx"), @@ -222,22 +221,16 @@ // std is implemented with unstable features, many of which are internal // compiler details that will never be stable // NB: the following list is sorted to minimize merge conflicts. -#![feature(absolute_path)] #![feature(alloc_error_handler)] #![feature(alloc_layout_extra)] #![feature(allocator_api)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] -#![feature(arbitrary_self_types)] #![feature(array_error_internals)] #![feature(assert_matches)] -#![feature(associated_type_bounds)] #![feature(async_iterator)] -#![feature(atomic_mut_ptr)] -#![feature(auto_traits)] #![feature(bench_black_box)] -#![feature(bool_to_option)] #![feature(box_syntax)] #![feature(c_unwind)] #![feature(c_variadic)] @@ -248,7 +241,6 @@ #![feature(char_internals)] #![feature(concat_bytes)] #![feature(concat_idents)] -#![feature(const_fn_floating_point_arithmetic)] #![feature(const_fn_fn_ptr_basics)] #![feature(const_fn_trait_bound)] #![feature(const_format_args)] @@ -257,10 +249,8 @@ #![feature(const_ipv4)] #![feature(const_ipv6)] #![feature(const_option)] -#![feature(const_mut_refs)] #![feature(const_socketaddr)] #![feature(const_trait_impl)] -#![feature(container_error_extra)] #![feature(c_size_t)] #![feature(core_ffi_c)] #![feature(core_intrinsics)] @@ -279,24 +269,17 @@ #![feature(exact_size_is_empty)] #![feature(exhaustive_patterns)] #![feature(extend_one)] -#![feature(fn_traits)] #![feature(float_minimum_maximum)] #![feature(format_args_nl)] -#![feature(gen_future)] -#![feature(generator_trait)] #![feature(get_mut_unchecked)] #![feature(hashmap_internals)] #![feature(int_error_internals)] -#![feature(integer_atomics)] -#![feature(int_log)] -#![feature(into_future)] #![feature(intra_doc_pointers)] #![feature(lang_items)] #![feature(linkage)] #![feature(log_syntax)] #![feature(map_try_insert)] #![feature(maybe_uninit_slice)] -#![feature(maybe_uninit_uninit_array)] #![feature(maybe_uninit_write_slice)] #![feature(min_specialization)] #![feature(mixed_integer_ops)] @@ -316,19 +299,14 @@ #![feature(portable_simd)] #![feature(prelude_import)] #![feature(ptr_as_uninit)] -#![feature(ptr_internals)] #![feature(raw_os_nonzero)] #![feature(rustc_attrs)] -#![feature(rustc_private)] #![feature(saturating_int_impl)] -#![feature(slice_concat_ext)] #![feature(slice_internals)] #![feature(slice_ptr_get)] -#![feature(slice_ptr_len)] #![feature(staged_api)] #![feature(std_internals)] #![feature(stdsimd)] -#![feature(stmt_expr_attributes)] #![feature(str_internals)] #![feature(test)] #![feature(thread_local)] @@ -338,8 +316,6 @@ #![feature(trace_macros)] #![feature(try_blocks)] #![feature(try_reserve_kind)] -#![feature(unboxed_closures)] -#![feature(unwrap_infallible)] #![feature(vec_into_raw_parts)] // NB: the above list is sorted to minimize merge conflicts. #![default_lib_allocator] From d233570fab08281f50ad1edbe82c5d404a9e3e1d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 3 Mar 2022 14:52:01 -0500 Subject: [PATCH 3/8] fix a warning when building core tests with cfg(miri) --- library/core/tests/slice.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 06a30d7096c77..7c4d2f266f958 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -2457,9 +2457,11 @@ take_tests! { (take_last_mut_empty, (), None, &mut []), } +#[cfg(not(miri))] // unused in Miri const EMPTY_MAX: &'static [()] = &[(); usize::MAX]; // can't be a constant due to const mutability rules +#[cfg(not(miri))] // unused in Miri macro_rules! empty_max_mut { () => { &mut [(); usize::MAX] as _ From e9149b6773c396e18534425ccb1d3ae5b974793f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 3 Mar 2022 14:52:14 -0500 Subject: [PATCH 4/8] Miri can run this test now --- library/core/tests/simd.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/core/tests/simd.rs b/library/core/tests/simd.rs index b84f3228e7800..5b516a72360aa 100644 --- a/library/core/tests/simd.rs +++ b/library/core/tests/simd.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] // Miri does not support all SIMD intrinsics - use core::simd::f32x4; #[test] From 50e7450bac9fd9faafb7adb7540ab07ddea896d1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 3 Mar 2022 15:11:06 -0500 Subject: [PATCH 5/8] only disable SIMD for doctests in Miri (not for the stdlib build itself) --- library/core/src/lib.rs | 4 ++-- library/core/src/slice/mod.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e7896b2cb66ed..45fbcf44b350c 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -408,12 +408,12 @@ pub mod arch { #[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)] #[allow(rustdoc::bare_urls)] #[unstable(feature = "portable_simd", issue = "86656")] -#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics +#[cfg(not(all(miri, doctest)))] // Skip SIMD doctests in Miri mod core_simd; #[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")] #[unstable(feature = "portable_simd", issue = "86656")] -#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics +#[cfg(not(all(miri, doctest)))] // Skip SIMD doctests in Miri pub mod simd { #[unstable(feature = "portable_simd", issue = "86656")] pub use crate::core_simd::simd::*; diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 08b95d791a38c..9467c7f54bac7 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -16,7 +16,7 @@ use crate::option::Option::{None, Some}; use crate::ptr; use crate::result::Result; use crate::result::Result::{Err, Ok}; -#[cfg(not(miri))] // Miri does not support all SIMD intrinsics +#[cfg(not(all(miri, doctest)))] // Miri skips SIMD doctests use crate::simd::{self, Simd}; use crate::slice; @@ -3540,7 +3540,7 @@ impl [T] { /// assert_eq!(basic_simd_sum(&numbers[1..99]), 4949.0); /// ``` #[unstable(feature = "portable_simd", issue = "86656")] - #[cfg(not(miri))] // Miri does not support all SIMD intrinsics + #[cfg(not(all(miri, doctest)))] // Miri skips SIMD doctests pub fn as_simd(&self) -> (&[T], &[Simd], &[T]) where Simd: AsRef<[T; LANES]>, @@ -3584,7 +3584,7 @@ impl [T] { /// be lifted in a way that would make it possible to see panics from this /// method for something like `LANES == 3`. #[unstable(feature = "portable_simd", issue = "86656")] - #[cfg(not(miri))] // Miri does not support all SIMD intrinsics + #[cfg(not(all(miri, doctest)))] // Miri skips SIMD doctests pub fn as_simd_mut(&mut self) -> (&mut [T], &mut [Simd], &mut [T]) where Simd: AsMut<[T; LANES]>, From 068a233d4d363333237c721e218f48c98694afce Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Fri, 4 Mar 2022 13:07:39 +0900 Subject: [PATCH 6/8] fix invalid `unresolved imports` errors the asterisk wildcard syntax causes use a path variabale --- compiler/rustc_resolve/src/imports.rs | 4 +++- src/test/ui/rust-2018/unresolved-asterisk-imports.rs | 6 ++++++ src/test/ui/rust-2018/unresolved-asterisk-imports.stderr | 9 +++++++++ src/test/ui/unresolved/unresolved-asterisk-imports.rs | 4 ++++ .../ui/unresolved/unresolved-asterisk-imports.stderr | 9 +++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/rust-2018/unresolved-asterisk-imports.rs create mode 100644 src/test/ui/rust-2018/unresolved-asterisk-imports.stderr create mode 100644 src/test/ui/unresolved/unresolved-asterisk-imports.rs create mode 100644 src/test/ui/unresolved/unresolved-asterisk-imports.stderr diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index bf570fb0f80b0..70ade7a5600ba 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -720,7 +720,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> { note: Vec::new(), suggestion: None, }; - errors.push((path, err)); + if path.contains("::") { + errors.push((path, err)) + } } } diff --git a/src/test/ui/rust-2018/unresolved-asterisk-imports.rs b/src/test/ui/rust-2018/unresolved-asterisk-imports.rs new file mode 100644 index 0000000000000..ad1064570c77b --- /dev/null +++ b/src/test/ui/rust-2018/unresolved-asterisk-imports.rs @@ -0,0 +1,6 @@ +// edition:2018 + +use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate +use std as foo; + +fn main() {} diff --git a/src/test/ui/rust-2018/unresolved-asterisk-imports.stderr b/src/test/ui/rust-2018/unresolved-asterisk-imports.stderr new file mode 100644 index 0000000000000..09e9edc638d1d --- /dev/null +++ b/src/test/ui/rust-2018/unresolved-asterisk-imports.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `not_existing_crate` + --> $DIR/unresolved-asterisk-imports.rs:3:5 + | +LL | use not_existing_crate::*; + | ^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `not_existing_crate` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/unresolved/unresolved-asterisk-imports.rs b/src/test/ui/unresolved/unresolved-asterisk-imports.rs new file mode 100644 index 0000000000000..2d853a66c8d06 --- /dev/null +++ b/src/test/ui/unresolved/unresolved-asterisk-imports.rs @@ -0,0 +1,4 @@ +use not_existing_crate::*; //~ ERROR unresolved import `not_existing_crate +use std as foo; + +fn main() {} diff --git a/src/test/ui/unresolved/unresolved-asterisk-imports.stderr b/src/test/ui/unresolved/unresolved-asterisk-imports.stderr new file mode 100644 index 0000000000000..a789179db65bd --- /dev/null +++ b/src/test/ui/unresolved/unresolved-asterisk-imports.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `not_existing_crate` + --> $DIR/unresolved-asterisk-imports.rs:1:5 + | +LL | use not_existing_crate::*; + | ^^^^^^^^^^^^^^^^^^ maybe a missing crate `not_existing_crate`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. From 4aa92aff054c8e89c61ac06551a405af828ade70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20BRANSTETT?= Date: Fri, 25 Feb 2022 16:10:26 +0100 Subject: [PATCH 7/8] Add well known values to --check-cfg implementation --- compiler/rustc_session/src/config.rs | 107 +++++++++++++++++- compiler/rustc_span/src/symbol.rs | 1 + compiler/rustc_target/src/spec/mod.rs | 20 +++- src/test/ui/check-cfg/empty-values.rs | 6 +- src/test/ui/check-cfg/empty-values.stderr | 11 ++ src/test/ui/check-cfg/well-known-values.rs | 28 +++++ .../ui/check-cfg/well-known-values.stderr | 31 +++++ 7 files changed, 196 insertions(+), 8 deletions(-) create mode 100644 src/test/ui/check-cfg/empty-values.stderr create mode 100644 src/test/ui/check-cfg/well-known-values.rs create mode 100644 src/test/ui/check-cfg/well-known-values.stderr diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 02cfdcf86f840..6c32115c6a25e 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -13,6 +13,7 @@ use rustc_data_structures::impl_stable_hash_via_hash; use rustc_target::abi::{Align, TargetDataLayout}; use rustc_target::spec::{LinkerFlavor, SplitDebuginfo, Target, TargetTriple, TargetWarnings}; +use rustc_target::spec::{PanicStrategy, SanitizerSet, TARGETS}; use rustc_serialize::json; @@ -1067,8 +1068,9 @@ pub fn to_crate_check_config(cfg: CheckCfg) -> CrateCheckConfig { impl CrateCheckConfig { /// Fills a `CrateCheckConfig` with well-known configuration names. - pub fn fill_well_known(&mut self) { - // NOTE: This should be kept in sync with `default_configuration` + fn fill_well_known_names(&mut self) { + // NOTE: This should be kept in sync with `default_configuration` and + // `fill_well_known_values` const WELL_KNOWN_NAMES: &[Symbol] = &[ sym::unix, sym::windows, @@ -1093,13 +1095,108 @@ impl CrateCheckConfig { sym::doctest, sym::feature, ]; + + // We only insert well-known names if `names()` was activated if let Some(names_valid) = &mut self.names_valid { - for &name in WELL_KNOWN_NAMES { - names_valid.insert(name); - } + names_valid.extend(WELL_KNOWN_NAMES); } } + /// Fills a `CrateCheckConfig` with well-known configuration values. + fn fill_well_known_values(&mut self) { + if !self.well_known_values { + return; + } + + // NOTE: This should be kept in sync with `default_configuration` and + // `fill_well_known_names` + + let panic_values = &PanicStrategy::all(); + + let atomic_values = &[ + sym::ptr, + sym::integer(8usize), + sym::integer(16usize), + sym::integer(32usize), + sym::integer(64usize), + sym::integer(128usize), + ]; + + let sanitize_values = SanitizerSet::all() + .into_iter() + .map(|sanitizer| Symbol::intern(sanitizer.as_str().unwrap())); + + // No-values + for name in [ + sym::unix, + sym::windows, + sym::debug_assertions, + sym::proc_macro, + sym::test, + sym::doc, + sym::doctest, + sym::target_thread_local, + ] { + self.values_valid.entry(name).or_default(); + } + + // Pre-defined values + self.values_valid.entry(sym::panic).or_default().extend(panic_values); + self.values_valid.entry(sym::sanitize).or_default().extend(sanitize_values); + self.values_valid.entry(sym::target_has_atomic).or_default().extend(atomic_values); + self.values_valid + .entry(sym::target_has_atomic_load_store) + .or_default() + .extend(atomic_values); + self.values_valid + .entry(sym::target_has_atomic_equal_alignment) + .or_default() + .extend(atomic_values); + + // Target specific values + for target in + TARGETS.iter().map(|target| Target::expect_builtin(&TargetTriple::from_triple(target))) + { + self.values_valid + .entry(sym::target_os) + .or_default() + .insert(Symbol::intern(&target.options.os)); + self.values_valid + .entry(sym::target_family) + .or_default() + .extend(target.options.families.iter().map(|family| Symbol::intern(family))); + self.values_valid + .entry(sym::target_arch) + .or_default() + .insert(Symbol::intern(&target.arch)); + self.values_valid + .entry(sym::target_endian) + .or_default() + .insert(Symbol::intern(&target.options.endian.as_str())); + self.values_valid + .entry(sym::target_env) + .or_default() + .insert(Symbol::intern(&target.options.env)); + self.values_valid + .entry(sym::target_abi) + .or_default() + .insert(Symbol::intern(&target.options.abi)); + self.values_valid + .entry(sym::target_vendor) + .or_default() + .insert(Symbol::intern(&target.options.vendor)); + self.values_valid + .entry(sym::target_pointer_width) + .or_default() + .insert(sym::integer(target.pointer_width)); + } + } + + pub fn fill_well_known(&mut self) { + self.fill_well_known_names(); + self.fill_well_known_values(); + } + /// Fills a `CrateCheckConfig` with configuration names and values that are actually active. pub fn fill_actual(&mut self, cfg: &CrateConfig) { for &(k, v) in cfg { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 6767593bbc51a..bb2d469ba6bcb 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1062,6 +1062,7 @@ symbols! { proc_macro_path_invoc, profiler_builtins, profiler_runtime, + ptr, ptr_guaranteed_eq, ptr_guaranteed_ne, ptr_null, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 92678aed5b1a2..ca5f2b4af8a97 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -186,12 +186,16 @@ impl PanicStrategy { } } - pub fn desc_symbol(&self) -> Symbol { + pub const fn desc_symbol(&self) -> Symbol { match *self { PanicStrategy::Unwind => sym::unwind, PanicStrategy::Abort => sym::abort, } } + + pub const fn all() -> [Symbol; 2] { + [Self::Abort.desc_symbol(), Self::Unwind.desc_symbol()] + } } impl ToJson for PanicStrategy { @@ -614,7 +618,7 @@ impl SanitizerSet { /// Return sanitizer's name /// /// Returns none if the flags is a set of sanitizers numbering not exactly one. - fn as_str(self) -> Option<&'static str> { + pub fn as_str(self) -> Option<&'static str> { Some(match self { SanitizerSet::ADDRESS => "address", SanitizerSet::CFI => "cfi", @@ -2137,6 +2141,18 @@ impl Target { )) } + /// Load a built-in target + pub fn expect_builtin(target_triple: &TargetTriple) -> Target { + match *target_triple { + TargetTriple::TargetTriple(ref target_triple) => { + load_builtin(target_triple).expect("built-in target") + } + TargetTriple::TargetPath(..) => { + panic!("built-in targets doens't support target-paths") + } + } + } + /// Search for a JSON file specifying the given target triple. /// /// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the diff --git a/src/test/ui/check-cfg/empty-values.rs b/src/test/ui/check-cfg/empty-values.rs index 5464846409ac9..9bda42e5d15fe 100644 --- a/src/test/ui/check-cfg/empty-values.rs +++ b/src/test/ui/check-cfg/empty-values.rs @@ -1,6 +1,10 @@ -// Check that a an empty values() pass +// Check warning for unexpected cfg value // // check-pass // compile-flags: --check-cfg=values() -Z unstable-options +#[cfg(test = "value")] +//~^ WARNING unexpected `cfg` condition value +pub fn f() {} + fn main() {} diff --git a/src/test/ui/check-cfg/empty-values.stderr b/src/test/ui/check-cfg/empty-values.stderr new file mode 100644 index 0000000000000..834b28f1244cb --- /dev/null +++ b/src/test/ui/check-cfg/empty-values.stderr @@ -0,0 +1,11 @@ +warning: unexpected `cfg` condition value + --> $DIR/empty-values.rs:6:7 + | +LL | #[cfg(test = "value")] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(unexpected_cfgs)]` on by default + = note: no expected value for `test` + +warning: 1 warning emitted + diff --git a/src/test/ui/check-cfg/well-known-values.rs b/src/test/ui/check-cfg/well-known-values.rs new file mode 100644 index 0000000000000..46004be43d812 --- /dev/null +++ b/src/test/ui/check-cfg/well-known-values.rs @@ -0,0 +1,28 @@ +// This test check that we lint on non well known values and that we don't lint on well known +// values +// +// check-pass +// compile-flags: --check-cfg=values() -Z unstable-options + +#[cfg(target_os = "linuz")] +//~^ WARNING unexpected `cfg` condition value +fn target_os_linux_misspell() {} + +#[cfg(target_os = "linux")] +fn target_os_linux() {} + +#[cfg(target_has_atomic = "0")] +//~^ WARNING unexpected `cfg` condition value +fn target_has_atomic_invalid() {} + +#[cfg(target_has_atomic = "8")] +fn target_has_atomic() {} + +#[cfg(unix = "aa")] +//~^ WARNING unexpected `cfg` condition value +fn unix_with_value() {} + +#[cfg(unix)] +fn unix() {} + +fn main() {} diff --git a/src/test/ui/check-cfg/well-known-values.stderr b/src/test/ui/check-cfg/well-known-values.stderr new file mode 100644 index 0000000000000..05b2a8af0eec0 --- /dev/null +++ b/src/test/ui/check-cfg/well-known-values.stderr @@ -0,0 +1,31 @@ +warning: unexpected `cfg` condition value + --> $DIR/well-known-values.rs:7:7 + | +LL | #[cfg(target_os = "linuz")] + | ^^^^^^^^^^^^------- + | | + | help: did you mean: `"linux"` + | + = note: `#[warn(unexpected_cfgs)]` on by default + = note: expected values for `target_os` are: android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, windows + +warning: unexpected `cfg` condition value + --> $DIR/well-known-values.rs:14:7 + | +LL | #[cfg(target_has_atomic = "0")] + | ^^^^^^^^^^^^^^^^^^^^--- + | | + | help: did you mean: `"8"` + | + = note: expected values for `target_has_atomic` are: 128, 16, 32, 64, 8, ptr + +warning: unexpected `cfg` condition value + --> $DIR/well-known-values.rs:21:7 + | +LL | #[cfg(unix = "aa")] + | ^^^^^^^^^^^ + | + = note: no expected value for `unix` + +warning: 3 warnings emitted + From 6843dd5013545652ccd1ff3e63462d6cffbe1dcf Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Fri, 4 Mar 2022 18:04:43 +0000 Subject: [PATCH 8/8] Don't round stack size up for created threads --- library/std/src/sys/windows/thread.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/std/src/sys/windows/thread.rs b/library/std/src/sys/windows/thread.rs index e4bba9255d23e..fdbf7d4fdeddd 100644 --- a/library/std/src/sys/windows/thread.rs +++ b/library/std/src/sys/windows/thread.rs @@ -28,12 +28,9 @@ impl Thread { // PTHREAD_STACK_MIN bytes big. Windows has no such lower limit, it's // just that below a certain threshold you can't do anything useful. // That threshold is application and architecture-specific, however. - // Round up to the next 64 kB because that's what the NT kernel does, - // might as well make it explicit. - let stack_size = (stack + 0xfffe) & (!0xfffe); let ret = c::CreateThread( ptr::null_mut(), - stack_size, + stack, thread_start, p as *mut _, c::STACK_SIZE_PARAM_IS_A_RESERVATION,