diff options
124 files changed, 1451 insertions, 573 deletions
diff --git a/RELEASES.md b/RELEASES.md index 1dd3fbea613..f0def1a0e42 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,130 @@ +Version 1.85.0 (2025-02-20) +========================== + +<a id="1.85.0-Language"></a> + +Language +-------- +- [The 2024 Edition is now stable.](https://github.com/rust-lang/rust/pull/133349) + See [the edition guide](https://doc.rust-lang.org/nightly/edition-guide/rust-2024/index.html) for more details. +- [Stabilize async closures](https://github.com/rust-lang/rust/pull/132706) + See [RFC 3668](https://rust-lang.github.io/rfcs/3668-async-closures.html) for more details. +- [Stabilize `#[diagnostic::do_not_recommend]`](https://github.com/rust-lang/rust/pull/132056) +- [Add `unpredictable_function_pointer_comparisons` lint to warn against function pointer comparisons](https://github.com/rust-lang/rust/pull/118833) +- [Lint on combining `#[no_mangle]` and `#[export_name]` attributes.](https://github.com/rust-lang/rust/pull/131558) + +<a id="1.85.0-Compiler"></a> + +Compiler +-------- +- [The unstable flag `-Zpolymorphize` has been removed](https://github.com/rust-lang/rust/pull/133883), see https://github.com/rust-lang/compiler-team/issues/810 for some background. + +<a id="1.85.0-Platform-Support"></a> + +Platform Support +---------------- +- [Promote `powerpc64le-unknown-linux-musl` to tier 2 with host tools](https://github.com/rust-lang/rust/pull/133801) + +Refer to Rust's [platform support page][platform-support-doc] +for more information on Rust's tiered platform support. + +<a id="1.85.0-Libraries"></a> + +Libraries +--------- +- [Panics in the standard library now have a leading `library/` in their path](https://github.com/rust-lang/rust/pull/132390) +- [`std::env::home_dir()` on Windows now ignores the non-standard `$HOME` environment variable](https://github.com/rust-lang/rust/pull/132515) + It will be un-deprecated in a subsequent release. +- [Add `AsyncFn*` to the prelude in all editions.](https://github.com/rust-lang/rust/pull/132611) + +<a id="1.85.0-Stabilized-APIs"></a> + +Stabilized APIs +--------------- + +- [`BuildHasherDefault::new`](https://doc.rust-lang.org/stable/std/hash/struct.BuildHasherDefault.html#method.new) +- [`ptr::fn_addr_eq`](https://doc.rust-lang.org/std/ptr/fn.fn_addr_eq.html) +- [`io::ErrorKind::QuotaExceeded`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#variant.QuotaExceeded) +- [`io::ErrorKind::CrossesDevices`](https://doc.rust-lang.org/stable/std/io/enum.ErrorKind.html#variant.CrossesDevices) +- [`{float}::midpoint`](https://doc.rust-lang.org/core/primitive.f32.html#method.midpoint) +- [Unsigned `{integer}::midpoint`](https://doc.rust-lang.org/std/primitive.u64.html#method.midpoint) +- [`NonZeroU*::midpoint`](https://doc.rust-lang.org/std/num/type.NonZeroU32.html#method.midpoint) +- [impl `std::iter::Extend` for tuples with arity 1 through 12](https://doc.rust-lang.org/stable/std/iter/trait.Extend.html#impl-Extend%3C(A,)%3E-for-(EA,)) +- [`FromIterator<(A, ...)>` for tuples with arity 1 through 12](https://doc.rust-lang.org/stable/std/iter/trait.FromIterator.html#impl-FromIterator%3C(EA,)%3E-for-(A,)) +- [`std::task::Waker::noop`](https://doc.rust-lang.org/stable/std/task/struct.Waker.html#method.noop) + +These APIs are now stable in const contexts: + +- [`mem::size_of_val`](https://doc.rust-lang.org/stable/std/mem/fn.size_of_val.html) +- [`mem::align_of_val`](https://doc.rust-lang.org/stable/std/mem/fn.align_of_val.html) +- [`Layout::for_value`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.for_value) +- [`Layout::align_to`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.align_to) +- [`Layout::pad_to_align`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.pad_to_align) +- [`Layout::extend`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.extend) +- [`Layout::array`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.array) +- [`std::mem::swap`](https://doc.rust-lang.org/stable/std/mem/fn.swap.html) +- [`std::ptr::swap`](https://doc.rust-lang.org/stable/std/ptr/fn.swap.html) +- [`NonNull::new`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.new) +- [`HashMap::with_hasher`](https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html#method.with_hasher) +- [`HashSet::with_hasher`](https://doc.rust-lang.org/stable/std/collections/struct.HashSet.html#method.with_hasher) +- [`BuildHasherDefault::new`](https://doc.rust-lang.org/stable/std/hash/struct.BuildHasherDefault.html#method.new) +- [`<float>::recip`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.recip) +- [`<float>::to_degrees`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.to_degrees) +- [`<float>::to_radians`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.to_radians) +- [`<float>::max`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.max) +- [`<float>::min`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.min) +- [`<float>::clamp`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.clamp) +- [`<float>::abs`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.abs) +- [`<float>::signum`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.signum) +- [`<float>::copysign`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.copysign) +- [`MaybeUninit::write`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.write) + +<a id="1.85.0-Cargo"></a> + +Cargo +----- +- [Add future-incompatibility warning against keywords in cfgs and add raw-idents](https://github.com/rust-lang/cargo/pull/14671/) +- [Stabilize higher precedence trailing flags](https://github.com/rust-lang/cargo/pull/14900/) +- [Pass `CARGO_CFG_FEATURE` to build scripts](https://github.com/rust-lang/cargo/pull/14902/) + +<a id="1.85.0-Rustdoc"></a> + +Rustdoc +----- +- [Doc comment on impl blocks shows the first line, even when the impl block is collapsed](https://github.com/rust-lang/rust/pull/132155) + +<a id="1.85.0-Compatibility-Notes"></a> + +Compatibility Notes +------------------- +- [`rustc` no longer treats the `test` cfg as a well known check-cfg](https://github.com/rust-lang/rust/pull/131729), instead it is up to the build systems and users of `--check-cfg`[^check-cfg] to set it as a well known cfg using `--check-cfg=cfg(test)`. + This is done to enable build systems like Cargo to set it conditionally, as not all source files are suitable for unit tests. + [Cargo (for now) unconditionally sets the `test` cfg as a well known cfg](https://github.com/rust-lang/cargo/pull/14963). +[^check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html +- [Disable potentially incorrect type inference if there are trivial and non-trivial where-clauses](https://github.com/rust-lang/rust/pull/132325) +- `std::env::home_dir()` has been deprecated for years, because it can give surprising results in some Windows configurations if the `HOME` environment variable is set (which is not the normal configuration on Windows). We had previously avoided changing its behavior, out of concern for compatibility with code depending on this non-standard configuration. Given how long this function has been deprecated, we're now fixing its behavior as a bugfix. A subsequent release will remove the deprecation for this function. +- [Make `core::ffi::c_char` signedness more closely match that of the platform-default `char`](https://github.com/rust-lang/rust/pull/132975) + This changed `c_char` from an `i8` to `u8` or vice versa on many Tier 2 and 3 + targets (mostly Arm and RISC-V embedded targets). The new definition may + result in compilation failures but fixes compatibility issues with C. + The `libc` crate matches this change as of its 0.2.169 release. +- [When compiling a nested `macro_rules` macro from an external crate, the content of the inner `macro_rules` is now built with the edition of the external crate, not the local crate.](https://github.com/rust-lang/rust/pull/133274) +- [Increase `sparcv9-sun-solaris` and `x86_64-pc-solaris` Solaris baseline to 11.4.](https://github.com/rust-lang/rust/pull/133293) +- [Show `abi_unsupported_vector_types` lint in future breakage reports](https://github.com/rust-lang/rust/pull/133374) +- [Error if multiple super-trait instantiations of `dyn Trait` need associated types to be specified but only one is provided](https://github.com/rust-lang/rust/pull/133392) +- [Change `powerpc64-ibm-aix` default `codemodel` to large](https://github.com/rust-lang/rust/pull/133811) + +<a id="1.85.0-Internal-Changes"></a> + +Internal Changes +---------------- + +These changes do not affect any public interfaces of Rust, but they represent +significant improvements to the performance or internals of rustc and related +tools. + +- [Build `x86_64-unknown-linux-gnu` with LTO for C/C++ code (e.g., `jemalloc`)](https://github.com/rust-lang/rust/pull/134690) + Version 1.84.1 (2025-01-30) ========================== diff --git a/compiler/rustc_codegen_cranelift/.github/workflows/main.yml b/compiler/rustc_codegen_cranelift/.github/workflows/main.yml index a8333df77e6..61a4c1270c9 100644 --- a/compiler/rustc_codegen_cranelift/.github/workflows/main.yml +++ b/compiler/rustc_codegen_cranelift/.github/workflows/main.yml @@ -188,8 +188,8 @@ jobs: fail-fast: false matrix: include: - # FIXME update at some point in the future once most distros use a newer glibc - - os: ubuntu-20.04 + # Intentionally using an older ubuntu version to lower the glibc requirements of the distributed cg_clif + - os: ubuntu-22.04 env: TARGET_TRIPLE: x86_64-unknown-linux-gnu - os: macos-latest diff --git a/compiler/rustc_codegen_cranelift/rust-toolchain b/compiler/rustc_codegen_cranelift/rust-toolchain index 8d423319fa9..481903c6afb 100644 --- a/compiler/rustc_codegen_cranelift/rust-toolchain +++ b/compiler/rustc_codegen_cranelift/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2025-02-07" +channel = "nightly-2025-02-15" components = ["rust-src", "rustc-dev", "llvm-tools"] profile = "minimal" diff --git a/compiler/rustc_codegen_cranelift/rustfmt.toml b/compiler/rustc_codegen_cranelift/rustfmt.toml index d9e6ac3d543..f31fa9c76ab 100644 --- a/compiler/rustc_codegen_cranelift/rustfmt.toml +++ b/compiler/rustc_codegen_cranelift/rustfmt.toml @@ -3,8 +3,9 @@ ignore = [ ] # Matches rustfmt.toml of rustc -version = "Two" +style_edition = "2024" use_small_heuristics = "Max" merge_derives = false group_imports = "StdExternalCrate" imports_granularity = "Module" +use_field_init_shorthand = true diff --git a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs index 7594a53fc75..b28c4c9539c 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs @@ -195,7 +195,7 @@ pub(super) fn from_casted_value<'tcx>( // It may also be smaller for example when the type is a wrapper around an integer with a // larger alignment than the integer. std::cmp::max(abi_param_size, layout_size), - u32::try_from(layout.align.pref.bytes()).unwrap(), + u32::try_from(layout.align.abi.bytes()).unwrap(), ); let mut offset = 0; let mut block_params_iter = block_params.iter().copied(); diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index 534557fcd41..766278d8718 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -382,6 +382,11 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { } pub(crate) fn create_stack_slot(&mut self, size: u32, align: u32) -> Pointer { + assert!( + size % align == 0, + "size must be a multiple of alignment (size={size}, align={align})" + ); + let abi_align = if self.tcx.sess.target.arch == "s390x" { 8 } else { 16 }; if align <= abi_align { let stack_slot = self.bcx.create_sized_stack_slot(StackSlotData { @@ -403,7 +408,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> { align_shift: 4, }); let base_ptr = self.bcx.ins().stack_addr(self.pointer_type, stack_slot, 0); - let misalign_offset = self.bcx.ins().urem_imm(base_ptr, i64::from(align)); + let misalign_offset = self.bcx.ins().band_imm(base_ptr, i64::from(align - 1)); let realign_offset = self.bcx.ins().irsub_imm(misalign_offset, i64::from(align)); Pointer::new(self.bcx.ins().iadd(base_ptr, realign_offset)) } diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs index f3a8623e216..bba6567774d 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs @@ -304,7 +304,7 @@ impl DebugContext { entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id))); entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line)); - entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(static_layout.align.pref.bytes())); + entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(static_layout.align.abi.bytes())); let mut expr = Expression::new(); expr.op_addr(address_for_data(data_id)); diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs index a2f6691cdd2..017d7784dc0 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/types.rs @@ -166,7 +166,7 @@ impl DebugContext { let tuple_entry = self.dwarf.unit.get_mut(tuple_type_id); tuple_entry.set(gimli::DW_AT_name, AttributeValue::StringRef(self.dwarf.strings.add(name))); tuple_entry.set(gimli::DW_AT_byte_size, AttributeValue::Udata(layout.size.bytes())); - tuple_entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(layout.align.pref.bytes())); + tuple_entry.set(gimli::DW_AT_alignment, AttributeValue::Udata(layout.align.abi.bytes())); for (i, (ty, dw_ty)) in components.into_iter().enumerate() { let member_id = self.dwarf.unit.add(tuple_type_id, gimli::DW_TAG_member); @@ -179,7 +179,7 @@ impl DebugContext { member_entry.set( gimli::DW_AT_alignment, AttributeValue::Udata( - FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.pref.bytes(), + FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.abi.bytes(), ), ); member_entry.set( diff --git a/compiler/rustc_codegen_cranelift/src/inline_asm.rs b/compiler/rustc_codegen_cranelift/src/inline_asm.rs index f2b0ec977c6..310b226814d 100644 --- a/compiler/rustc_codegen_cranelift/src/inline_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/inline_asm.rs @@ -871,7 +871,8 @@ fn call_inline_asm<'tcx>( inputs: Vec<(Size, Value)>, outputs: Vec<(Size, CPlace<'tcx>)>, ) { - let stack_slot = fx.create_stack_slot(u32::try_from(slot_size.bytes()).unwrap(), 16); + let stack_slot = + fx.create_stack_slot(u32::try_from(slot_size.bytes().next_multiple_of(16)).unwrap(), 16); let inline_asm_func = fx .module diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index c17d1f30fbe..a9b8e1bd393 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -101,7 +101,7 @@ impl<'tcx> CValue<'tcx> { /// The is represented by a dangling pointer of suitable alignment. pub(crate) fn zst(layout: TyAndLayout<'tcx>) -> CValue<'tcx> { assert!(layout.is_zst()); - CValue::by_ref(crate::Pointer::dangling(layout.align.pref), layout) + CValue::by_ref(crate::Pointer::dangling(layout.align.abi), layout) } pub(crate) fn layout(&self) -> TyAndLayout<'tcx> { @@ -392,7 +392,7 @@ impl<'tcx> CPlace<'tcx> { assert!(layout.is_sized()); if layout.size.bytes() == 0 { return CPlace { - inner: CPlaceInner::Addr(Pointer::dangling(layout.align.pref), None), + inner: CPlaceInner::Addr(Pointer::dangling(layout.align.abi), None), layout, }; } @@ -405,7 +405,7 @@ impl<'tcx> CPlace<'tcx> { let stack_slot = fx.create_stack_slot( u32::try_from(layout.size.bytes()).unwrap(), - u32::try_from(layout.align.pref.bytes()).unwrap(), + u32::try_from(layout.align.abi.bytes()).unwrap(), ); CPlace { inner: CPlaceInner::Addr(stack_slot, None), layout } } diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 7fe527a4c07..e7952bc95e7 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -194,6 +194,12 @@ pub(crate) unsafe fn create_module<'ll>( target_data_layout = target_data_layout.replace("-i128:128", ""); } } + if llvm_version < (21, 0, 0) { + if sess.target.arch == "nvptx64" { + // LLVM 21 updated the default layout on nvptx: https://github.com/llvm/llvm-project/pull/124961 + target_data_layout = target_data_layout.replace("e-p6:32:32-i64", "e-i64"); + } + } // Ensure the data-layout values hardcoded remain the defaults. { diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 05d6ff35751..e3ace01c1eb 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1776,6 +1776,7 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) - symbols.push(symbol_export::exporting_symbol_name_for_instance_in_crate( tcx, symbol, cnum, )); + symbol_export::extend_exported_symbols(&mut symbols, tcx, symbol, cnum); } }); diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 1dbaffaa577..12ee872d531 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -10,9 +10,10 @@ use rustc_middle::middle::exported_symbols::{ ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, metadata_symbol_name, }; use rustc_middle::query::LocalCrate; -use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, TyCtxt}; +use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, Ty, TyCtxt}; use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; +use rustc_target::callconv::Conv; use rustc_target::spec::{SanitizerSet, TlsModel}; use tracing::debug; @@ -584,6 +585,42 @@ pub(crate) fn symbol_name_for_instance_in_crate<'tcx>( } } +fn calling_convention_for_symbol<'tcx>( + tcx: TyCtxt<'tcx>, + symbol: ExportedSymbol<'tcx>, +) -> (Conv, &'tcx [rustc_target::callconv::ArgAbi<'tcx, Ty<'tcx>>]) { + let instance = match symbol { + ExportedSymbol::NonGeneric(def_id) | ExportedSymbol::Generic(def_id, _) + if tcx.is_static(def_id) => + { + None + } + ExportedSymbol::NonGeneric(def_id) => Some(Instance::mono(tcx, def_id)), + ExportedSymbol::Generic(def_id, args) => Some(Instance::new(def_id, args)), + // DropGlue always use the Rust calling convention and thus follow the target's default + // symbol decoration scheme. + ExportedSymbol::DropGlue(..) => None, + // AsyncDropGlueCtorShim always use the Rust calling convention and thus follow the + // target's default symbol decoration scheme. + ExportedSymbol::AsyncDropGlueCtorShim(..) => None, + // NoDefId always follow the target's default symbol decoration scheme. + ExportedSymbol::NoDefId(..) => None, + // ThreadLocalShim always follow the target's default symbol decoration scheme. + ExportedSymbol::ThreadLocalShim(..) => None, + }; + + instance + .map(|i| { + tcx.fn_abi_of_instance( + ty::TypingEnv::fully_monomorphized().as_query_input((i, ty::List::empty())), + ) + .unwrap_or_else(|_| bug!("fn_abi_of_instance({i:?}) failed")) + }) + .map(|fnabi| (fnabi.conv, &fnabi.args[..])) + // FIXME(workingjubilee): why don't we know the convention here? + .unwrap_or((Conv::Rust, &[])) +} + /// This is the symbol name of the given instance as seen by the linker. /// /// On 32-bit Windows symbols are decorated according to their calling conventions. @@ -592,8 +629,6 @@ pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>( symbol: ExportedSymbol<'tcx>, instantiating_crate: CrateNum, ) -> String { - use rustc_target::callconv::Conv; - let mut undecorated = symbol_name_for_instance_in_crate(tcx, symbol, instantiating_crate); // thread local will not be a function call, @@ -617,35 +652,7 @@ pub(crate) fn linking_symbol_name_for_instance_in_crate<'tcx>( _ => return undecorated, }; - let instance = match symbol { - ExportedSymbol::NonGeneric(def_id) | ExportedSymbol::Generic(def_id, _) - if tcx.is_static(def_id) => - { - None - } - ExportedSymbol::NonGeneric(def_id) => Some(Instance::mono(tcx, def_id)), - ExportedSymbol::Generic(def_id, args) => Some(Instance::new(def_id, args)), - // DropGlue always use the Rust calling convention and thus follow the target's default - // symbol decoration scheme. - ExportedSymbol::DropGlue(..) => None, - // AsyncDropGlueCtorShim always use the Rust calling convention and thus follow the - // target's default symbol decoration scheme. - ExportedSymbol::AsyncDropGlueCtorShim(..) => None, - // NoDefId always follow the target's default symbol decoration scheme. - ExportedSymbol::NoDefId(..) => None, - // ThreadLocalShim always follow the target's default symbol decoration scheme. - ExportedSymbol::ThreadLocalShim(..) => None, - }; - - let (conv, args) = instance - .map(|i| { - tcx.fn_abi_of_instance( - ty::TypingEnv::fully_monomorphized().as_query_input((i, ty::List::empty())), - ) - .unwrap_or_else(|_| bug!("fn_abi_of_instance({i:?}) failed")) - }) - .map(|fnabi| (fnabi.conv, &fnabi.args[..])) - .unwrap_or((Conv::Rust, &[])); + let (conv, args) = calling_convention_for_symbol(tcx, symbol); // Decorate symbols with prefixes, suffixes and total number of bytes of arguments. // Reference: https://docs.microsoft.com/en-us/cpp/build/reference/decorated-names?view=msvc-170 @@ -677,6 +684,27 @@ pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>( maybe_emutls_symbol_name(tcx, symbol, &undecorated).unwrap_or(undecorated) } +/// On amdhsa, `gpu-kernel` functions have an associated metadata object with a `.kd` suffix. +/// Add it to the symbols list for all kernel functions, so that it is exported in the linked +/// object. +pub(crate) fn extend_exported_symbols<'tcx>( + symbols: &mut Vec<String>, + tcx: TyCtxt<'tcx>, + symbol: ExportedSymbol<'tcx>, + instantiating_crate: CrateNum, +) { + let (conv, _) = calling_convention_for_symbol(tcx, symbol); + + if conv != Conv::GpuKernel || tcx.sess.target.os != "amdhsa" { + return; + } + + let undecorated = symbol_name_for_instance_in_crate(tcx, symbol, instantiating_crate); + + // Add the symbol for the kernel descriptor (with .kd suffix) + symbols.push(format!("{undecorated}.kd")); +} + fn maybe_emutls_symbol_name<'tcx>( tcx: TyCtxt<'tcx>, symbol: ExportedSymbol<'tcx>, diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 2bcc33241df..a2ddff7183e 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -667,11 +667,12 @@ fn print_crate_info( return Compilation::Continue; }; let t_outputs = rustc_interface::util::build_output_filenames(attrs, sess); - let id = rustc_session::output::find_crate_name(sess, attrs); + let crate_name = passes::get_crate_name(sess, attrs); let crate_types = collect_crate_types(sess, attrs); for &style in &crate_types { - let fname = - rustc_session::output::filename_for_input(sess, style, id, &t_outputs); + let fname = rustc_session::output::filename_for_input( + sess, style, crate_name, &t_outputs, + ); println_info!("{}", fname.as_path().file_name().unwrap().to_string_lossy()); } } @@ -680,8 +681,7 @@ fn print_crate_info( // no crate attributes, print out an error and exit return Compilation::Continue; }; - let id = rustc_session::output::find_crate_name(sess, attrs); - println_info!("{id}"); + println_info!("{}", passes::get_crate_name(sess, attrs)); } Cfg => { let mut cfgs = sess diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs index 9c35b26772b..e925052c607 100644 --- a/compiler/rustc_expand/src/module.rs +++ b/compiler/rustc_expand/src/module.rs @@ -183,12 +183,12 @@ pub(crate) fn mod_file_path_from_attr( let first_path = attrs.iter().find(|at| at.has_name(sym::path))?; let Some(path_sym) = first_path.value_str() else { // This check is here mainly to catch attempting to use a macro, - // such as #[path = concat!(...)]. This isn't currently supported - // because otherwise the InvocationCollector would need to defer - // loading a module until the #[path] attribute was expanded, and - // it doesn't support that (and would likely add a bit of - // complexity). Usually bad forms are checked in AstValidator (via - // `check_builtin_attribute`), but by the time that runs the macro + // such as `#[path = concat!(...)]`. This isn't supported because + // otherwise the `InvocationCollector` would need to defer loading + // a module until the `#[path]` attribute was expanded, and it + // doesn't support that (and would likely add a bit of complexity). + // Usually bad forms are checked during semantic analysis via + // `TyCtxt::check_mod_attrs`), but by the time that runs the macro // is expanded, and it doesn't give an error. validate_attr::emit_fatal_malformed_builtin_attribute(&sess.psess, first_path, sym::path); }; diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 4ea171ab4a9..19cca48af61 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -117,8 +117,9 @@ use rustc_data_structures::{base_n, flock}; use rustc_fs_util::{LinkOrCopy, link_or_copy, try_canonicalize}; use rustc_middle::bug; use rustc_session::config::CrateType; -use rustc_session::output::{collect_crate_types, find_crate_name}; +use rustc_session::output::collect_crate_types; use rustc_session::{Session, StableCrateId}; +use rustc_span::Symbol; use tracing::debug; use crate::errors; @@ -211,7 +212,7 @@ pub fn in_incr_comp_dir(incr_comp_session_dir: &Path, file_name: &str) -> PathBu /// The garbage collection will take care of it. /// /// [`rustc_interface::queries::dep_graph`]: ../../rustc_interface/struct.Queries.html#structfield.dep_graph -pub(crate) fn prepare_session_directory(sess: &Session) { +pub(crate) fn prepare_session_directory(sess: &Session, crate_name: Symbol) { if sess.opts.incremental.is_none() { return; } @@ -221,7 +222,7 @@ pub(crate) fn prepare_session_directory(sess: &Session) { debug!("prepare_session_directory"); // {incr-comp-dir}/{crate-name-and-disambiguator} - let crate_dir = crate_path(sess); + let crate_dir = crate_path(sess, crate_name); debug!("crate-dir: {}", crate_dir.display()); create_dir(sess, &crate_dir, "crate"); @@ -594,10 +595,9 @@ fn string_to_timestamp(s: &str) -> Result<SystemTime, &'static str> { Ok(UNIX_EPOCH + duration) } -fn crate_path(sess: &Session) -> PathBuf { +fn crate_path(sess: &Session, crate_name: Symbol) -> PathBuf { let incr_dir = sess.opts.incremental.as_ref().unwrap().clone(); - let crate_name = find_crate_name(sess, &[]); let crate_types = collect_crate_types(sess, &[]); let stable_crate_id = StableCrateId::new( crate_name, diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index 48df84f3d09..7977bcc6891 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -11,6 +11,7 @@ use rustc_serialize::Decodable; use rustc_serialize::opaque::MemDecoder; use rustc_session::Session; use rustc_session::config::IncrementalStateAssertion; +use rustc_span::Symbol; use tracing::{debug, warn}; use super::data::*; @@ -203,9 +204,9 @@ pub fn load_query_result_cache(sess: &Session) -> Option<OnDiskCache> { /// Setups the dependency graph by loading an existing graph from disk and set up streaming of a /// new graph to an incremental session directory. -pub fn setup_dep_graph(sess: &Session) -> DepGraph { +pub fn setup_dep_graph(sess: &Session, crate_name: Symbol) -> DepGraph { // `load_dep_graph` can only be called after `prepare_session_directory`. - prepare_session_directory(sess); + prepare_session_directory(sess, crate_name); let res = sess.opts.build_dep_graph().then(|| load_dep_graph(sess)); diff --git a/compiler/rustc_interface/messages.ftl b/compiler/rustc_interface/messages.ftl index 31123625369..43c69c8e571 100644 --- a/compiler/rustc_interface/messages.ftl +++ b/compiler/rustc_interface/messages.ftl @@ -6,6 +6,10 @@ interface_abi_required_feature_issue = for more information, see issue #116344 < interface_cant_emit_mir = could not emit MIR: {$error} +interface_crate_name_does_not_match = `--crate-name` and `#[crate_name]` are required to match, but `{$crate_name}` != `{$attr_crate_name}` + +interface_crate_name_invalid = crate names cannot start with a `-`, but `{$crate_name}` has a leading hyphen + interface_emoji_identifier = identifiers cannot contain emoji: `{$ident}` diff --git a/compiler/rustc_interface/src/errors.rs b/compiler/rustc_interface/src/errors.rs index b62950d6709..c3b858d4f2e 100644 --- a/compiler/rustc_interface/src/errors.rs +++ b/compiler/rustc_interface/src/errors.rs @@ -5,6 +5,21 @@ use rustc_macros::Diagnostic; use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] +#[diag(interface_crate_name_does_not_match)] +pub(crate) struct CrateNameDoesNotMatch { + #[primary_span] + pub(crate) span: Span, + pub(crate) crate_name: Symbol, + pub(crate) attr_crate_name: Symbol, +} + +#[derive(Diagnostic)] +#[diag(interface_crate_name_invalid)] +pub(crate) struct CrateNameInvalid<'a> { + pub(crate) crate_name: &'a str, +} + +#[derive(Diagnostic)] #[diag(interface_ferris_identifier)] pub struct FerrisIdentifier { #[primary_span] diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index e5adcdb244f..fcebca3ecc9 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -28,10 +28,12 @@ use rustc_passes::{abi_test, input_stats, layout_test}; use rustc_resolve::Resolver; use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType}; use rustc_session::cstore::Untracked; -use rustc_session::output::{collect_crate_types, filename_for_input, find_crate_name}; +use rustc_session::output::{collect_crate_types, filename_for_input}; use rustc_session::search_paths::PathKind; use rustc_session::{Limit, Session}; -use rustc_span::{ErrorGuaranteed, FileName, SourceFileHash, SourceFileHashAlgorithm, Symbol, sym}; +use rustc_span::{ + ErrorGuaranteed, FileName, SourceFileHash, SourceFileHashAlgorithm, Span, Symbol, sym, +}; use rustc_target::spec::PanicStrategy; use rustc_trait_selection::traits; use tracing::{info, instrument}; @@ -725,8 +727,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>( let pre_configured_attrs = rustc_expand::config::pre_configure_attrs(sess, &krate.attrs); - // parse `#[crate_name]` even if `--crate-name` was passed, to make sure it matches. - let crate_name = find_crate_name(sess, &pre_configured_attrs); + let crate_name = get_crate_name(sess, &pre_configured_attrs); let crate_types = collect_crate_types(sess, &pre_configured_attrs); let stable_crate_id = StableCrateId::new( crate_name, @@ -735,7 +736,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>( sess.cfg_version, ); let outputs = util::build_output_filenames(&pre_configured_attrs, sess); - let dep_graph = setup_dep_graph(sess); + let dep_graph = setup_dep_graph(sess, crate_name); let cstore = FreezeLock::new(Box::new(CStore::new(compiler.codegen_backend.metadata_loader())) as _); @@ -1080,23 +1081,85 @@ pub(crate) fn start_codegen<'tcx>( codegen } -fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit { - if let Some(attr) = krate_attrs - .iter() - .find(|attr| attr.has_name(sym::recursion_limit) && attr.value_str().is_none()) +/// Compute and validate the crate name. +pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol { + // We validate *all* occurrences of `#![crate_name]`, pick the first find and + // if a crate name was passed on the command line via `--crate-name` we enforce + // that they match. + // We perform the validation step here instead of later to ensure it gets run + // in all code paths that require the crate name very early on, namely before + // macro expansion. + + let attr_crate_name = + validate_and_find_value_str_builtin_attr(sym::crate_name, sess, krate_attrs); + + let validate = |name, span| { + rustc_session::output::validate_crate_name(sess, name, span); + name + }; + + if let Some(crate_name) = &sess.opts.crate_name { + let crate_name = Symbol::intern(crate_name); + if let Some((attr_crate_name, span)) = attr_crate_name + && attr_crate_name != crate_name + { + sess.dcx().emit_err(errors::CrateNameDoesNotMatch { + span, + crate_name, + attr_crate_name, + }); + } + return validate(crate_name, None); + } + + if let Some((crate_name, span)) = attr_crate_name { + return validate(crate_name, Some(span)); + } + + if let Input::File(ref path) = sess.io.input + && let Some(file_stem) = path.file_stem().and_then(|s| s.to_str()) { - // This is here mainly to check for using a macro, such as - // #![recursion_limit = foo!()]. That is not supported since that - // would require expanding this while in the middle of expansion, - // which needs to know the limit before expanding. Otherwise, - // validation would normally be caught in AstValidator (via - // `check_builtin_attribute`), but by the time that runs the macro - // is expanded, and it doesn't give an error. - validate_attr::emit_fatal_malformed_builtin_attribute( - &sess.psess, - attr, - sym::recursion_limit, - ); + if file_stem.starts_with('-') { + sess.dcx().emit_err(errors::CrateNameInvalid { crate_name: file_stem }); + } else { + return validate(Symbol::intern(&file_stem.replace('-', "_")), None); + } } + + sym::rust_out +} + +fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit { + // We don't permit macro calls inside of the attribute (e.g., #![recursion_limit = `expand!()`]) + // because that would require expanding this while in the middle of expansion, which needs to + // know the limit before expanding. + let _ = validate_and_find_value_str_builtin_attr(sym::recursion_limit, sess, krate_attrs); rustc_middle::middle::limits::get_recursion_limit(krate_attrs, sess) } + +/// Validate *all* occurrences of the given "[value-str]" built-in attribute and return the first find. +/// +/// This validator is intended for built-in attributes whose value needs to be known very early +/// during compilation (namely, before macro expansion) and it mainly exists to reject macro calls +/// inside of the attributes, such as in `#![name = expand!()]`. Normal attribute validation happens +/// during semantic analysis via [`TyCtxt::check_mod_attrs`] which happens *after* macro expansion +/// when such macro calls (here: `expand`) have already been expanded and we can no longer check for +/// their presence. +/// +/// [value-str]: ast::Attribute::value_str +fn validate_and_find_value_str_builtin_attr( + name: Symbol, + sess: &Session, + krate_attrs: &[ast::Attribute], +) -> Option<(Symbol, Span)> { + let mut result = None; + // Validate *all* relevant attributes, not just the first occurrence. + for attr in ast::attr::filter_by_name(krate_attrs, name) { + let Some(value) = attr.value_str() else { + validate_attr::emit_fatal_malformed_builtin_attribute(&sess.psess, attr, name) + }; + // Choose the first occurrence as our result. + result.get_or_insert((value, attr.span)); + } + result +} diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index e900ec14fca..bc2aae7cd87 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -433,11 +433,11 @@ pub(crate) fn check_attr_crate_type( } } else { // This is here mainly to check for using a macro, such as - // #![crate_type = foo!()]. That is not supported since the + // `#![crate_type = foo!()]`. That is not supported since the // crate type needs to be known very early in compilation long // before expansion. Otherwise, validation would normally be - // caught in AstValidator (via `check_builtin_attribute`), but - // by the time that runs the macro is expanded, and it doesn't + // caught during semantic analysis via `TyCtxt::check_mod_attrs`, + // but by the time that runs the macro is expanded, and it doesn't // give an error. validate_attr::emit_fatal_malformed_builtin_attribute( &sess.psess, diff --git a/compiler/rustc_monomorphize/messages.ftl b/compiler/rustc_monomorphize/messages.ftl index 540ce7cc4ce..463c42b69b1 100644 --- a/compiler/rustc_monomorphize/messages.ftl +++ b/compiler/rustc_monomorphize/messages.ftl @@ -1,17 +1,17 @@ monomorphize_abi_error_disabled_vector_type_call = - this function call uses a SIMD vector type that (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled in the caller + this function call uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled in the caller .label = function called here .help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`) monomorphize_abi_error_disabled_vector_type_def = - this function definition uses a SIMD vector type that (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled + this function definition uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled .label = function defined here .help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`) monomorphize_abi_error_unsupported_vector_type_call = - this function call uses a SIMD vector type that is not currently supported with the chosen ABI + this function call uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI .label = function called here monomorphize_abi_error_unsupported_vector_type_def = - this function definition uses a SIMD vector type that is not currently supported with the chosen ABI + this function definition uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI .label = function defined here monomorphize_couldnt_dump_mono_stats = diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index fc8d63b5888..75687a80b82 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use rustc_macros::{Diagnostic, LintDiagnostic}; +use rustc_middle::ty::Ty; use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] @@ -75,6 +76,7 @@ pub(crate) struct AbiErrorDisabledVectorTypeDef<'a> { #[label] pub span: Span, pub required_feature: &'a str, + pub ty: Ty<'a>, } #[derive(LintDiagnostic)] @@ -84,18 +86,21 @@ pub(crate) struct AbiErrorDisabledVectorTypeCall<'a> { #[label] pub span: Span, pub required_feature: &'a str, + pub ty: Ty<'a>, } #[derive(LintDiagnostic)] #[diag(monomorphize_abi_error_unsupported_vector_type_def)] -pub(crate) struct AbiErrorUnsupportedVectorTypeDef { +pub(crate) struct AbiErrorUnsupportedVectorTypeDef<'a> { #[label] pub span: Span, + pub ty: Ty<'a>, } #[derive(LintDiagnostic)] #[diag(monomorphize_abi_error_unsupported_vector_type_call)] -pub(crate) struct AbiErrorUnsupportedVectorTypeCall { +pub(crate) struct AbiErrorUnsupportedVectorTypeCall<'a> { #[label] pub span: Span, + pub ty: Ty<'a>, } diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index a0be7f11d70..36cd3e00b76 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -34,7 +34,7 @@ fn do_check_abi<'tcx>( tcx: TyCtxt<'tcx>, abi: &FnAbi<'tcx, Ty<'tcx>>, target_feature_def: DefId, - mut emit_err: impl FnMut(Option<&'static str>), + mut emit_err: impl FnMut(Ty<'tcx>, Option<&'static str>), ) { let feature_def = tcx.sess.target.features_for_correct_vector_abi(); let codegen_attrs = tcx.codegen_fn_attrs(target_feature_def); @@ -45,7 +45,7 @@ fn do_check_abi<'tcx>( let feature = match feature_def.iter().find(|(bits, _)| size.bits() <= *bits) { Some((_, feature)) => feature, None => { - emit_err(None); + emit_err(arg_abi.layout.ty, None); continue; } }; @@ -53,7 +53,7 @@ fn do_check_abi<'tcx>( if !tcx.sess.unstable_target_features.contains(&feature_sym) && !codegen_attrs.target_features.iter().any(|x| x.name == feature_sym) { - emit_err(Some(&feature)); + emit_err(arg_abi.layout.ty, Some(&feature)); } } } @@ -69,21 +69,21 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) { // function. return; }; - do_check_abi(tcx, abi, instance.def_id(), |required_feature| { + do_check_abi(tcx, abi, instance.def_id(), |ty, required_feature| { let span = tcx.def_span(instance.def_id()); if let Some(required_feature) = required_feature { tcx.emit_node_span_lint( ABI_UNSUPPORTED_VECTOR_TYPES, CRATE_HIR_ID, span, - AbiErrorDisabledVectorTypeDef { span, required_feature }, + AbiErrorDisabledVectorTypeDef { span, required_feature, ty }, ); } else { tcx.emit_node_span_lint( ABI_UNSUPPORTED_VECTOR_TYPES, CRATE_HIR_ID, span, - AbiErrorUnsupportedVectorTypeDef { span }, + AbiErrorUnsupportedVectorTypeDef { span, ty }, ); } }) @@ -123,20 +123,20 @@ fn check_call_site_abi<'tcx>( // ABI failed to compute; this will not get through codegen. return; }; - do_check_abi(tcx, callee_abi, caller.def_id(), |required_feature| { + do_check_abi(tcx, callee_abi, caller.def_id(), |ty, required_feature| { if let Some(required_feature) = required_feature { tcx.emit_node_span_lint( ABI_UNSUPPORTED_VECTOR_TYPES, CRATE_HIR_ID, span, - AbiErrorDisabledVectorTypeCall { span, required_feature }, + AbiErrorDisabledVectorTypeCall { span, required_feature, ty }, ); } else { tcx.emit_node_span_lint( ABI_UNSUPPORTED_VECTOR_TYPES, CRATE_HIR_ID, span, - AbiErrorUnsupportedVectorTypeCall { span }, + AbiErrorUnsupportedVectorTypeCall { span, ty }, ); } }); diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index d50bd18a1d7..563081c7240 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -743,9 +743,6 @@ parse_single_colon_import_path = expected `::`, found `:` .suggestion = use double colon .note = import paths are delimited using `::` -parse_single_colon_struct_type = found single colon in a struct field type path - .suggestion = write a path separator here - parse_static_with_generics = static items may not have generic parameters parse_struct_literal_body_without_path = diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 8f0e29c2769..dc03d6f9521 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -3072,14 +3072,6 @@ pub(crate) struct BadItemKind { } #[derive(Diagnostic)] -#[diag(parse_single_colon_struct_type)] -pub(crate) struct SingleColonStructType { - #[primary_span] - #[suggestion(code = "::", applicability = "maybe-incorrect", style = "verbose")] - pub span: Span, -} - -#[derive(Diagnostic)] #[diag(parse_macro_rules_missing_bang)] pub(crate) struct MacroRulesMissingBang { #[primary_span] diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 637ed2774a2..c923717ecaf 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2043,9 +2043,6 @@ impl<'a> Parser<'a> { } self.expect_field_ty_separator()?; let ty = self.parse_ty()?; - if self.token == token::Colon && self.look_ahead(1, |t| *t != token::Colon) { - self.dcx().emit_err(errors::SingleColonStructType { span: self.token.span }); - } let default = if self.token == token::Eq { self.bump(); let const_expr = self.parse_expr_anon_const()?; diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 64bcb1a5a36..8ce749ec814 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -1472,17 +1472,6 @@ impl<'a> Parser<'a> { let mut last_non_comma_dotdot_span = None; while self.token != token::CloseDelim(Delimiter::Brace) { - let attrs = match self.parse_outer_attributes() { - Ok(attrs) => attrs, - Err(err) => { - if let Some(delayed) = delayed_err { - delayed.emit(); - } - return Err(err); - } - }; - let lo = self.token.span; - // check that a comma comes after every field if !ate_comma { let err = if self.token == token::At { @@ -1585,6 +1574,17 @@ impl<'a> Parser<'a> { } } + let attrs = match self.parse_outer_attributes() { + Ok(attrs) => attrs, + Err(err) => { + if let Some(delayed) = delayed_err { + delayed.emit(); + } + return Err(err); + } + }; + let lo = self.token.span; + let field = self.collect_tokens(None, attrs, ForceCollect::No, |this, attrs| { let field = match this.parse_pat_field(lo, attrs) { Ok(field) => Ok(field), diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 576711e6677..b241aa892db 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -246,8 +246,19 @@ impl<'a> Parser<'a> { segments.push(segment); if self.is_import_coupler() || !self.eat_path_sep() { - if style == PathStyle::Expr - && self.may_recover() + let ok_for_recovery = self.may_recover() + && match style { + PathStyle::Expr => true, + PathStyle::Type if let Some((ident, _)) = self.prev_token.ident() => { + self.token == token::Colon + && ident.as_str().chars().all(|c| c.is_lowercase()) + && self.token.span.lo() == self.prev_token.span.hi() + && self + .look_ahead(1, |token| self.token.span.hi() == token.span.lo()) + } + _ => false, + }; + if ok_for_recovery && self.token == token::Colon && self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident()) { diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index fecb9735019..52aaab77ebe 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -7,7 +7,7 @@ use pulldown_cmark::{ use rustc_ast as ast; use rustc_ast::attr::AttributeExt; use rustc_ast::util::comments::beautify_doc_string; -use rustc_data_structures::fx::FxIndexMap; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_middle::ty::TyCtxt; use rustc_span::def_id::DefId; use rustc_span::{DUMMY_SP, InnerSpan, Span, Symbol, kw, sym}; @@ -422,9 +422,11 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> { ); let mut links = Vec::new(); + let mut refids = FxHashSet::default(); + while let Some(event) = event_iter.next() { match event { - Event::Start(Tag::Link { link_type, dest_url, title: _, id: _ }) + Event::Start(Tag::Link { link_type, dest_url, title: _, id }) if may_be_doc_link(link_type) => { if matches!( @@ -439,6 +441,12 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> { links.push(display_text); } } + if matches!( + link_type, + LinkType::Reference | LinkType::Shortcut | LinkType::Collapsed + ) { + refids.insert(id); + } links.push(preprocess_link(&dest_url)); } @@ -446,6 +454,12 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> { } } + for (label, refdef) in event_iter.reference_definitions().iter() { + if !refids.contains(label) { + links.push(preprocess_link(&refdef.dest)); + } + } + links } diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index e5fba8cc5a2..74b8087e077 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -8,12 +8,8 @@ session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible session_cli_feature_diagnostic_help = add `-Zcrate-attr="feature({$feature})"` to the command-line options to enable -session_crate_name_does_not_match = `--crate-name` and `#[crate_name]` are required to match, but `{$s}` != `{$name}` - session_crate_name_empty = crate name must not be empty -session_crate_name_invalid = crate names cannot start with a `-`, but `{$s}` has a leading hyphen - session_embed_source_insufficient_dwarf_version = `-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version} session_embed_source_requires_debug_info = `-Zembed-source=y` requires debug information to be enabled @@ -52,8 +48,8 @@ session_instrumentation_not_supported = {$us} instrumentation is not supported f session_int_literal_too_large = integer literal is too large .note = value exceeds limit of `{$limit}` -session_invalid_character_in_create_name = invalid character `{$character}` in crate name: `{$crate_name}` -session_invalid_character_in_create_name_help = you can either pass `--crate-name` on the command line or add `#![crate_name="…"]` to set the crate name +session_invalid_character_in_crate_name = invalid character {$character} in crate name: `{$crate_name}` + .help = you can either pass `--crate-name` on the command line or add `#![crate_name = "…"]` to set the crate name session_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float literal .label = invalid suffix `{$suffix}` diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index aa9ebdd9cea..231ca434962 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -29,7 +29,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_lint_defs::BuiltinLintDiag; use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS; use rustc_span::{Symbol, sym}; -use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, TARGETS, Target, TargetTuple}; +use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target}; use crate::Session; use crate::config::{CrateType, FmtDebug}; @@ -432,11 +432,7 @@ impl CheckCfg { panic!("unable to get all the check-cfg values buckets"); }; - for target in TARGETS - .iter() - .map(|target| Target::expect_builtin(&TargetTuple::from_tuple(target))) - .chain(iter::once(current_target.clone())) - { + for target in Target::builtins().chain(iter::once(current_target.clone())) { values_target_abi.insert(Symbol::intern(&target.options.abi)); values_target_arch.insert(Symbol::intern(&target.arch)); values_target_endian.insert(Symbol::intern(target.options.endian.as_str())); diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 75c3b2c7a85..71d8dbe44fe 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -213,21 +213,6 @@ pub(crate) struct FileWriteFail<'a> { } #[derive(Diagnostic)] -#[diag(session_crate_name_does_not_match)] -pub(crate) struct CrateNameDoesNotMatch { - #[primary_span] - pub(crate) span: Span, - pub(crate) s: Symbol, - pub(crate) name: Symbol, -} - -#[derive(Diagnostic)] -#[diag(session_crate_name_invalid)] -pub(crate) struct CrateNameInvalid<'a> { - pub(crate) s: &'a str, -} - -#[derive(Diagnostic)] #[diag(session_crate_name_empty)] pub(crate) struct CrateNameEmpty { #[primary_span] @@ -235,20 +220,14 @@ pub(crate) struct CrateNameEmpty { } #[derive(Diagnostic)] -#[diag(session_invalid_character_in_create_name)] +#[diag(session_invalid_character_in_crate_name)] pub(crate) struct InvalidCharacterInCrateName { #[primary_span] pub(crate) span: Option<Span>, pub(crate) character: char, pub(crate) crate_name: Symbol, - #[subdiagnostic] - pub(crate) crate_name_help: Option<InvalidCrateNameHelp>, -} - -#[derive(Subdiagnostic)] -pub(crate) enum InvalidCrateNameHelp { - #[help(session_invalid_character_in_create_name_help)] - AddCrateName, + #[help] + pub(crate) help: Option<()>, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index ff0419d06bf..b37a80274c0 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -2,15 +2,12 @@ use std::path::Path; -use rustc_ast::{self as ast, attr}; +use rustc_ast as ast; use rustc_span::{Span, Symbol, sym}; use crate::Session; -use crate::config::{self, CrateType, Input, OutFileName, OutputFilenames, OutputType}; -use crate::errors::{ - self, CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable, - InvalidCharacterInCrateName, InvalidCrateNameHelp, -}; +use crate::config::{self, CrateType, OutFileName, OutputFilenames, OutputType}; +use crate::errors::{self, CrateNameEmpty, FileIsNotWriteable, InvalidCharacterInCrateName}; pub fn out_filename( sess: &Session, @@ -49,69 +46,31 @@ fn is_writeable(p: &Path) -> bool { } } -pub fn find_crate_name(sess: &Session, attrs: &[ast::Attribute]) -> Symbol { - let validate = |s: Symbol, span: Option<Span>| { - validate_crate_name(sess, s, span); - s - }; - - // Look in attributes 100% of the time to make sure the attribute is marked - // as used. After doing this, however, we still prioritize a crate name from - // the command line over one found in the #[crate_name] attribute. If we - // find both we ensure that they're the same later on as well. - let attr_crate_name = - attr::find_by_name(attrs, sym::crate_name).and_then(|at| at.value_str().map(|s| (at, s))); - - if let Some(ref s) = sess.opts.crate_name { - let s = Symbol::intern(s); - if let Some((attr, name)) = attr_crate_name { - if name != s { - sess.dcx().emit_err(CrateNameDoesNotMatch { span: attr.span, s, name }); - } - } - return validate(s, None); - } +/// Validate the given crate name. +/// +/// Note that this validation is more permissive than identifier parsing. It considers +/// non-empty sequences of alphanumeric and underscore characters to be valid crate names. +/// Most notably, it accepts names starting with a numeric character like `0`! +/// +/// Furthermore, this shouldn't be taken as the canonical crate name validator. +/// Other places may use a more restrictive grammar (e.g., identifier or ASCII identifier). +pub fn validate_crate_name(sess: &Session, crate_name: Symbol, span: Option<Span>) { + let mut guar = None; - if let Some((attr, s)) = attr_crate_name { - return validate(s, Some(attr.span)); - } - if let Input::File(ref path) = sess.io.input { - if let Some(s) = path.file_stem().and_then(|s| s.to_str()) { - if s.starts_with('-') { - sess.dcx().emit_err(CrateNameInvalid { s }); - } else { - return validate(Symbol::intern(&s.replace('-', "_")), None); - } - } + if crate_name.is_empty() { + guar = Some(sess.dcx().emit_err(CrateNameEmpty { span })); } - sym::rust_out -} - -pub fn validate_crate_name(sess: &Session, s: Symbol, sp: Option<Span>) { - let mut guar = None; - { - if s.is_empty() { - guar = Some(sess.dcx().emit_err(CrateNameEmpty { span: sp })); - } - for c in s.as_str().chars() { - if c.is_alphanumeric() { - continue; - } - if c == '_' { - continue; - } - guar = Some(sess.dcx().emit_err(InvalidCharacterInCrateName { - span: sp, - character: c, - crate_name: s, - crate_name_help: if sp.is_none() { - Some(InvalidCrateNameHelp::AddCrateName) - } else { - None - }, - })); + for c in crate_name.as_str().chars() { + if c.is_alphanumeric() || c == '_' { + continue; } + guar = Some(sess.dcx().emit_err(InvalidCharacterInCrateName { + span, + character: c, + crate_name, + help: span.is_none().then_some(()), + })); } if let Some(guar) = guar { diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 794d6457cb7..f7e467b0c11 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1658,6 +1658,14 @@ macro_rules! supported_targets { Some(t) } + fn load_all_builtins() -> impl Iterator<Item = Target> { + [ + $( targets::$module::target, )+ + ] + .into_iter() + .map(|f| f()) + } + #[cfg(test)] mod tests { // Cannot put this into a separate file without duplication, make an exception. @@ -3360,6 +3368,11 @@ impl Target { } } + /// Load all built-in targets + pub fn builtins() -> impl Iterator<Item = Target> { + load_all_builtins() + } + /// Search for a JSON file specifying the given target tuple. /// /// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs index 289251e906a..80bfa358243 100644 --- a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -5,7 +5,7 @@ use crate::spec::{ pub(crate) fn target() -> Target { Target { arch: "nvptx64".into(), - data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".into(), + data_layout: "e-p6:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64".into(), llvm_target: "nvptx64-nvidia-cuda".into(), metadata: crate::spec::TargetMetadata { description: Some("--emit=asm generates PTX code that runs on NVIDIA GPUs".into()), diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index 617bc87a9d2..a0df74835bc 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -187,7 +187,10 @@ fn predicates_reference_self( fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> { tcx.associated_items(trait_def_id) .in_definition_order() + // We're only looking at associated type bounds .filter(|item| item.kind == ty::AssocKind::Type) + // Ignore GATs with `Self: Sized` + .filter(|item| !tcx.generics_require_sized_self(item.def_id)) .flat_map(|item| tcx.explicit_item_bounds(item.def_id).iter_identity_copied()) .filter_map(|(clause, sp)| { // Item bounds *can* have self projections, since they never get diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 1ea7b731461..4b124b5a3b3 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1053,7 +1053,6 @@ impl<T: ?Sized> Box<T> { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[stable(feature = "box_raw", since = "1.4.0")] #[inline] #[must_use = "call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`"] @@ -1108,7 +1107,6 @@ impl<T: ?Sized> Box<T> { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] #[inline] #[must_use = "call `drop(Box::from_non_null(ptr))` if you intend to drop the `Box`"] @@ -1165,7 +1163,6 @@ impl<T: ?Sized, A: Allocator> Box<T, A> { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "allocator_api", issue = "32838")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] #[inline] @@ -1219,7 +1216,6 @@ impl<T: ?Sized, A: Allocator> Box<T, A> { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "allocator_api", issue = "32838")] // #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] diff --git a/library/core/src/alloc/global.rs b/library/core/src/alloc/global.rs index 8f48af24557..5bf6f143b4f 100644 --- a/library/core/src/alloc/global.rs +++ b/library/core/src/alloc/global.rs @@ -70,7 +70,7 @@ use crate::{cmp, ptr}; /// { /// return null_mut(); /// }; -/// self.arena.get().cast::<u8>().add(allocated) +/// unsafe { self.arena.get().cast::<u8>().add(allocated) } /// } /// unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} /// } diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 520b9941ae4..76afb3b8e20 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -52,7 +52,7 @@ use crate::{intrinsics, ub_checks}; /// // Safety: `divisor` can't be zero because of `prepare_inputs`, /// // but the compiler does not know about this. We *promise* /// // that we always call `prepare_inputs`. -/// std::hint::unreachable_unchecked() +/// unsafe { std::hint::unreachable_unchecked() } /// } /// // The compiler would normally introduce a check here that prevents /// // a division by zero. However, if `divisor` was zero, the branch diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 6c9c6d0edc2..99c42f3626e 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -1703,12 +1703,12 @@ pub const fn forget<T: ?Sized>(_: T) { /// ``` /// struct R<'a>(&'a i32); /// unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> { -/// std::mem::transmute::<R<'b>, R<'static>>(r) +/// unsafe { std::mem::transmute::<R<'b>, R<'static>>(r) } /// } /// /// unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>) /// -> &'b mut R<'c> { -/// std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) +/// unsafe { std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) } /// } /// ``` /// @@ -4498,11 +4498,11 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us /// /// // SAFETY: Our precondition ensures the source is aligned and valid, /// // and `Vec::with_capacity` ensures that we have usable space to write them. -/// ptr::copy(ptr, dst.as_mut_ptr(), elts); +/// unsafe { ptr::copy(ptr, dst.as_mut_ptr(), elts); } /// /// // SAFETY: We created it with this much capacity earlier, /// // and the previous `copy` has initialized these elements. -/// dst.set_len(elts); +/// unsafe { dst.set_len(elts); } /// dst /// } /// ``` diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 2c7f1d86341..edc39f8f28c 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -98,7 +98,7 @@ use crate::{fmt, intrinsics, ptr, slice}; /// /// unsafe fn make_vec(out: *mut Vec<i32>) { /// // `write` does not drop the old contents, which is important. -/// out.write(vec![1, 2, 3]); +/// unsafe { out.write(vec![1, 2, 3]); } /// } /// /// let mut v = MaybeUninit::uninit(); @@ -844,7 +844,7 @@ impl<T> MaybeUninit<T> { /// # #![allow(unexpected_cfgs)] /// use std::mem::MaybeUninit; /// - /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { *buf = [0; 1024] } + /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { unsafe { *buf = [0; 1024] } } /// # #[cfg(FALSE)] /// extern "C" { /// /// Initializes *all* the bytes of the input buffer. diff --git a/library/core/src/mem/transmutability.rs b/library/core/src/mem/transmutability.rs index 6a4f84c849c..7b920d7a777 100644 --- a/library/core/src/mem/transmutability.rs +++ b/library/core/src/mem/transmutability.rs @@ -32,7 +32,7 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy}; /// src: ManuallyDrop::new(src), /// }; /// -/// let dst = transmute.dst; +/// let dst = unsafe { transmute.dst }; /// /// ManuallyDrop::into_inner(dst) /// } diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 0c6eaf60d04..974946a7818 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -724,13 +724,13 @@ impl<T: ?Sized> *const T { /// that their safety preconditions are met: /// ```rust /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { + /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { unsafe { /// ptr.sub_ptr(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index d1b0104c0fa..94ebd0d2522 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -896,13 +896,13 @@ impl<T: ?Sized> *mut T { /// that their safety preconditions are met: /// ```rust /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { + /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { unsafe { /// ptr.sub_ptr(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index d93069d384e..f4ac00062d7 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -857,13 +857,13 @@ impl<T: ?Sized> NonNull<T> { /// that their safety preconditions are met: /// ```rust /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool { + /// # unsafe fn blah(ptr: std::ptr::NonNull<u32>, origin: std::ptr::NonNull<u32>, count: usize) -> bool { unsafe { /// ptr.sub_ptr(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 4c51ca0a5e4..3f57b04753a 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -40,17 +40,14 @@ impl RawWaker { /// of the `vtable` as the first parameter. /// /// It is important to consider that the `data` pointer must point to a - /// thread safe type such as an `[Arc]<T: Send + Sync>` + /// thread safe type such as an `Arc<T: Send + Sync>` /// when used to construct a [`Waker`]. This restriction is lifted when /// constructing a [`LocalWaker`], which allows using types that do not implement - /// <code>[Send] + [Sync]</code> like `[Rc]<T>`. + /// <code>[Send] + [Sync]</code> like `Rc<T>`. /// /// The `vtable` customizes the behavior of a `Waker` which gets created /// from a `RawWaker`. For each operation on the `Waker`, the associated /// function in the `vtable` of the underlying `RawWaker` will be called. - /// - /// [`Arc`]: std::sync::Arc - /// [`Rc`]: std::rc::Rc #[inline] #[rustc_promotable] #[stable(feature = "futures_api", since = "1.36.0")] diff --git a/library/panic_abort/src/android.rs b/library/panic_abort/src/android.rs index 47c22834597..1cc2077d14b 100644 --- a/library/panic_abort/src/android.rs +++ b/library/panic_abort/src/android.rs @@ -16,9 +16,10 @@ type SetAbortMessageType = unsafe extern "C" fn(*const libc::c_char) -> (); // Weakly resolve the symbol for android_set_abort_message. This function is only available // for API >= 21. pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) { - let func_addr = + let func_addr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, ANDROID_SET_ABORT_MESSAGE.as_ptr() as *const libc::c_char) - as usize; + as usize + }; if func_addr == 0 { return; } @@ -37,13 +38,14 @@ pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) { // Allocate a new buffer to append the null byte. let size = msg.len() + 1usize; - let buf = libc::malloc(size) as *mut libc::c_char; + let buf = unsafe { libc::malloc(size) as *mut libc::c_char }; if buf.is_null() { return; // allocation failure } - copy_nonoverlapping(msg.as_ptr(), buf as *mut u8, msg.len()); - buf.add(msg.len()).write(0); - - let func = transmute::<usize, SetAbortMessageType>(func_addr); - func(buf); + unsafe { + copy_nonoverlapping(msg.as_ptr(), buf as *mut u8, msg.len()); + buf.add(msg.len()).write(0); + let func = transmute::<usize, SetAbortMessageType>(func_addr); + func(buf); + } } diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index 7718d68aef8..b2ad0f4ac3d 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -15,6 +15,7 @@ #![feature(staged_api)] #![feature(rustc_attrs)] #![allow(internal_features)] +#![deny(unsafe_op_in_unsafe_fn)] #[cfg(target_os = "android")] mod android; @@ -36,16 +37,22 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { // Android has the ability to attach a message as part of the abort. #[cfg(target_os = "android")] - android::android_set_abort_message(_payload); + unsafe { + android::android_set_abort_message(_payload); + } #[cfg(target_os = "zkvm")] - zkvm::zkvm_set_abort_message(_payload); + unsafe { + zkvm::zkvm_set_abort_message(_payload); + } - abort(); + unsafe { + abort(); + } cfg_if::cfg_if! { if #[cfg(any(unix, target_os = "solid_asp3"))] { unsafe fn abort() -> ! { - libc::abort(); + unsafe { libc::abort(); } } } else if #[cfg(any(target_os = "hermit", all(target_vendor = "fortanix", target_env = "sgx"), @@ -57,7 +64,7 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { unsafe extern "C" { pub fn __rust_abort() -> !; } - __rust_abort(); + unsafe { __rust_abort(); } } } else if #[cfg(all(windows, not(miri)))] { // On Windows, use the processor-specific __fastfail mechanism. In Windows 8 @@ -75,11 +82,17 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { const FAST_FAIL_FATAL_APP_EXIT: usize = 7; cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { - core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else if #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] { - core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else { core::intrinsics::abort(); } @@ -93,7 +106,7 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { } unsafe fn abort() -> ! { - teeos::TEE_Panic(1); + unsafe { teeos::TEE_Panic(1); } } } else { unsafe fn abort() -> ! { diff --git a/library/panic_abort/src/zkvm.rs b/library/panic_abort/src/zkvm.rs index 11150eafd0b..7b1e89c6a8e 100644 --- a/library/panic_abort/src/zkvm.rs +++ b/library/panic_abort/src/zkvm.rs @@ -20,5 +20,7 @@ pub(crate) unsafe fn zkvm_set_abort_message(payload: &mut dyn PanicPayload) { fn sys_panic(msg_ptr: *const u8, len: usize) -> !; } - sys_panic(msg.as_ptr(), msg.len()); + unsafe { + sys_panic(msg.as_ptr(), msg.len()); + } } diff --git a/library/panic_unwind/src/emcc.rs b/library/panic_unwind/src/emcc.rs index 4140b004ad1..1569c26c9de 100644 --- a/library/panic_unwind/src/emcc.rs +++ b/library/panic_unwind/src/emcc.rs @@ -71,42 +71,46 @@ pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { ptr: *mut u8, is_rust_panic: bool, } - let catch_data = &*(ptr as *mut CatchData); + unsafe { + let catch_data = &*(ptr as *mut CatchData); - let adjusted_ptr = __cxa_begin_catch(catch_data.ptr as *mut libc::c_void) as *mut Exception; - if !catch_data.is_rust_panic { - super::__rust_foreign_exception(); - } + let adjusted_ptr = __cxa_begin_catch(catch_data.ptr as *mut libc::c_void) as *mut Exception; + if !catch_data.is_rust_panic { + super::__rust_foreign_exception(); + } - let canary = (&raw const (*adjusted_ptr).canary).read(); - if !ptr::eq(canary, &EXCEPTION_TYPE_INFO) { - super::__rust_foreign_exception(); - } + let canary = (&raw const (*adjusted_ptr).canary).read(); + if !ptr::eq(canary, &EXCEPTION_TYPE_INFO) { + super::__rust_foreign_exception(); + } - let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed); - if was_caught { - // Since cleanup() isn't allowed to panic, we just abort instead. - intrinsics::abort(); + let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed); + if was_caught { + // Since cleanup() isn't allowed to panic, we just abort instead. + intrinsics::abort(); + } + let out = (*adjusted_ptr).data.take().unwrap(); + __cxa_end_catch(); + out } - let out = (*adjusted_ptr).data.take().unwrap(); - __cxa_end_catch(); - out } pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { - let exception = __cxa_allocate_exception(mem::size_of::<Exception>()) as *mut Exception; - if exception.is_null() { - return uw::_URC_FATAL_PHASE1_ERROR as u32; + unsafe { + let exception = __cxa_allocate_exception(mem::size_of::<Exception>()) as *mut Exception; + if exception.is_null() { + return uw::_URC_FATAL_PHASE1_ERROR as u32; + } + ptr::write( + exception, + Exception { + canary: &EXCEPTION_TYPE_INFO, + caught: AtomicBool::new(false), + data: Some(data), + }, + ); + __cxa_throw(exception as *mut _, &EXCEPTION_TYPE_INFO, exception_cleanup); } - ptr::write( - exception, - Exception { - canary: &EXCEPTION_TYPE_INFO, - caught: AtomicBool::new(false), - data: Some(data), - }, - ); - __cxa_throw(exception as *mut _, &EXCEPTION_TYPE_INFO, exception_cleanup); } extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void { diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index e478f6c5fc8..5f95870069d 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -69,7 +69,7 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { cause: data, }); let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; - return uw::_Unwind_RaiseException(exception_param) as u32; + return unsafe { uw::_Unwind_RaiseException(exception_param) as u32 }; extern "C" fn exception_cleanup( _unwind_code: uw::_Unwind_Reason_Code, @@ -83,26 +83,28 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { } pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { - let exception = ptr as *mut uw::_Unwind_Exception; - if (*exception).exception_class != RUST_EXCEPTION_CLASS { - uw::_Unwind_DeleteException(exception); - super::__rust_foreign_exception(); - } + unsafe { + let exception = ptr as *mut uw::_Unwind_Exception; + if (*exception).exception_class != RUST_EXCEPTION_CLASS { + uw::_Unwind_DeleteException(exception); + super::__rust_foreign_exception(); + } - let exception = exception.cast::<Exception>(); - // Just access the canary field, avoid accessing the entire `Exception` as - // it can be a foreign Rust exception. - let canary = (&raw const (*exception).canary).read(); - if !ptr::eq(canary, &CANARY) { - // A foreign Rust exception, treat it slightly differently from other - // foreign exceptions, because call into `_Unwind_DeleteException` will - // call into `__rust_drop_panic` which produces a confusing - // "Rust panic must be rethrown" message. - super::__rust_foreign_exception(); - } + let exception = exception.cast::<Exception>(); + // Just access the canary field, avoid accessing the entire `Exception` as + // it can be a foreign Rust exception. + let canary = (&raw const (*exception).canary).read(); + if !ptr::eq(canary, &CANARY) { + // A foreign Rust exception, treat it slightly differently from other + // foreign exceptions, because call into `_Unwind_DeleteException` will + // call into `__rust_drop_panic` which produces a confusing + // "Rust panic must be rethrown" message. + super::__rust_foreign_exception(); + } - let exception = Box::from_raw(exception as *mut Exception); - exception.cause + let exception = Box::from_raw(exception as *mut Exception); + exception.cause + } } // Rust's exception class identifier. This is used by personality routines to diff --git a/library/panic_unwind/src/hermit.rs b/library/panic_unwind/src/hermit.rs index 9719c133415..8f4562d07fc 100644 --- a/library/panic_unwind/src/hermit.rs +++ b/library/panic_unwind/src/hermit.rs @@ -9,12 +9,16 @@ pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> { unsafe extern "C" { fn __rust_abort() -> !; } - __rust_abort(); + unsafe { + __rust_abort(); + } } pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 { unsafe extern "C" { fn __rust_abort() -> !; } - __rust_abort(); + unsafe { + __rust_abort(); + } } diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index 45e2a466b4d..1111c2009b3 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -27,6 +27,7 @@ #![allow(internal_features)] #![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))] #![warn(unreachable_pub)] +#![deny(unsafe_op_in_unsafe_fn)] use alloc::boxed::Box; use core::any::Any; @@ -87,14 +88,16 @@ unsafe extern "C" { #[rustc_std_internal_symbol] #[allow(improper_ctypes_definitions)] pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static) { - Box::into_raw(imp::cleanup(payload)) + unsafe { Box::into_raw(imp::cleanup(payload)) } } // Entry point for raising an exception, just delegates to the platform-specific // implementation. #[rustc_std_internal_symbol] pub unsafe fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32 { - let payload = Box::from_raw(payload.take_box()); + unsafe { + let payload = Box::from_raw(payload.take_box()); - imp::panic(payload) + imp::panic(payload) + } } diff --git a/library/panic_unwind/src/miri.rs b/library/panic_unwind/src/miri.rs index ec48b1105ab..d6d4af8218d 100644 --- a/library/panic_unwind/src/miri.rs +++ b/library/panic_unwind/src/miri.rs @@ -16,11 +16,11 @@ pub(crate) unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 { // The payload we pass to `miri_start_unwind` will be exactly the argument we get // in `cleanup` below. So we just box it up once, to get something pointer-sized. let payload_box: Payload = Box::new(payload); - miri_start_unwind(Box::into_raw(payload_box) as *mut u8) + unsafe { miri_start_unwind(Box::into_raw(payload_box) as *mut u8) } } pub(crate) unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> { // Recover the underlying `Box`. - let payload_box: Payload = Box::from_raw(payload_box as *mut _); + let payload_box: Payload = unsafe { Box::from_raw(payload_box as *mut _) }; *payload_box } diff --git a/library/panic_unwind/src/seh.rs b/library/panic_unwind/src/seh.rs index c8dfddf821e..3a95b940221 100644 --- a/library/panic_unwind/src/seh.rs +++ b/library/panic_unwind/src/seh.rs @@ -268,9 +268,11 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { macro_rules! define_cleanup { ($abi:tt $abi2:tt) => { unsafe extern $abi fn exception_cleanup(e: *mut Exception) { - if let Exception { data: Some(b), .. } = e.read() { - drop(b); - super::__rust_drop_panic(); + unsafe { + if let Exception { data: Some(b), .. } = e.read() { + drop(b); + super::__rust_drop_panic(); + } } } unsafe extern $abi2 fn exception_copy( @@ -322,45 +324,51 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { // // In any case, we basically need to do something like this until we can // express more operations in statics (and we may never be able to). - atomic_store_seqcst( - (&raw mut THROW_INFO.pmfnUnwind).cast(), - ptr_t::new(exception_cleanup as *mut u8).raw(), - ); - atomic_store_seqcst( - (&raw mut THROW_INFO.pCatchableTypeArray).cast(), - ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(), - ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE.pType).cast(), - ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE.copyFunction).cast(), - ptr_t::new(exception_copy as *mut u8).raw(), - ); + unsafe { + atomic_store_seqcst( + (&raw mut THROW_INFO.pmfnUnwind).cast(), + ptr_t::new(exception_cleanup as *mut u8).raw(), + ); + atomic_store_seqcst( + (&raw mut THROW_INFO.pCatchableTypeArray).cast(), + ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(), + ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE.pType).cast(), + ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE.copyFunction).cast(), + ptr_t::new(exception_copy as *mut u8).raw(), + ); + } unsafe extern "system-unwind" { fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8) -> !; } - _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); + unsafe { + _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); + } } pub(crate) unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> { - // A null payload here means that we got here from the catch (...) of - // __rust_try. This happens when a non-Rust foreign exception is caught. - if payload.is_null() { - super::__rust_foreign_exception(); - } - let exception = payload as *mut Exception; - let canary = (&raw const (*exception).canary).read(); - if !core::ptr::eq(canary, &raw const TYPE_DESCRIPTOR) { - // A foreign Rust exception. - super::__rust_foreign_exception(); + unsafe { + // A null payload here means that we got here from the catch (...) of + // __rust_try. This happens when a non-Rust foreign exception is caught. + if payload.is_null() { + super::__rust_foreign_exception(); + } + let exception = payload as *mut Exception; + let canary = (&raw const (*exception).canary).read(); + if !core::ptr::eq(canary, &raw const TYPE_DESCRIPTOR) { + // A foreign Rust exception. + super::__rust_foreign_exception(); + } + (*exception).data.take().unwrap() } - (*exception).data.take().unwrap() } diff --git a/library/proc_macro/src/bridge/closure.rs b/library/proc_macro/src/bridge/closure.rs index 524fdf53d6b..e0e688434dc 100644 --- a/library/proc_macro/src/bridge/closure.rs +++ b/library/proc_macro/src/bridge/closure.rs @@ -19,7 +19,7 @@ struct Env; impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> { fn from(f: &'a mut F) -> Self { unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: *mut Env, arg: A) -> R { - (*(env as *mut _ as *mut F))(arg) + unsafe { (*(env as *mut _ as *mut F))(arg) } } Closure { call: call::<A, R, F>, env: f as *mut _ as *mut Env, _marker: PhantomData } } diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 6611ce30a1b..d9141eab591 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -33,6 +33,7 @@ #![deny(ffi_unwind_calls)] #![warn(rustdoc::unescaped_backticks)] #![warn(unreachable_pub)] +#![deny(unsafe_op_in_unsafe_fn)] #[unstable(feature = "proc_macro_internals", issue = "27812")] #[doc(hidden)] diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 3936ed057e6..99d105a2454 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -20,11 +20,11 @@ //! //! unsafe impl GlobalAlloc for MyAllocator { //! unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -//! System.alloc(layout) +//! unsafe { System.alloc(layout) } //! } //! //! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -//! System.dealloc(ptr, layout) +//! unsafe { System.dealloc(ptr, layout) } //! } //! } //! @@ -102,7 +102,7 @@ pub use alloc_crate::alloc::*; /// /// unsafe impl GlobalAlloc for Counter { /// unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -/// let ret = System.alloc(layout); +/// let ret = unsafe { System.alloc(layout) }; /// if !ret.is_null() { /// ALLOCATED.fetch_add(layout.size(), Relaxed); /// } @@ -110,7 +110,7 @@ pub use alloc_crate::alloc::*; /// } /// /// unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -/// System.dealloc(ptr, layout); +/// unsafe { System.dealloc(ptr, layout); } /// ALLOCATED.fetch_sub(layout.size(), Relaxed); /// } /// } diff --git a/library/std/src/sys/pal/teeos/thread.rs b/library/std/src/sys/pal/teeos/thread.rs index c779c5f3ed8..e3b4908f858 100644 --- a/library/std/src/sys/pal/teeos/thread.rs +++ b/library/std/src/sys/pal/teeos/thread.rs @@ -56,7 +56,7 @@ impl Thread { } }; - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = unsafe { libc::pthread_create(&mut native, &attr, thread_start, p as *mut _) }; // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. diff --git a/library/std/src/sys/pal/windows/stack_overflow_uwp.rs b/library/std/src/sys/pal/windows/stack_overflow_uwp.rs index 9e9b3efaf1b..6f1ea12fc1e 100644 --- a/library/std/src/sys/pal/windows/stack_overflow_uwp.rs +++ b/library/std/src/sys/pal/windows/stack_overflow_uwp.rs @@ -1,4 +1,4 @@ #![cfg_attr(test, allow(dead_code))] -pub unsafe fn reserve_stack() {} -pub unsafe fn init() {} +pub fn reserve_stack() {} +pub fn init() {} diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index 2650b273a4d..761f9248446 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -9,6 +9,7 @@ )] #![allow(internal_features)] #![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))] +#![deny(unsafe_op_in_unsafe_fn)] // Force libc to be included even if unused. This is required by many platforms. #[cfg(not(all(windows, target_env = "msvc")))] diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 62165f8a200..1a640bbde71 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -218,36 +218,38 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word { let mut val: _Unwind_Word = core::ptr::null(); - _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - (&raw mut val) as *mut c_void); + unsafe { _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, + (&raw mut val) as *mut c_void); } val } pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { let mut value = value; - _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - (&raw mut value) as *mut c_void); + unsafe { _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, + (&raw mut value) as *mut c_void); } } pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word { - let val = _Unwind_GetGR(ctx, UNWIND_IP_REG); + let val = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG) }; val.map_addr(|v| v & !1) } pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word) { // Propagate thumb bit to instruction pointer - let thumb_state = _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1; + let thumb_state = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1 }; let value = value.map_addr(|v| v | thumb_state); - _Unwind_SetGR(ctx, UNWIND_IP_REG, value); + unsafe { _Unwind_SetGR(ctx, UNWIND_IP_REG, value); } } pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ip_before_insn: *mut c_int) -> _Unwind_Word { - *ip_before_insn = 0; - _Unwind_GetIP(ctx) + unsafe { + *ip_before_insn = 0; + _Unwind_GetIP(ctx) + } } // This function also doesn't exist on Android or ARM/Linux, so make it a no-op diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 45797c1276c..1e84a7deff1 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -29,6 +29,7 @@ use crate::core::config::TargetSelection; use crate::utils::exec::{BootstrapCommand, command}; use crate::{Build, CLang, GitRepo}; +/// Finds archiver tool for the given target if possible. /// FIXME(onur-ozkan): This logic should be replaced by calling into the `cc` crate. fn cc2ar(cc: &Path, target: TargetSelection, default_ar: PathBuf) -> Option<PathBuf> { if let Some(ar) = env::var_os(format!("AR_{}", target.triple.replace('-', "_"))) { @@ -58,6 +59,7 @@ fn cc2ar(cc: &Path, target: TargetSelection, default_ar: PathBuf) -> Option<Path } } +/// Creates and configures a new [`cc::Build`] instance for the given target. fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { let mut cfg = cc::Build::new(); cfg.cargo_metadata(false) @@ -84,6 +86,12 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build { cfg } +/// Probes for C and C++ compilers and configures the corresponding entries in the [`Build`] +/// structure. +/// +/// This function determines which targets need a C compiler (and, if needed, a C++ compiler) +/// by combining the primary build target, host targets, and any additional targets. For +/// each target, it calls [`find_target`] to configure the necessary compiler tools. pub fn find(build: &Build) { let targets: HashSet<_> = match build.config.cmd { // We don't need to check cross targets for these commands. @@ -112,6 +120,11 @@ pub fn find(build: &Build) { } } +/// Probes and configures the C and C++ compilers for a single target. +/// +/// This function uses both user-specified configuration (from `config.toml`) and auto-detection +/// logic to determine the correct C/C++ compilers for the target. It also determines the appropriate +/// archiver (`ar`) and sets up additional compilation flags (both handled and unhandled). pub fn find_target(build: &Build, target: TargetSelection) { let mut cfg = new_cc_build(build, target); let config = build.config.target_config.get(&target); @@ -172,6 +185,8 @@ pub fn find_target(build: &Build, target: TargetSelection) { } } +/// Determines the default compiler for a given target and language when not explicitly +/// configured in `config.toml`. fn default_compiler( cfg: &mut cc::Build, compiler: Language, @@ -248,6 +263,12 @@ fn default_compiler( } } +/// Constructs the path to the Android NDK compiler for the given target triple and language. +/// +/// This helper function transform the target triple by converting certain architecture names +/// (for example, translating "arm" to "arm7a"), appends the minimum API level (hardcoded as "21" +/// for NDK r26d), and then constructs the full path based on the provided NDK directory and host +/// platform. pub(crate) fn ndk_compiler(compiler: Language, triple: &str, ndk: &Path) -> PathBuf { let mut triple_iter = triple.split('-'); let triple_translated = if let Some(arch) = triple_iter.next() { @@ -277,7 +298,11 @@ pub(crate) fn ndk_compiler(compiler: Language, triple: &str, ndk: &Path) -> Path ndk.join("toolchains").join("llvm").join("prebuilt").join(host_tag).join("bin").join(compiler) } -/// The target programming language for a native compiler. +/// Representing the target programming language for a native compiler. +/// +/// This enum is used to indicate whether a particular compiler is intended for C or C++. +/// It also provides helper methods for obtaining the standard executable names for GCC and +/// clang-based compilers. #[derive(PartialEq)] pub(crate) enum Language { /// The compiler is targeting C. @@ -287,7 +312,7 @@ pub(crate) enum Language { } impl Language { - /// Obtains the name of a compiler in the GCC collection. + /// Returns the executable name for a GCC compiler corresponding to this language. fn gcc(self) -> &'static str { match self { Language::C => "gcc", @@ -295,7 +320,7 @@ impl Language { } } - /// Obtains the name of a compiler in the clang suite. + /// Returns the executable name for a clang-based compiler corresponding to this language. fn clang(self) -> &'static str { match self { Language::C => "clang", @@ -303,3 +328,6 @@ impl Language { } } } + +#[cfg(test)] +mod tests; diff --git a/src/bootstrap/src/utils/cc_detect/tests.rs b/src/bootstrap/src/utils/cc_detect/tests.rs new file mode 100644 index 00000000000..006dfe7e5d7 --- /dev/null +++ b/src/bootstrap/src/utils/cc_detect/tests.rs @@ -0,0 +1,254 @@ +use std::path::{Path, PathBuf}; +use std::{env, iter}; + +use super::*; +use crate::core::config::{Target, TargetSelection}; +use crate::{Build, Config, Flags}; + +#[test] +fn test_cc2ar_env_specific() { + let triple = "x86_64-unknown-linux-gnu"; + let key = "AR_x86_64_unknown_linux_gnu"; + env::set_var(key, "custom-ar"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + env::remove_var(key); + assert_eq!(result, Some(PathBuf::from("custom-ar"))); +} + +#[test] +fn test_cc2ar_musl() { + let triple = "x86_64-unknown-linux-musl"; + env::remove_var("AR_x86_64_unknown_linux_musl"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + assert_eq!(result, Some(PathBuf::from("ar"))); +} + +#[test] +fn test_cc2ar_openbsd() { + let triple = "x86_64-unknown-openbsd"; + env::remove_var("AR_x86_64_unknown_openbsd"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/cc"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + assert_eq!(result, Some(PathBuf::from("ar"))); +} + +#[test] +fn test_cc2ar_vxworks() { + let triple = "armv7-wrs-vxworks"; + env::remove_var("AR_armv7_wrs_vxworks"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + assert_eq!(result, Some(PathBuf::from("wr-ar"))); +} + +#[test] +fn test_cc2ar_nto_i586() { + let triple = "i586-unknown-nto-something"; + env::remove_var("AR_i586_unknown_nto_something"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + assert_eq!(result, Some(PathBuf::from("ntox86-ar"))); +} + +#[test] +fn test_cc2ar_nto_aarch64() { + let triple = "aarch64-unknown-nto-something"; + env::remove_var("AR_aarch64_unknown_nto_something"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + assert_eq!(result, Some(PathBuf::from("ntoaarch64-ar"))); +} + +#[test] +fn test_cc2ar_nto_x86_64() { + let triple = "x86_64-unknown-nto-something"; + env::remove_var("AR_x86_64_unknown_nto_something"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let result = cc2ar(cc, target, default_ar); + assert_eq!(result, Some(PathBuf::from("ntox86_64-ar"))); +} + +#[test] +#[should_panic(expected = "Unknown architecture, cannot determine archiver for Neutrino QNX")] +fn test_cc2ar_nto_unknown() { + let triple = "powerpc-unknown-nto-something"; + env::remove_var("AR_powerpc_unknown_nto_something"); + env::remove_var("AR"); + let target = TargetSelection::from_user(triple); + let cc = Path::new("/usr/bin/clang"); + let default_ar = PathBuf::from("default-ar"); + let _ = cc2ar(cc, target, default_ar); +} + +#[test] +fn test_ndk_compiler_c() { + let ndk_path = PathBuf::from("/ndk"); + let target_triple = "arm-unknown-linux-android"; + let expected_triple_translated = "armv7a-unknown-linux-android"; + let expected_compiler = format!("{}21-{}", expected_triple_translated, Language::C.clang()); + let host_tag = if cfg!(target_os = "macos") { + "darwin-x86_64" + } else if cfg!(target_os = "windows") { + "windows-x86_64" + } else { + "linux-x86_64" + }; + let expected_path = ndk_path + .join("toolchains") + .join("llvm") + .join("prebuilt") + .join(host_tag) + .join("bin") + .join(&expected_compiler); + let result = ndk_compiler(Language::C, target_triple, &ndk_path); + assert_eq!(result, expected_path); +} + +#[test] +fn test_ndk_compiler_cpp() { + let ndk_path = PathBuf::from("/ndk"); + let target_triple = "arm-unknown-linux-android"; + let expected_triple_translated = "armv7a-unknown-linux-android"; + let expected_compiler = + format!("{}21-{}", expected_triple_translated, Language::CPlusPlus.clang()); + let host_tag = if cfg!(target_os = "macos") { + "darwin-x86_64" + } else if cfg!(target_os = "windows") { + "windows-x86_64" + } else { + "linux-x86_64" + }; + let expected_path = ndk_path + .join("toolchains") + .join("llvm") + .join("prebuilt") + .join(host_tag) + .join("bin") + .join(&expected_compiler); + let result = ndk_compiler(Language::CPlusPlus, target_triple, &ndk_path); + assert_eq!(result, expected_path); +} + +#[test] +fn test_language_gcc() { + assert_eq!(Language::C.gcc(), "gcc"); + assert_eq!(Language::CPlusPlus.gcc(), "g++"); +} + +#[test] +fn test_language_clang() { + assert_eq!(Language::C.clang(), "clang"); + assert_eq!(Language::CPlusPlus.clang(), "clang++"); +} + +#[test] +fn test_new_cc_build() { + let build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) }); + let target = TargetSelection::from_user("x86_64-unknown-linux-gnu"); + let cfg = new_cc_build(&build, target.clone()); + let compiler = cfg.get_compiler(); + assert!(!compiler.path().to_str().unwrap().is_empty(), "Compiler path should not be empty"); +} + +#[test] +fn test_default_compiler_wasi() { + let build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) }); + let target = TargetSelection::from_user("wasm32-wasi"); + let wasi_sdk = PathBuf::from("/wasi-sdk"); + env::set_var("WASI_SDK_PATH", &wasi_sdk); + let mut cfg = cc::Build::new(); + if let Some(result) = default_compiler(&mut cfg, Language::C, target.clone(), &build) { + let expected = { + let compiler = format!("{}-clang", target.triple); + wasi_sdk.join("bin").join(compiler) + }; + assert_eq!(result, expected); + } else { + panic!( + "default_compiler should return a compiler path for wasi target when WASI_SDK_PATH is set" + ); + } + env::remove_var("WASI_SDK_PATH"); +} + +#[test] +fn test_default_compiler_fallback() { + let build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) }); + let target = TargetSelection::from_user("x86_64-unknown-linux-gnu"); + let mut cfg = cc::Build::new(); + let result = default_compiler(&mut cfg, Language::C, target, &build); + assert!(result.is_none(), "default_compiler should return None for generic targets"); +} + +#[test] +fn test_find_target_with_config() { + let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) }); + let target = TargetSelection::from_user("x86_64-unknown-linux-gnu"); + let mut target_config = Target::default(); + target_config.cc = Some(PathBuf::from("dummy-cc")); + target_config.cxx = Some(PathBuf::from("dummy-cxx")); + target_config.ar = Some(PathBuf::from("dummy-ar")); + target_config.ranlib = Some(PathBuf::from("dummy-ranlib")); + build.config.target_config.insert(target.clone(), target_config); + find_target(&build, target.clone()); + let binding = build.cc.borrow(); + let cc_tool = binding.get(&target).unwrap(); + assert_eq!(cc_tool.path(), &PathBuf::from("dummy-cc")); + let binding = build.cxx.borrow(); + let cxx_tool = binding.get(&target).unwrap(); + assert_eq!(cxx_tool.path(), &PathBuf::from("dummy-cxx")); + let binding = build.ar.borrow(); + let ar = binding.get(&target).unwrap(); + assert_eq!(ar, &PathBuf::from("dummy-ar")); + let binding = build.ranlib.borrow(); + let ranlib = binding.get(&target).unwrap(); + assert_eq!(ranlib, &PathBuf::from("dummy-ranlib")); +} + +#[test] +fn test_find_target_without_config() { + let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) }); + let target = TargetSelection::from_user("x86_64-unknown-linux-gnu"); + build.config.target_config.clear(); + find_target(&build, target.clone()); + assert!(build.cc.borrow().contains_key(&target)); + if !target.triple.contains("vxworks") { + assert!(build.cxx.borrow().contains_key(&target)); + } + assert!(build.ar.borrow().contains_key(&target)); +} + +#[test] +fn test_find() { + let mut build = Build::new(Config { ..Config::parse(Flags::parse(&["check".to_owned()])) }); + let target1 = TargetSelection::from_user("x86_64-unknown-linux-gnu"); + let target2 = TargetSelection::from_user("arm-linux-androideabi"); + build.targets.push(target1.clone()); + build.hosts.push(target2.clone()); + find(&build); + for t in build.hosts.iter().chain(build.targets.iter()).chain(iter::once(&build.build)) { + assert!(build.cc.borrow().contains_key(t), "CC not set for target {}", t.triple); + } +} diff --git a/src/ci/scripts/upload-artifacts.sh b/src/ci/scripts/upload-artifacts.sh index 0bc91f6ba71..975b4c52726 100755 --- a/src/ci/scripts/upload-artifacts.sh +++ b/src/ci/scripts/upload-artifacts.sh @@ -52,10 +52,15 @@ access_url="https://ci-artifacts.rust-lang.org/${deploy_dir}/$(ciCommit)" # to make them easily accessible. if [ -n "${GITHUB_STEP_SUMMARY}" ] then - echo "# CI artifacts" >> "${GITHUB_STEP_SUMMARY}" + archives=($(find "${upload_dir}" -maxdepth 1 -name "*.xz")) - for filename in "${upload_dir}"/*.xz; do - filename=$(basename "${filename}") - echo "- [${filename}](${access_url}/${filename})" >> "${GITHUB_STEP_SUMMARY}" - done + # Avoid generating an invalid "*.xz" file if there are no archives + if [ ${#archives[@]} -gt 0 ]; then + echo "# CI artifacts" >> "${GITHUB_STEP_SUMMARY}" + + for filename in "${upload_dir}"/*.xz; do + filename=$(basename "${filename}") + echo "- [${filename}](${access_url}/${filename})" >> "${GITHUB_STEP_SUMMARY}" + done + fi fi diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md index b6209bcb2d8..00bb2bc4dbb 100644 --- a/src/doc/rustc-dev-guide/src/tests/directives.md +++ b/src/doc/rustc-dev-guide/src/tests/directives.md @@ -154,6 +154,7 @@ Some examples of `X` in `ignore-X` or `only-X`: `ignore-coverage-map`, `ignore-coverage-run` - When testing a dist toolchain: `dist` - This needs to be enabled with `COMPILETEST_ENABLE_DIST_TESTS=1` +- The `rustc_abi` of the target: e.g. `rustc_abi-x86_64-sse2` The following directives will check rustc build settings and target settings: diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index bd8eda2fed6..d9e49577d39 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -38,7 +38,7 @@ use std::sync::{Arc, Weak}; use pulldown_cmark::{ BrokenLink, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag, TagEnd, html, }; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_errors::{Diag, DiagMessage}; use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::TyCtxt; @@ -1763,6 +1763,46 @@ pub(crate) fn markdown_links<'md, R>( } }; + let span_for_refdef = |link: &CowStr<'_>, span: Range<usize>| { + // We want to underline the link's definition, but `span` will point at the entire refdef. + // Skip the label, then try to find the entire URL. + let mut square_brace_count = 0; + let mut iter = md.as_bytes()[span.start..span.end].iter().copied().enumerate(); + for (_i, c) in &mut iter { + match c { + b':' if square_brace_count == 0 => break, + b'[' => square_brace_count += 1, + b']' => square_brace_count -= 1, + _ => {} + } + } + while let Some((i, c)) = iter.next() { + if c == b'<' { + while let Some((j, c)) = iter.next() { + match c { + b'\\' => { + let _ = iter.next(); + } + b'>' => { + return MarkdownLinkRange::Destination( + i + 1 + span.start..j + span.start, + ); + } + _ => {} + } + } + } else if !c.is_ascii_whitespace() { + while let Some((j, c)) = iter.next() { + if c.is_ascii_whitespace() { + return MarkdownLinkRange::Destination(i + span.start..j + span.start); + } + } + return MarkdownLinkRange::Destination(i + span.start..span.end); + } + } + span_for_link(link, span) + }; + let span_for_offset_backward = |span: Range<usize>, open: u8, close: u8| { let mut open_brace = !0; let mut close_brace = !0; @@ -1844,9 +1884,16 @@ pub(crate) fn markdown_links<'md, R>( .into_offset_iter(); let mut links = Vec::new(); + let mut refdefs = FxIndexMap::default(); + for (label, refdef) in event_iter.reference_definitions().iter() { + refdefs.insert(label.to_string(), (false, refdef.dest.to_string(), refdef.span.clone())); + } + for (event, span) in event_iter { match event { - Event::Start(Tag::Link { link_type, dest_url, .. }) if may_be_doc_link(link_type) => { + Event::Start(Tag::Link { link_type, dest_url, id, .. }) + if may_be_doc_link(link_type) => + { let range = match link_type { // Link is pulled from the link itself. LinkType::ReferenceUnknown | LinkType::ShortcutUnknown => { @@ -1856,7 +1903,12 @@ pub(crate) fn markdown_links<'md, R>( LinkType::Inline => span_for_offset_backward(span, b'(', b')'), // Link is pulled from elsewhere in the document. LinkType::Reference | LinkType::Collapsed | LinkType::Shortcut => { - span_for_link(&dest_url, span) + if let Some((is_used, dest_url, span)) = refdefs.get_mut(&id[..]) { + *is_used = true; + span_for_refdef(&CowStr::from(&dest_url[..]), span.clone()) + } else { + span_for_link(&dest_url, span) + } } LinkType::Autolink | LinkType::Email => unreachable!(), }; @@ -1873,6 +1925,18 @@ pub(crate) fn markdown_links<'md, R>( } } + for (_label, (is_used, dest_url, span)) in refdefs.into_iter() { + if !is_used + && let Some(link) = preprocess_link(MarkdownLink { + kind: LinkType::Reference, + range: span_for_refdef(&CowStr::from(&dest_url[..]), span), + link: dest_url, + }) + { + links.push(link); + } + } + links } diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index a348c6c5678..e46cc1897e9 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -2039,7 +2039,10 @@ function preLoadCss(cssUrl) { // Most page titles are '<Item> in <path::to::module> - Rust', except // modules (which don't have the first part) and keywords/primitives // (which don't have a module path) - const [item, module] = document.title.split(" in "); + const titleElement = document.querySelector("title"); + const title = titleElement && titleElement.textContent ? + titleElement.textContent.replace(" - Rust", "") : ""; + const [item, module] = title.split(" in "); const path = [item]; if (module !== undefined) { path.unshift(module); diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 121a43e3d92..ccbd6811b07 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -5318,8 +5318,9 @@ function registerSearchEvents() { // @ts-expect-error searchState.input.addEventListener("blur", () => { - // @ts-expect-error - searchState.input.placeholder = searchState.input.origPlaceholder; + if (window.searchState.input) { + window.searchState.input.placeholder = window.searchState.origPlaceholder; + } }); // Push and pop states are used to add search results to the browser diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 2928e32734b04925ee51e1ae88bea9a83d2fd45 +Subproject ce948f4616e3d4277e30c75c8bb01e094910df3 diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index cde4f7a665c..1614c35cb1c 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -517,6 +517,7 @@ pub struct TargetCfgs { pub all_abis: HashSet<String>, pub all_families: HashSet<String>, pub all_pointer_widths: HashSet<String>, + pub all_rustc_abis: HashSet<String>, } impl TargetCfgs { @@ -536,6 +537,9 @@ impl TargetCfgs { let mut all_abis = HashSet::new(); let mut all_families = HashSet::new(); let mut all_pointer_widths = HashSet::new(); + // NOTE: for distinction between `abi` and `rustc_abi`, see comment on + // `TargetCfg::rustc_abi`. + let mut all_rustc_abis = HashSet::new(); // If current target is not included in the `--print=all-target-specs-json` output, // we check whether it is a custom target from the user or a synthetic target from bootstrap. @@ -576,7 +580,9 @@ impl TargetCfgs { all_families.insert(family.clone()); } all_pointer_widths.insert(format!("{}bit", cfg.pointer_width)); - + if let Some(rustc_abi) = &cfg.rustc_abi { + all_rustc_abis.insert(rustc_abi.clone()); + } all_targets.insert(target.clone()); } @@ -590,6 +596,7 @@ impl TargetCfgs { all_abis, all_families, all_pointer_widths, + all_rustc_abis, } } @@ -676,6 +683,10 @@ pub struct TargetCfg { pub(crate) xray: bool, #[serde(default = "default_reloc_model")] pub(crate) relocation_model: String, + // NOTE: `rustc_abi` should not be confused with `abi`. `rustc_abi` was introduced in #137037 to + // make SSE2 *required* by the ABI (kind of a hack to make a target feature *required* via the + // target spec). + pub(crate) rustc_abi: Option<String>, // Not present in target cfg json output, additional derived information. #[serde(skip)] diff --git a/src/tools/compiletest/src/directive-list.rs b/src/tools/compiletest/src/directive-list.rs index a7ac875d0a3..8c909bcb195 100644 --- a/src/tools/compiletest/src/directive-list.rs +++ b/src/tools/compiletest/src/directive-list.rs @@ -87,6 +87,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "ignore-remote", "ignore-riscv64", "ignore-rustc-debug-assertions", + "ignore-rustc_abi-x86-sse2", "ignore-s390x", "ignore-sgx", "ignore-sparc64", @@ -198,6 +199,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "only-nvptx64", "only-powerpc", "only-riscv64", + "only-rustc_abi-x86-sse2", "only-s390x", "only-sparc", "only-sparc64", diff --git a/src/tools/compiletest/src/header/cfg.rs b/src/tools/compiletest/src/header/cfg.rs index cfe51b5655f..72a3b9d85c8 100644 --- a/src/tools/compiletest/src/header/cfg.rs +++ b/src/tools/compiletest/src/header/cfg.rs @@ -234,6 +234,14 @@ fn parse_cfg_name_directive<'a>( allowed_names: ["coverage-map", "coverage-run"], message: "when the test mode is {name}", } + condition! { + name: target_cfg.rustc_abi.as_ref().map(|abi| format!("rustc_abi-{abi}")).unwrap_or_default(), + allowed_names: ContainsPrefixed { + prefix: "rustc_abi-", + inner: target_cfgs.all_rustc_abis.clone(), + }, + message: "when the target `rustc_abi` is {name}", + } condition! { name: "dist", diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 522d340b678..55292c46bba 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -889,3 +889,17 @@ fn test_needs_target_has_atomic() { assert!(!check_ignore(&config, "//@ needs-target-has-atomic: 8, ptr")); assert!(check_ignore(&config, "//@ needs-target-has-atomic: 8, ptr, 128")); } + +#[test] +// FIXME: this test will fail against stage 0 until #137037 changes reach beta. +#[cfg_attr(bootstrap, ignore)] +fn test_rustc_abi() { + let config = cfg().target("i686-unknown-linux-gnu").build(); + assert_eq!(config.target_cfg().rustc_abi, Some("x86-sse2".to_string())); + assert!(check_ignore(&config, "//@ ignore-rustc_abi-x86-sse2")); + assert!(!check_ignore(&config, "//@ only-rustc_abi-x86-sse2")); + let config = cfg().target("x86_64-unknown-linux-gnu").build(); + assert_eq!(config.target_cfg().rustc_abi, None); + assert!(!check_ignore(&config, "//@ ignore-rustc_abi-x86-sse2")); + assert!(check_ignore(&config, "//@ only-rustc_abi-x86-sse2")); +} diff --git a/src/tools/miri/tests/fail/panic/panic_abort1.rs b/src/tools/miri/tests/fail/panic/panic_abort1.rs index 300bfa32ecb..7552c7b7e80 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort1.rs +++ b/src/tools/miri/tests/fail/panic/panic_abort1.rs @@ -1,6 +1,6 @@ //@error-in-other-file: the program aborted execution //@normalize-stderr-test: "\| +\^+" -> "| ^" -//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();" //@compile-flags: -C panic=abort fn main() { diff --git a/src/tools/miri/tests/fail/panic/panic_abort2.rs b/src/tools/miri/tests/fail/panic/panic_abort2.rs index 5d691350577..624f9933545 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort2.rs +++ b/src/tools/miri/tests/fail/panic/panic_abort2.rs @@ -1,6 +1,6 @@ //@error-in-other-file: the program aborted execution //@normalize-stderr-test: "\| +\^+" -> "| ^" -//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();" //@compile-flags: -C panic=abort fn main() { diff --git a/src/tools/miri/tests/fail/panic/panic_abort3.rs b/src/tools/miri/tests/fail/panic/panic_abort3.rs index 25afc315628..d1435b55946 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort3.rs +++ b/src/tools/miri/tests/fail/panic/panic_abort3.rs @@ -1,6 +1,6 @@ //@error-in-other-file: the program aborted execution //@normalize-stderr-test: "\| +\^+" -> "| ^" -//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();" //@compile-flags: -C panic=abort fn main() { diff --git a/src/tools/miri/tests/fail/panic/panic_abort4.rs b/src/tools/miri/tests/fail/panic/panic_abort4.rs index 025b51a5cf5..54b9c9cbfdb 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort4.rs +++ b/src/tools/miri/tests/fail/panic/panic_abort4.rs @@ -1,6 +1,6 @@ //@error-in-other-file: the program aborted execution //@normalize-stderr-test: "\| +\^+" -> "| ^" -//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" +//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();" //@compile-flags: -C panic=abort fn main() { diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index d75a68d5973..e8e7dfe0d84 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -132,6 +132,7 @@ const EXCEPTIONS_CARGO: ExceptionList = &[ ("dunce", "CC0-1.0 OR MIT-0 OR Apache-2.0"), ("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"), ("fiat-crypto", "MIT OR Apache-2.0 OR BSD-1-Clause"), + ("foldhash", "Zlib"), ("im-rc", "MPL-2.0+"), ("normalize-line-endings", "Apache-2.0"), ("openssl", "Apache-2.0"), diff --git a/src/version b/src/version index b7844a6ffdc..f6342716723 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.86.0 +1.87.0 diff --git a/tests/run-make/amdgpu-kd/foo.rs b/tests/run-make/amdgpu-kd/foo.rs new file mode 100644 index 00000000000..a0d803ab813 --- /dev/null +++ b/tests/run-make/amdgpu-kd/foo.rs @@ -0,0 +1,11 @@ +#![allow(internal_features)] +#![feature(no_core, lang_items, abi_gpu_kernel)] +#![no_core] +#![no_std] + +// This is needed because of #![no_core]: +#[lang = "sized"] +trait Sized {} + +#[no_mangle] +extern "gpu-kernel" fn kernel() {} diff --git a/tests/run-make/amdgpu-kd/rmake.rs b/tests/run-make/amdgpu-kd/rmake.rs new file mode 100644 index 00000000000..a787fa1da93 --- /dev/null +++ b/tests/run-make/amdgpu-kd/rmake.rs @@ -0,0 +1,20 @@ +// On the amdhsa OS, the host runtime (HIP or HSA) expects a kernel descriptor object for each +// kernel in the ELF file. The amdgpu LLVM backend generates the object. It is created as a symbol +// with the name of the kernel plus a .kd suffix. +// Check that the produced object has the .kd symbol exported. + +//@ needs-llvm-components: amdgpu +//@ needs-rust-lld + +use run_make_support::{llvm_readobj, rustc}; + +fn main() { + rustc() + .crate_name("foo") + .target("amdgcn-amd-amdhsa") + .arg("-Ctarget-cpu=gfx900") + .crate_type("cdylib") + .input("foo.rs") + .run(); + llvm_readobj().input("foo.elf").symbols().run().assert_stdout_contains("kernel.kd"); +} diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.rs b/tests/rustdoc-ui/intra-doc/weird-syntax.rs index ca18842fb21..d2a922b2b62 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.rs +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.rs @@ -117,24 +117,49 @@ pub struct WLinkToCloneWithUnmatchedEscapedCloseParenAndDoubleSpace; // References -/// The [cln][] link here is going to be unresolved, because `Clone()` gets rejected //~ERROR link -/// in Markdown for not being URL-shaped enough. -/// -/// [cln]: Clone() //~ERROR link +/// The [cln][] link here is going to be unresolved, because `Clone()` gets +//~^ ERROR link +/// rejected in Markdown for not being URL-shaped enough. +/// [cln]: Clone() +//~^ ERROR link pub struct LinkToCloneWithParensInReference; -/// The [cln][] link here is going to be unresolved, because `struct@Clone` gets //~ERROR link -/// rejected in Markdown for not being URL-shaped enough. +/// The [cln][] link here is going to produce a good inline suggestion /// -/// [cln]: struct@Clone //~ERROR link +/// [cln]: struct@Clone +//~^ ERROR link pub struct LinkToCloneWithWrongPrefix; -/// The [cln][] link here will produce a plain text suggestion //~ERROR link +/// The [cln][] link here will produce a good inline suggestion /// /// [cln]: Clone\(\) +//~^ ERROR link pub struct LinkToCloneWithEscapedParensInReference; -/// The [cln][] link here will produce a plain text suggestion //~ERROR link +/// The [cln][] link here will produce a good inline suggestion /// /// [cln]: struct\@Clone +//~^ ERROR link pub struct LinkToCloneWithEscapedAtsInReference; + + +/// This link reference definition isn't used, but since it is still parsed, +/// it should still produce a warning. +/// +/// [cln]: struct\@Clone +//~^ ERROR link +pub struct UnusedLinkToCloneReferenceDefinition; + +/// <https://github.com/rust-lang/rust/issues/133150> +/// +/// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the +//~^ ERROR link +/// `(__unsafe_unretained)` NSWindow associated with the window, if you want +/// to wrap an existing window. +/// - [`SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`]: the `(__unsafe_unretained)` +/// NSView associated with the window, defaults to `[window contentView]` +pub fn a() {} +#[allow(nonstandard_style)] +pub struct SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER; +#[allow(nonstandard_style)] +pub struct SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER; diff --git a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr index 1381c1b31eb..ad813f0f9b6 100644 --- a/tests/rustdoc-ui/intra-doc/weird-syntax.stderr +++ b/tests/rustdoc-ui/intra-doc/weird-syntax.stderr @@ -230,7 +230,7 @@ LL | /// [w](Clone \)) error: unresolved link to `cln` --> $DIR/weird-syntax.rs:120:10 | -LL | /// The [cln][] link here is going to be unresolved, because `Clone()` gets rejected +LL | /// The [cln][] link here is going to be unresolved, because `Clone()` gets | ^^^ no item named `cln` in scope | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` @@ -243,37 +243,61 @@ LL | /// [cln]: Clone() | = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` -error: unresolved link to `cln` - --> $DIR/weird-syntax.rs:126:10 +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:129:12 | -LL | /// The [cln][] link here is going to be unresolved, because `struct@Clone` gets - | ^^^ no item named `cln` in scope +LL | /// [cln]: struct@Clone + | ^^^^^^^^^^^^ this link resolved to a trait, which is not a struct | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -error: unresolved link to `cln` - --> $DIR/weird-syntax.rs:129:6 +help: to link to the trait, prefix with `trait@` | -LL | /// [cln]: struct@Clone - | ^^^ no item named `cln` in scope +LL - /// [cln]: struct@Clone +LL + /// [cln]: trait@Clone | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` error: unresolved link to `Clone` - --> $DIR/weird-syntax.rs:132:9 + --> $DIR/weird-syntax.rs:135:12 + | +LL | /// [cln]: Clone\(\) + | ^^^^^^^^^ this link resolves to the trait `Clone`, which is not a function + | +help: to link to the trait, prefix with `trait@` | -LL | /// The [cln][] link here will produce a plain text suggestion - | ^^^^^ this link resolves to the trait `Clone`, which is not a function +LL - /// [cln]: Clone\(\) +LL + /// [cln]: trait@Clone | - = help: to link to the trait, prefix with `trait@`: trait@Clone error: incompatible link kind for `Clone` - --> $DIR/weird-syntax.rs:137:9 + --> $DIR/weird-syntax.rs:141:12 | -LL | /// The [cln][] link here will produce a plain text suggestion - | ^^^^^ this link resolved to a trait, which is not a struct +LL | /// [cln]: struct\@Clone + | ^^^^^^^^^^^^^ this link resolved to a trait, which is not a struct | - = help: to link to the trait, prefix with `trait@`: trait@Clone +help: to link to the trait, prefix with `trait@` + | +LL - /// [cln]: struct\@Clone +LL + /// [cln]: trait@struct + | + +error: incompatible link kind for `Clone` + --> $DIR/weird-syntax.rs:149:12 + | +LL | /// [cln]: struct\@Clone + | ^^^^^^^^^^^^^ this link resolved to a trait, which is not a struct + | +help: to link to the trait, prefix with `trait@` + | +LL - /// [cln]: struct\@Clone +LL + /// [cln]: trait@struct + | + +error: unresolved link to `the` + --> $DIR/weird-syntax.rs:155:56 + | +LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the + | ^^^ no item named `the` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` -error: aborting due to 26 previous errors +error: aborting due to 27 previous errors diff --git a/tests/ui/attributes/crate-name-macro-call.rs b/tests/ui/attributes/crate-name-macro-call.rs new file mode 100644 index 00000000000..1aae2e506e2 --- /dev/null +++ b/tests/ui/attributes/crate-name-macro-call.rs @@ -0,0 +1,6 @@ +// issue: rust-lang/rust#122001 +// Ensure we reject macro calls inside `#![crate_name]` as their result wouldn't get honored anyway. + +#![crate_name = concat!("my", "crate")] //~ ERROR malformed `crate_name` attribute input + +fn main() {} diff --git a/tests/ui/attributes/crate-name-macro-call.stderr b/tests/ui/attributes/crate-name-macro-call.stderr new file mode 100644 index 00000000000..ab562b41a31 --- /dev/null +++ b/tests/ui/attributes/crate-name-macro-call.stderr @@ -0,0 +1,8 @@ +error: malformed `crate_name` attribute input + --> $DIR/crate-name-macro-call.rs:4:1 + | +LL | #![crate_name = concat!("my", "crate")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/invalid_crate_type_syntax.rs b/tests/ui/attributes/crate-type-delimited.rs index 621587af35e..621587af35e 100644 --- a/tests/ui/invalid_crate_type_syntax.rs +++ b/tests/ui/attributes/crate-type-delimited.rs diff --git a/tests/ui/invalid_crate_type_syntax.stderr b/tests/ui/attributes/crate-type-delimited.stderr index a5563720f62..0bbbe07b198 100644 --- a/tests/ui/invalid_crate_type_syntax.stderr +++ b/tests/ui/attributes/crate-type-delimited.stderr @@ -1,5 +1,5 @@ error: malformed `crate_type` attribute input - --> $DIR/invalid_crate_type_syntax.rs:2:1 + --> $DIR/crate-type-delimited.rs:2:1 | LL | #![crate_type(lib)] | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]` diff --git a/tests/ui/no_crate_type.rs b/tests/ui/attributes/crate-type-empty.rs index d8e687e04a7..d8e687e04a7 100644 --- a/tests/ui/no_crate_type.rs +++ b/tests/ui/attributes/crate-type-empty.rs diff --git a/tests/ui/no_crate_type.stderr b/tests/ui/attributes/crate-type-empty.stderr index 85d8f87afa6..b9279d961ee 100644 --- a/tests/ui/no_crate_type.stderr +++ b/tests/ui/attributes/crate-type-empty.stderr @@ -1,5 +1,5 @@ error: malformed `crate_type` attribute input - --> $DIR/no_crate_type.rs:2:1 + --> $DIR/crate-type-empty.rs:2:1 | LL | #![crate_type] | ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]` diff --git a/tests/ui/invalid/invalid-crate-type-macro.rs b/tests/ui/attributes/crate-type-macro-call.rs index 9ba5e79ba94..9ba5e79ba94 100644 --- a/tests/ui/invalid/invalid-crate-type-macro.rs +++ b/tests/ui/attributes/crate-type-macro-call.rs diff --git a/tests/ui/invalid/invalid-crate-type-macro.stderr b/tests/ui/attributes/crate-type-macro-call.stderr index 1cf77d4086b..6ccc3edf885 100644 --- a/tests/ui/invalid/invalid-crate-type-macro.stderr +++ b/tests/ui/attributes/crate-type-macro-call.stderr @@ -1,5 +1,5 @@ error: malformed `crate_type` attribute input - --> $DIR/invalid-crate-type-macro.rs:1:1 + --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] | ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]` diff --git a/tests/ui/command/need-crate-arg-ignore-tidy$x.stderr b/tests/ui/command/need-crate-arg-ignore-tidy$x.stderr deleted file mode 100644 index 28f6d31b1ce..00000000000 --- a/tests/ui/command/need-crate-arg-ignore-tidy$x.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error: invalid character `'$'` in crate name: `need_crate_arg_ignore_tidy$x` - | - = help: you can either pass `--crate-name` on the command line or add `#![crate_name="…"]` to set the crate name - -error: aborting due to 1 previous error - diff --git a/tests/ui/dyn-compatibility/associated_type_bound_mentions_self.rs b/tests/ui/dyn-compatibility/associated_type_bound_mentions_self.rs new file mode 100644 index 00000000000..0be5fa27b4c --- /dev/null +++ b/tests/ui/dyn-compatibility/associated_type_bound_mentions_self.rs @@ -0,0 +1,14 @@ +// Ensure that we properly ignore the `B<Self>` associated type bound on `A::T` +// since that associated type requires `Self: Sized`. + +//@ check-pass + +struct X(&'static dyn A); + +trait A { + type T: B<Self> where Self: Sized; +} + +trait B<T> {} + +fn main() {} diff --git a/tests/ui/generics/single-colon-path-not-const-generics.stderr b/tests/ui/generics/single-colon-path-not-const-generics.stderr index 4e695b2dcd6..c14a5e62a0c 100644 --- a/tests/ui/generics/single-colon-path-not-const-generics.stderr +++ b/tests/ui/generics/single-colon-path-not-const-generics.stderr @@ -1,8 +1,6 @@ error: path separator must be a double colon --> $DIR/single-colon-path-not-const-generics.rs:8:18 | -LL | pub struct Foo { - | --- while parsing this struct LL | a: Vec<foo::bar:A>, | ^ | @@ -10,7 +8,7 @@ LL | a: Vec<foo::bar:A>, help: use a double colon instead | LL | a: Vec<foo::bar::A>, - | + + | + error: aborting due to 1 previous error diff --git a/tests/ui/command/need-crate-arg-ignore-tidy$x.rs b/tests/ui/invalid-compile-flags/need-crate-arg-ignore-tidy$x.rs index b1ac4a4ae21..b1ac4a4ae21 100644 --- a/tests/ui/command/need-crate-arg-ignore-tidy$x.rs +++ b/tests/ui/invalid-compile-flags/need-crate-arg-ignore-tidy$x.rs diff --git a/tests/ui/invalid-compile-flags/need-crate-arg-ignore-tidy$x.stderr b/tests/ui/invalid-compile-flags/need-crate-arg-ignore-tidy$x.stderr new file mode 100644 index 00000000000..861510212f9 --- /dev/null +++ b/tests/ui/invalid-compile-flags/need-crate-arg-ignore-tidy$x.stderr @@ -0,0 +1,6 @@ +error: invalid character '$' in crate name: `need_crate_arg_ignore_tidy$x` + | + = help: you can either pass `--crate-name` on the command line or add `#![crate_name = "…"]` to set the crate name + +error: aborting due to 1 previous error + diff --git a/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.rs b/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.rs new file mode 100644 index 00000000000..c7f3c2c5403 --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.rs @@ -0,0 +1,5 @@ +// Ensure we validate `#![crate_name]` on print requests and reject macro calls inside of it. +// See also <https://github.com/rust-lang/rust/issues/122001>. + +//@ compile-flags: --print=crate-name +#![crate_name = concat!("wrapped")] //~ ERROR malformed `crate_name` attribute input diff --git a/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr b/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr new file mode 100644 index 00000000000..6bf09a2b131 --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr @@ -0,0 +1,8 @@ +error: malformed `crate_name` attribute input + --> $DIR/print-crate-name-request-malformed-crate-name.rs:5:1 + | +LL | #![crate_name = concat!("wrapped")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.rs b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.rs new file mode 100644 index 00000000000..5cf1ae36b42 --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.rs @@ -0,0 +1,4 @@ +// Ensure we validate `#![crate_name]` on print requests. + +//@ compile-flags: --print=file-names +#![crate_name] //~ ERROR malformed `crate_name` attribute input diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr new file mode 100644 index 00000000000..de62aed79fc --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr @@ -0,0 +1,8 @@ +error: malformed `crate_name` attribute input + --> $DIR/print-file-names-request-malformed-crate-name-1.rs:4:1 + | +LL | #![crate_name] + | ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.rs b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.rs new file mode 100644 index 00000000000..13c9d1e0027 --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.rs @@ -0,0 +1,7 @@ +// Ensure that we validate *all* `#![crate_name]`s on print requests, not just the first, +// and that we reject macro calls inside of them. +// See also <https://github.com/rust-lang/rust/issues/122001>. + +//@ compile-flags: --print=file-names +#![crate_name = "this_one_is_okay"] +#![crate_name = concat!("this_one_is_not")] //~ ERROR malformed `crate_name` attribute input diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr new file mode 100644 index 00000000000..42c33de1221 --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr @@ -0,0 +1,8 @@ +error: malformed `crate_name` attribute input + --> $DIR/print-file-names-request-malformed-crate-name-2.rs:7:1 + | +LL | #![crate_name = concat!("this_one_is_not")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.rs b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.rs new file mode 100644 index 00000000000..5fe8bd7945f --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.rs @@ -0,0 +1,5 @@ +// Ensure we validate `#![crate_name]` on print requests and reject macro calls inside of it. +// See also <https://github.com/rust-lang/rust/issues/122001>. + +//@ compile-flags: --print=file-names +#![crate_name = concat!("wrapped")] //~ ERROR malformed `crate_name` attribute input diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr new file mode 100644 index 00000000000..cb5ffaab9ca --- /dev/null +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr @@ -0,0 +1,8 @@ +error: malformed `crate_name` attribute input + --> $DIR/print-file-names-request-malformed-crate-name.rs:5:1 + | +LL | #![crate_name = concat!("wrapped")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/attribute/attr-pat-struct-rest.rs b/tests/ui/parser/attribute/attr-pat-struct-rest.rs new file mode 100644 index 00000000000..b2bfcf82df8 --- /dev/null +++ b/tests/ui/parser/attribute/attr-pat-struct-rest.rs @@ -0,0 +1,8 @@ +// #81282: Attributes are not allowed on struct field rest patterns (the ..). + +struct S {} + +fn main() { + let S { #[cfg(any())] .. } = S {}; + //~^ ERROR expected identifier, found `..` +} diff --git a/tests/ui/parser/attribute/attr-pat-struct-rest.stderr b/tests/ui/parser/attribute/attr-pat-struct-rest.stderr new file mode 100644 index 00000000000..f72c54973fc --- /dev/null +++ b/tests/ui/parser/attribute/attr-pat-struct-rest.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found `..` + --> $DIR/attr-pat-struct-rest.rs:6:27 + | +LL | let S { #[cfg(any())] .. } = S {}; + | - ^^ expected identifier + | | + | while parsing the fields for this pattern + +error: aborting due to 1 previous error + diff --git a/tests/ui/simd-abi-checks-empty-list.rs b/tests/ui/simd-abi-checks-empty-list.rs index c1785051e5a..fd4957b5b93 100644 --- a/tests/ui/simd-abi-checks-empty-list.rs +++ b/tests/ui/simd-abi-checks-empty-list.rs @@ -15,5 +15,5 @@ trait Copy {} pub struct SimdVec([i32; 4]); pub extern "C" fn pass_by_vec(_: SimdVec) {} -//~^ this function definition uses a SIMD vector type that is not currently supported with the chosen ABI +//~^ this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI //~| WARNING this was previously accepted by the compiler diff --git a/tests/ui/simd-abi-checks-empty-list.stderr b/tests/ui/simd-abi-checks-empty-list.stderr index c49fe1a01de..91c61884fd0 100644 --- a/tests/ui/simd-abi-checks-empty-list.stderr +++ b/tests/ui/simd-abi-checks-empty-list.stderr @@ -1,4 +1,4 @@ -warning: this function definition uses a SIMD vector type that is not currently supported with the chosen ABI +warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI --> $DIR/simd-abi-checks-empty-list.rs:17:1 | LL | pub extern "C" fn pass_by_vec(_: SimdVec) {} @@ -11,7 +11,7 @@ LL | pub extern "C" fn pass_by_vec(_: SimdVec) {} warning: 1 warning emitted Future incompatibility report: Future breakage diagnostic: -warning: this function definition uses a SIMD vector type that is not currently supported with the chosen ABI +warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI --> $DIR/simd-abi-checks-empty-list.rs:17:1 | LL | pub extern "C" fn pass_by_vec(_: SimdVec) {} diff --git a/tests/ui/simd-abi-checks-s390x.rs b/tests/ui/simd-abi-checks-s390x.rs index 15df66a2ced..7e408f66561 100644 --- a/tests/ui/simd-abi-checks-s390x.rs +++ b/tests/ui/simd-abi-checks-s390x.rs @@ -44,13 +44,13 @@ impl<T: Copy> Copy for TransparentWrapper<T> {} #[no_mangle] extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted *x } #[no_mangle] extern "C" fn vector_ret(x: &i8x16) -> i8x16 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted *x } @@ -99,7 +99,7 @@ extern "C" fn vector_wrapper_ret_large(x: &Wrapper<i8x32>) -> Wrapper<i8x32> { extern "C" fn vector_transparent_wrapper_ret_small( x: &TransparentWrapper<i8x8>, ) -> TransparentWrapper<i8x8> { - //~^^^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^^^ ERROR requires the `vector` target feature, which is not enabled //~^^^^ WARN this was previously accepted *x } @@ -107,7 +107,7 @@ extern "C" fn vector_transparent_wrapper_ret_small( extern "C" fn vector_transparent_wrapper_ret( x: &TransparentWrapper<i8x16>, ) -> TransparentWrapper<i8x16> { - //~^^^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^^^ ERROR requires the `vector` target feature, which is not enabled //~^^^^ WARN this was previously accepted *x } @@ -121,13 +121,13 @@ extern "C" fn vector_transparent_wrapper_ret_large( #[no_mangle] extern "C" fn vector_arg_small(x: i8x8) -> i64 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted unsafe { *(&x as *const i8x8 as *const i64) } } #[no_mangle] extern "C" fn vector_arg(x: i8x16) -> i64 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted unsafe { *(&x as *const i8x16 as *const i64) } } @@ -139,13 +139,13 @@ extern "C" fn vector_arg_large(x: i8x32) -> i64 { #[no_mangle] extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted unsafe { *(&x as *const Wrapper<i8x8> as *const i64) } } #[no_mangle] extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted unsafe { *(&x as *const Wrapper<i8x16> as *const i64) } } @@ -157,13 +157,13 @@ extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 { #[no_mangle] extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted unsafe { *(&x as *const TransparentWrapper<i8x8> as *const i64) } } #[no_mangle] extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { - //~^ ERROR this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled + //~^ ERROR requires the `vector` target feature, which is not enabled //~^^ WARN this was previously accepted unsafe { *(&x as *const TransparentWrapper<i8x16> as *const i64) } } diff --git a/tests/ui/simd-abi-checks-s390x.z10.stderr b/tests/ui/simd-abi-checks-s390x.z10.stderr index cf135afb428..ab97299e84a 100644 --- a/tests/ui/simd-abi-checks-s390x.z10.stderr +++ b/tests/ui/simd-abi-checks-s390x.z10.stderr @@ -1,4 +1,4 @@ -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:46:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { @@ -13,7 +13,7 @@ note: the lint level is defined here LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:52:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { @@ -23,7 +23,7 @@ LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:99:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( @@ -35,7 +35,7 @@ LL | | ) -> TransparentWrapper<i8x8> { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:107:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( @@ -47,7 +47,7 @@ LL | | ) -> TransparentWrapper<i8x16> { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:123:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { @@ -57,7 +57,7 @@ LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:129:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { @@ -67,7 +67,7 @@ LL | extern "C" fn vector_arg(x: i8x16) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:141:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { @@ -77,7 +77,7 @@ LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:147:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { @@ -87,7 +87,7 @@ LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:159:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { @@ -97,7 +97,7 @@ LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8 = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:165:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { @@ -110,7 +110,7 @@ LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) error: aborting due to 10 previous errors Future incompatibility report: Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:46:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { @@ -126,7 +126,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:52:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { @@ -142,7 +142,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:99:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( @@ -160,7 +160,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:107:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( @@ -178,7 +178,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:123:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { @@ -194,7 +194,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:129:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { @@ -210,7 +210,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:141:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { @@ -226,7 +226,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:147:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { @@ -242,7 +242,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:159:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { @@ -258,7 +258,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:165:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { diff --git a/tests/ui/simd-abi-checks-s390x.z13_no_vector.stderr b/tests/ui/simd-abi-checks-s390x.z13_no_vector.stderr index cf135afb428..ab97299e84a 100644 --- a/tests/ui/simd-abi-checks-s390x.z13_no_vector.stderr +++ b/tests/ui/simd-abi-checks-s390x.z13_no_vector.stderr @@ -1,4 +1,4 @@ -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:46:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { @@ -13,7 +13,7 @@ note: the lint level is defined here LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:52:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { @@ -23,7 +23,7 @@ LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:99:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( @@ -35,7 +35,7 @@ LL | | ) -> TransparentWrapper<i8x8> { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:107:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( @@ -47,7 +47,7 @@ LL | | ) -> TransparentWrapper<i8x16> { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:123:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { @@ -57,7 +57,7 @@ LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:129:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { @@ -67,7 +67,7 @@ LL | extern "C" fn vector_arg(x: i8x16) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:141:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { @@ -77,7 +77,7 @@ LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:147:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { @@ -87,7 +87,7 @@ LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:159:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { @@ -97,7 +97,7 @@ LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8 = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:165:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { @@ -110,7 +110,7 @@ LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) error: aborting due to 10 previous errors Future incompatibility report: Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:46:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { @@ -126,7 +126,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:52:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { @@ -142,7 +142,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:99:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( @@ -160,7 +160,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:107:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( @@ -178,7 +178,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:123:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { @@ -194,7 +194,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:129:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { @@ -210,7 +210,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:141:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { @@ -226,7 +226,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:147:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { @@ -242,7 +242,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:159:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { @@ -258,7 +258,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:165:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { diff --git a/tests/ui/simd-abi-checks-s390x.z13_soft_float.stderr b/tests/ui/simd-abi-checks-s390x.z13_soft_float.stderr index cf135afb428..ab97299e84a 100644 --- a/tests/ui/simd-abi-checks-s390x.z13_soft_float.stderr +++ b/tests/ui/simd-abi-checks-s390x.z13_soft_float.stderr @@ -1,4 +1,4 @@ -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:46:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { @@ -13,7 +13,7 @@ note: the lint level is defined here LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:52:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { @@ -23,7 +23,7 @@ LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:99:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( @@ -35,7 +35,7 @@ LL | | ) -> TransparentWrapper<i8x8> { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:107:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( @@ -47,7 +47,7 @@ LL | | ) -> TransparentWrapper<i8x16> { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:123:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { @@ -57,7 +57,7 @@ LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:129:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { @@ -67,7 +67,7 @@ LL | extern "C" fn vector_arg(x: i8x16) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:141:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { @@ -77,7 +77,7 @@ LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:147:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { @@ -87,7 +87,7 @@ LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:159:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { @@ -97,7 +97,7 @@ LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8 = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:165:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { @@ -110,7 +110,7 @@ LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) error: aborting due to 10 previous errors Future incompatibility report: Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:46:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { @@ -126,7 +126,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:52:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { @@ -142,7 +142,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:99:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( @@ -160,7 +160,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:107:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( @@ -178,7 +178,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:123:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { @@ -194,7 +194,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:129:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { @@ -210,7 +210,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:141:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { @@ -226,7 +226,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:147:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { @@ -242,7 +242,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:159:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { @@ -258,7 +258,7 @@ LL | #![deny(abi_unsupported_vector_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: -error: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `vector` target feature, which is not enabled +error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled --> $DIR/simd-abi-checks-s390x.rs:165:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { diff --git a/tests/ui/simd-abi-checks.rs b/tests/ui/simd-abi-checks.rs index 3a344a1f5f8..acab74300b8 100644 --- a/tests/ui/simd-abi-checks.rs +++ b/tests/ui/simd-abi-checks.rs @@ -13,19 +13,19 @@ use std::arch::x86_64::*; struct Wrapper(__m256); unsafe extern "C" fn w(_: Wrapper) { - //~^ this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled + //~^ requires the `avx` target feature, which is not enabled //~| WARNING this was previously accepted by the compiler todo!() } unsafe extern "C" fn f(_: __m256) { - //~^ this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled + //~^ requires the `avx` target feature, which is not enabled //~| WARNING this was previously accepted by the compiler todo!() } unsafe extern "C" fn g() -> __m256 { - //~^ this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled + //~^ requires the `avx` target feature, which is not enabled //~| WARNING this was previously accepted by the compiler todo!() } @@ -55,23 +55,23 @@ unsafe fn test() { unsafe fn in_closure() -> impl FnOnce() -> __m256 { #[inline(always)] // this disables target-feature inheritance || g() - //~^ WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + //~^ WARNING requires the `avx` target feature, which is not enabled in the caller //~| WARNING this was previously accepted by the compiler } fn main() { unsafe { f(g()); - //~^ WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + //~^ WARNING requires the `avx` target feature, which is not enabled in the caller + //~| WARNING requires the `avx` target feature, which is not enabled in the caller //~| WARNING this was previously accepted by the compiler //~| WARNING this was previously accepted by the compiler } unsafe { gavx(favx()); - //~^ WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + //~^ WARNING requires the `avx` target feature, which is not enabled in the caller + //~| WARNING requires the `avx` target feature, which is not enabled in the caller //~| WARNING this was previously accepted by the compiler //~| WARNING this was previously accepted by the compiler } @@ -82,8 +82,8 @@ fn main() { unsafe { w(Wrapper(g())); - //~^ WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + //~^ WARNING requires the `avx` target feature, which is not enabled in the caller + //~| WARNING requires the `avx` target feature, which is not enabled in the caller //~| WARNING this was previously accepted by the compiler //~| WARNING this was previously accepted by the compiler } @@ -98,7 +98,7 @@ fn main() { fn some_extern() -> __m256; } some_extern(); - //~^ WARNING this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + //~^ WARNING requires the `avx` target feature, which is not enabled in the caller //~| WARNING this was previously accepted by the compiler } } diff --git a/tests/ui/simd-abi-checks.stderr b/tests/ui/simd-abi-checks.stderr index eb7d9e81029..a849993a166 100644 --- a/tests/ui/simd-abi-checks.stderr +++ b/tests/ui/simd-abi-checks.stderr @@ -1,4 +1,4 @@ -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:64:11 | LL | f(g()); @@ -9,7 +9,7 @@ LL | f(g()); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) = note: `#[warn(abi_unsupported_vector_types)]` on by default -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:64:9 | LL | f(g()); @@ -19,7 +19,7 @@ LL | f(g()); = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:72:14 | LL | gavx(favx()); @@ -29,7 +29,7 @@ LL | gavx(favx()); = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:72:9 | LL | gavx(favx()); @@ -39,7 +39,7 @@ LL | gavx(favx()); = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:84:19 | LL | w(Wrapper(g())); @@ -49,7 +49,7 @@ LL | w(Wrapper(g())); = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:84:9 | LL | w(Wrapper(g())); @@ -59,7 +59,7 @@ LL | w(Wrapper(g())); = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:100:9 | LL | some_extern(); @@ -69,7 +69,7 @@ LL | some_extern(); = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled +warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled --> $DIR/simd-abi-checks.rs:27:1 | LL | unsafe extern "C" fn g() -> __m256 { @@ -79,7 +79,7 @@ LL | unsafe extern "C" fn g() -> __m256 { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled +warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled --> $DIR/simd-abi-checks.rs:21:1 | LL | unsafe extern "C" fn f(_: __m256) { @@ -89,7 +89,7 @@ LL | unsafe extern "C" fn f(_: __m256) { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled +warning: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled --> $DIR/simd-abi-checks.rs:15:1 | LL | unsafe extern "C" fn w(_: Wrapper) { @@ -99,7 +99,7 @@ LL | unsafe extern "C" fn w(_: Wrapper) { = note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:57:8 | LL | || g() @@ -112,7 +112,7 @@ LL | || g() warning: 11 warnings emitted Future incompatibility report: Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:64:11 | LL | f(g()); @@ -124,7 +124,7 @@ LL | f(g()); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:64:9 | LL | f(g()); @@ -136,7 +136,7 @@ LL | f(g()); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:72:14 | LL | gavx(favx()); @@ -148,7 +148,7 @@ LL | gavx(favx()); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:72:9 | LL | gavx(favx()); @@ -160,7 +160,7 @@ LL | gavx(favx()); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:84:19 | LL | w(Wrapper(g())); @@ -172,7 +172,7 @@ LL | w(Wrapper(g())); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:84:9 | LL | w(Wrapper(g())); @@ -184,7 +184,7 @@ LL | w(Wrapper(g())); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:100:9 | LL | some_extern(); @@ -196,7 +196,7 @@ LL | some_extern(); = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled +warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled --> $DIR/simd-abi-checks.rs:27:1 | LL | unsafe extern "C" fn g() -> __m256 { @@ -208,7 +208,7 @@ LL | unsafe extern "C" fn g() -> __m256 { = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled +warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled --> $DIR/simd-abi-checks.rs:21:1 | LL | unsafe extern "C" fn f(_: __m256) { @@ -220,7 +220,7 @@ LL | unsafe extern "C" fn f(_: __m256) { = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled +warning: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled --> $DIR/simd-abi-checks.rs:15:1 | LL | unsafe extern "C" fn w(_: Wrapper) { @@ -232,7 +232,7 @@ LL | unsafe extern "C" fn w(_: Wrapper) { = note: `#[warn(abi_unsupported_vector_types)]` on by default Future breakage diagnostic: -warning: this function call uses a SIMD vector type that (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller +warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller --> $DIR/simd-abi-checks.rs:57:8 | LL | || g() diff --git a/tests/ui/sse-abi-checks.rs b/tests/ui/sse-abi-checks.rs index d400e6eb698..3c9fe1f0ddb 100644 --- a/tests/ui/sse-abi-checks.rs +++ b/tests/ui/sse-abi-checks.rs @@ -19,6 +19,6 @@ pub struct SseVector([i64; 2]); #[no_mangle] pub unsafe extern "C" fn f(_: SseVector) { - //~^ this function definition uses a SIMD vector type that (with the chosen ABI) requires the `sse` target feature, which is not enabled + //~^ this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled //~| WARNING this was previously accepted by the compiler } diff --git a/tests/ui/sse-abi-checks.stderr b/tests/ui/sse-abi-checks.stderr index e08b2d4e191..712322a5848 100644 --- a/tests/ui/sse-abi-checks.stderr +++ b/tests/ui/sse-abi-checks.stderr @@ -1,4 +1,4 @@ -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `sse` target feature, which is not enabled +warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled --> $DIR/sse-abi-checks.rs:21:1 | LL | pub unsafe extern "C" fn f(_: SseVector) { @@ -12,7 +12,7 @@ LL | pub unsafe extern "C" fn f(_: SseVector) { warning: 1 warning emitted Future incompatibility report: Future breakage diagnostic: -warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `sse` target feature, which is not enabled +warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled --> $DIR/sse-abi-checks.rs:21:1 | LL | pub unsafe extern "C" fn f(_: SseVector) { diff --git a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.fixed b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.fixed new file mode 100644 index 00000000000..f5dbf0c8b6f --- /dev/null +++ b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.fixed @@ -0,0 +1,15 @@ +//@ run-rustfix + +use std::fmt; + +struct Hello; + +impl fmt::Display for Hello { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { //~ ERROR path separator must be a double colon + write!(f, "hello") + } +} + +fn main() { + let _ = Hello; +} diff --git a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.rs b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.rs new file mode 100644 index 00000000000..c41880a26f6 --- /dev/null +++ b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.rs @@ -0,0 +1,15 @@ +//@ run-rustfix + +use std::fmt; + +struct Hello; + +impl fmt::Display for Hello { + fn fmt(&self, f: &mut fmt:Formatter) -> fmt::Result { //~ ERROR path separator must be a double colon + write!(f, "hello") + } +} + +fn main() { + let _ = Hello; +} diff --git a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.stderr b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.stderr new file mode 100644 index 00000000000..92947e3b177 --- /dev/null +++ b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.stderr @@ -0,0 +1,14 @@ +error: path separator must be a double colon + --> $DIR/argument-list-from-path-sep-error-129273.rs:8:30 + | +LL | fn fmt(&self, f: &mut fmt:Formatter) -> fmt::Result { + | ^ + | + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> +help: use a double colon instead + | +LL | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + | + + +error: aborting due to 1 previous error + diff --git a/tests/ui/suggestions/struct-field-type-including-single-colon.rs b/tests/ui/suggestions/struct-field-type-including-single-colon.rs index b7ad6d996f1..a3111028895 100644 --- a/tests/ui/suggestions/struct-field-type-including-single-colon.rs +++ b/tests/ui/suggestions/struct-field-type-including-single-colon.rs @@ -7,14 +7,14 @@ mod foo { struct Foo { a: foo:A, - //~^ ERROR found single colon in a struct field type path - //~| expected `,`, or `}`, found `:` + //~^ ERROR path separator must be a double colon + //~| ERROR struct `A` is private } struct Bar { b: foo::bar:B, - //~^ ERROR found single colon in a struct field type path - //~| expected `,`, or `}`, found `:` + //~^ ERROR path separator must be a double colon + //~| ERROR module `bar` is private } fn main() {} diff --git a/tests/ui/suggestions/struct-field-type-including-single-colon.stderr b/tests/ui/suggestions/struct-field-type-including-single-colon.stderr index 5ffc5b40849..ce16aca1e14 100644 --- a/tests/ui/suggestions/struct-field-type-including-single-colon.stderr +++ b/tests/ui/suggestions/struct-field-type-including-single-colon.stderr @@ -1,40 +1,53 @@ -error: found single colon in a struct field type path +error: path separator must be a double colon --> $DIR/struct-field-type-including-single-colon.rs:9:11 | LL | a: foo:A, | ^ | -help: write a path separator here + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> +help: use a double colon instead | LL | a: foo::A, | + -error: expected `,`, or `}`, found `:` - --> $DIR/struct-field-type-including-single-colon.rs:9:11 - | -LL | struct Foo { - | --- while parsing this struct -LL | a: foo:A, - | ^ - -error: found single colon in a struct field type path +error: path separator must be a double colon --> $DIR/struct-field-type-including-single-colon.rs:15:16 | LL | b: foo::bar:B, | ^ | -help: write a path separator here + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> +help: use a double colon instead | LL | b: foo::bar::B, | + -error: expected `,`, or `}`, found `:` - --> $DIR/struct-field-type-including-single-colon.rs:15:16 +error[E0603]: struct `A` is private + --> $DIR/struct-field-type-including-single-colon.rs:9:12 + | +LL | a: foo:A, + | ^ private struct + | +note: the struct `A` is defined here + --> $DIR/struct-field-type-including-single-colon.rs:2:5 + | +LL | struct A; + | ^^^^^^^^^ + +error[E0603]: module `bar` is private + --> $DIR/struct-field-type-including-single-colon.rs:15:13 | -LL | struct Bar { - | --- while parsing this struct LL | b: foo::bar:B, - | ^ + | ^^^ - struct `B` is not publicly re-exported + | | + | private module + | +note: the module `bar` is defined here + --> $DIR/struct-field-type-including-single-colon.rs:3:5 + | +LL | mod bar { + | ^^^^^^^ error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0603`. diff --git a/triagebot.toml b/triagebot.toml index 512736b0e8f..31061bd288e 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -962,6 +962,9 @@ message = "This PR changes how LLVM is built. Consider updating src/bootstrap/do [mentions."test/crashes"] message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, please move into the corresponding `ui` subdir and add 'Fixes #<issueNr>' to the PR description to autoclose the issue upon merge." +[mentions."tests/rustdoc-json"] +cc = ["@aDotInTheVoid"] + [mentions."tests/ui/deriving/deriving-all-codegen.stdout"] message = "Changes to the code generated for builtin derived traits." cc = ["@nnethercote"] |
