10000 Auto merge of #135925 - matthiaskrgr:rollup-5dlaatt, r=jieyouxu · rust-lang-ci/rust@c353c12 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c353c12

Browse files
committed
Auto merge of rust-lang#135925 - matthiaskrgr:rollup-5dlaatt, r=jieyouxu
Rollup of 8 pull requests Successful merges: - rust-lang#133154 (Reword resolve errors caused by likely missing crate in dep tree) - rust-lang#135366 (Enable `unreachable_pub` lint in `test` and `proc_macro` crates) - rust-lang#135638 (Make it possible to build GCC on CI) - rust-lang#135648 (support wasm inline assembly in `naked_asm!`) - rust-lang#135827 (CI: free disk with in-tree script instead of GitHub Action) - rust-lang#135855 (Only assert the `Parser` size on specific arches) - rust-lang#135878 (ci: use 8 core arm runner for dist-aarch64-linux) - rust-lang#135905 (Enable kernel sanitizers for aarch64-unknown-none-softfloat) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 99768c8 + 5e90f11 commit c353c12

File tree

138 files changed

+1076
-393
lines changed
  • macros
  • mir
  • modules_and_files_visibility
  • parser
  • privacy/restricted
  • resolve
  • rfcs/rfc-2126-extern-absolute-paths
  • rust-2018
  • suggestions
  • tool-attributes
  • typeck
  • unresolved
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    138 files changed

    +1076
    -393
    lines changed

    .github/workflows/ci.yml

    Lines changed: 1 addition & 1 deletion
    Original file line num 10000 berDiff line numberDiff line change
    @@ -109,7 +109,7 @@ jobs:
    109109
    # intensive jobs to run on free runners, which however also have
    110110
    # less disk space.
    111111
    - name: free up disk space
    112-
    uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
    112+
    run: src/ci/scripts/free-disk-space.sh
    113113
    if: matrix.free_disk
    114114

    115115
    # Rust Log Analyzer can't currently detect the PR number of a GitHub

    compiler/rustc_codegen_ssa/src/mir/naked_asm.rs

    Lines changed: 168 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,10 +1,14 @@
    1+
    use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind};
    12
    use rustc_attr_parsing::InstructionSetAttr;
    3+
    use rustc_hir::def_id::DefId;
    24
    use rustc_middle::mir::mono::{Linkage, MonoItem, MonoItemData, Visibility};
    35
    use rustc_middle::mir::{Body, InlineAsmOperand};
    4-
    use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf};
    5-
    use rustc_middle::ty::{Instance, TyCtxt};
    6-
    use rustc_middle::{bug, ty};
    6+
    use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
    7+
    use rustc_middle::ty::{Instance, Ty, TyCtxt};
    8+
    use rustc_middle::{bug, span_bug, ty};
    79
    use rustc_span::sym;
    10+
    use rustc_target::callconv::{ArgAbi, FnAbi, PassMode};
    11+
    use rustc_target::spec::WasmCAbi;
    812

    913
    use crate::common;
    1014
    use crate::traits::{AsmCodegenMethods, BuilderMethods, GlobalAsmOperandRef, MiscCodegenMethods};
    @@ -32,7 +36,8 @@ pub(crate) fn codegen_naked_asm<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
    3236

    3337
    let item_data = cx.codegen_unit().items().get(&MonoItem::Fn(instance)).unwrap();
    3438
    let name = cx.mangled_name(instance);
    35-
    let (begin, end) = prefix_and_suffix(cx.tcx(), instance, &name, item_data);
    39+
    let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
    40+
    let (begin, end) = prefix_and_suffix(cx.tcx(), instance, &name, item_data, fn_abi);
    3641

    3742
    let mut template_vec = Vec::new();
    3843
    template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin.into())< 10000 /span>);
    @@ -103,6 +108,7 @@ enum AsmBinaryFormat {
    103108
    Elf,
    104109
    Macho,
    105110
    Coff,
    111+
    Wasm,
    106112
    }
    107113

    108114
    impl AsmBinaryFormat {
    @@ -111,6 +117,8 @@ impl AsmBinaryFormat {
    111117
    Self::Coff
    112118
    } else if target.is_like_osx {
    113119
    Self::Macho
    120+
    } else if target.is_like_wasm {
    121+
    Self::Wasm
    114122
    } else {
    115123
    Self::Elf
    116124
    }
    @@ -122,6 +130,7 @@ fn prefix_and_suffix<'tcx>(
    122130
    instance: Instance<'tcx>,
    123131
    asm_name: &str,
    124132
    item_data: &MonoItemData,
    133+
    fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
    125134
    ) -> (String, String) {
    126135
    use std::fmt::Write;
    127136

    @@ -169,7 +178,7 @@ fn prefix_and_suffix<'tcx>(
    169178
    }
    170179
    Linkage::LinkOnceAny | Linkage::LinkOnceODR | Linkage::WeakAny | Linkage::WeakODR => {
    171180
    match asm_binary_format {
    172-
    AsmBinaryFormat::Elf | AsmBinaryFormat::Coff => {
    181+
    AsmBinaryFormat::Elf | AsmBinaryFormat::Coff | AsmBinaryFormat::Wasm => {
    173182
    writeln!(w, ".weak {asm_name}")?;
    174183
    }
    175184
    AsmBinaryFormat::Macho => {
    @@ -264,7 +273,161 @@ fn prefix_and_suffix<'tcx>(
    264273
    writeln!(end, "{}", arch_suffix).unwrap();
    265274
    }
    266275
    }
    276+
    AsmBinaryFormat::Wasm => {
    277+
    let section = link_section.unwrap_or(format!(".text.{asm_name}"));
    278+
    279+
    writeln!(begin, ".section {section},\"\",@").unwrap();
    280+
    // wasm functions cannot be aligned, so skip
    281+
    write_linkage(&mut begin).unwrap();
    282+
    if let Visibility::Hidden = item_data.visibility {
    283+
    writeln!(begin, ".hidden {asm_name}").unwrap();
    284+
    }
    285+
    writeln!(begin, ".type {asm_name}, @function").unwrap();
    286+
    if !arch_prefix.is_empty() {
    287+
    writeln!(begin, "{}", arch_prefix).unwrap();
    288+
    }
    289+
    writeln!(begin, "{asm_name}:").unwrap();
    290+
    writeln!(
    291+
    begin,
    292+
    ".functype {asm_name} {}",
    293+
    wasm_functype(tcx, fn_abi, instance.def_id())
    294+
    )
    295+
    .unwrap();
    296+
    297+
    writeln!(end).unwrap();
    298+
    // .size is ignored for function symbols, so we can skip it
    299+
    writeln!(end, "end_function").unwrap();
    300+
    }
    267301
    }
    268302

    269303
    (begin, end)
    270304
    }
    305+
    306+
    /// The webassembly type signature for the given function.
    307+
    ///
    308+
    /// Used by the `.functype` directive on wasm targets.
    309+
    fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id: DefId) -> String {
    310+
    let mut signature = String::with_capacity(64);
    311+
    312+
    let ptr_type = match tcx.data_layout.pointer_size.bits() {
    313+
    32 => "i32",
    314+
    64 => "i64",
    315+
    other => bug!("wasm pointer size cannot be {other} bits"),
    316+
    };
    317+
    318+
    // FIXME: remove this once the wasm32-unknown-unknown ABI is fixed
    319+
    // please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
    320+
    // basically the commit introducing this comment should be reverted
    321+
    if let PassMode::Pair { .. } = fn_abi.ret.mode {
    322+
    let _ = WasmCAbi::Legacy;
    323+
    span_bug!(
    324+
    tcx.def_span(def_id),
    325+
    "cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
    326+
    );
    327+
    }
    328+
    329+
    let hidden_return = matches!(fn_abi.ret.mode, PassMode::Indirect { .. });
    330+
    331+
    signature.push('(');
    332+
    333+
    if hidden_return {
    334+
    signature.push_str(ptr_type);
    335+
    if !fn_abi.args.is_empty() {
    336+
    signature.push_str(", ");
    337+
    }
    338+
    }
    339+
    340+
    let mut it = fn_abi.args.iter().peekable();
    341+
    while let Some(arg_abi) = it.next() {
    342+
    wasm_type(tcx, &mut signature, arg_abi, ptr_type, def_id);
    343+
    if it.peek().is_some() {
    344+
    signature.push_str(", ");
    345+
    }
    346+
    }
    347+
    348+
    signature.push_str(") -> (");
    349+
    350+
    if !hidden_return {
    351+
    wasm_type(tcx, &mut signature, &fn_abi.ret, ptr_type, def_id);
    352+
    }
    353+
    354+
    signature.push(')');
    355+
    356+
    signature
    357+
    }
    358+
    359+
    fn wasm_type<'tcx>(
    360+
    tcx: TyCtxt<'tcx>,
    361+
    signature: &mut String,
    362+
    arg_abi: &ArgAbi<'_, Ty<'tcx>>,
    363+
    ptr_type: &'static str,
    364+
    def_id: DefId,
    365+
    ) {
    366+
    match arg_abi.mode {
    367+
    PassMode::Ignore => { /* do nothing */ }
    368+
    PassMode::Direct(_) => {
    369+
    let direct_type = match arg_abi.layout.backend_repr {
    370+
    BackendRepr::Scalar(scalar) => wasm_primitive(scalar.primitive(), ptr_type),
    371+
    BackendRepr::Vector { .. } => "v128",
    372+
    BackendRepr::Memory { .. } => {
    373+
    // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
    374+
    let _ = WasmCAbi::Legacy;
    375+
    span_bug!(
    376+
    tcx.def_span(def_id),
    377+
    "cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
    378+
    );
    379+
    }
    380+
    other => unreachable!("unexpected BackendRepr: {:?}", other),
    381+
    };
    382+
    383+
    signature.push_str(direct_type);
    384+
    }
    385+
    PassMode::Pair(_, _) => match arg_abi.layout.backend_repr {
    386+
    BackendRepr::ScalarPair(a, b) => {
    387+
    signature.push_str(wasm_primitive(a.primitive(), ptr_type));
    388+
    signature.push_str(", ");
    389+
    signature.push_str(wasm_primitive(b.primitive(), ptr_type));
    390+
    }
    391+
    other => unreachable!("{other:?}"),
    392+
    },
    393+
    PassMode::Cast { pad_i32, ref cast } => {
    394+
    // For wasm, Cast is used for single-field primitive wrappers like `struct Wrapper(i64);`
    395+
    assert!(!pad_i32, "not currently used by wasm calling convention");
    396+
    assert!(cast.prefix[0].is_none(), "no prefix");
    397+
    assert_eq!(cast.rest.total, arg_abi.layout.size, "single item");
    398+
    399+
    let wrapped_wasm_type = match cast.rest.unit.kind {
    400+
    RegKind::Integer => match cast.rest.unit.size.bytes() {
    401+
    ..=4 => "i32",
    402+
    ..=8 => "i64",
    403+
    _ => ptr_type,
    404+
    },
    405+
    RegKind::Float => match cast.rest.unit.size.bytes() {
    406+
    ..=4 => "f32",
    407+
    ..=8 => "f64",
    408+
    _ => ptr_type,
    409+
    },
    410+
    RegKind::Vector => "v128",
    411+
    };
    412+
    413+
    signature.push_str(wrapped_wasm_type);
    414+
    }
    415+
    PassMode::Indirect { .. } => signature.push_str(ptr_type),
    416+
    }
    417+
    }
    418+
    419+
    fn wasm_primitive(primitive: Primitive, ptr_type: &'static str) -> &'static str {
    420+
    match primitive {
    421+
    Primitive::Int(integer, _) => match integer {
    422+
    Integer::I8 | Integer::I16 | Integer::I32 => "i32",
    423+
    Integer::I64 => "i64",
    424+
    Integer::I128 => "i64, i64",
    425+
    },
    426+
    Primitive::Float(float) => match float {
    427+
    Float::F16 | Float::F32 => "f32",
    428+
    Float::F64 => "f64",
    429+
    Float::F128 => "i64, i64",
    430+
    },
    431+
    Primitive::Pointer(_) => ptr_type,
    432+
    }
    433+
    }

    compiler/rustc_parse/src/parser/mod.rs

    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -189,8 +189,9 @@ pub struct Parser<'a> {
    189189
    }
    190190

    191191
    // This type is used a lot, e.g. it's cloned when matching many declarative macro rules with
    192-
    // nonterminals. Make sure it doesn't unintentionally get bigger.
    193-
    #[cfg(all(target_pointer_width = "64", not(target_arch = "s390x")))]
    192+
    // nonterminals. Make sure it doesn't unintentionally get bigger. We only check a few arches
    193+
    // though, because `TokenTypeSet(u128)` alignment varies on others, changing the total size.
    194+
    #[cfg(all(target_pointer_width = "64", any(target_arch = "aarch64", target_arch = "x86_64")))]
    194195
    rustc_data_structures::static_assert_size!(Parser<'_>, 288);
    195196

    196197
    /// Stores span information about a closure.

    compiler/rustc_resolve/src/diagnostics.rs

    Lines changed: 32 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -24,6 +24,7 @@ use rustc_session::lint::builtin::{
    2424
    MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
    2525
    };
    2626
    use rustc_session::lint::{AmbiguityErrorDiag, BuiltinLintDiag};
    27+
    use rustc_session::utils::was_invoked_from_cargo;
    2728
    use rustc_span::edit_distance::find_best_match_for_name;
    2829
    use rustc_span::edition::Edition;
    2930
    use rustc_span::hygiene::MacroKind;
    @@ -800,7 +801,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
    800801
    }
    801802
    err.multipart_suggestion(msg, suggestions, applicability);
    802803
    }
    803-
    804804
    if let Some(ModuleOrUniformRoot::Module(module)) = module
    805805
    && let Some(module) = module.opt_def_id()
    806806
    && let Some(segment) = segment
    @@ -2034,13 +2034,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
    20342034
    (format!("`_` is not a valid crate or module name"), None)
    20352035
    } else if self.tcx.sess.is_rust_2015() {
    20362036
    (
    2037-
    format!("you might be missing crate `{ident}`"),
    2037+
    format!("use of unresolved module or unlinked crate `{ident}`"),
    20382038
    Some((
    20392039
    vec![(
    20402040
    self.current_crate_outer_attr_insert_span,
    20412041
    format!("extern crate {ident};\n"),
    20422042
    )],
    2043-
    format!("consider importing the `{ident}` crate"),
    2043+
    if was_invoked_from_cargo() {
    2044+
    format!(
    2045+
    "if you wanted to use a crate named `{ident}`, use `cargo add {ident}` \
    2046+
    to add it to your `Cargo.toml` and import it in your code",
    2047+
    )
    2048+
    } else {
    2049+
    format!(
    2050+
    "you might be missing a crate named `{ident}`, add it to your \
    2051+
    project and import it in your code",
    2052+
    )
    2053+
    },
    20442054
    Applicability::MaybeIncorrect,
    20452055
    )),
    20462056
    )
    @@ -2219,7 +2229,25 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
    22192229
    let descr = binding.res().descr();
    22202230
    (format!("{descr} `{ident}` is not a crate or module"), suggestion)
    22212231
    } else {
    2222-
    (format!("use of undeclared crate or module `{ident}`"), suggestion)
    2232+
    let suggestion = if suggestion.is_some() {
    2233+
    suggestion
    2234+
    } else if was_invoked_from_cargo() {
    2235+
    Some((
    2236+
    vec![],
    2237+
    format!(
    2238+
    "if you wanted to use a crate named `{ident}`, use `cargo add {ident}` \
    2239+
    to add it to your `Cargo.toml`",
    2240+
    ),
    2241+
    Applicability::MaybeIncorrect,
    2242+
    ))
    2243+
    } else {
    2244+
    Some((
    2245+
    vec![],
    2246+
    format!("you might be missing a crate named `{ident}`",),
    2247+
    Applicability::MaybeIncorrect,
    2248+
    ))
    2249+
    };
    2250+
    (format!("use of unresolved module or unlinked crate `{ident}`"), suggestion)
    22232251
    }
    22242252
    }
    22252253
    }

    compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -7,7 +7,8 @@
    77
    // For example, `-C target-cpu=cortex-a53`.
    88

    99
    use crate::spec::{
    10-
    Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, StackProbeType, Target, TargetOptions,
    10+
    Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
    11+
    TargetOptions,
    1112
    };
    1213

    1314
    pub(crate) fn target() -> Target {
    @@ -19,6 +20,7 @@ pub(crate) fn target() -> Target {
    1920
    relocation_model: RelocModel::Static,
    2021
    disable_redzone: true,
    2122
    max_atomic_width: Some(128),
    23+
    supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
    2224
    stack_probes: StackProbeType::Inline,
    2325
    panic_strategy: PanicStrategy::Abort,
    2426
    ..Default::default()

    library/proc_macro/src/bridge/closure.rs

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3,7 +3,7 @@
    33
    use std::marker::PhantomData;
    44

    55
    #[repr(C)]
    6-
    pub struct Closure<'a, A, R> {
    6+
    pub(super) struct Closure<'a, A, R> {
    77
    call: unsafe extern "C" fn(*mut Env, A) -> R,
    88
    env: *mut Env,
    99
    // Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing
    @@ -26,7 +26,7 @@ impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
    2626
    }
    2727

    2828
    impl<'a, A, R> Closure<'a, A, R> {
    29-
    pub fn call(&mut self, arg: A) -> R {
    29+
    pub(super) fn call(&mut self, arg: A) -> R {
    3030
    unsafe { (self.call)(self.env, arg) }
    3131
    }
    3232
    }

    library/proc_macro/src/bridge/fxhash.rs

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -9,7 +9,7 @@ use std::hash::{BuildHasherDefault, Hasher};
    99
    use std::ops::BitXor;
    1010

    1111
    /// Type alias for a hashmap using the `fx` hash algorithm.
    12-
    pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
    12+
    pub(super) type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>< 17AE span class="pl-kos">;
    1313

    1414
    /// A speedy hash algorithm for use within rustc. The hashmap in alloc by
    1515
    /// default uses SipHash which isn't quite as speedy as we want. In the compiler
    @@ -23,7 +23,7 @@ pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
    2323
    /// similar or slightly worse than FNV, but the speed of the hash function
    2424
    /// itself is much higher because it works on up to 8 bytes at a time.
    2525
    #[derive(Default)]
    26-
    pub struct FxHasher {
    26+
    pub(super) struct FxHasher {
    2727
    hash: usize,
    2828
    }
    2929

    library/proc_macro/src/bridge/rpc.rs

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -67,7 +67,7 @@ macro_rules! rpc_encode_decode {
    6767
    mod tag {
    6868
    #[repr(u8)] enum Tag { $($variant),* }
    6969

    70-
    $(pub const $variant: u8 = Tag::$variant as u8;)*
    70+
    $(pub(crate) const $variant: u8 = Tag::$variant as u8;)*
    7171
    }
    7272

    7373
    match self {
    @@ -89,7 +89,7 @@ macro_rules! rpc_encode_decode {
    8989
    mod tag {
    9090
    #[repr(u8)] enum Tag { $($variant),* }
    9191

    92-
    $(pub const $variant: u8 = Tag::$variant as u8;)*
    92+
    $(pub(crate) const $variant: u8 = Tag::$variant as u8;)*
    9393
    }
    9494

    9595
    match u8::decode(r, s) {

    library/proc_macro/src/bridge/selfless_reify.rs

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -44,7 +44,7 @@ macro_rules! define_reify_functions {
    4444
    fn $name:ident $(<$($param:ident),*>)?
    4545
    for $(extern $abi:tt)? fn($($arg:ident: $arg_ty:ty),*) -> $ret_ty:ty;
    4646
    )+) => {
    47-
    $(pub const fn $name<
    47+
    $(pub(super) const fn $name<
    4848
    $($($param,)*)?
    4949
    F: Fn($($arg_ty),*) -> $ret_ty + Copy
    5050
    >(f: F) -> $(extern $abi)? fn($($arg_ty),*) -> $ret_ty {

    0 commit comments

    Comments
     (0)
    0