diff --git a/Cargo.lock b/Cargo.lock index 01083d7c43f49..5a40c73601340 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3664,7 +3664,7 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", - "rustc_target", + "rustc_structures", "smallvec", "thin-vec", "tracing", @@ -3688,6 +3688,7 @@ dependencies = [ "rustc_parse_format", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "thin-vec", ] @@ -3785,6 +3786,7 @@ dependencies = [ "rustc_sanitizers", "rustc_session", "rustc_span", + "rustc_structures", "rustc_symbol_mangling", "rustc_target", "smallvec", @@ -3824,6 +3826,7 @@ dependencies = [ "rustc_serialize", "rustc_session", "rustc_span", + "rustc_structures", "rustc_symbol_mangling", "rustc_target", "rustc_trait_selection", @@ -3855,6 +3858,7 @@ dependencies = [ "rustc_mir_dataflow", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "rustc_trait_selection", "tracing", @@ -3871,6 +3875,7 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", + "rustc_structures", ] [[package]] @@ -3949,6 +3954,7 @@ dependencies = [ "rustc_resolve", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "serde_json", "shlex", @@ -4023,6 +4029,7 @@ dependencies = [ "rustc_serialize", "rustc_session", "rustc_span", + "rustc_structures", "scoped-tls", "smallvec", "thin-vec", @@ -4098,6 +4105,7 @@ dependencies = [ "rustc_middle", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "rustc_trait_selection", "smallvec", @@ -4251,6 +4259,7 @@ dependencies = [ "rustc_resolve", "rustc_session", "rustc_span", + "rustc_structures", "rustc_symbol_mangling", "rustc_target", "rustc_thread_pool", @@ -4292,6 +4301,7 @@ dependencies = [ "rustc_parse_format", "rustc_session", "rustc_span", + "rustc_structures", "rustc_symbol_mangling", "rustc_target", "rustc_trait_selection", @@ -4373,6 +4383,7 @@ dependencies = [ "rustc_serialize", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "tempfile", "tracing", @@ -4405,6 +4416,7 @@ dependencies = [ "rustc_serialize", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "rustc_thread_pool", "rustc_type_ir", @@ -4476,6 +4488,7 @@ dependencies = [ "rustc_mir_dataflow", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "rustc_trait_selection", "smallvec", @@ -4498,6 +4511,7 @@ dependencies = [ "rustc_serialize", "rustc_session", "rustc_span", + "rustc_structures", "rustc_symbol_mangling", "rustc_target", "serde", @@ -4571,6 +4585,7 @@ dependencies = [ "rustc_privacy", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "rustc_trait_selection", "tracing", @@ -4663,6 +4678,7 @@ dependencies = [ "rustc_middle", "rustc_serialize", "rustc_span", + "rustc_structures", "rustc_thread_pool", "tracing", ] @@ -4690,6 +4706,7 @@ dependencies = [ "rustc_middle", "rustc_session", "rustc_span", + "rustc_structures", "smallvec", "thin-vec", "tracing", @@ -4731,7 +4748,6 @@ dependencies = [ "libc", "rustc_abi", "rustc_ast", - "rustc_attr_ir", "rustc_data_structures", "rustc_errors", "rustc_feature", @@ -4741,6 +4757,7 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", + "rustc_structures", "rustc_target", "termize", "tracing", @@ -4770,6 +4787,20 @@ dependencies = [ "unicode-width 0.2.2", ] +[[package]] +name = "rustc_structures" +version = "0.0.0" +dependencies = [ + "bitflags", + "rustc_data_structures", + "rustc_error_messages", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "schemars", + "serde", +] + [[package]] name = "rustc_symbol_mangling" version = "0.0.0" @@ -4800,6 +4831,7 @@ dependencies = [ "rustc_macros", "rustc_serialize", "rustc_span", + "rustc_structures", "schemars", "serde", "serde_derive", @@ -4849,6 +4881,7 @@ dependencies = [ "rustc_next_trait_solver", "rustc_session", "rustc_span", + "rustc_structures", "rustc_transmute", "smallvec", "thin-vec", @@ -4897,6 +4930,7 @@ dependencies = [ "rustc_middle", "rustc_session", "rustc_span", + "rustc_structures", "rustc_target", "rustc_trait_selection", "rustc_ty_walk", diff --git a/compiler/rustc_attr_ir/Cargo.toml b/compiler/rustc_attr_ir/Cargo.toml index 28ca2c8839508..2ede16da2fa22 100644 --- a/compiler/rustc_attr_ir/Cargo.toml +++ b/compiler/rustc_attr_ir/Cargo.toml @@ -13,7 +13,7 @@ rustc_error_messages = { path = "../rustc_error_messages" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } -rustc_target = { path = "../rustc_target" } +rustc_structures = { path = "../rustc_structures" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } thin-vec = "0.2.18" tracing = "0.1" diff --git a/compiler/rustc_attr_ir/src/data_structures.rs b/compiler/rustc_attr_ir/src/data_structures.rs index eb15c2af14d88..195712559782d 100644 --- a/compiler/rustc_attr_ir/src/data_structures.rs +++ b/compiler/rustc_attr_ir/src/data_structures.rs @@ -10,14 +10,13 @@ use rustc_ast::expand::autodiff_attrs::{DiffActivity, DiffMode}; use rustc_ast::expand::typetree::TypeTree; use rustc_ast::token::DocFragmentKind; use rustc_ast::{AttrStyle, Path, ast}; -use rustc_data_structures::Limit; use rustc_data_structures::fx::FxIndexMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash}; use rustc_span::def_id::DefId; use rustc_span::hygiene::Transparency; use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; -pub use rustc_target::spec::SanitizerSet; +use rustc_structures::{CollapseMacroDebuginfo, CrateType, Limit, NativeLibKind, SanitizerSet}; use thin_vec::ThinVec; pub use crate::canonical_symbols::{CanonicalSymbol, CanonicalSymbols}; @@ -372,76 +371,6 @@ pub enum PeImportNameType { Undecorated, } -#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[derive(Encodable, Decodable, PrintAttribute)] -#[derive(StableHash)] -pub enum NativeLibKind { - /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) - Static { - /// Whether to bundle objects from static library into produced rlib - bundle: Option, - /// Whether to link static library without throwing any object files away - whole_archive: Option, - /// Whether to export c static library symbols - export_symbols: Option, - }, - /// Dynamic library (e.g. `libfoo.so` on Linux) - /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC). - Dylib { - /// Whether the dynamic library will be linked only if it satisfies some undefined symbols - as_needed: Option, - }, - /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library. - /// On Linux, it refers to a generated shared library stub. - RawDylib { - /// Whether the dynamic library will be linked only if it satisfies some undefined symbols - as_needed: Option, - }, - /// A macOS-specific kind of dynamic libraries. - Framework { - /// Whether the framework will be linked only if it satisfies some undefined symbols - as_needed: Option, - }, - /// Argument which is passed to linker, relative order with libraries and other arguments - /// is preserved - LinkArg, - - /// Module imported from WebAssembly - WasmImportModule, - - /// The library kind wasn't specified, `Dylib` is currently used as a default. - Unspecified, -} - -impl NativeLibKind { - pub fn has_modifiers(&self) -> bool { - match self { - NativeLibKind::Static { bundle, whole_archive, export_symbols } => { - bundle.is_some() || whole_archive.is_some() || export_symbols.is_some() - } - NativeLibKind::Dylib { as_needed } - | NativeLibKind::Framework { as_needed } - | NativeLibKind::RawDylib { as_needed } => as_needed.is_some(), - NativeLibKind::Unspecified - | NativeLibKind::LinkArg - | NativeLibKind::WasmImportModule => false, - } - } - - pub fn is_statically_included(&self) -> bool { - matches!(self, NativeLibKind::Static { .. }) - } - - pub fn is_dllimport(&self) -> bool { - matches!( - self, - NativeLibKind::Dylib { .. } - | NativeLibKind::RawDylib { .. } - | NativeLibKind::Unspecified - ) - } -} - #[derive(Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct LinkEntry { pub span: Span, @@ -672,128 +601,6 @@ impl rustc_serialize::Encodable for DocAttribute } } -/// How to perform collapse macros debug info -/// if-ext - if macro from different crate (related to callsite code) -/// | cmd \ attr | no | (unspecified) | external | yes | -/// | no | no | no | no | no | -/// | (unspecified) | no | no | if-ext | yes | -/// | external | no | if-ext | if-ext | yes | -/// | yes | yes | yes | yes | yes | -#[derive(Copy, Clone, Debug, Hash, PartialEq)] -#[derive(StableHash, Encodable, Decodable, PrintAttribute)] -pub enum CollapseMacroDebuginfo { - /// Don't collapse debuginfo for the macro - No = 0, - /// Unspecified value - Unspecified = 1, - /// Collapse debuginfo if the macro comes from a different crate - External = 2, - /// Collapse debuginfo for the macro - Yes = 3, -} - -/// Crate type, as specified by `#![crate_type]` -#[derive(Copy, Clone, Debug, Hash, PartialEq, Default, PartialOrd, Eq, Ord)] -#[derive(StableHash, Encodable, Decodable, PrintAttribute)] -pub enum CrateType { - /// `#![crate_type = "bin"]` - Executable, - /// `#![crate_type = "dylib"]` - Dylib, - /// `#![crate_type = "rlib"]` or `#![crate_type = "lib"]` - #[default] - Rlib, - /// `#![crate_type = "staticlib"]` - StaticLib, - /// `#![crate_type = "cdylib"]` - Cdylib, - /// `#![crate_type = "proc-macro"]` - ProcMacro, - /// `#![crate_type = "sdylib"]` - // Unstable; feature(export_stable) - Sdylib, -} - -impl CrateType { - /// Pairs of each `#[crate_type] = "..."` value and the crate type it resolves to - pub fn all() -> &'static [(Symbol, Self)] { - debug_assert_eq!(CrateType::default(), CrateType::Rlib); - &[ - (rustc_span::sym::lib, CrateType::Rlib), - (rustc_span::sym::rlib, CrateType::Rlib), - (rustc_span::sym::dylib, CrateType::Dylib), - (rustc_span::sym::cdylib, CrateType::Cdylib), - (rustc_span::sym::staticlib, CrateType::StaticLib), - (rustc_span::sym::proc_dash_macro, CrateType::ProcMacro), - (rustc_span::sym::bin, CrateType::Executable), - (rustc_span::sym::sdylib, CrateType::Sdylib), - ] - } - - /// Same as [`CrateType::all`], but does not include unstable options. - /// Used for diagnostics. - pub fn all_stable() -> &'static [(Symbol, Self)] { - debug_assert_eq!(CrateType::default(), CrateType::Rlib); - &[ - (rustc_span::sym::lib, CrateType::Rlib), - (rustc_span::sym::rlib, CrateType::Rlib), - (rustc_span::sym::dylib, CrateType::Dylib), - (rustc_span::sym::cdylib, CrateType::Cdylib), - (rustc_span::sym::staticlib, CrateType::StaticLib), - (rustc_span::sym::proc_dash_macro, CrateType::ProcMacro), - (rustc_span::sym::bin, CrateType::Executable), - ] - } - - pub fn has_metadata(self) -> bool { - match self { - CrateType::Rlib | CrateType::Dylib | CrateType::ProcMacro => true, - CrateType::Executable - | CrateType::Cdylib - | CrateType::StaticLib - | CrateType::Sdylib => false, - } - } -} - -impl TryFrom for CrateType { - type Error = (); - - fn try_from(value: Symbol) -> Result { - Ok(match value { - rustc_span::sym::bin => CrateType::Executable, - rustc_span::sym::dylib => CrateType::Dylib, - rustc_span::sym::staticlib => CrateType::StaticLib, - rustc_span::sym::cdylib => CrateType::Cdylib, - rustc_span::sym::rlib => CrateType::Rlib, - rustc_span::sym::lib => CrateType::default(), - rustc_span::sym::proc_dash_macro => CrateType::ProcMacro, - rustc_span::sym::sdylib => CrateType::Sdylib, - _ => return Err(()), - }) - } -} - -impl std::fmt::Display for CrateType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match *self { - CrateType::Executable => "bin".fmt(f), - CrateType::Dylib => "dylib".fmt(f), - CrateType::Rlib => "rlib".fmt(f), - CrateType::StaticLib => "staticlib".fmt(f), - CrateType::Cdylib => "cdylib".fmt(f), - CrateType::ProcMacro => "proc-macro".fmt(f), - CrateType::Sdylib => "sdylib".fmt(f), - } - } -} - -impl IntoDiagArg for CrateType { - fn into_diag_arg(self, _: &mut Option) -> DiagArgValue { - self.to_string().into_diag_arg(&mut None) - } -} - #[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum RustcDumpLayoutKind { Align, diff --git a/compiler/rustc_attr_ir/src/pretty_printing.rs b/compiler/rustc_attr_ir/src/pretty_printing.rs index 1cecd49aa1424..cd8a0c0e1e96f 100644 --- a/compiler/rustc_attr_ir/src/pretty_printing.rs +++ b/compiler/rustc_attr_ir/src/pretty_printing.rs @@ -10,12 +10,11 @@ use rustc_ast::expand::autodiff_attrs::{DiffActivity, DiffMode}; use rustc_ast::token::{CommentKind, DocFragmentKind}; use rustc_ast::{AttrId, AttrStyle, IntTy, UintTy}; use rustc_ast_pretty::pp::Printer; -use rustc_data_structures::Limit; use rustc_data_structures::fx::FxIndexMap; use rustc_span::def_id::DefId; use rustc_span::hygiene::Transparency; use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; -use rustc_target::spec::SanitizerSet; +use rustc_structures::{CollapseMacroDebuginfo, CrateType, Limit, NativeLibKind, SanitizerSet}; use thin_vec::ThinVec; /// This trait is used to print attributes in `rustc_hir_pretty`. @@ -208,4 +207,7 @@ print_debug!( CfgEntry, DiffActivity, DiffMode, + CrateType, + NativeLibKind, + CollapseMacroDebuginfo, ); diff --git a/compiler/rustc_attr_parsing/Cargo.toml b/compiler/rustc_attr_parsing/Cargo.toml index 70161a7961815..3c40253e34a4c 100644 --- a/compiler/rustc_attr_parsing/Cargo.toml +++ b/compiler/rustc_attr_parsing/Cargo.toml @@ -19,6 +19,7 @@ rustc_parse = { path = "../rustc_parse" } rustc_parse_format = { path = "../rustc_parse_format" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } thin-vec = "0.2.19" # tidy-alphabetical-end diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index feed600d44df4..ba845acc9e23c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -1,9 +1,10 @@ use rustc_attr_ir::{ - CoverageAttrKind, InstrumentFnAttr, OptimizeAttr, RtsanSetting, SanitizerSet, UsedBy, find_attr, + CoverageAttrKind, InstrumentFnAttr, OptimizeAttr, RtsanSetting, UsedBy, find_attr, }; use rustc_feature::AttributeStability; use rustc_session::diagnostics::feature_err; use rustc_span::edition::Edition::Edition2024; +use rustc_structures::SanitizerSet; use super::prelude::*; use crate::attributes::AttributeSafety; diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index 571750bf142a8..3a1c7858f030b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -1,9 +1,10 @@ -use rustc_attr_ir::{CrateType, WindowsSubsystemKind}; +use rustc_attr_ir::WindowsSubsystemKind; use rustc_data_structures::fx::FxIndexSet; use rustc_feature::AttributeStability; use rustc_lint_defs::builtin::{DUPLICATE_TOOLS, UNKNOWN_CRATE_TYPES}; use rustc_span::Symbol; use rustc_span::edit_distance::find_best_match_for_name_with_substrings; +use rustc_structures::CrateType; use super::prelude::*; use crate::diagnostics::{ diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index 6d25e7fb00183..d674149c225f6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -7,6 +7,7 @@ use rustc_session::Session; use rustc_session::diagnostics::feature_err; use rustc_span::edition::Edition::Edition2024; use rustc_span::kw; +use rustc_structures::NativeLibKind; use rustc_target::spec::{Arch, BinaryFormat}; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index fc1f0f2361b35..c9625521aec44 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -1,6 +1,7 @@ -use rustc_attr_ir::{CollapseMacroDebuginfo, MacroUseArgs, find_attr}; +use rustc_attr_ir::{MacroUseArgs, find_attr}; use rustc_feature::AttributeStability; use rustc_lint_defs::builtin::INVALID_MACRO_EXPORT_ARGUMENTS; +use rustc_structures::CollapseMacroDebuginfo; use super::prelude::*; use crate::diagnostics::MacroOnlyAttribute; diff --git a/compiler/rustc_attr_parsing/src/attributes/util.rs b/compiler/rustc_attr_parsing/src/attributes/util.rs index ed6d27b4c58f7..8f8af2218506e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/util.rs +++ b/compiler/rustc_attr_parsing/src/attributes/util.rs @@ -2,9 +2,9 @@ use std::num::IntErrorKind; use rustc_ast::{LitKind, ast}; use rustc_attr_ir::RustcVersion; -use rustc_data_structures::Limit; use rustc_feature::is_builtin_attr_name; use rustc_span::Symbol; +use rustc_structures::Limit; use crate::context::AcceptContext; use crate::diagnostics::LimitInvalid; diff --git a/compiler/rustc_codegen_cranelift/src/driver/jit.rs b/compiler/rustc_codegen_cranelift/src/driver/jit.rs index 32f60615844bc..8bf1cd9bf85bc 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/jit.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/jit.rs @@ -37,7 +37,7 @@ fn create_jit_module( } pub(crate) fn run_jit(tcx: TyCtxt<'_>, target_cpu: String, jit_args: Vec) -> ! { - if !tcx.crate_types().contains(&rustc_session::config::CrateType::Executable) { + if !tcx.crate_types().contains(&rustc_structures::CrateType::Executable) { tcx.dcx().fatal("can't jit non-executable crate"); } @@ -180,7 +180,7 @@ fn dep_symbol_lookup_fn( let mut dylib_paths = Vec::new(); - let data = &crate_info.dependency_formats[&rustc_session::config::CrateType::Executable]; + let data = &crate_info.dependency_formats[&rustc_structures::CrateType::Executable]; // `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to // get a postorder which ensures that all dependencies of a dylib are loaded before the dylib // itself. This helps the dynamic linker to find dylibs not in the regular dynamic library diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index b325742325ef2..27c4062ddd941 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -36,6 +36,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_sanitizers = { path = "../rustc_sanitizers" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 4883eb1087be3..db111926ca671 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -18,10 +18,10 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::memmap::Mmap; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_errors::{DiagCtxt, DiagCtxtHandle}; -use rustc_hir::attrs::SanitizerSet; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; use rustc_session::config; +use rustc_structures::SanitizerSet; use tracing::{debug, info}; use crate::back::write::{ diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 668072ff082ec..fe27498b900f3 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -21,10 +21,11 @@ use rustc_middle::ty::layout::{ use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_session::config::{ - BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet, + BranchProtection, CFGuard, CFProtection, DebugInfo, FunctionReturn, PAuthKey, PacRet, }; use rustc_session::{PointerAuthSchema, Session}; use rustc_span::{DUMMY_SP, Span, Spanned, Symbol, sym}; +use rustc_structures::CrateType; use rustc_target::spec::{ Arch, CfgAbi, Env, FramePointer, HasTargetSpec, Os, RelocModel, SmallDataThresholdSupport, Target, TlsModel, @@ -563,6 +564,17 @@ pub(crate) unsafe fn create_module<'ll>( ); } + if llvm_version >= (24, 0, 0) + && let Some(floatabi) = sess.target.llvm_floatabi + { + llvm::add_module_flag_str( + llmod, + llvm::ModuleFlagMergeBehavior::Error, + "float-abi", + floatabi.desc(), + ); + } + // Add module flags specified via -Z llvm_module_flag for (key, value, merge_behavior) in &sess.opts.unstable_opts.llvm_module_flag { let merge_behavior = match merge_behavior.as_str() { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs index f5b843b4e3e74..dbf877077cb49 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs @@ -6,7 +6,8 @@ use rustc_codegen_ssa::traits::*; use rustc_hir::attrs::DebuggerVisualizerType; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::bug; -use rustc_session::config::{CrateType, DebugInfo}; +use rustc_session::config::DebugInfo; +use rustc_structures::CrateType; use crate::builder::Builder; use crate::common::CodegenCx; diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index b407b577042a1..ddc57af0a56e7 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -23,9 +23,9 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf}; use rustc_middle::ty::offload_meta::OffloadMetadata; use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv}; use rustc_middle::{bug, span_bug}; -use rustc_session::config::CrateType; use rustc_session::diagnostics::feature_err; use rustc_span::{ErrorGuaranteed, Span, Symbol, sym}; +use rustc_structures::CrateType; use rustc_symbol_mangling::{ mangle_internal_symbol, mangle_offload_export, symbol_name_for_instance_in_crate, }; diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 19d43797a875d..d67156c6cfa39 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -11,7 +11,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::mono::Visibility; use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf}; use rustc_middle::ty::{self, Instance, Ty, TypeVisitableExt}; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; use rustc_target::callconv::{FnAbi, PassMode}; use rustc_target::spec::{Arch, RelocModel}; use tracing::debug; diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index ab4ab9c80319b..a1306143a680a 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -32,6 +32,7 @@ rustc_mir_transform = { path = "../rustc_mir_transform" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index f14d58c24f316..25003e071beb7 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -21,7 +21,6 @@ use rustc_data_structures::memmap::Mmap; use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_errors::DiagCtxtHandle; use rustc_fs_util::{TempDirBuilder, fix_windows_verbatim_for_gcc, try_canonicalize}; -use rustc_hir::attrs::NativeLibKind; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_lint_defs::builtin::{LINKER_INFO, LINKER_MESSAGES}; use rustc_macros::Diagnostic; @@ -34,8 +33,8 @@ use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::SymbolExportKind; use rustc_session::config::{ - self, CFGuard, CrateType, DebugInfo, InstrumentMcount, LinkerFeaturesCli, LinkerJobs, - OutFileName, OutputFilenames, OutputType, PrintKind, SplitDwarfKind, Strip, + self, CFGuard, DebugInfo, InstrumentMcount, LinkerFeaturesCli, LinkerJobs, OutFileName, + OutputFilenames, OutputType, PrintKind, SplitDwarfKind, Strip, }; use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; use rustc_session::search_paths::PathKind; @@ -43,6 +42,7 @@ use rustc_session::search_paths::PathKind; /// need out of the shared crate context before we get rid of it. use rustc_session::{Session, filesearch}; use rustc_span::Symbol; +use rustc_structures::{CrateType, NativeLibKind}; use rustc_target::spec::crt_objects::CrtObjects; use rustc_target::spec::{ Arch, BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents, diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs index 2857c4f28b222..13478f417238a 100644 --- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs +++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs @@ -8,9 +8,9 @@ use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_data_structures::stable_hash::StableHasher; use rustc_hashes::Hash128; -use rustc_hir::attrs::NativeLibKind; use rustc_session::Session; use rustc_span::Symbol; +use rustc_structures::NativeLibKind; use rustc_target::spec::Arch; use crate::back::archive::ImportLibraryItem; diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 40e2f60ca6442..15f0c450f55f8 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -14,7 +14,8 @@ use rustc_middle::middle::exported_symbols::{ }; use rustc_middle::ty::{SymbolName, TyCtxt}; use rustc_session::Session; -use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; +use rustc_session::config::{self, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; +use rustc_structures::CrateType; use rustc_target::spec::{Arch, Cc, CfgAbi, LinkOutputKind, LinkerFlavor, Lld, Os}; use tracing::{debug, warn}; diff --git a/compiler/rustc_codegen_ssa/src/back/lto.rs b/compiler/rustc_codegen_ssa/src/back/lto.rs index 0b33c1db8e5dc..31fae5b4f96b0 100644 --- a/compiler/rustc_codegen_ssa/src/back/lto.rs +++ b/compiler/rustc_codegen_ssa/src/back/lto.rs @@ -8,7 +8,8 @@ use rustc_errors::DiagCtxtHandle; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, SymbolExportLevel}; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{CrateType, Lto}; +use rustc_session::config::Lto; +use rustc_structures::CrateType; use tracing::info; use crate::back::symbol_export::{self, allocator_shim_symbols, symbol_name_for_instance_in_crate}; diff --git a/compiler/rustc_codegen_ssa/src/back/rmeta_link.rs b/compiler/rustc_codegen_ssa/src/back/rmeta_link.rs index 69ec3788ac632..59139214146c4 100644 --- a/compiler/rustc_codegen_ssa/src/back/rmeta_link.rs +++ b/compiler/rustc_codegen_ssa/src/back/rmeta_link.rs @@ -8,11 +8,11 @@ use std::path::{Path, PathBuf}; use object::read::archive::ArchiveFile; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::memmap::Mmap; -use rustc_hir::attrs::NativeLibKind; use rustc_serialize::opaque::mem_encoder::MemEncoder; use rustc_serialize::opaque::{MAGIC_END_BYTES, MemDecoder}; use rustc_serialize::{Decodable, Encodable}; use rustc_span::Symbol; +use rustc_structures::NativeLibKind; use rustc_target::spec::Target; use tracing::debug; diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index cc102c636f4ae..f30ba43b0b0ba 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -18,8 +18,8 @@ use rustc_middle::ty::{ self, GenericArgKind, GenericArgsRef, Instance, ShimKind, SymbolName, Ty, TyCtxt, }; use rustc_middle::util::Providers; -use rustc_session::config::CrateType; use rustc_span::Span; +use rustc_structures::CrateType; use rustc_symbol_mangling::{is_offload_kernel, mangle_internal_symbol}; use rustc_target::spec::{Arch, Os, TlsModel}; use tracing::debug; diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 691ac892aa39a..78cdd3e38f68c 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -23,12 +23,12 @@ use rustc_middle::bug; use rustc_middle::dep_graph::{WorkProduct, WorkProductMap}; use rustc_middle::ty::TyCtxt; use rustc_session::config::{ - self, CrateType, Lto, OptLevel, OutFileName, OutputFilenames, OutputType, Passes, - SwitchWithOptPath, + self, Lto, OptLevel, OutFileName, OutputFilenames, OutputType, Passes, SwitchWithOptPath, }; use rustc_session::{IncrCompSession, Session}; use rustc_span::source_map::SourceMap; use rustc_span::{FileName, InnerSpan, Span, SpanData}; +use rustc_structures::CrateType; use rustc_target::spec::{MergeFunctions, SanitizerSet}; use tracing::debug; diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 0468e3de18d8b..9eb4fd510fd7f 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -30,8 +30,9 @@ use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, Instance, PatternKind, Ty, TyCtxt, UintTy, Unnormalized}; use rustc_middle::{bug, span_bug}; use rustc_session::Session; -use rustc_session::config::{self, CrateType, EntryFnType}; +use rustc_session::config::{self, EntryFnType}; use rustc_span::{DUMMY_SP, Symbol}; +use rustc_structures::CrateType; use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::spec::{Arch, Os}; use rustc_trait_selection::infer::{BoundRegionConversionTime, TyCtxtInferExt}; diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index edf06c4023e2f..bf2ce74e38d84 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -22,7 +22,7 @@ use rustc_crate_store::{self as cstore, CrateSource}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_hir::CRATE_HIR_ID; -use rustc_hir::attrs::{CfgEntry, NativeLibKind, WindowsSubsystemKind}; +use rustc_hir::attrs::{CfgEntry, WindowsSubsystemKind}; use rustc_hir::def_id::CrateNum; use rustc_lint_defs::builtin::{LINKER_INFO, LINKER_MESSAGES}; use rustc_macros::{Decodable, Encodable}; @@ -37,8 +37,9 @@ use rustc_middle::util::Providers; use rustc_serialize::opaque::{FileEncoder, MemDecoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_session::Session; -use rustc_session::config::{CrateType, OutputFilenames, OutputType}; +use rustc_session::config::{OutputFilenames, OutputType}; use rustc_span::{Span, Symbol}; +use rustc_structures::{CrateType, NativeLibKind}; pub mod assert_module_sources; pub mod back; diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 36f4d858d0be5..11878c1f5165d 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -8,9 +8,10 @@ use rustc_metadata::creader::MetadataLoaderDyn; use rustc_middle::dep_graph::WorkProductMap; use rustc_middle::ty::TyCtxt; use rustc_middle::util::Providers; -use rustc_session::config::{CrateType, OutputFilenames, PrintRequest}; +use rustc_session::config::{OutputFilenames, PrintRequest}; use rustc_session::{IncrCompSession, Session}; use rustc_span::Symbol; +use rustc_structures::CrateType; use super::CodegenObject; use crate::back::archive::ArArchiveBuilderBuilder; diff --git a/compiler/rustc_const_eval/Cargo.toml b/compiler/rustc_const_eval/Cargo.toml index eac00eb7b876d..296368c42034b 100644 --- a/compiler/rustc_const_eval/Cargo.toml +++ b/compiler/rustc_const_eval/Cargo.toml @@ -20,6 +20,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_mir_dataflow = { path = "../rustc_mir_dataflow" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } tracing = "0.1" diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 571e7e5975c79..8fa028df9455f 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -3,7 +3,6 @@ use std::collections::hash_map::Entry; use either::{Left, Right}; use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout}; -use rustc_data_structures::Limit; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; use rustc_middle::mir::interpret::{ErrorHandled, InvalidMetaKind, ReportedErrorInfo}; @@ -17,6 +16,7 @@ use rustc_middle::ty::{ }; use rustc_middle::{mir, span_bug}; use rustc_span::Span; +use rustc_structures::Limit; use rustc_target::callconv::FnAbi; use tracing::{debug, trace}; diff --git a/compiler/rustc_crate_store/Cargo.toml b/compiler/rustc_crate_store/Cargo.toml index 7c84c26afe2dc..1857ae8130c10 100644 --- a/compiler/rustc_crate_store/Cargo.toml +++ b/compiler/rustc_crate_store/Cargo.toml @@ -12,4 +12,5 @@ rustc_hir_id = { path = "../rustc_hir_id" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } # tidy-alphabetical-end diff --git a/compiler/rustc_crate_store/src/cstore.rs b/compiler/rustc_crate_store/src/cstore.rs index e3b339a5ce871..fba2fc288f5a9 100644 --- a/compiler/rustc_crate_store/src/cstore.rs +++ b/compiler/rustc_crate_store/src/cstore.rs @@ -6,7 +6,7 @@ use std::any::Any; use std::path::PathBuf; use rustc_abi::ExternAbi; -use rustc_attr_ir::{CfgEntry, NativeLibKind, PeImportNameType}; +use rustc_attr_ir::{CfgEntry, PeImportNameType}; use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock}; use rustc_hir_id::definitions::{DefKey, DefPath, Definitions}; use rustc_macros::{BlobDecodable, Decodable, Encodable, StableHash}; @@ -14,6 +14,7 @@ use rustc_span::def_id::{ CrateNum, DefId, DefPathHash, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap, }; use rustc_span::{Span, Symbol}; +use rustc_structures::NativeLibKind; /// Where a crate came from on the local filesystem. One of these three options /// must be non-None. diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 9714fb2123b08..d8c1e2bd0ed30 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -48,7 +48,6 @@ pub use ena::{snapshot_vec, undo_log, unify}; // (via `ShardedHashMap`), and because it lets other compiler crates use the // lower-level `HashTable` API without a tricky `hashbrown` dependency. pub use hashbrown::hash_table; -pub use limit::Limit; pub use rustc_index::static_assert_size; // Re-export some data-structure crates which are part of our public API. pub use {either, indexmap, smallvec, thin_vec}; @@ -63,7 +62,6 @@ pub mod fx; pub mod graph; pub mod intern; pub mod jobserver; -mod limit; pub mod marker; pub mod memmap; pub mod obligation_forest; diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 04a30933a4276..6dba3dff47327 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -34,6 +34,7 @@ rustc_public = { path = "../rustc_public", features = ["rustc_internal"] } rustc_resolve = { path = "../rustc_resolve" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } serde_json = "1.0.59" shlex = "1.0" diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index f7949995849a1..54a1babbaae72 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -52,7 +52,7 @@ use rustc_middle::ty::TyCtxt; use rustc_parse::lexer::StripTokens; use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal}; use rustc_session::config::{ - CG_OPTIONS, CrateType, ErrorOutputType, Input, OptionDesc, OutFileName, OutputType, Sysroot, + CG_OPTIONS, ErrorOutputType, Input, OptionDesc, OutFileName, OutputType, Sysroot, UnstableOptions, Z_OPTIONS, nightly_options, parse_target_triple, }; use rustc_session::getopts::{self, Matches}; @@ -60,6 +60,7 @@ use rustc_session::output::invalid_output_for_target; use rustc_session::{EarlyDiagCtxt, Session, config}; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::{DUMMY_SP, FileName}; +use rustc_structures::CrateType; use rustc_target::json::ToJson; use rustc_target::spec::{Target, TargetTuple}; use tracing::trace; diff --git a/compiler/rustc_driver_impl/src/signal_handler.rs b/compiler/rustc_driver_impl/src/signal_handler.rs index 3d5df19bf67ee..f1dbb45539c91 100644 --- a/compiler/rustc_driver_impl/src/signal_handler.rs +++ b/compiler/rustc_driver_impl/src/signal_handler.rs @@ -115,7 +115,8 @@ unsafe extern "C" fn print_stack_trace(signum: libc::c_int) { written += rem.len() + 1; let random_depth = || 8 * 16; // chosen by random diceroll (2d20) - if (cyclic || stack.len() > random_depth()) && signum == libc::SIGSEGV { + let maybe_stack_overflow = (cyclic || stack.len() > random_depth()) && signum == libc::SIGSEGV; + if maybe_stack_overflow { // technically speculation, but assert it with confidence anyway. // rustc only arrived in this signal handler because bad things happened // and this message is for explaining it's not the programmer's fault @@ -128,7 +129,7 @@ unsafe extern "C" fn print_stack_trace(signum: libc::c_int) { } raw_errln!("note: we would appreciate a report at https://github.com/rust-lang/rust"); written += 1; - if signum == libc::SIGSEGV { + if maybe_stack_overflow { // get the current stack size WITHOUT blocking and double it let new_size = STACK_SIZE.get().copied().unwrap_or(DEFAULT_STACK_SIZE) * 2; raw_errln!( diff --git a/compiler/rustc_error_messages/src/diagnostic_impls.rs b/compiler/rustc_error_messages/src/diagnostic_impls.rs index d2bbdde362156..38b086eaa80d3 100644 --- a/compiler/rustc_error_messages/src/diagnostic_impls.rs +++ b/compiler/rustc_error_messages/src/diagnostic_impls.rs @@ -5,7 +5,6 @@ use std::num::ParseIntError; use std::path::{Path, PathBuf}; use std::process::ExitStatus; -use rustc_data_structures::Limit; use rustc_span::edition::Edition; use crate::{DiagArgValue, IntoDiagArg}; @@ -157,9 +156,3 @@ impl IntoDiagArg for Backtrace { DiagArgValue::Str(Cow::from(self.to_string())) } } - -impl IntoDiagArg for Limit { - fn into_diag_arg(self, _: &mut Option) -> DiagArgValue { - self.0.into_diag_arg(&mut None) - } -} diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index 885de14fd6b2f..80353e4c8dba4 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -29,6 +29,7 @@ rustc_proc_macro = { path = "../rustc_proc_macro" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } scoped-tls = "1.0" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } thin-vec = "0.2.19" diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 64b6e4b8ef498..fda75319b087b 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -9,11 +9,9 @@ use rustc_ast::attr::MarkedAttrs; use rustc_ast::tokenstream::TokenStream; use rustc_ast::visit::{AssocCtxt, Visitor}; use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind, Safety}; -use rustc_attr_ir::{ - self as attrs, CfgEntry, CollapseMacroDebuginfo, Deprecation, Stability, find_attr, -}; +use rustc_attr_ir::{self as attrs, CfgEntry, Deprecation, Stability, find_attr}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; -use rustc_data_structures::{Limit, sync}; +use rustc_data_structures::sync; use rustc_errors::{BufferedEarlyLint, DiagCtxtHandle, ErrorGuaranteed}; use rustc_feature::Features; use rustc_hir::def::MacroKinds; @@ -27,6 +25,7 @@ use rustc_span::edition::Edition; use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind}; use rustc_span::source_map::SourceMap; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw}; +use rustc_structures::{CollapseMacroDebuginfo, Limit}; use smallvec::{SmallVec, smallvec}; use thin_vec::ThinVec; diff --git a/compiler/rustc_expand/src/diagnostics.rs b/compiler/rustc_expand/src/diagnostics.rs index 8c9e0dc9b85de..34fe7cab71b5b 100644 --- a/compiler/rustc_expand/src/diagnostics.rs +++ b/compiler/rustc_expand/src/diagnostics.rs @@ -1,9 +1,9 @@ use std::borrow::Cow; -use rustc_data_structures::Limit; use rustc_errors::codes::*; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol}; +use rustc_structures::Limit; #[derive(Diagnostic)] #[diag("`#[cfg_attr]` does not expand to any attributes")] diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 18e789314fa78..3a51b758a427b 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -19,7 +19,6 @@ use rustc_attr_parsing::{ AttributeParser, AttributeSafety, CFG_TEMPLATE, EvalConfigResult, ShouldEmit, eval_config_entry, parse_cfg, validate_attr, }; -use rustc_data_structures::Limit; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_errors::PResult; use rustc_feature::Features; @@ -32,6 +31,7 @@ use rustc_parse::parser::{ use rustc_session::diagnostics::feature_err; use rustc_span::hygiene::SyntaxContext; use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, Symbol, sym}; +use rustc_structures::Limit; use smallvec::SmallVec; use crate::base::*; diff --git a/compiler/rustc_hir_analysis/Cargo.toml b/compiler/rustc_hir_analysis/Cargo.toml index 955629d40cee2..06092f53272ce 100644 --- a/compiler/rustc_hir_analysis/Cargo.toml +++ b/compiler/rustc_hir_analysis/Cargo.toml @@ -24,6 +24,7 @@ rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs index 20c3ac6036678..01d0c8483ac54 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -1,9 +1,9 @@ -use rustc_data_structures::Limit; use rustc_infer::infer::InferCtxt; use rustc_infer::traits::PredicateObligations; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Unnormalized}; use rustc_span::def_id::{LOCAL_CRATE, LocalDefId}; use rustc_span::{ErrorGuaranteed, Span}; +use rustc_structures::Limit; use rustc_trait_selection::traits::ObligationCtxt; use tracing::{debug, instrument}; diff --git a/compiler/rustc_hir_analysis/src/diagnostics.rs b/compiler/rustc_hir_analysis/src/diagnostics.rs index 890d25f14b264..2547695132e7d 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics.rs @@ -1,7 +1,6 @@ //! Errors emitted by `rustc_hir_analysis`. use rustc_abi::ExternAbi; -use rustc_data_structures::Limit; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level, @@ -10,6 +9,7 @@ use rustc_errors::{ use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::{self, Ty}; use rustc_span::{Ident, Span, Symbol}; +use rustc_structures::Limit; pub(crate) mod wrong_number_of_generic_args; mod precise_captures; diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index bda6f48734b31..4e99ba176d57b 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -41,6 +41,7 @@ rustc_query_impl = { path = "../rustc_query_impl" } rustc_resolve = { path = "../rustc_resolve" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } rustc_thread_pool = { path = "../rustc_thread_pool" } diff --git a/compiler/rustc_interface/src/diagnostics.rs b/compiler/rustc_interface/src/diagnostics.rs index 9e6d4317c98e5..2a2757f814715 100644 --- a/compiler/rustc_interface/src/diagnostics.rs +++ b/compiler/rustc_interface/src/diagnostics.rs @@ -1,9 +1,9 @@ use std::io; use std::path::Path; -use rustc_hir::attrs::CrateType; use rustc_macros::Diagnostic; use rustc_span::{Span, Symbol}; +use rustc_structures::CrateType; use rustc_target::spec::TargetTuple; #[derive(Diagnostic)] diff --git a/compiler/rustc_interface/src/limits.rs b/compiler/rustc_interface/src/limits.rs index f1f2b1536f806..8f116cfdf6a86 100644 --- a/compiler/rustc_interface/src/limits.rs +++ b/compiler/rustc_interface/src/limits.rs @@ -8,10 +8,10 @@ //! Users can override these limits via an attribute on the crate like //! `#![recursion_limit="22"]`. This pass just looks for those attributes. -use rustc_data_structures::Limit; use rustc_hir::{Attribute, find_attr}; use rustc_middle::query::Providers; use rustc_session::{Limits, Session}; +use rustc_structures::Limit; pub(crate) fn provide(providers: &mut Providers) { providers.limits = |tcx, ()| { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index fa9d2f8e852b5..c829864b02288 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -15,7 +15,7 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{ AppendOnlyIndexVec, DynSend, DynSync, FreezeLock, WorkerLocal, par_fns, }; -use rustc_data_structures::{Limit, thousands}; +use rustc_data_structures::thousands; use rustc_errors::timings::TimingSection; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level}; use rustc_expand::base::{ExtCtxt, LintStoreExpand}; @@ -36,7 +36,7 @@ use rustc_parse::lexer::StripTokens; use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal}; use rustc_passes::{abi_test, input_stats, layout_test}; use rustc_resolve::{Resolver, ResolverOutputs}; -use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType}; +use rustc_session::config::{Input, OutFileName, OutputFilenames, OutputType}; use rustc_session::diagnostics::feature_err; use rustc_session::output::{filename_for_input, invalid_output_for_target}; use rustc_session::search_paths::PathKind; @@ -44,6 +44,7 @@ use rustc_session::{IncrCompSession, Session}; use rustc_span::{ DUMMY_SP, ErrorGuaranteed, ExpnKind, SourceFileHash, SourceFileHashAlgorithm, Span, Symbol, sym, }; +use rustc_structures::{CrateType, Limit}; use rustc_trait_selection::{solve, traits}; use tracing::{info, instrument}; @@ -875,7 +876,7 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) { } pub fn write_interface<'tcx>(tcx: TyCtxt<'tcx>) { - if !tcx.crate_types().contains(&rustc_session::config::CrateType::Sdylib) { + if !tcx.crate_types().contains(&rustc_structures::CrateType::Sdylib) { return; } let _timer = tcx.sess.timer("write_interface"); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 6f7688e021c39..1628c8466cdf6 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -8,7 +8,6 @@ use rustc_abi::Align; use rustc_data_structures::profiling::TimePassesFormat; use rustc_errors::ColorConfig; use rustc_errors::emitter::HumanReadableErrorType; -use rustc_hir::attrs::{CollapseMacroDebuginfo, NativeLibKind}; use rustc_lint_defs::Level; use rustc_session::config::{ AnnotateMoves, AutoDiff, BranchProtection, CFGuard, Cfg, CodegenRetagOptions, CoverageLevel, @@ -26,6 +25,7 @@ use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, build_session, getopts}; use rustc_span::edition::{DEFAULT_EDITION, Edition}; use rustc_span::source_map::{RealFileLoader, SourceMapInputs}; use rustc_span::{FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, sym}; +use rustc_structures::{CollapseMacroDebuginfo, NativeLibKind}; use rustc_target::spec::{ CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 23b152bd57240..89907447571ee 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -22,12 +22,13 @@ use rustc_middle::dep_graph::WorkProductMap; use rustc_middle::ty::{CurrentGcx, TyCtxt}; use rustc_query_impl::{CollectActiveJobsKind, collect_active_query_jobs}; use rustc_session::config::{ - Cfg, CrateType, Jobs, OutFileName, OutputFilenames, OutputTypes, Sysroot, host_tuple, + Cfg, Jobs, OutFileName, OutputFilenames, OutputTypes, Sysroot, host_tuple, }; use rustc_session::{EarlyDiagCtxt, IncrCompSession, Session, filesearch}; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMapInputs; use rustc_span::{SessionGlobals, Symbol, sym}; +use rustc_structures::CrateType; use rustc_target::spec::Target; use tracing::info; diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index 5d575dc7c1641..a672f242449e4 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -23,6 +23,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_parse_format = { path = "../rustc_parse_format" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 30c65a504d8d7..45f34e6a6e3c1 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -11,9 +11,9 @@ use rustc_hir::{Attribute, GenericParamKind, PatExprKind, PatKind, find_attr}; use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_middle::hir::nested_filter::All; use rustc_middle::ty::AssocContainer; -use rustc_session::config::CrateType; use rustc_span::def_id::LocalDefId; use rustc_span::{BytePos, Ident, Span, sym}; +use rustc_structures::CrateType; use crate::diagnostics::{ NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub, diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 3ad59c53a5bf3..81a506c63a8ee 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -365,7 +365,9 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Trip); +#if LLVM_VERSION_LT(24, 0) Options.FloatABIType = FloatABIType; +#endif Options.DataSections = DataSections; Options.FunctionSections = FunctionSections; Options.UniqueSectionNames = UniqueSectionNames; @@ -439,7 +441,11 @@ extern "C" void LLVMRustAddLibraryInfo(LLVMTargetMachineRef T, if (DisableSimplifyLibCalls) TLII.disableAllFunctions(); unwrap(PMR)->add(new TargetLibraryInfoWrapperPass(TLII)); -#if LLVM_VERSION_GE(22, 0) +#if LLVM_VERSION_GE(24, 0) + unwrap(PMR)->add(new RuntimeLibraryInfoWrapper( + Options->ExceptionModel, Options->EABIVersion, Options->MCOptions.ABIName, + Options->VecLib)); +#elif LLVM_VERSION_GE(22, 0) unwrap(PMR)->add(new RuntimeLibraryInfoWrapper( TargetTriple, Options->ExceptionModel, Options->FloatABIType, Options->EABIVersion, Options->MCOptions.ABIName, Options->VecLib)); diff --git a/compiler/rustc_metadata/Cargo.toml b/compiler/rustc_metadata/Cargo.toml index 46a2f4b5114f9..a2ef8454ed6a6 100644 --- a/compiler/rustc_metadata/Cargo.toml +++ b/compiler/rustc_metadata/Cargo.toml @@ -29,6 +29,7 @@ rustc_proc_macro = { path = "../rustc_proc_macro" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } tempfile = "3.7.1" tracing = "0.1" diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 8feb1fbbb3d82..60de9d179cb98 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -27,14 +27,14 @@ use rustc_proc_macro::bridge::client::Client as ProcMacroClient; use rustc_session::Session; use rustc_session::config::mitigation_coverage::DeniedPartialMitigationLevel; use rustc_session::config::{ - CrateType, ExtendedTargetModifierInfo, ExternLocation, Externs, OptionsTargetModifiers, - TargetModifier, + ExtendedTargetModifierInfo, ExternLocation, Externs, OptionsTargetModifiers, TargetModifier, }; use rustc_session::output::validate_crate_name; use rustc_session::search_paths::PathKind; use rustc_span::def_id::DefId; use rustc_span::edition::Edition; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, sym}; +use rustc_structures::CrateType; use rustc_target::spec::{PanicStrategy, Target}; use tracing::{debug, info}; diff --git a/compiler/rustc_metadata/src/dependency_format.rs b/compiler/rustc_metadata/src/dependency_format.rs index 6460e20ce211b..90844009f6bbe 100644 --- a/compiler/rustc_metadata/src/dependency_format.rs +++ b/compiler/rustc_metadata/src/dependency_format.rs @@ -59,8 +59,8 @@ use rustc_index::IndexVec; use rustc_middle::bug; use rustc_middle::middle::dependency_format::{Dependencies, DependencyList, Linkage}; use rustc_middle::ty::TyCtxt; -use rustc_session::config::CrateType; use rustc_span::sym; +use rustc_structures::CrateType; use rustc_target::spec::PanicStrategy; use tracing::info; diff --git a/compiler/rustc_metadata/src/fs.rs b/compiler/rustc_metadata/src/fs.rs index 044ec5345cdcd..535197b3dc51a 100644 --- a/compiler/rustc_metadata/src/fs.rs +++ b/compiler/rustc_metadata/src/fs.rs @@ -5,8 +5,9 @@ use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_fs_util::TempDirBuilder; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_session::config::{CrateType, OutFileName, OutputType}; +use rustc_session::config::{OutFileName, OutputType}; use rustc_session::output::filename_for_metadata; +use rustc_structures::CrateType; use crate::diagnostics::{ BinaryOutputToTty, FailedCopyToStdout, FailedCreateEncodedMetadata, FailedCreateFile, diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 138bb55847255..87e0902b1f7f8 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -4,7 +4,7 @@ use rustc_crate_store::{ DllCallingConvention, DllImport, DllImportSymbolType, ForeignModule, NativeLib, }; use rustc_data_structures::fx::FxHashSet; -use rustc_hir::attrs::{NativeLibKind, PeImportNameType}; +use rustc_hir::attrs::PeImportNameType; use rustc_hir::def::DefKind; use rustc_hir::find_attr; use rustc_middle::bug; @@ -14,6 +14,7 @@ use rustc_middle::ty::{self, List, Ty, TyCtxt}; use rustc_session::Session; use rustc_span::Symbol; use rustc_span::def_id::{DefId, LOCAL_CRATE}; +use rustc_structures::NativeLibKind; use rustc_target::spec::{Arch, BinaryFormat, CfgAbi}; use crate::diagnostics; diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 228600fa76794..cc7da00fcec5c 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -27,13 +27,14 @@ use rustc_middle::ty::fast_reject::{self, TreatParams}; use rustc_middle::{bug, span_bug}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque}; use rustc_session::config::mitigation_coverage::DeniedPartialMitigation; -use rustc_session::config::{CrateType, OptLevel, TargetModifier}; +use rustc_session::config::{OptLevel, TargetModifier}; use rustc_span::def_id::CRATE_MOD_ID; use rustc_span::hygiene::HygieneEncodeContext; use rustc_span::{ ByteSymbol, ExternalSource, FileName, SourceFile, SpanData, SpanEncoder, StableSourceFileId, Symbol, SyntaxContext, sym, }; +use rustc_structures::CrateType; use tracing::{debug, instrument, trace}; use crate::diagnostics::{FailCreateFileEncoder, FailWriteFile}; diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 96506291735ba..b26969a830f11 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -28,6 +28,7 @@ rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } rustc_thread_pool = { path = "../rustc_thread_pool" } rustc_type_ir = { path = "../rustc_type_ir" } diff --git a/compiler/rustc_middle/src/diagnostics.rs b/compiler/rustc_middle/src/diagnostics.rs index 9d90691e51446..b2e987602963f 100644 --- a/compiler/rustc_middle/src/diagnostics.rs +++ b/compiler/rustc_middle/src/diagnostics.rs @@ -59,7 +59,7 @@ pub(crate) struct RecursionLimitReached<'tcx> { #[primary_span] pub span: Span, pub ty: Ty<'tcx>, - pub suggested_limit: rustc_data_structures::Limit, + pub suggested_limit: rustc_structures::Limit, } #[derive(Diagnostic)] @@ -71,7 +71,7 @@ pub(crate) struct RecursionLimitReachedSizeSkeleton<'tcx> { #[primary_span] pub span: Span, pub ty: Ty<'tcx>, - pub suggested_limit: rustc_data_structures::Limit, + pub suggested_limit: rustc_structures::Limit, } #[derive(Diagnostic)] diff --git a/compiler/rustc_middle/src/middle/dependency_format.rs b/compiler/rustc_middle/src/middle/dependency_format.rs index ea04b519a7dea..f71a5d8e2718b 100644 --- a/compiler/rustc_middle/src/middle/dependency_format.rs +++ b/compiler/rustc_middle/src/middle/dependency_format.rs @@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_hir::def_id::CrateNum; use rustc_index::IndexVec; use rustc_macros::{Decodable, Encodable, StableHash}; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; /// A list of dependencies for a certain crate type. pub type DependencyList = IndexVec; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f4ee5a693ecb3..35c61f66d639e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -18,6 +18,7 @@ use std::{fmt, iter, mem}; use rustc_abi::{ExternAbi, FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx}; use rustc_ast as ast; use rustc_crate_store::{CrateStoreDyn, Untracked}; +use rustc_data_structures::defer; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; use rustc_data_structures::profiling::SelfProfilerRef; @@ -27,7 +28,6 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{ self, DynSend, DynSync, FreezeReadGuard, Lock, RwLock, WorkerLocal, }; -use rustc_data_structures::{Limit, defer}; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, MultiSpan}; use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def::DefKind; @@ -39,10 +39,10 @@ use rustc_index::IndexVec; use rustc_lint_defs::Lint; use rustc_lint_defs::builtin::UNUSED_FEATURES; use rustc_macros::Diagnostic; -use rustc_session::config::CrateType; use rustc_session::{IncrCompSession, Session}; use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId}; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; +use rustc_structures::{CrateType, Limit}; use rustc_type_ir::TyKind::*; pub use rustc_type_ir::lift::Lift; use rustc_type_ir::{CollectAndApply, WithCachedTypeInfo, elaborate, search_graph}; diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs index 2444f8513b8e4..637fc1d34b9e1 100644 --- a/compiler/rustc_middle/src/ty/context/impl_interner.rs +++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs @@ -2,7 +2,6 @@ use std::{debug_assert_matches, fmt}; -use rustc_data_structures::Limit; use rustc_data_structures::intern::Interned; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; @@ -12,6 +11,7 @@ use rustc_hir::def::{CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; use rustc_lint_defs::builtin::RECURSION_DEPTH_EXCEEDING_LIMIT; use rustc_span::{DUMMY_SP, Span, Symbol}; +use rustc_structures::Limit; use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverProjectionLangItem, SolverTraitLangItem}; use rustc_type_ir::{ BoundVar, CollectAndApply, DebruijnIndex, Interner, TypeFoldable, Unnormalized, VisitorResult, diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index a16352e45564e..33541dee52fe6 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -4,11 +4,11 @@ use std::hash::{DefaultHasher, Hash, Hasher}; use std::io::{Read, Write}; use std::path::PathBuf; -use rustc_data_structures::Limit; use rustc_errors::pluralize; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind}; use rustc_macros::extension; +use rustc_structures::Limit; pub use rustc_type_ir::error::ExpectedFound; use crate::ty::print::{FmtPrinter, Print, with_forced_trimmed_paths}; diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index c525a9e4ebe61..f6e0e03858157 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -6,7 +6,6 @@ use rustc_abi::{ PointerKind, Primitive, ReprFlags, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, TyAbiInterface, VariantIdx, Variants, }; -use rustc_data_structures::Limit; use rustc_errors::{ Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, }; @@ -16,6 +15,7 @@ use rustc_hir::def_id::DefId; use rustc_macros::{StableHash, TyDecodable, TyEncodable, extension}; use rustc_session::config::OptLevel; use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym}; +use rustc_structures::Limit; use rustc_target::callconv::FnAbi; use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi}; use tracing::debug; diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 84437a237c28a..67a2a23b15a07 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -7,7 +7,6 @@ use rustc_abi::{ExternAbi, Size}; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_crate_store::{ExternCrate, ExternCrateSource}; -use rustc_data_structures::Limit; use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; use rustc_data_structures::unord::UnordMap; use rustc_hir as hir; @@ -17,6 +16,7 @@ use rustc_hir::def_id::{DefIdMap, DefIdSet, LOCAL_CRATE, ModId}; use rustc_hir::definitions::{DefKey, DefPathDataName}; use rustc_macros::{Lift, extension}; use rustc_span::{Ident, RemapPathScopeComponents, Symbol, kw, sym}; +use rustc_structures::Limit; use rustc_type_ir::{FieldInfo, Unnormalized, Upcast as _, elaborate}; use smallvec::SmallVec; diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 2e31e666f8f48..d18882e4649ca 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -4,7 +4,6 @@ use std::{fmt, iter}; use rustc_abi::{Float, Integer, IntegerType, Size}; use rustc_apfloat::Float as _; -use rustc_data_structures::Limit; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hash::{StableHash, StableHasher}; use rustc_errors::ErrorGuaranteed; @@ -15,6 +14,7 @@ use rustc_hir::{self as hir, find_attr}; use rustc_index::bit_set::GrowableBitSet; use rustc_macros::{StableHash, TyDecodable, TyEncodable, extension}; use rustc_span::sym; +use rustc_structures::Limit; use rustc_type_ir::solve::SizedTraitKind; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; diff --git a/compiler/rustc_mir_transform/Cargo.toml b/compiler/rustc_mir_transform/Cargo.toml index b5dc8100cbb26..4d157391ed4b0 100644 --- a/compiler/rustc_mir_transform/Cargo.toml +++ b/compiler/rustc_mir_transform/Cargo.toml @@ -22,6 +22,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_mir_dataflow = { path = "../rustc_mir_dataflow" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs index b974cb656379d..5b6b5203fdafa 100644 --- a/compiler/rustc_mir_transform/src/inline/cycle.rs +++ b/compiler/rustc_mir_transform/src/inline/cycle.rs @@ -1,10 +1,10 @@ -use rustc_data_structures::Limit; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_data_structures::unord::UnordSet; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::mir::TerminatorKind; use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, ShimKind, TyCtxt, TypeVisitableExt}; use rustc_span::sym; +use rustc_structures::Limit; use tracing::{instrument, trace}; #[instrument(level = "debug", skip(tcx), ret)] diff --git a/compiler/rustc_monomorphize/Cargo.toml b/compiler/rustc_monomorphize/Cargo.toml index de020de0b1dc5..ce5b90e2593a8 100644 --- a/compiler/rustc_monomorphize/Cargo.toml +++ b/compiler/rustc_monomorphize/Cargo.toml @@ -17,6 +17,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_target = { path = "../rustc_target" } serde = "1" diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 62519ee4f13ee..b7813992db5bf 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -208,7 +208,6 @@ use std::cell::OnceCell; use std::ops::ControlFlow; -use rustc_data_structures::Limit; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync::{Lock, par_for_each_in}; use rustc_data_structures::unord::{UnordMap, UnordSet}; @@ -233,6 +232,7 @@ use rustc_middle::util::Providers; use rustc_middle::{bug, span_bug}; use rustc_session::config::{DebugInfo, EntryFnType, Offload}; use rustc_span::{DUMMY_SP, Span, Spanned, Symbol, dummy_spanned, respan}; +use rustc_structures::Limit; use tracing::{debug, instrument, trace}; use crate::diagnostics::{ diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs index b32ca204f3998..3d925baa0a32b 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs @@ -1,5 +1,4 @@ use rustc_abi::Size; -use rustc_data_structures::Limit; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_lint_defs::builtin::LARGE_ASSIGNMENTS; @@ -7,6 +6,7 @@ use rustc_middle::mir::visit::Visitor as MirVisitor; use rustc_middle::mir::{self, Location, traversal}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable}; use rustc_span::{Span, Spanned, sym}; +use rustc_structures::Limit; use tracing::{debug, trace}; use crate::diagnostics::LargeAssignmentsLint; diff --git a/compiler/rustc_passes/Cargo.toml b/compiler/rustc_passes/Cargo.toml index bcfe65f31b082..acdefb96bb9be 100644 --- a/compiler/rustc_passes/Cargo.toml +++ b/compiler/rustc_passes/Cargo.toml @@ -21,6 +21,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_privacy = { path = "../rustc_privacy" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } tracing = "0.1" diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 3a3b0ed519708..343257e9c4875 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -39,10 +39,10 @@ use rustc_middle::traits::ObligationCause; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::{self, TyCtxt, TypingMode, Unnormalized}; use rustc_middle::{bug, span_bug}; -use rustc_session::config::CrateType; use rustc_session::diagnostics::feature_err; use rustc_span::edition::Edition; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; +use rustc_structures::CrateType; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs}; use rustc_trait_selection::traits::{ObligationCtxt, TraitErrors}; diff --git a/compiler/rustc_passes/src/check_export.rs b/compiler/rustc_passes/src/check_export.rs index 411aad0717959..bd2cf272faa35 100644 --- a/compiler/rustc_passes/src/check_export.rs +++ b/compiler/rustc_passes/src/check_export.rs @@ -14,8 +14,8 @@ use rustc_middle::query::{LocalCrate, Providers}; use rustc_middle::ty::{ self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, Unnormalized, Visibility, }; -use rustc_session::config::CrateType; use rustc_span::Span; +use rustc_structures::CrateType; use crate::diagnostics::UnexportableItem; diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 68ee14bc5474d..e67408a419611 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -23,8 +23,8 @@ use rustc_middle::middle::privacy::Level; use rustc_middle::query::Providers; use rustc_middle::ty::{self, AssocTag, TyCtxt}; use rustc_middle::{bug, span_bug}; -use rustc_session::config::CrateType; use rustc_span::{Symbol, kw}; +use rustc_structures::CrateType; use crate::diagnostics::{ ChangeFields, DeadCodePubInBinaryNote, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, diff --git a/compiler/rustc_passes/src/eii.rs b/compiler/rustc_passes/src/eii.rs index 48621faeecc2f..05cb10e174d89 100644 --- a/compiler/rustc_passes/src/eii.rs +++ b/compiler/rustc_passes/src/eii.rs @@ -8,7 +8,7 @@ use rustc_hir::attrs::{EiiDecl, EiiImpl}; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc_middle::diagnostics::DuplicateEiiImpls; use rustc_middle::ty::TyCtxt; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; use crate::diagnostics::EiiWithoutImpl; diff --git a/compiler/rustc_passes/src/entry.rs b/compiler/rustc_passes/src/entry.rs index 80cfe10ca7176..3b0ee311efc22 100644 --- a/compiler/rustc_passes/src/entry.rs +++ b/compiler/rustc_passes/src/entry.rs @@ -4,8 +4,9 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::{ItemId, Node, find_attr}; use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{CrateType, EntryFnType, sigpipe}; +use rustc_session::config::{EntryFnType, sigpipe}; use rustc_span::{RemapPathScopeComponents, Span}; +use rustc_structures::CrateType; use crate::diagnostics::{ExternMain, MultipleRustcMain, NoMainErr}; diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs index 86a57a4d36121..ddf8bbf764e6e 100644 --- a/compiler/rustc_passes/src/lang_items.rs +++ b/compiler/rustc_passes/src/lang_items.rs @@ -230,7 +230,7 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> { } } - if self.tcx.crate_types().contains(&rustc_session::config::CrateType::Sdylib) { + if self.tcx.crate_types().contains(&rustc_structures::CrateType::Sdylib) { self.tcx.dcx().emit_err(IncorrectCrateType { span: attr_span }); } diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index 05f12aaedcfce..576c65a58021c 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -35,7 +35,7 @@ use rustc_middle::mir::interpret::{ConstAllocation, ErrorHandled, GlobalAlloc}; use rustc_middle::query::Providers; use rustc_middle::ty::{self, ExistentialTraitRef, TyCtxt}; use rustc_privacy::DefIdVisitor; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; use tracing::debug; /// Determines whether this item is recursive for reachability. See `is_recursively_reachable_local` diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index 3d451fde8adb8..e7042767f8bae 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -5,7 +5,7 @@ use rustc_hir::attrs::lang_items::{self, LangItem}; use rustc_hir::attrs::weak_lang_items::WEAK_LANG_ITEMS; use rustc_middle::middle::lang_items::required; use rustc_middle::ty::TyCtxt; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; use crate::diagnostics::{MissingLangItem, MissingPanicHandler, PanicUnwindWithoutStd}; diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index ec1d8dab74519..1b526e416b38d 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -13,6 +13,7 @@ rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_thread_pool = { path = "../rustc_thread_pool" } tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_query_impl/src/diagnostics.rs b/compiler/rustc_query_impl/src/diagnostics.rs index eee6cea623909..dd33d4c7bbf57 100644 --- a/compiler/rustc_query_impl/src/diagnostics.rs +++ b/compiler/rustc_query_impl/src/diagnostics.rs @@ -1,7 +1,7 @@ -use rustc_data_structures::Limit; use rustc_errors::codes::*; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; +use rustc_structures::Limit; #[derive(Diagnostic)] #[help( diff --git a/compiler/rustc_query_impl/src/execution.rs b/compiler/rustc_query_impl/src/execution.rs index 3e5ee960e2772..796ce8e666fc5 100644 --- a/compiler/rustc_query_impl/src/execution.rs +++ b/compiler/rustc_query_impl/src/execution.rs @@ -3,7 +3,7 @@ use std::mem::ManuallyDrop; use std::num::NonZero; use rustc_data_structures::hash_table::Entry; -use rustc_data_structures::{Limit, defer, outline, sharded, sync}; +use rustc_data_structures::{defer, outline, sharded, sync}; use rustc_errors::FatalError; use rustc_middle::dep_graph::{ DepGraphData, DepNode, DepNodeIndex, DepNodeKey, SerializedDepNodeIndex, @@ -17,6 +17,7 @@ use rustc_middle::ty::tls::{self, ImplicitCtxt}; use rustc_middle::verify_ich::incremental_verify_ich; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::{DUMMY_SP, Span}; +use rustc_structures::Limit; use crate::diagnostics::{QueryOverflow, QueryOverflowNote}; use crate::handle_cycle_error; diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml index c8330631a979e..19a4ee5a55ff7 100644 --- a/compiler/rustc_resolve/Cargo.toml +++ b/compiler/rustc_resolve/Cargo.toml @@ -26,6 +26,7 @@ rustc_metadata = { path = "../rustc_metadata" } rustc_middle = { path = "../rustc_middle" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } thin-vec = "0.2.19" tracing = "0.1" diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index b9cc7b7fff74c..0e99db1b95cc1 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -32,9 +32,10 @@ use rustc_lint_defs::builtin::{ELIDED_LIFETIMES_IN_PATHS, UNUSED_LABELS}; use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::ty::{AssocTag, DelegationInfo, Visibility}; use rustc_middle::{bug, span_bug}; -use rustc_session::config::{CrateType, ResolveDocLinks}; +use rustc_session::config::ResolveDocLinks; use rustc_session::diagnostics::feature_err; use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Spanned, Symbol, kw, respan, sym}; +use rustc_structures::CrateType; use smallvec::{SmallVec, smallvec}; use thin_vec::ThinVec; use tracing::{debug, instrument, trace}; diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 5faf0cd642440..180157dbfb950 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -70,10 +70,10 @@ use rustc_middle::ty::{ ResolverAstLowering, ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility, }; use rustc_middle::{bug, span_bug}; -use rustc_session::config::CrateType; use rustc_span::def_id::{LocalModId, ModId}; use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency}; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; +use rustc_structures::CrateType; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index c230c6793f0c2..0bf35dac5513b 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -8,7 +8,6 @@ edition = "2024" getopts = "0.2" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } -rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_feature = { path = "../rustc_feature" } @@ -18,6 +17,7 @@ rustc_lint_defs = { path = "../rustc_lint_defs" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } termize = "0.2" tracing = "0.1" diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 266a5adb2f29c..f5d56698c7680 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -26,6 +26,7 @@ use rustc_span::source_map::FilePathMapping; use rustc_span::{ FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym, }; +use rustc_structures::CrateType; use rustc_target::spec::{ FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo, Target, TargetTuple, @@ -1579,8 +1580,6 @@ pub enum EntryFnType { }, } -pub use rustc_attr_ir::CrateType; - #[derive(Clone, Hash, Debug, PartialEq, Eq, Encodable, Decodable)] pub enum Passes { Some(Vec), @@ -3318,7 +3317,6 @@ pub(crate) mod dep_tracking { use rustc_abi::Align; use rustc_ast::attr::version::RustcVersion; - use rustc_attr_ir::CollapseMacroDebuginfo; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stable_hash::StableHasher; use rustc_errors::LanguageIdentifier; @@ -3326,6 +3324,7 @@ pub(crate) mod dep_tracking { use rustc_hashes::Hash64; use rustc_span::edition::Edition; use rustc_span::{RealFileName, RemapPathScopeComponents}; + use rustc_structures::CollapseMacroDebuginfo; use rustc_target::spec::{ CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, TargetTuple, diff --git a/compiler/rustc_session/src/config/native_libs.rs b/compiler/rustc_session/src/config/native_libs.rs index d8c41fbae4c96..0733bd3ca4b78 100644 --- a/compiler/rustc_session/src/config/native_libs.rs +++ b/compiler/rustc_session/src/config/native_libs.rs @@ -4,8 +4,8 @@ //! (There is also a similar but separate syntax for `#[link]` attributes, //! which have their own parser in `rustc_metadata`.) -use rustc_attr_ir::NativeLibKind; use rustc_feature::UnstableFeatures; +use rustc_structures::NativeLibKind; use crate::EarlyDiagCtxt; use crate::config::UnstableOptions; diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 9ed3975043966..68e0fec59f06e 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -5,7 +5,6 @@ use std::str; use rustc_abi::Align; use rustc_ast::attr::version::RustcVersion; -use rustc_attr_ir::CollapseMacroDebuginfo; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::stable_hash::StableHasher; @@ -16,6 +15,7 @@ use rustc_macros::{BlobDecodable, Encodable}; use rustc_span::edit_distance::edit_distance; use rustc_span::edition::Edition; use rustc_span::{RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm}; +use rustc_structures::{CollapseMacroDebuginfo, CrateType}; use rustc_target::spec::{ CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, SymbolVisibility, diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index 26c53258a0d59..4824abae622c2 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -3,9 +3,10 @@ use std::path::Path; use rustc_span::{Span, Symbol}; +use rustc_structures::CrateType; use crate::Session; -use crate::config::{CrateType, OutFileName, OutputFilenames, OutputType}; +use crate::config::{OutFileName, OutputFilenames, OutputType}; use crate::diagnostics::{ CrateNameEmpty, FileIsNotWriteable, InvalidCharacterInCrateName, InvalidCharacterInCrateNameSuggestion, diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 74f533e11e66f..f04f40dd17168 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -6,10 +6,10 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::{env, io}; +use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef}; use rustc_data_structures::sync::{AppendOnlyVec, DynSend, DynSync, Lock}; -use rustc_data_structures::{Limit, flock}; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; use rustc_errors::codes::*; use rustc_errors::emitter::{DynEmitter, HumanReadableErrorType, OutputTheme, stderr_destination}; @@ -25,6 +25,7 @@ pub use rustc_span::def_id::StableCrateId; use rustc_span::edition::Edition; use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{RealFileName, Span, Symbol}; +use rustc_structures::{CrateType, Limit}; use rustc_target::asm::InlineAsmArch; use rustc_target::spec::{ Arch, CfgAbi, CodeModel, DebuginfoKind, Os, PanicStrategy, RelocModel, RelroLevel, @@ -35,7 +36,7 @@ use rustc_target::spec::{ use crate::code_stats::CodeStats; pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use crate::config::{ - self, BranchProtection, Cfg, CheckCfg, CoverageLevel, CoverageOptions, CrateType, DebugInfo, + self, BranchProtection, Cfg, CheckCfg, CoverageLevel, CoverageOptions, DebugInfo, ErrorOutputType, FunctionReturn, Input, InstrumentCoverage, InstrumentMcount, NATIVE_CPU, OptLevel, OutFileName, OutputType, PAuthKey, PointerAuthOption, SwitchWithOptPath, }; diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index d1d0f18b2c4cf..42300d540ed49 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -1,10 +1,10 @@ use std::path::PathBuf; use std::sync::OnceLock; -use rustc_attr_ir::NativeLibKind; use rustc_data_structures::profiling::VerboseTimingGuard; use rustc_fs_util::try_canonicalize; use rustc_macros::{Decodable, Encodable, StableHash}; +use rustc_structures::NativeLibKind; use crate::session::Session; diff --git a/compiler/rustc_structures/Cargo.toml b/compiler/rustc_structures/Cargo.toml new file mode 100644 index 0000000000000..8b91e2951876b --- /dev/null +++ b/compiler/rustc_structures/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "rustc_structures" +version = "0.0.0" +edition = "2024" + +[dependencies] +# tidy-alphabetical-start +bitflags = "2.4.1" +rustc_data_structures = { path = "../rustc_data_structures", optional = true } +rustc_error_messages = { path = "../rustc_error_messages", optional = true } +rustc_macros = { path = "../rustc_macros", optional = true } +rustc_serialize = { path = "../rustc_serialize", optional = true } +rustc_span = { path = "../rustc_span", optional = true } +schemars = "1.0.4" +serde = "1.0.219" +# tidy-alphabetical-end + +[features] +# tidy-alphabetical-start +default = ["nightly"] +nightly = [ + "dep:rustc_data_structures", + "dep:rustc_error_messages", + "dep:rustc_macros", + "dep:rustc_serialize", + "dep:rustc_span", +] +# tidy-alphabetical-end diff --git a/compiler/rustc_structures/src/collapse_macro_debug_info.rs b/compiler/rustc_structures/src/collapse_macro_debug_info.rs new file mode 100644 index 0000000000000..8dd3f6cb5c337 --- /dev/null +++ b/compiler/rustc_structures/src/collapse_macro_debug_info.rs @@ -0,0 +1,22 @@ +#[cfg(feature = "nightly")] +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; + +// How to perform collapse macros debug info +/// if-ext - if macro from different crate (related to callsite code) +/// | cmd \ attr | no | (unspecified) | external | yes | +/// | no | no | no | no | no | +/// | (unspecified) | no | no | if-ext | yes | +/// | external | no | if-ext | if-ext | yes | +/// | yes | yes | yes | yes | yes | +#[derive(Copy, Clone, Debug, Hash, PartialEq)] +#[cfg_attr(feature = "nightly", derive(StableHash, Encodable_NoContext, Decodable_NoContext))] +pub enum CollapseMacroDebuginfo { + /// Don't collapse debuginfo for the macro + No = 0, + /// Unspecified value + Unspecified = 1, + /// Collapse debuginfo if the macro comes from a different crate + External = 2, + /// Collapse debuginfo for the macro + Yes = 3, +} diff --git a/compiler/rustc_structures/src/crate_type.rs b/compiler/rustc_structures/src/crate_type.rs new file mode 100644 index 0000000000000..505370a524281 --- /dev/null +++ b/compiler/rustc_structures/src/crate_type.rs @@ -0,0 +1,114 @@ +#[cfg(feature = "nightly")] +use { + rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}, + rustc_span::{Symbol, sym}, +}; + +/// Crate type, as specified by `#![crate_type]` +#[derive(Copy, Clone, Debug, Hash, PartialEq, Default, PartialOrd, Eq, Ord)] +#[cfg_attr(feature = "nightly", derive(StableHash, Encodable_NoContext, Decodable_NoContext))] +pub enum CrateType { + /// `#![crate_type = "bin"]` + Executable, + /// `#![crate_type = "dylib"]` + Dylib, + /// `#![crate_type = "rlib"]` or `#![crate_type = "lib"]` + #[default] + Rlib, + /// `#![crate_type = "staticlib"]` + StaticLib, + /// `#![crate_type = "cdylib"]` + Cdylib, + /// `#![crate_type = "proc-macro"]` + ProcMacro, + /// `#![crate_type = "sdylib"]` + // Unstable; feature(export_stable) + Sdylib, +} +#[cfg(feature = "nightly")] +impl CrateType { + /// Pairs of each `#[crate_type] = "..."` value and the crate type it resolves to + pub fn all() -> &'static [(Symbol, Self)] { + debug_assert_eq!(CrateType::default(), CrateType::Rlib); + &[ + (sym::lib, CrateType::Rlib), + (sym::rlib, CrateType::Rlib), + (sym::dylib, CrateType::Dylib), + (sym::cdylib, CrateType::Cdylib), + (sym::staticlib, CrateType::StaticLib), + (sym::proc_dash_macro, CrateType::ProcMacro), + (sym::bin, CrateType::Executable), + (sym::sdylib, CrateType::Sdylib), + ] + } + + /// Same as [`CrateType::all`], but does not include unstable options. + /// Used for diagnostics. + pub fn all_stable() -> &'static [(Symbol, Self)] { + debug_assert_eq!(CrateType::default(), CrateType::Rlib); + &[ + (sym::lib, CrateType::Rlib), + (sym::rlib, CrateType::Rlib), + (sym::dylib, CrateType::Dylib), + (sym::cdylib, CrateType::Cdylib), + (sym::staticlib, CrateType::StaticLib), + (sym::proc_dash_macro, CrateType::ProcMacro), + (sym::bin, CrateType::Executable), + ] + } +} + +impl CrateType { + pub fn has_metadata(self) -> bool { + match self { + CrateType::Rlib | CrateType::Dylib | CrateType::ProcMacro => true, + CrateType::Executable + | CrateType::Cdylib + | CrateType::StaticLib + | CrateType::Sdylib => false, + } + } +} + +#[cfg(feature = "nightly")] +impl TryFrom for CrateType { + type Error = (); + + fn try_from(value: Symbol) -> Result { + Ok(match value { + sym::bin => CrateType::Executable, + sym::dylib => CrateType::Dylib, + sym::staticlib => CrateType::StaticLib, + sym::cdylib => CrateType::Cdylib, + sym::rlib => CrateType::Rlib, + sym::lib => CrateType::default(), + sym::proc_dash_macro => CrateType::ProcMacro, + sym::sdylib => CrateType::Sdylib, + _ => return Err(()), + }) + } +} + +impl std::fmt::Display for CrateType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + CrateType::Executable => "bin".fmt(f), + CrateType::Dylib => "dylib".fmt(f), + CrateType::Rlib => "rlib".fmt(f), + CrateType::StaticLib => "staticlib".fmt(f), + CrateType::Cdylib => "cdylib".fmt(f), + CrateType::ProcMacro => "proc-macro".fmt(f), + CrateType::Sdylib => "sdylib".fmt(f), + } + } +} + +#[cfg(feature = "nightly")] +impl rustc_error_messages::IntoDiagArg for CrateType { + fn into_diag_arg( + self, + _: &mut Option, + ) -> rustc_error_messages::DiagArgValue { + self.to_string().into_diag_arg(&mut None) + } +} diff --git a/compiler/rustc_structures/src/lib.rs b/compiler/rustc_structures/src/lib.rs new file mode 100644 index 0000000000000..a7ebea5ba9943 --- /dev/null +++ b/compiler/rustc_structures/src/lib.rs @@ -0,0 +1,15 @@ +//! Basic structs that end up being used in attributes for one reason or another, +//! but are not used exclusively in or around attributes. +#![deny(unstable_features, reason = "ends up in dependencies of rust-analyzer")] + +mod collapse_macro_debug_info; +mod crate_type; +mod limit; +mod native_lib_kind; +mod sanitizer_set; + +pub use collapse_macro_debug_info::CollapseMacroDebuginfo; +pub use crate_type::CrateType; +pub use limit::Limit; +pub use native_lib_kind::NativeLibKind; +pub use sanitizer_set::SanitizerSet; diff --git a/compiler/rustc_data_structures/src/limit.rs b/compiler/rustc_structures/src/limit.rs similarity index 76% rename from compiler/rustc_data_structures/src/limit.rs rename to compiler/rustc_structures/src/limit.rs index ee1588d5112ed..ade348523bce7 100644 --- a/compiler/rustc_data_structures/src/limit.rs +++ b/compiler/rustc_structures/src/limit.rs @@ -1,11 +1,13 @@ use std::fmt; use std::ops::{Div, Mul}; +#[cfg(feature = "nightly")] use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; /// New-type wrapper around `usize` for representing limits. Ensures that comparisons against /// limits are consistent throughout the compiler. -#[derive(Clone, Copy, Debug, StableHash, Encodable_NoContext, Decodable_NoContext)] +#[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "nightly", derive(StableHash, Encodable_NoContext, Decodable_NoContext))] pub struct Limit(pub usize); impl Limit { @@ -54,3 +56,13 @@ impl Mul for Limit { Limit::new(self.0 * rhs) } } + +#[cfg(feature = "nightly")] +impl rustc_error_messages::IntoDiagArg for Limit { + fn into_diag_arg( + self, + _: &mut Option, + ) -> rustc_error_messages::DiagArgValue { + self.0.into_diag_arg(&mut None) + } +} diff --git a/compiler/rustc_structures/src/native_lib_kind.rs b/compiler/rustc_structures/src/native_lib_kind.rs new file mode 100644 index 0000000000000..a232d7a314573 --- /dev/null +++ b/compiler/rustc_structures/src/native_lib_kind.rs @@ -0,0 +1,71 @@ +#[cfg(feature = "nightly")] +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; + +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cfg_attr(feature = "nightly", derive(StableHash, Encodable_NoContext, Decodable_NoContext))] +pub enum NativeLibKind { + /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) + Static { + /// Whether to bundle objects from static library into produced rlib + bundle: Option, + /// Whether to link static library without throwing any object files away + whole_archive: Option, + /// Whether to export c static library symbols + export_symbols: Option, + }, + /// Dynamic library (e.g. `libfoo.so` on Linux) + /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC). + Dylib { + /// Whether the dynamic library will be linked only if it satisfies some undefined symbols + as_needed: Option, + }, + /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library. + /// On Linux, it refers to a generated shared library stub. + RawDylib { + /// Whether the dynamic library will be linked only if it satisfies some undefined symbols + as_needed: Option, + }, + /// A macOS-specific kind of dynamic libraries. + Framework { + /// Whether the framework will be linked only if it satisfies some undefined symbols + as_needed: Option, + }, + /// Argument which is passed to linker, relative order with libraries and other arguments + /// is preserved + LinkArg, + + /// Module imported from WebAssembly + WasmImportModule, + + /// The library kind wasn't specified, `Dylib` is currently used as a default. + Unspecified, +} + +impl NativeLibKind { + pub fn has_modifiers(&self) -> bool { + match self { + NativeLibKind::Static { bundle, whole_archive, export_symbols } => { + bundle.is_some() || whole_archive.is_some() || export_symbols.is_some() + } + NativeLibKind::Dylib { as_needed } + | NativeLibKind::Framework { as_needed } + | NativeLibKind::RawDylib { as_needed } => as_needed.is_some(), + NativeLibKind::Unspecified + | NativeLibKind::LinkArg + | NativeLibKind::WasmImportModule => false, + } + } + + pub fn is_statically_included(&self) -> bool { + matches!(self, NativeLibKind::Static { .. }) + } + + pub fn is_dllimport(&self) -> bool { + matches!( + self, + NativeLibKind::Dylib { .. } + | NativeLibKind::RawDylib { .. } + | NativeLibKind::Unspecified + ) + } +} diff --git a/compiler/rustc_structures/src/sanitizer_set.rs b/compiler/rustc_structures/src/sanitizer_set.rs new file mode 100644 index 0000000000000..bce77f3abc05b --- /dev/null +++ b/compiler/rustc_structures/src/sanitizer_set.rs @@ -0,0 +1,160 @@ +use core::fmt; +use std::str::FromStr; + +#[cfg(feature = "nightly")] +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; + +#[derive(Default, Clone, Copy, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] +pub struct SanitizerSet(u16); +bitflags::bitflags! { + impl SanitizerSet: u16 { + const ADDRESS = 1 << 0; + const LEAK = 1 << 1; + const MEMORY = 1 << 2; + const THREAD = 1 << 3; + const HWADDRESS = 1 << 4; + const CFI = 1 << 5; + const MEMTAG = 1 << 6; + const SHADOWCALLSTACK = 1 << 7; + const KCFI = 1 << 8; + const KERNELADDRESS = 1 << 9; + const KERNELHWADDRESS = 1 << 10; + const SAFESTACK = 1 << 11; + const DATAFLOW = 1 << 12; + const REALTIME = 1 << 13; + } +} + +#[cfg(feature = "nightly")] +rustc_data_structures::external_bitflags_debug! { SanitizerSet } + +impl SanitizerSet { + // Taken from LLVM's sanitizer compatibility logic: + // https://github.com/llvm/llvm-project/blob/release/18.x/clang/lib/Driver/SanitizerArgs.cpp#L512 + const MUTUALLY_EXCLUSIVE: &'static [(SanitizerSet, SanitizerSet)] = &[ + (SanitizerSet::ADDRESS, SanitizerSet::MEMORY), + (SanitizerSet::ADDRESS, SanitizerSet::THREAD), + (SanitizerSet::ADDRESS, SanitizerSet::HWADDRESS), + (SanitizerSet::ADDRESS, SanitizerSet::MEMTAG), + (SanitizerSet::ADDRESS, SanitizerSet::KERNELADDRESS), + (SanitizerSet::ADDRESS, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::ADDRESS, SanitizerSet::SAFESTACK), + (SanitizerSet::LEAK, SanitizerSet::MEMORY), + (SanitizerSet::LEAK, SanitizerSet::THREAD), + (SanitizerSet::LEAK, SanitizerSet::KERNELADDRESS), + (SanitizerSet::LEAK, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::LEAK, SanitizerSet::SAFESTACK), + (SanitizerSet::MEMORY, SanitizerSet::THREAD), + (SanitizerSet::MEMORY, SanitizerSet::HWADDRESS), + (SanitizerSet::MEMORY, SanitizerSet::KERNELADDRESS), + (SanitizerSet::MEMORY, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::MEMORY, SanitizerSet::SAFESTACK), + (SanitizerSet::THREAD, SanitizerSet::HWADDRESS), + (SanitizerSet::THREAD, SanitizerSet::KERNELADDRESS), + (SanitizerSet::THREAD, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::THREAD, SanitizerSet::SAFESTACK), + (SanitizerSet::HWADDRESS, SanitizerSet::MEMTAG), + (SanitizerSet::HWADDRESS, SanitizerSet::KERNELADDRESS), + (SanitizerSet::HWADDRESS, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::HWADDRESS, SanitizerSet::SAFESTACK), + (SanitizerSet::CFI, SanitizerSet::KCFI), + (SanitizerSet::MEMTAG, SanitizerSet::KERNELADDRESS), + (SanitizerSet::MEMTAG, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::KERNELADDRESS, SanitizerSet::KERNELHWADDRESS), + (SanitizerSet::KERNELADDRESS, SanitizerSet::SAFESTACK), + (SanitizerSet::KERNELHWADDRESS, SanitizerSet::SAFESTACK), + ]; + + /// Return sanitizer's name + /// + /// Returns none if the flags is a set of sanitizers numbering not exactly one. + pub fn as_str(self) -> Option<&'static str> { + Some(match self { + SanitizerSet::ADDRESS => "address", + SanitizerSet::CFI => "cfi", + SanitizerSet::DATAFLOW => "dataflow", + SanitizerSet::KCFI => "kcfi", + SanitizerSet::KERNELADDRESS => "kernel-address", + SanitizerSet::KERNELHWADDRESS => "kernel-hwaddress", + SanitizerSet::LEAK => "leak", + SanitizerSet::MEMORY => "memory", + SanitizerSet::MEMTAG => "memtag", + SanitizerSet::SAFESTACK => "safestack", + SanitizerSet::SHADOWCALLSTACK => "shadow-call-stack", + SanitizerSet::THREAD => "thread", + SanitizerSet::HWADDRESS => "hwaddress", + SanitizerSet::REALTIME => "realtime", + _ => return None, + }) + } + + pub fn mutually_exclusive(self) -> Option<(SanitizerSet, SanitizerSet)> { + Self::MUTUALLY_EXCLUSIVE + .into_iter() + .find(|&(a, b)| self.contains(*a) && self.contains(*b)) + .copied() + } +} + +/// Formats a sanitizer set as a comma separated list of sanitizers' names. +impl fmt::Display for SanitizerSet { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut first = true; + for s in *self { + let name = s.as_str().unwrap_or_else(|| panic!("unrecognized sanitizer {s:?}")); + if !first { + f.write_str(", ")?; + } + f.write_str(name)?; + first = false; + } + Ok(()) + } +} + +impl FromStr for SanitizerSet { + type Err = String; + fn from_str(s: &str) -> Result { + Ok(match s { + "address" => SanitizerSet::ADDRESS, + "cfi" => SanitizerSet::CFI, + "dataflow" => SanitizerSet::DATAFLOW, + "kcfi" => SanitizerSet::KCFI, + "kernel-address" => SanitizerSet::KERNELADDRESS, + "kernel-hwaddress" => SanitizerSet::KERNELHWADDRESS, + "leak" => SanitizerSet::LEAK, + "memory" => SanitizerSet::MEMORY, + "memtag" => SanitizerSet::MEMTAG, + "safestack" => SanitizerSet::SAFESTACK, + "shadow-call-stack" => SanitizerSet::SHADOWCALLSTACK, + "thread" => SanitizerSet::THREAD, + "hwaddress" => SanitizerSet::HWADDRESS, + "realtime" => SanitizerSet::REALTIME, + s => return Err(format!("unknown sanitizer {s}")), + }) + } +} + +impl schemars::JsonSchema for SanitizerSet { + fn schema_name() -> std::borrow::Cow<'static, str> { + "SanitizerSet".into() + } + fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema { + let all = Self::all().iter().map(|sanitizer| sanitizer.as_str()).collect::>(); + schemars::json_schema! ({ + "type": "string", + "enum": all, + }) + } +} + +impl<'de> serde::Deserialize<'de> for SanitizerSet { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + FromStr::from_str(&s).map_err(serde::de::Error::custom) + } +} diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml index 33d40625323c3..af19aff21c116 100644 --- a/compiler/rustc_target/Cargo.toml +++ b/compiler/rustc_target/Cargo.toml @@ -15,6 +15,7 @@ rustc_fs_util = { path = "../rustc_fs_util" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } schemars = "1.0.4" serde = "1.0.219" serde_derive = "1.0.219" diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index ff6cade232523..0b952a3bf1c1c 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -41,7 +41,6 @@ use core::result::Result; use std::borrow::Cow; use std::collections::BTreeMap; -use std::fmt; use std::hash::Hash; use std::ops::{Deref, DerefMut}; use std::path::{Path, PathBuf}; @@ -73,6 +72,7 @@ pub use abi_map::{AbiMap, AbiMapping}; pub use base::apple; pub use base::avr::ef_avr_arch; pub use json::json_schema; +pub use rustc_structures::SanitizerSet; pub use tuple::TargetTuple; /// Linker is called through a C/C++ compiler. @@ -1148,149 +1148,6 @@ impl ToJson for StackProbeType { } } -#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] -pub struct SanitizerSet(u16); -bitflags::bitflags! { - impl SanitizerSet: u16 { - const ADDRESS = 1 << 0; - const LEAK = 1 << 1; - const MEMORY = 1 << 2; - const THREAD = 1 << 3; - const HWADDRESS = 1 << 4; - const CFI = 1 << 5; - const MEMTAG = 1 << 6; - const SHADOWCALLSTACK = 1 << 7; - const KCFI = 1 << 8; - const KERNELADDRESS = 1 << 9; - const KERNELHWADDRESS = 1 << 10; - const SAFESTACK = 1 << 11; - const DATAFLOW = 1 << 12; - const REALTIME = 1 << 13; - } -} -rustc_data_structures::external_bitflags_debug! { SanitizerSet } - -impl SanitizerSet { - // Taken from LLVM's sanitizer compatibility logic: - // https://github.com/llvm/llvm-project/blob/release/18.x/clang/lib/Driver/SanitizerArgs.cpp#L512 - const MUTUALLY_EXCLUSIVE: &'static [(SanitizerSet, SanitizerSet)] = &[ - (SanitizerSet::ADDRESS, SanitizerSet::MEMORY), - (SanitizerSet::ADDRESS, SanitizerSet::THREAD), - (SanitizerSet::ADDRESS, SanitizerSet::HWADDRESS), - (SanitizerSet::ADDRESS, SanitizerSet::MEMTAG), - (SanitizerSet::ADDRESS, SanitizerSet::KERNELADDRESS), - (SanitizerSet::ADDRESS, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::ADDRESS, SanitizerSet::SAFESTACK), - (SanitizerSet::LEAK, SanitizerSet::MEMORY), - (SanitizerSet::LEAK, SanitizerSet::THREAD), - (SanitizerSet::LEAK, SanitizerSet::KERNELADDRESS), - (SanitizerSet::LEAK, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::LEAK, SanitizerSet::SAFESTACK), - (SanitizerSet::MEMORY, SanitizerSet::THREAD), - (SanitizerSet::MEMORY, SanitizerSet::HWADDRESS), - (SanitizerSet::MEMORY, SanitizerSet::KERNELADDRESS), - (SanitizerSet::MEMORY, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::MEMORY, SanitizerSet::SAFESTACK), - (SanitizerSet::THREAD, SanitizerSet::HWADDRESS), - (SanitizerSet::THREAD, SanitizerSet::KERNELADDRESS), - (SanitizerSet::THREAD, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::THREAD, SanitizerSet::SAFESTACK), - (SanitizerSet::HWADDRESS, SanitizerSet::MEMTAG), - (SanitizerSet::HWADDRESS, SanitizerSet::KERNELADDRESS), - (SanitizerSet::HWADDRESS, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::HWADDRESS, SanitizerSet::SAFESTACK), - (SanitizerSet::CFI, SanitizerSet::KCFI), - (SanitizerSet::MEMTAG, SanitizerSet::KERNELADDRESS), - (SanitizerSet::MEMTAG, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::KERNELADDRESS, SanitizerSet::KERNELHWADDRESS), - (SanitizerSet::KERNELADDRESS, SanitizerSet::SAFESTACK), - (SanitizerSet::KERNELHWADDRESS, SanitizerSet::SAFESTACK), - ]; - - /// Return sanitizer's name - /// - /// Returns none if the flags is a set of sanitizers numbering not exactly one. - pub fn as_str(self) -> Option<&'static str> { - Some(match self { - SanitizerSet::ADDRESS => "address", - SanitizerSet::CFI => "cfi", - SanitizerSet::DATAFLOW => "dataflow", - SanitizerSet::KCFI => "kcfi", - SanitizerSet::KERNELADDRESS => "kernel-address", - SanitizerSet::KERNELHWADDRESS => "kernel-hwaddress", - SanitizerSet::LEAK => "leak", - SanitizerSet::MEMORY => "memory", - SanitizerSet::MEMTAG => "memtag", - SanitizerSet::SAFESTACK => "safestack", - SanitizerSet::SHADOWCALLSTACK => "shadow-call-stack", - SanitizerSet::THREAD => "thread", - SanitizerSet::HWADDRESS => "hwaddress", - SanitizerSet::REALTIME => "realtime", - _ => return None, - }) - } - - pub fn mutually_exclusive(self) -> Option<(SanitizerSet, SanitizerSet)> { - Self::MUTUALLY_EXCLUSIVE - .into_iter() - .find(|&(a, b)| self.contains(*a) && self.contains(*b)) - .copied() - } -} - -/// Formats a sanitizer set as a comma separated list of sanitizers' names. -impl fmt::Display for SanitizerSet { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut first = true; - for s in *self { - let name = s.as_str().unwrap_or_else(|| panic!("unrecognized sanitizer {s:?}")); - if !first { - f.write_str(", ")?; - } - f.write_str(name)?; - first = false; - } - Ok(()) - } -} - -impl FromStr for SanitizerSet { - type Err = String; - fn from_str(s: &str) -> Result { - Ok(match s { - "address" => SanitizerSet::ADDRESS, - "cfi" => SanitizerSet::CFI, - "dataflow" => SanitizerSet::DATAFLOW, - "kcfi" => SanitizerSet::KCFI, - "kernel-address" => SanitizerSet::KERNELADDRESS, - "kernel-hwaddress" => SanitizerSet::KERNELHWADDRESS, - "leak" => SanitizerSet::LEAK, - "memory" => SanitizerSet::MEMORY, - "memtag" => SanitizerSet::MEMTAG, - "safestack" => SanitizerSet::SAFESTACK, - "shadow-call-stack" => SanitizerSet::SHADOWCALLSTACK, - "thread" => SanitizerSet::THREAD, - "hwaddress" => SanitizerSet::HWADDRESS, - "realtime" => SanitizerSet::REALTIME, - s => return Err(format!("unknown sanitizer {s}")), - }) - } -} - -crate::json::serde_deserialize_from_str!(SanitizerSet); -impl schemars::JsonSchema for SanitizerSet { - fn schema_name() -> std::borrow::Cow<'static, str> { - "SanitizerSet".into() - } - fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema { - let all = Self::all().iter().map(|sanitizer| sanitizer.as_str()).collect::>(); - schemars::json_schema! ({ - "type": "string", - "enum": all, - }) - } -} - impl ToJson for SanitizerSet { fn to_json(&self) -> Json { self.into_iter() diff --git a/compiler/rustc_trait_selection/Cargo.toml b/compiler/rustc_trait_selection/Cargo.toml index 52d88db0fba66..039856eeb4857 100644 --- a/compiler/rustc_trait_selection/Cargo.toml +++ b/compiler/rustc_trait_selection/Cargo.toml @@ -19,6 +19,7 @@ rustc_middle = { path = "../rustc_middle" } rustc_next_trait_solver = { path = "../rustc_next_trait_solver" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } thin-vec = "0.2.19" diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index ee8a4099b21cf..ccbe23cf7a631 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -1,6 +1,5 @@ use std::fmt; -use rustc_data_structures::Limit; use rustc_data_structures::intern::Interned; use rustc_errors::{Applicability, Diag, IntoDiagArg}; use rustc_hir as hir; @@ -12,6 +11,7 @@ use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHi use rustc_middle::ty::{ self, GenericArgsRef, IsSuggestable, RePlaceholder, Region, RegionExt, TyCtxt, }; +use rustc_structures::Limit; use tracing::{debug, instrument}; use crate::diagnostics::{ diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs index da73c3e0d687d..30a18a928e842 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs @@ -1,6 +1,5 @@ use std::fmt; -use rustc_data_structures::Limit; use rustc_errors::{Diag, E0275, EmissionGuarantee, ErrorGuaranteed, struct_span_code_err}; use rustc_hir::def::Namespace; use rustc_hir::def_id::LOCAL_CRATE; @@ -8,6 +7,7 @@ use rustc_infer::traits::{Obligation, PredicateObligation}; use rustc_middle::ty::print::{FmtPrinter, Print}; use rustc_middle::ty::{self, TyCtxt, Upcast}; use rustc_span::Span; +use rustc_structures::Limit; use tracing::debug; use crate::error_reporting::TypeErrCtxt; diff --git a/compiler/rustc_ty_utils/Cargo.toml b/compiler/rustc_ty_utils/Cargo.toml index f633ef9950c09..e6de7bd1fab24 100644 --- a/compiler/rustc_ty_utils/Cargo.toml +++ b/compiler/rustc_ty_utils/Cargo.toml @@ -17,6 +17,7 @@ rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_structures = { path = "../rustc_structures" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_ty_walk = { path = "../rustc_ty_walk" } diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 9e9aed008bf31..a8042374ee42f 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -9,7 +9,6 @@ use rustc_abi::{ LayoutCalculatorError, LayoutData, Niche, ReprOptions, Scalar, Size, StructKind, TagEncoding, VariantIdx, Variants, WrappingRange, }; -use rustc_data_structures::Limit; use rustc_hashes::Hash64; use rustc_hir as hir; use rustc_hir::find_attr; @@ -27,6 +26,7 @@ use rustc_middle::ty::{ }; use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use rustc_span::{Symbol, sym}; +use rustc_structures::Limit; use tracing::{debug, instrument}; use crate::diagnostics::NonPrimitiveSimdType; diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index ec51304104745..e4d389cffd800 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -1,6 +1,5 @@ //! Check whether a type has (potentially) non-trivial drop glue. -use rustc_data_structures::Limit; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::DefId; use rustc_hir::find_attr; @@ -8,6 +7,7 @@ use rustc_middle::bug; use rustc_middle::query::Providers; use rustc_middle::ty::util::{AlwaysRequiresDrop, needs_drop_components}; use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt, Unnormalized}; +use rustc_structures::Limit; use tracing::{debug, instrument}; use crate::diagnostics::NeedsDropOverflow; diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 8b41a3792ac9a..861d49073f56a 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -3329,7 +3329,7 @@ impl Path { /// use std::path::Path; /// /// let path = Path::new("/Minas/tirith"); - /// let metadata = path.metadata().expect("metadata call failed"); + /// let metadata = path.metadata().expect("the path should point to an existing file or directory"); /// println!("{:?}", metadata.file_type()); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] @@ -3348,7 +3348,7 @@ impl Path { /// use std::path::Path; /// /// let path = Path::new("/Minas/tirith"); - /// let metadata = path.symlink_metadata().expect("symlink_metadata call failed"); + /// let metadata = path.symlink_metadata().expect("the path should exist"); /// println!("{:?}", metadata.file_type()); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] @@ -3483,7 +3483,7 @@ impl Path { /// use std::path::Path; /// /// let path = Path::new("/laputa/sky_castle.rs"); - /// let path_link = path.read_link().expect("read_link call failed"); + /// let path_link = path.read_link().expect("the path should be an existing symbolic link"); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] #[inline] @@ -3504,7 +3504,7 @@ impl Path { /// use std::path::Path; /// /// let path = Path::new("/laputa"); - /// for entry in path.read_dir().expect("read_dir call failed") { + /// for entry in path.read_dir().expect("the path should point to an existing directory") { /// if let Ok(entry) = entry { /// println!("{:?}", entry.path()); /// } @@ -3569,7 +3569,7 @@ impl Path { /// /// ```no_run /// use std::path::Path; - /// assert!(!Path::new("does_not_exist.txt").try_exists().expect("Can't check existence of file does_not_exist.txt")); + /// assert!(!Path::new("does_not_exist.txt").try_exists().expect("the path's existence should be verifiable")); /// assert!(Path::new("/root/secret_file.txt").try_exists().is_err()); /// ``` /// diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap index 755c0e19b8ae1..bb55f31c405d6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap @@ -86,6 +86,7 @@ expression: bench - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap index 924972d28e607..9d3ff75cc1cce 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap @@ -68,6 +68,7 @@ expression: build compiler - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap index 46e00afd325d1..812bc18078999 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap @@ -70,6 +70,7 @@ expression: check - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap index eb48e337aeb0e..dc069febfcebe 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap @@ -70,6 +70,7 @@ expression: check compiler - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap index c84a6aed4eba8..921060318f5e5 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap @@ -70,6 +70,7 @@ expression: check compiletest --include-default-paths - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap index 99db9ae7b0268..dfb838638bf68 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap @@ -85,6 +85,7 @@ expression: clippy - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap index 529073c5b5a55..356be4863d1a6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap @@ -70,6 +70,7 @@ expression: fix - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 7807566751a2f..49a1c04c6af63 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -134,6 +134,7 @@ expression: test - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index 7bac4c859c450..397f8dbd794a3 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -131,6 +131,7 @@ expression: test --skip=coverage - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 732b84e90a880..d4723f9070859 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -134,6 +134,7 @@ expression: test --skip=coverage-map - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index c36a9fd752aed..40d211627d7e0 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -134,6 +134,7 @@ expression: test --skip=coverage-run - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index bf5de019af6f4..bdd627ae37cc3 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -95,6 +95,7 @@ expression: test --skip=tests - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 3236872a46469..7551afd31a79c 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -131,6 +131,7 @@ expression: test --skip=tests/coverage - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index 93d3ee139e3fb..4457208ab56b9 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -79,6 +79,7 @@ expression: test --skip=tests --skip=library --skip=tidyselftest - Set({compiler/rustc_serialize}) - Set({compiler/rustc_session}) - Set({compiler/rustc_span}) + - Set({compiler/rustc_structures}) - Set({compiler/rustc_symbol_mangling}) - Set({compiler/rustc_target}) - Set({compiler/rustc_thread_pool}) diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 465c7d8a82726..3b20f5198eb19 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1661,7 +1661,7 @@ mod snapshot { insta::assert_snapshot!( ctx.config("check") .path("compiler") - .render_steps(), @"[check] rustc 0 -> rustc 1 (76 crates)"); + .render_steps(), @"[check] rustc 0 -> rustc 1 (77 crates)"); } #[test] @@ -1687,7 +1687,7 @@ mod snapshot { ctx.config("check") .path("compiler") .stage(1) - .render_steps(), @"[check] rustc 0 -> rustc 1 (76 crates)"); + .render_steps(), @"[check] rustc 0 -> rustc 1 (77 crates)"); } #[test] @@ -1701,7 +1701,7 @@ mod snapshot { [build] llvm [build] rustc 0 -> rustc 1 [build] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 (76 crates) + [check] rustc 1 -> rustc 2 (77 crates) "); } @@ -1717,7 +1717,7 @@ mod snapshot { [build] rustc 0 -> rustc 1 [build] rustc 1 -> std 1 [check] rustc 1 -> std 1 - [check] rustc 1 -> rustc 2 (76 crates) + [check] rustc 1 -> rustc 2 (77 crates) [check] rustc 1 -> rustc 2 [check] rustc 1 -> Rustdoc 2 [check] rustc 1 -> rustc_codegen_cranelift 2 @@ -1814,7 +1814,7 @@ mod snapshot { ctx.config("check") .paths(&["library", "compiler"]) .args(&args) - .render_steps(), @"[check] rustc 0 -> rustc 1 (76 crates)"); + .render_steps(), @"[check] rustc 0 -> rustc 1 (77 crates)"); } #[test] @@ -3025,7 +3025,7 @@ mod snapshot { let ctx = TestCtx::new(); insta::assert_snapshot!(ctx.config("fix").path("compiler").render_steps(), @r" [build] llvm - [fix] rustc 0 -> rustc 1 (76 crates) + [fix] rustc 0 -> rustc 1 (77 crates) "); } } diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 3b5bf4ae080dc..ab317ba1048a4 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -812,8 +812,7 @@ Defines which scopes of paths should be remapped by --remap-path-prefix. `rustdoc` (and by extension `rustc`) have a special `documentation` remapping scope, it permits remapping source paths that ends up in the generated documentation. -Currently the scope can only be specified from `rustc`, due to the lack of an equivalent -`--remap-path-scope` flag in `rustc`. +It can specified with `--remap-path-scope=documentation`. ## `#[doc(cfg)]` and `#[doc(auto_cfg)]` diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 7c3e91b90b754..3ad07dd35ccf0 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_errors::DiagCtxtHandle; use rustc_lint::Level; use rustc_session::config::{ - self, CodegenOptions, CrateType, ErrorOutputType, Externs, Input, JsonUnusedExterns, + self, CodegenOptions, ErrorOutputType, Externs, Input, JsonUnusedExterns, OptionsTargetModifiers, OutFileName, Sysroot, UnstableOptions, get_cmd_lint_options, nightly_options, parse_crate_types_from_list, parse_externs, parse_target_triple, }; @@ -17,6 +17,7 @@ use rustc_session::search_paths::SearchPath; use rustc_session::{EarlyDiagCtxt, getopts}; use rustc_span::edition::Edition; use rustc_span::{FileName, RemapPathScopeComponents}; +use rustc_structures::CrateType; use rustc_target::spec::TargetTuple; use smallvec::SmallVec; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 0aec839025936..c30c68a1fa5c8 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -20,11 +20,12 @@ use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt}; use rustc_session::Session; use rustc_session::config::{ - self, CrateType, ErrorOutputType, Input, OutputType, OutputTypes, ResolveDocLinks, + self, ErrorOutputType, Input, OutputType, OutputTypes, ResolveDocLinks, }; pub(crate) use rustc_session::config::{Options, UnstableOptions}; use rustc_span::source_map; use rustc_span::symbol::sym; +use rustc_structures::CrateType; use tracing::{debug, info}; use crate::clean::inline::build_trait; diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 68d491618353a..f5ea54971b848 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -27,9 +27,10 @@ use rustc_hir::{Attribute, CRATE_HIR_ID}; use rustc_interface::interface; use rustc_lint as lint; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{self, CrateType, ErrorOutputType, Input}; +use rustc_session::config::{self, ErrorOutputType, Input}; use rustc_span::edition::Edition; use rustc_span::{FileName, RemapPathScopeComponents, Span}; +use rustc_structures::CrateType; use rustc_target::spec::{Target, TargetTuple}; use tempfile::{Builder as TempFileBuilder, TempDir}; use tracing::{debug, info}; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index cf7d61c520f04..c4f7d2c361952 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -53,6 +53,7 @@ extern crate rustc_resolve; extern crate rustc_serialize; extern crate rustc_session; extern crate rustc_span; +extern crate rustc_structures; extern crate rustc_target; extern crate rustc_trait_selection; extern crate test; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 815b82d5361c4..38d285f4fe86d 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -24,10 +24,10 @@ use rustc_resolve::rustdoc::{ MalformedGenerics, has_primitive_or_keyword_or_attribute_docs, prepare_to_doc_link_resolution, source_span_for_markdown_range, strip_generics_from_path, }; -use rustc_session::config::CrateType; use rustc_span::BytePos; use rustc_span::def_id::ModId; use rustc_span::symbol::{Ident, Symbol, sym}; +use rustc_structures::CrateType; use smallvec::{SmallVec, smallvec}; use tracing::{debug, info, instrument, trace}; diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index 8b0765fb6c012..c539edddf6a4d 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -38,8 +38,8 @@ extern crate rustc_lint; extern crate rustc_middle; extern crate rustc_parse_format; extern crate rustc_resolve; -extern crate rustc_session; extern crate rustc_span; +extern crate rustc_structures; extern crate rustc_target; extern crate rustc_trait_selection; diff --git a/src/tools/clippy/clippy_lints/src/missing_inline.rs b/src/tools/clippy/clippy_lints/src/missing_inline.rs index adad6a2b2cba2..f1baa6a697d78 100644 --- a/src/tools/clippy/clippy_lints/src/missing_inline.rs +++ b/src/tools/clippy/clippy_lints/src/missing_inline.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_hir::{ImplItem, ImplItemKind, Item, ItemKind, OwnerId, TraitFn, TraitItem, TraitItemKind, find_attr}; use rustc_lint::{LateContext, LateLintPass, declare_lint_pass}; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; use rustc_span::Span; declare_clippy_lint! { diff --git a/src/tools/miri/priroda/src/main.rs b/src/tools/miri/priroda/src/main.rs index 74f5bd4f89c5d..44743c446091b 100644 --- a/src/tools/miri/priroda/src/main.rs +++ b/src/tools/miri/priroda/src/main.rs @@ -7,6 +7,7 @@ extern crate rustc_interface; extern crate rustc_middle; extern crate rustc_session; extern crate rustc_span; +extern crate rustc_structures; mod debugger; mod frontend; @@ -14,11 +15,11 @@ mod frontend; use debugger::PrirodaContext; use miri::*; use rustc_driver::Compilation; -use rustc_hir::attrs::CrateType; use rustc_interface::interface; use rustc_middle::ty::TyCtxt; use rustc_session::EarlyDiagCtxt; use rustc_session::config::ErrorOutputType; +use rustc_structures::CrateType; fn find_sysroot() -> String { std::env::var("MIRI_SYSROOT") diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index ae9a64b0abcf4..f28bb524775ed 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -16,6 +16,7 @@ extern crate rustc_log; extern crate rustc_metadata; extern crate rustc_middle; extern crate rustc_session; +extern crate rustc_structures; // Override the C allocator in the same way that the `rustc` binary would do. rustc_driver::override_c_allocator_in_binary!(); @@ -44,7 +45,8 @@ use rustc_interface::util::DummyCodegenBackend; use rustc_log::tracing::debug; use rustc_middle::query::LocalCrate; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{CrateType, ErrorOutputType, OptLevel}; +use rustc_structures::CrateType; +use rustc_session::config::{ ErrorOutputType, OptLevel}; use rustc_session::{EarlyDiagCtxt, Session}; use crate::log::setup::{deinit_loggers, init_early_loggers, init_late_loggers}; diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 1e47ff4e56f1e..9bf202e8254e8 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -12,7 +12,7 @@ use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::ty::layout::{LayoutOf, MaybeResult, TyAndLayout}; use rustc_middle::ty::{self, FnSigKind, IntTy, Ty, TyCtxt, UintTy}; -use rustc_session::config::CrateType; +use rustc_structures::CrateType; use rustc_span::{Span, Symbol}; use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::spec::Os; diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 7d878024b02e2..a2b6108882df3 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -73,6 +73,7 @@ extern crate rustc_log; extern crate rustc_middle; extern crate rustc_session; extern crate rustc_span; +extern crate rustc_structures; extern crate rustc_symbol_mangling; extern crate rustc_target; // Linking `rustc_driver` pulls in the required object code as the rest of the rustc crates are diff --git a/tests/codegen-llvm/float/abi-flag.rs b/tests/codegen-llvm/float/abi-flag.rs new file mode 100644 index 0000000000000..8b99988e4ba81 --- /dev/null +++ b/tests/codegen-llvm/float/abi-flag.rs @@ -0,0 +1,23 @@ +//@ add-minicore +//@ min-llvm-version: 24 +//@ revisions: armhf armsf aarch64sf + +//@ [armhf] needs-llvm-components: arm +//@ [armhf] compile-flags: --target=armv7-unknown-linux-gnueabihf + +//@ [armsf] needs-llvm-components: arm +//@ [armsf] compile-flags: --target=armv7-unknown-linux-gnueabi + +//@ [aarch64sf] needs-llvm-components: aarch64 +//@ [aarch64sf] compile-flags: --target=aarch64-unknown-none-softfloat + +#![crate_type = "lib"] +#![feature(no_core)] +#![no_core] + +// rustc sets the module flag only for targets with an explicit `llvm_floatabi`, +// which is (currently) only the case on ARM. + +// armhf: !{i32 1, !"float-abi", !"hard"} +// armsf: !{i32 1, !"float-abi", !"soft"} +// aarch64sf-NOT: !"float-abi" diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml new file mode 100644 index 0000000000000..d776021917e8c --- /dev/null +++ b/tests/rustdoc-gui/notable-trait.goml @@ -0,0 +1,256 @@ +// This test checks the position of the `i` for the notable traits. +include: "utils.goml" +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" +show-text: true + +define-function: ( + "check-notable-tooltip-position", + [x, i_x], + block { + // Checking they have the same y position. + compare-elements-position-near: ( + "//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + {"y": 1}, + ) + // Checking they don't have the same x position. + compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + ["x"], + ) + // The `i` should be *after* the type. + assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']", + {"x": |x|}, + ) + assert-position: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + {"x": |i_x|}, + ) + }, +) + +define-function: ( + "check-notable-tooltip-position-complete", + [x, i_x, popover_x], + block { + call-function: ("check-notable-tooltip-position", {"x": |x|, "i_x": |i_x|}) + assert-count: ("//*[@class='tooltip popover']", 0) + click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" + assert-count: ("//*[@class='tooltip popover']", 1) + wait-for-position: ( + "//*[@class='tooltip popover']", + {"x": |popover_x|} + ) + compare-elements-position-near: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + "//*[@class='tooltip popover']", + {"y": 30} + ) + compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + "//*[@class='tooltip popover']", + ["x"] + ) + click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" + move-cursor-to: "//h1" + assert-count: ("//*[@class='tooltip popover']", 0) + }, +) + +// We start with a wide screen. +set-window-size: (1100, 600) +call-function: ("check-notable-tooltip-position-complete", { + "x": 682, + "i_x": 960, + "popover_x": 468, +}) + +// Now only the `i` should be on the next line. +set-window-size: (1055, 600) +compare-elements-position-false: ( + "//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']", + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + ["y", "x"], +) + +// Now both the `i` and the struct name should be on the next line. +set-window-size: (980, 600) +call-function: ("check-notable-tooltip-position", { + "x": 250, + "i_x": 528, +}) + +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html" +// This is needed to ensure that the text color is computed. +show-text: true + +// Now check the colors. +define-function: ( + "check-colors", + [theme, header_color, content_color, type_color, trait_color, link_color], + block { + call-function: ("switch-theme", {"theme": |theme|}) + + assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + {"color": |content_color|}, + ALL, + ) + + move-cursor-to: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" + wait-for-count: (".tooltip.popover", 1) + + assert-css: ( + "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", + {"color": |link_color|}, + ALL, + ) + + assert-css: ( + ".tooltip.popover h3", + {"color": |header_color|}, + ALL, + ) + assert-css: ( + ".tooltip.popover pre", + {"color": |content_color|}, + ALL, + ) + assert-css: ( + ".tooltip.popover pre a.struct", + {"color": |type_color|}, + ALL, + ) + assert-css: ( + ".tooltip.popover pre a.trait", + {"color": |trait_color|}, + ALL, + ) + }, +) + +call-function: ( + "check-colors", + { + "theme": "ayu", + "link_color": "#39afd7", + "content_color": "#e6e1cf", + "header_color": "#fff", + "type_color": "#ffa0a5", + "trait_color": "#39afd7", + }, +) + +call-function: ( + "check-colors", + { + "theme": "dark", + "link_color": "#d2991d", + "content_color": "#ddd", + "header_color": "#ddd", + "type_color": "#2dbfb8", + "trait_color": "#b78cf2", + }, +) + +call-function: ( + "check-colors", + { + "theme": "light", + "link_color": "#3873ad", + "content_color": "black", + "header_color": "black", + "type_color": "#ad378a", + "trait_color": "#6e4fc9", + }, +) + +// Checking on mobile now. +set-window-size: (650, 600) +wait-for-size: ("body", {"width": 650}) +call-function: ("check-notable-tooltip-position-complete", { + "x": 26, + "i_x": 305, + "popover_x": 0, +}) + +reload: + +// Check that pressing escape works +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" +move-cursor-to: "//*[@class='tooltip popover']" +assert-count: ("//*[@class='tooltip popover']", 1) +press-key: "Escape" +assert-count: ("//*[@class='tooltip popover']", 0) +assert: "#method\.create_an_iterator_from_read .tooltip:focus" + +// Check that clicking outside works. +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" +assert-count: ("//*[@class='tooltip popover']", 1) +click: ".main-heading h1" +assert-count: ("//*[@class='tooltip popover']", 0) +assert-false: "#method\.create_an_iterator_from_read .tooltip:focus" + +// Check that pressing tab over and over works. +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" +move-cursor-to: "//*[@class='tooltip popover']" +assert-count: ("//*[@class='tooltip popover']", 1) +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +assert-count: ("//*[@class='tooltip popover']", 0) +assert: "#method\.create_an_iterator_from_read .tooltip:focus" + +define-function: ( + "setup-popup", + [], + block { + store-window-property: {"scrollY": scroll} + click: "#method\.create_an_iterator_from_read .fn" + // We ensure that the scroll position changed. + assert-window-property-false: {"scrollY": |scroll|} + // Store the new position. + store-window-property: {"scrollY": scroll} + click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" + wait-for: "//*[@class='tooltip popover']" + click: ".main-heading h1" + } +) + +// Now we check that the focus isn't given back to the wrong item when opening +// another popover. +call-function: ("setup-popup", {}) +click: ".main-heading h1" +// We ensure we didn't come back to the previous focused item. +assert-window-property-false: {"scrollY": |scroll|} + +// Same but with Escape handling. +call-function: ("setup-popup", {}) +press-key: "Escape" +// We ensure we didn't come back to the previous focused item. +assert-window-property-false: {"scrollY": |scroll|} + +// Opening the mobile sidebar should close the popover. +set-window-size: (650, 600) +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" +assert-count: ("//*[@class='tooltip popover']", 1) +click: ".sidebar-menu-toggle" +assert: "//*[@class='sidebar shown']" +assert-count: ("//*[@class='tooltip popover']", 0) +assert-false: "#method\.create_an_iterator_from_read .tooltip:focus" + +// Also check the focus handling for the settings button. +set-window-size: (1100, 600) +reload: +assert-count: ("//*[@class='tooltip popover']", 0) +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" +wait-for-count: ("//*[@class='tooltip popover']", 1) +call-function: ("open-settings-menu", {}) +wait-for-count: ("//*[@class='tooltip popover']", 0) +assert-false: "#method\.create_an_iterator_from_read .tooltip:focus" diff --git a/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs b/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs index 5ddaed75aa323..a147e3ddf6942 100644 --- a/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs +++ b/tests/ui-fulldeps/codegen-backend/auxiliary/the_backend.rs @@ -8,6 +8,7 @@ extern crate rustc_driver as _; extern crate rustc_metadata; extern crate rustc_middle; extern crate rustc_session; +extern crate rustc_structures; use std::any::Any; @@ -58,8 +59,9 @@ impl CodegenBackend for TheBackend { ) { use std::io::Write; - use rustc_session::config::{CrateType, OutFileName}; + use rustc_session::config::OutFileName; use rustc_session::output::out_filename; + use rustc_structures::CrateType; let crate_name = crate_info.local_crate_name; for &crate_type in sess.opts.crate_types.iter() { diff --git a/tests/ui/impl-trait/confusing-lifetime-error-issue-79033.rs b/tests/ui/impl-trait/confusing-lifetime-error-issue-79033.rs new file mode 100644 index 0000000000000..323d42bdc979f --- /dev/null +++ b/tests/ui/impl-trait/confusing-lifetime-error-issue-79033.rs @@ -0,0 +1,36 @@ +// Regression test for https://github.com/rust-lang/rust/issues/79033/ +// rustc should be clear about the lifetime issue below where +// self is borrowed for the duration of the returned iterator +// but the lifetime of self will end when fn lines() returns. +//@ edition: 2024 + +#[derive(Debug, Clone, Copy)] +pub struct Location<'a> { + pub filename: &'a str, + pub start: LocationHalf, + pub end: LocationHalf, +} + +#[derive(Debug, Clone, Copy)] +pub struct LocationHalf { + pub line: u32, + pub column: u32, +} + +impl Location<'_> { + /// Returns an iterator over the line numbers and lines of this location. + pub fn lines<'a>(self, source: &'a str) -> impl Iterator { + let lines = source.split('\n'); + lines.enumerate().filter_map(|(i, line)| { + //~^ ERROR closure may outlive the current function, but it borrows `self.start.line`, which is owned by the current function + //~| ERROR closure may outlive the current function, but it borrows `self.end.line`, which is owned by the current function + if self.start.line as usize <= i && i <= self.end.line as usize { + Some((i as u32 + 1, line)) + } else { + None + } + }) + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/confusing-lifetime-error-issue-79033.stderr b/tests/ui/impl-trait/confusing-lifetime-error-issue-79033.stderr new file mode 100644 index 0000000000000..81cad8de969eb --- /dev/null +++ b/tests/ui/impl-trait/confusing-lifetime-error-issue-79033.stderr @@ -0,0 +1,51 @@ +error[E0373]: closure may outlive the current function, but it borrows `self.start.line`, which is owned by the current function + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:38 + | +LL | lines.enumerate().filter_map(|(i, line)| { + | ^^^^^^^^^^^ may outlive borrowed value `self.start.line` +... +LL | if self.start.line as usize <= i && i <= self.end.line as usize { + | --------------- `self.start.line` is borrowed here + | +note: function requires argument type to outlive `'static` + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:9 + | +LL | / lines.enumerate().filter_map(|(i, line)| { +LL | | +LL | | +LL | | if self.start.line as usize <= i && i <= self.end.line as usize { +... | +LL | | }) + | |__________^ +help: to force the closure to take ownership of `self.start.line` (and any other referenced variables), use the `move` keyword + | +LL | lines.enumerate().filter_map(move |(i, line)| { + | ++++ + +error[E0373]: closure may outlive the current function, but it borrows `self.end.line`, which is owned by the current function + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:38 + | +LL | lines.enumerate().filter_map(|(i, line)| { + | ^^^^^^^^^^^ may outlive borrowed value `self.end.line` +... +LL | if self.start.line as usize <= i && i <= self.end.line as usize { + | ------------- `self.end.line` is borrowed here + | +note: function requires argument type to outlive `'static` + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:9 + | +LL | / lines.enumerate().filter_map(|(i, line)| { +LL | | +LL | | +LL | | if self.start.line as usize <= i && i <= self.end.line as usize { +... | +LL | | }) + | |__________^ +help: to force the closure to take ownership of `self.end.line` (and any other referenced variables), use the `move` keyword + | +LL | lines.enumerate().filter_map(move |(i, line)| { + | ++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0373`. diff --git a/tests/ui/lint/dead-code/type-alias-used-in-impl-59333.rs b/tests/ui/lint/dead-code/type-alias-used-in-impl-59333.rs new file mode 100644 index 0000000000000..5f2e4296b0eb7 --- /dev/null +++ b/tests/ui/lint/dead-code/type-alias-used-in-impl-59333.rs @@ -0,0 +1,34 @@ +//@ check-pass +//! Regression test for . +//! A type alias used only as (part of) the self type of an impl was +//! incorrectly flagged as dead code. + +#![deny(dead_code)] + +struct Runner; + +type RuntimeImpl = Runner; + +trait Runtime { + fn run(&mut self); +} + +impl Runtime for &mut RuntimeImpl { + fn run(&mut self) {} +} + +struct Walker; + +type WalkerImpl = Walker; + +trait Walk { + fn walk(&self) {} +} + +impl Walk for WalkerImpl {} + +fn main() { + let mut runner = Runner; + (&mut runner).run(); + Walker.walk(); +} diff --git a/tests/ui/splat/splat-fn-ptr-ptr-tuple.rs b/tests/ui/splat/splat-fn-ptr-ptr-tuple.rs index 6473abce4b750..6a108a1411a6b 100644 --- a/tests/ui/splat/splat-fn-ptr-ptr-tuple.rs +++ b/tests/ui/splat/splat-fn-ptr-ptr-tuple.rs @@ -66,25 +66,24 @@ fn main() { assert_eq!((*fn_pp)(1u32, 2i8), (2i8, 1u32)); // Now with *mut and non-terminal splat + let mut fn_p = splat_non_terminal_arg as fn(#[rustc_splat] (u32, i8), f64) -> (i8, f64, u32); let fn_pp: *mut fn(#[rustc_splat] (u32, i8), f64) -> (i8, f64, u32) - = ptr::from_mut( - &mut (splat_non_terminal_arg as fn(#[rustc_splat] (u32, i8), f64) -> (i8, f64, u32)) - ); + = ptr::from_mut(&mut fn_p); unsafe { assert_eq!((*fn_pp)(1, 2, 3.5), (2, 3.5, 1)); assert_eq!((*fn_pp)(1u32, 2i8, 3.5f64), (2i8, 3.5f64, 1u32)); } + let mut fn_p = splat_non_terminal_arg as _; let fn_pp: *mut fn(#[rustc_splat] (u32, i8), f64) -> (i8, f64, u32) - = ptr::from_mut(&mut (splat_non_terminal_arg as _)); + = ptr::from_mut(&mut fn_p); unsafe { assert_eq!((*fn_pp)(1, 2, 3.5), (2, 3.5, 1)); assert_eq!((*fn_pp)(1u32, 2i8, 3.5f64), (2i8, 3.5f64, 1u32)); } - let fn_pp = ptr::from_mut( - &mut (splat_non_terminal_arg as fn(#[rustc_splat] (u32, i8), f64) -> (i8, f64, u32)) - ); + let mut fn_p = splat_non_terminal_arg as fn(#[rustc_splat] (u32, i8), f64) -> (i8, f64, u32); + let fn_pp = ptr::from_mut(&mut fn_p); unsafe { assert_eq!((*fn_pp)(1, 2, 3.5), (2, 3.5, 1)); assert_eq!((*fn_pp)(1u32, 2i8, 3.5f64), (2i8, 3.5f64, 1u32)); diff --git a/triagebot.toml b/triagebot.toml index 6e8fbbad2651a..3995949e5aacf 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -850,7 +850,7 @@ zulip_stream = 542373 # #t-libs/backports topic = "#{number}: beta-nominated" message_on_add = [ """\ -@*T-libs* PR #{number} "{title}" has been nominated for beta backport. +@*T-libs-fcp* PR #{number} "{title}" has been nominated for beta backport. """, """\ /poll Should #{number} be beta backported? @@ -874,7 +874,7 @@ zulip_stream = 542373 # #t-libs/backports topic = "#{number}: stable-nominated" message_on_add = [ """\ -@**channel** PR #{number} "{title}" has been nominated for stable backport. +@*T-libs-fcp* PR #{number} "{title}" has been nominated for stable backport. """, """\ /poll Approve stable backport of #{number}? @@ -1588,6 +1588,7 @@ cc = ["@rust-lang/wg-const-eval"] [assign] warn_non_default_branch.enable = true contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html" +llm_policy_url = "https://forge.rust-lang.org/policies/llm-usage.html" [[assign.warn_non_default_branch.exceptions]] title = "[beta"