Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #94623

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
"`values()` first argument must be a simple identifer"
);
}
} else if args.is_empty() {
cfg.well_known_values = true;
continue 'specs;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}

Expand Down
116 changes: 110 additions & 6 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1025,13 +1026,19 @@ pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> CrateConfig
pub struct CheckCfg<T = String> {
/// The set of all `names()`, if None no name checking is performed
pub names_valid: Option<FxHashSet<T>>,
/// Is well known values activated
pub well_known_values: bool,
/// The set of all `values()`
pub values_valid: FxHashMap<T, FxHashSet<T>>,
}

impl<T> Default for CheckCfg<T> {
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,
}
}
}

Expand All @@ -1047,6 +1054,7 @@ impl<T> CheckCfg<T> {
.iter()
.map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect()))
.collect(),
well_known_values: self.well_known_values,
}
}
}
Expand All @@ -1060,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,
Expand All @@ -1086,11 +1095,106 @@ 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.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ symbols! {
proc_macro_path_invoc,
profiler_builtins,
profiler_runtime,
ptr,
ptr_guaranteed_eq,
ptr_guaranteed_ne,
ptr_null,
Expand Down
20 changes: 18 additions & 2 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -3540,7 +3540,7 @@ impl<T> [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<const LANES: usize>(&self) -> (&[T], &[Simd<T, LANES>], &[T])
where
Simd<T, LANES>: AsRef<[T; LANES]>,
Expand Down Expand Up @@ -3584,7 +3584,7 @@ impl<T> [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<const LANES: usize>(&mut self) -> (&mut [T], &mut [Simd<T, LANES>], &mut [T])
where
Simd<T, LANES>: AsMut<[T; LANES]>,
Expand Down
2 changes: 0 additions & 2 deletions library/core/tests/simd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(not(miri))] // Miri does not support all SIMD intrinsics

use core::simd::f32x4;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions library/core/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down
24 changes: 0 additions & 24 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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)]
Expand All @@ -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)]
Expand All @@ -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)]
Expand All @@ -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)]
Expand All @@ -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)]
Expand All @@ -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]
Expand Down
Loading