diff options
Diffstat (limited to 'tests')
140 files changed, 1494 insertions, 905 deletions
diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index 267da060240..90073ff3081 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -1,10 +1,10 @@ -//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 +//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -Clink-dead-code #![crate_type = "lib"] #![feature(fn_align)] // CHECK: align 16 -#[no_mangle] +#[unsafe(no_mangle)] #[align(16)] pub fn fn_align() {} @@ -12,12 +12,12 @@ pub struct A; impl A { // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn method_align(self) {} // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn associated_fn() {} } @@ -25,46 +25,94 @@ impl A { trait T: Sized { fn trait_fn() {} - // CHECK: align 32 - #[align(32)] fn trait_method(self) {} + + #[align(8)] + fn trait_method_inherit_low(self); + + #[align(32)] + fn trait_method_inherit_high(self); + + #[align(32)] + fn trait_method_inherit_default(self) {} + + #[align(4)] + #[align(128)] + #[align(8)] + fn inherit_highest(self) {} } impl T for A { - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_fn + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_fn() {} - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_method + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_method(self) {} -} -impl T for () {} + // The prototype's align is ignored because the align here is higher. + // CHECK-LABEL: trait_method_inherit_low + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_low(self) {} + + // The prototype's align is used because it is higher. + // CHECK-LABEL: trait_method_inherit_high + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_high(self) {} + + // The prototype's align inherited. + // CHECK-LABEL: trait_method_inherit_default + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + fn trait_method_inherit_default(self) {} + + // The prototype's highest align inherited. + // CHECK-LABEL: inherit_highest + // CHECK-SAME: align 128 + #[unsafe(no_mangle)] + #[align(32)] + #[align(64)] + fn inherit_highest(self) {} +} -pub fn foo() { - ().trait_method(); +trait HasDefaultImpl: Sized { + // CHECK-LABEL: inherit_from_default_method + // CHECK-LABEL: inherit_from_default_method + // CHECK-SAME: align 32 + #[align(32)] + fn inherit_from_default_method(self) {} } +pub struct InstantiateDefaultMethods; + +impl HasDefaultImpl for InstantiateDefaultMethods {} + // CHECK-LABEL: align_specified_twice_1 // CHECK-SAME: align 64 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(64)] pub fn align_specified_twice_1() {} // CHECK-LABEL: align_specified_twice_2 // CHECK-SAME: align 128 -#[no_mangle] +#[unsafe(no_mangle)] #[align(128)] #[align(32)] pub fn align_specified_twice_2() {} // CHECK-LABEL: align_specified_twice_3 // CHECK-SAME: align 256 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(256)] pub fn align_specified_twice_3() {} diff --git a/tests/crashes/132882.rs b/tests/crashes/132882.rs deleted file mode 100644 index 6b5e4dba803..00000000000 --- a/tests/crashes/132882.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #132882 - -use std::ops::Add; - -pub trait Numoid -where - for<N: Numoid> &'a Self: Add<Self>, -{ -} - -pub fn compute<N: Numoid>(a: N) -> N { - &a + a -} diff --git a/tests/run-make/short-ice/rmake.rs b/tests/run-make/short-ice/rmake.rs index 483def62fc7..dbe0f692aef 100644 --- a/tests/run-make/short-ice/rmake.rs +++ b/tests/run-make/short-ice/rmake.rs @@ -5,9 +5,12 @@ // See https://github.com/rust-lang/rust/issues/107910 //@ needs-target-std -//@ ignore-i686-pc-windows-msvc -// Reason: the assert_eq! on line 37 fails, almost seems like it missing debug info? -// Haven't been able to reproduce locally, but it happens on CI. +//@ ignore-windows-msvc +// +// - FIXME(#143198): On `i686-pc-windows-msvc`: the assert_eq! on line 37 fails, almost seems like +// it missing debug info? Haven't been able to reproduce locally, but it happens on CI. +// - FIXME(#143198): On `x86_64-pc-windows-msvc`: full backtrace sometimes do not contain matching +// count of short backtrace markers (e.g. 5x end marker, but 3x start marker). use run_make_support::rustc; diff --git a/tests/run-make/used-proc-macro/dep.rs b/tests/run-make/used-proc-macro/dep.rs new file mode 100644 index 00000000000..9f881d926d6 --- /dev/null +++ b/tests/run-make/used-proc-macro/dep.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +#[used] +static VERY_IMPORTANT_SYMBOL: u32 = 12345; diff --git a/tests/run-make/used-proc-macro/proc_macro.rs b/tests/run-make/used-proc-macro/proc_macro.rs new file mode 100644 index 00000000000..af592ea0c7e --- /dev/null +++ b/tests/run-make/used-proc-macro/proc_macro.rs @@ -0,0 +1,3 @@ +#![crate_type = "proc-macro"] + +extern crate dep as _; diff --git a/tests/run-make/used-proc-macro/rmake.rs b/tests/run-make/used-proc-macro/rmake.rs new file mode 100644 index 00000000000..58b2760e64d --- /dev/null +++ b/tests/run-make/used-proc-macro/rmake.rs @@ -0,0 +1,18 @@ +// Test that #[used] statics are included in the final dylib for proc-macros too. + +//@ ignore-cross-compile +//@ ignore-windows llvm-readobj --all doesn't show local symbols on Windows +//@ needs-crate-type: proc-macro +//@ ignore-musl (FIXME: can't find `-lunwind`) + +use run_make_support::{dynamic_lib_name, llvm_readobj, rustc}; + +fn main() { + rustc().input("dep.rs").run(); + rustc().input("proc_macro.rs").run(); + llvm_readobj() + .input(dynamic_lib_name("proc_macro")) + .arg("--all") + .run() + .assert_stdout_contains("VERY_IMPORTANT_SYMBOL"); +} diff --git a/tests/rustdoc-json/attrs/link_section_2021.rs b/tests/rustdoc-json/attrs/link_section_2021.rs new file mode 100644 index 00000000000..a1312f4210b --- /dev/null +++ b/tests/rustdoc-json/attrs/link_section_2021.rs @@ -0,0 +1,6 @@ +//@ edition: 2021 +#![no_std] + +//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]' +#[link_section = ".text"] +pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/link_section_2024.rs b/tests/rustdoc-json/attrs/link_section_2024.rs new file mode 100644 index 00000000000..edb028451a8 --- /dev/null +++ b/tests/rustdoc-json/attrs/link_section_2024.rs @@ -0,0 +1,9 @@ +//@ edition: 2024 +#![no_std] + +// Since the 2024 edition the link_section attribute must use the unsafe qualification. +// However, the unsafe qualification is not shown by rustdoc. + +//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]' +#[unsafe(link_section = ".text")] +pub extern "C" fn example() {} diff --git a/tests/rustdoc/intra-doc/deps.rs b/tests/rustdoc/intra-doc/deps.rs new file mode 100644 index 00000000000..fd40b8326d0 --- /dev/null +++ b/tests/rustdoc/intra-doc/deps.rs @@ -0,0 +1,23 @@ +// Checks that links to crates are correctly generated and only existing crates +// have a link generated. +// Regression test for <https://github.com/rust-lang/rust/issues/137857>. + +//@ compile-flags: --document-private-items -Z unstable-options +//@ compile-flags: --extern-html-root-url=empty=https://empty.example/ +// This one is to ensure that we don't link to any item we see which has +// an external html root URL unless it actually exists. +//@ compile-flags: --extern-html-root-url=non_existant=https://non-existant.example/ +//@ aux-build: empty.rs + +#![crate_name = "foo"] +#![expect(rustdoc::broken_intra_doc_links)] + +//@ has 'foo/index.html' +//@ has - '//a[@href="https://empty.example/empty/index.html"]' 'empty' +// There should only be one intra doc links, we should not link `non_existant`. +//@ count - '//*[@class="docblock"]//a' 1 +//! [`empty`] +//! +//! [`non_existant`] + +extern crate empty; diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 692c24f0544..64194e72888 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -19,12 +19,6 @@ extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; -use stable_mir::crate_def::CrateDef; -use stable_mir::mir::alloc::GlobalAlloc; -use stable_mir::mir::mono::{Instance, InstanceKind, StaticDef}; -use stable_mir::mir::{Body, TerminatorKind}; -use stable_mir::ty::{Allocation, ConstantKind, RigidTy, TyKind}; -use stable_mir::{CrateItem, CrateItems, ItemKind}; use std::ascii::Char; use std::assert_matches::assert_matches; use std::cmp::{max, min}; @@ -33,6 +27,13 @@ use std::ffi::CStr; use std::io::Write; use std::ops::ControlFlow; +use stable_mir::crate_def::CrateDef; +use stable_mir::mir::Body; +use stable_mir::mir::alloc::GlobalAlloc; +use stable_mir::mir::mono::{Instance, StaticDef}; +use stable_mir::ty::{Allocation, ConstantKind}; +use stable_mir::{CrateItem, CrateItems, ItemKind}; + const CRATE_NAME: &str = "input"; /// This function uses the Stable MIR APIs to get information about the test crate. @@ -44,7 +45,6 @@ fn test_stable_mir() -> ControlFlow<()> { check_len(*get_item(&items, (ItemKind::Static, "LEN")).unwrap()); check_cstr(*get_item(&items, (ItemKind::Static, "C_STR")).unwrap()); check_other_consts(*get_item(&items, (ItemKind::Fn, "other_consts")).unwrap()); - check_type_id(*get_item(&items, (ItemKind::Fn, "check_type_id")).unwrap()); ControlFlow::Continue(()) } @@ -107,7 +107,9 @@ fn check_other_consts(item: CrateItem) { // Instance body will force constant evaluation. let body = Instance::try_from(item).unwrap().body().unwrap(); let assigns = collect_consts(&body); - assert_eq!(assigns.len(), 8); + assert_eq!(assigns.len(), 10); + let mut char_id = None; + let mut bool_id = None; for (name, alloc) in assigns { match name.as_str() { "_max_u128" => { @@ -149,35 +151,21 @@ fn check_other_consts(item: CrateItem) { assert_eq!(max(first, second) as u32, u32::MAX); assert_eq!(min(first, second), 10); } + "_bool_id" => { + bool_id = Some(alloc); + } + "_char_id" => { + char_id = Some(alloc); + } _ => { unreachable!("{name} -- {alloc:?}") } } } -} - -/// Check that we can retrieve the type id of char and bool, and that they have different values. -fn check_type_id(item: CrateItem) { - let body = Instance::try_from(item).unwrap().body().unwrap(); - let mut ids: Vec<u128> = vec![]; - for term in body.blocks.iter().map(|bb| &bb.terminator) { - match &term.kind { - TerminatorKind::Call { func, destination, .. } => { - let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { - unreachable!() - }; - let RigidTy::FnDef(def, args) = ty else { unreachable!() }; - let instance = Instance::resolve(def, &args).unwrap(); - assert_eq!(instance.kind, InstanceKind::Intrinsic); - let dest_ty = destination.ty(body.locals()).unwrap(); - let alloc = instance.try_const_eval(dest_ty).unwrap(); - ids.push(alloc.read_uint().unwrap()); - } - _ => { /* Do nothing */ } - } - } - assert_eq!(ids.len(), 2); - assert_ne!(ids[0], ids[1]); + let bool_id = bool_id.unwrap(); + let char_id = char_id.unwrap(); + // FIXME(stable_mir): add `read_ptr` to `Allocation` + assert_ne!(bool_id, char_id); } /// Collects all the constant assignments. @@ -235,6 +223,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { file, r#" #![feature(core_intrinsics)] + #![expect(internal_features)] use std::intrinsics::type_id; static LEN: usize = 2; @@ -254,11 +243,8 @@ fn generate_input(path: &str) -> std::io::Result<()> { let _ptr = &BAR; let _null_ptr: *const u8 = NULL; let _tuple = TUPLE; - }} - - fn check_type_id() {{ - let _char_id = type_id::<char>(); - let _bool_id = type_id::<bool>(); + let _char_id = const {{ type_id::<char>() }}; + let _bool_id = const {{ type_id::<bool>() }}; }} pub fn main() {{ diff --git a/tests/ui/empty-allocation-non-null.rs b/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs index 45035a42a5f..f4081306c77 100644 --- a/tests/ui/empty-allocation-non-null.rs +++ b/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs @@ -1,3 +1,7 @@ +//! Check that the default global Rust allocator produces non-null Box allocations for ZSTs. +//! +//! See https://github.com/rust-lang/rust/issues/11998 + //@ run-pass pub fn main() { diff --git a/tests/ui/associated-types/unconstrained-lifetime-assoc-type.rs b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.rs new file mode 100644 index 00000000000..2c4af7da921 --- /dev/null +++ b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.rs @@ -0,0 +1,21 @@ +//! Regression test for issue #22077 +//! lifetime parameters must be constrained in associated type definitions + +trait Fun { + type Output; + fn call<'x>(&'x self) -> Self::Output; +} + +struct Holder { + x: String, +} + +impl<'a> Fun for Holder { + //~^ ERROR E0207 + type Output = &'a str; + fn call<'b>(&'b self) -> &'b str { + &self.x[..] + } +} + +fn main() {} diff --git a/tests/ui/impl-unused-rps-in-assoc-type.stderr b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr index ef61fa4be48..15d0820c895 100644 --- a/tests/ui/impl-unused-rps-in-assoc-type.stderr +++ b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr @@ -1,5 +1,5 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-rps-in-assoc-type.rs:11:6 + --> $DIR/unconstrained-lifetime-assoc-type.rs:13:6 | LL | impl<'a> Fun for Holder { | ^^ unconstrained lifetime parameter diff --git a/tests/ui/inline-disallow-on-variant.rs b/tests/ui/attributes/inline-attribute-enum-variant-error.rs index d92a4e8cc8d..305b285d2a4 100644 --- a/tests/ui/inline-disallow-on-variant.rs +++ b/tests/ui/attributes/inline-attribute-enum-variant-error.rs @@ -1,3 +1,5 @@ +//! Test that #[inline] attribute cannot be applied to enum variants + enum Foo { #[inline] //~^ ERROR attribute should be applied diff --git a/tests/ui/inline-disallow-on-variant.stderr b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr index 255f6bc6a19..a4564d8f722 100644 --- a/tests/ui/inline-disallow-on-variant.stderr +++ b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr @@ -1,5 +1,5 @@ error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-disallow-on-variant.rs:2:5 + --> $DIR/inline-attribute-enum-variant-error.rs:4:5 | LL | #[inline] | ^^^^^^^^^ diff --git a/tests/ui/attributes/inline-main.rs b/tests/ui/attributes/inline-main.rs new file mode 100644 index 00000000000..7181ee19b67 --- /dev/null +++ b/tests/ui/attributes/inline-main.rs @@ -0,0 +1,6 @@ +//! Test that #[inline(always)] can be applied to main function + +//@ run-pass + +#[inline(always)] +fn main() {} diff --git a/tests/ui/attributes/inner-attrs-impl-cfg.rs b/tests/ui/attributes/inner-attrs-impl-cfg.rs new file mode 100644 index 00000000000..e7a5cfa9e2f --- /dev/null +++ b/tests/ui/attributes/inner-attrs-impl-cfg.rs @@ -0,0 +1,36 @@ +//! Test inner attributes (#![...]) behavior in impl blocks with cfg conditions. +//! +//! This test verifies that: +//! - Inner attributes can conditionally exclude entire impl blocks +//! - Regular attributes within impl blocks work independently +//! - Attribute parsing doesn't consume too eagerly + +//@ run-pass + +struct Foo; + +impl Foo { + #![cfg(false)] + + fn method(&self) -> bool { + false + } +} + +impl Foo { + #![cfg(not(FALSE))] + + // Check that we don't eat attributes too eagerly. + #[cfg(false)] + fn method(&self) -> bool { + false + } + + fn method(&self) -> bool { + true + } +} + +pub fn main() { + assert!(Foo.method()); +} diff --git a/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs new file mode 100644 index 00000000000..64c31beba28 --- /dev/null +++ b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs @@ -0,0 +1,12 @@ +//! Test that -Z maximal-hir-to-mir-coverage flag is accepted. +//! +//! Original PR: https://github.com/rust-lang/rust/pull/105286 + +//@ compile-flags: -Zmaximal-hir-to-mir-coverage +//@ run-pass + +fn main() { + let x = 1; + let y = x + 1; + println!("{y}"); +} diff --git a/tests/ui/codegen/mono-respects-abi-alignment.rs b/tests/ui/codegen/mono-respects-abi-alignment.rs new file mode 100644 index 00000000000..045d82b761f --- /dev/null +++ b/tests/ui/codegen/mono-respects-abi-alignment.rs @@ -0,0 +1,37 @@ +//! Test that monomorphization correctly distinguishes types with different ABI alignment. +//! +//! On x86_64-linux-gnu and similar platforms, structs get 8-byte "preferred" +//! alignment, but their "ABI" alignment (what actually matters for data layout) +//! is the largest alignment of any field. If monomorphization incorrectly uses +//! "preferred" alignment instead of "ABI" alignment, it might unify types `A` +//! and `B` even though `S<A>` and `S<B>` have field `t` at different offsets, +//! leading to incorrect method dispatch for `unwrap()`. + +//@ run-pass + +#[derive(Copy, Clone)] +struct S<T> { + #[allow(dead_code)] + i: u8, + t: T, +} + +impl<T> S<T> { + fn unwrap(self) -> T { + self.t + } +} + +#[derive(Copy, Clone, PartialEq, Debug)] +struct A((u32, u32)); // Different ABI alignment than B + +#[derive(Copy, Clone, PartialEq, Debug)] +struct B(u64); // Different ABI alignment than A + +pub fn main() { + static CA: S<A> = S { i: 0, t: A((13, 104)) }; + static CB: S<B> = S { i: 0, t: B(31337) }; + + assert_eq!(CA.unwrap(), A((13, 104))); + assert_eq!(CB.unwrap(), B(31337)); +} diff --git a/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs b/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs new file mode 100644 index 00000000000..ba97acec822 --- /dev/null +++ b/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs @@ -0,0 +1,37 @@ +//! Test that opt-level=z produces correct code on Windows MSVC targets. +//! +//! A previously outdated version of LLVM caused compilation failures and +//! generated invalid code on Windows specifically with optimization level `z`. +//! The bug manifested as corrupted base pointers due to incorrect register +//! usage in the generated assembly (e.g., `popl %esi` corrupting local variables). +//! After updating to a more recent LLVM version, this test ensures that +//! compilation and execution both succeed with opt-level=z. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/45034>. + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ only-windows +// Reason: the observed bug only occurred on Windows MSVC targets +//@ run-pass +//@ compile-flags: -C opt-level=z + +#![feature(test)] +extern crate test; + +fn foo(x: i32, y: i32) -> i64 { + (x + y) as i64 +} + +#[inline(never)] +fn bar() { + let _f = Box::new(0); + // This call used to trigger an LLVM bug in opt-level=z where the base + // pointer gets corrupted due to incorrect register allocation + let y: fn(i32, i32) -> i64 = test::black_box(foo); + test::black_box(y(1, 2)); +} + +fn main() { + bar(); +} diff --git a/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs new file mode 100644 index 00000000000..3a110bdad35 --- /dev/null +++ b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs @@ -0,0 +1,9 @@ +//! Regression test checks UI tests without error annotations are detected as failing. +//! +//! This tests that when we forget to use any `//~ ERROR` comments whatsoever, +//! the test doesn't succeed +//! Originally created in https://github.com/rust-lang/rust/pull/56244 + +//@ should-fail + +fn main() {} diff --git a/tests/ui/consts/const-fn-type-name.rs b/tests/ui/consts/const-fn-type-name.rs index 5403c26b979..733ab79b7cd 100644 --- a/tests/ui/consts/const-fn-type-name.rs +++ b/tests/ui/consts/const-fn-type-name.rs @@ -5,7 +5,7 @@ #![allow(dead_code)] const fn type_name_wrapper<T>(_: &T) -> &'static str { - core::intrinsics::type_name::<T>() + const { core::intrinsics::type_name::<T>() } } struct Struct<TA, TB, TC> { diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index ee716c932e8..445dd75f824 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -5,145 +5,145 @@ LL | #![feature(const_fn_trait_ref_impls)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:14:6 + --> $DIR/fn_trait_refs.rs:14:8 | LL | T: [const] Fn<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:14:6 + --> $DIR/fn_trait_refs.rs:14:8 | LL | T: [const] Fn<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:14:6 + --> $DIR/fn_trait_refs.rs:14:8 | LL | T: [const] Fn<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:21:6 + --> $DIR/fn_trait_refs.rs:21:8 | LL | T: [const] FnMut<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:21:6 + --> $DIR/fn_trait_refs.rs:21:8 | LL | T: [const] FnMut<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:21:6 + --> $DIR/fn_trait_refs.rs:21:8 | LL | T: [const] FnMut<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:28:6 + --> $DIR/fn_trait_refs.rs:28:8 | LL | T: [const] FnOnce<()>, - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:28:6 + --> $DIR/fn_trait_refs.rs:28:8 | LL | T: [const] FnOnce<()>, - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:28:6 + --> $DIR/fn_trait_refs.rs:28:8 | LL | T: [const] FnOnce<()>, - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:35:6 + --> $DIR/fn_trait_refs.rs:35:8 | LL | T: [const] Fn<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:35:6 + --> $DIR/fn_trait_refs.rs:35:8 | LL | T: [const] Fn<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:35:6 + --> $DIR/fn_trait_refs.rs:35:8 | LL | T: [const] Fn<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:49:6 + --> $DIR/fn_trait_refs.rs:49:8 | LL | T: [const] FnMut<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:49:6 + --> $DIR/fn_trait_refs.rs:49:8 | LL | T: [const] FnMut<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/fn_trait_refs.rs:49:6 + --> $DIR/fn_trait_refs.rs:49:8 | LL | T: [const] FnMut<()> + [const] Destruct, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index b43fa1f7e6c..95e48b7b7c8 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,17 +1,17 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/unstable-const-fn-in-libcore.rs:19:30 + --> $DIR/unstable-const-fn-in-libcore.rs:19:32 | LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/unstable-const-fn-in-libcore.rs:19:30 + --> $DIR/unstable-const-fn-in-libcore.rs:19:32 | LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/derives/derive-Debug-enum-variants.rs b/tests/ui/derives/derive-Debug-enum-variants.rs new file mode 100644 index 00000000000..26f527f7664 --- /dev/null +++ b/tests/ui/derives/derive-Debug-enum-variants.rs @@ -0,0 +1,30 @@ +//! Test that `#[derive(Debug)]` for enums correctly formats variant names. + +//@ run-pass + +#[derive(Debug)] +enum Foo { + A(usize), + C, +} + +#[derive(Debug)] +enum Bar { + D, +} + +pub fn main() { + // Test variant with data + let foo_a = Foo::A(22); + assert_eq!("A(22)".to_string(), format!("{:?}", foo_a)); + + if let Foo::A(value) = foo_a { + println!("Value: {}", value); // This needs to remove #[allow(dead_code)] + } + + // Test unit variant + assert_eq!("C".to_string(), format!("{:?}", Foo::C)); + + // Test unit variant from different enum + assert_eq!("D".to_string(), format!("{:?}", Bar::D)); +} diff --git a/tests/ui/diverging-fn-tail-35849.rs b/tests/ui/diverging-fn-tail-35849.rs deleted file mode 100644 index f21ce2973e9..00000000000 --- a/tests/ui/diverging-fn-tail-35849.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn assert_sizeof() -> ! { - unsafe { - ::std::mem::transmute::<f64, [u8; 8]>(panic!()) - //~^ ERROR mismatched types - } -} - -fn main() { } diff --git a/tests/ui/early-ret-binop-add.rs b/tests/ui/early-ret-binop-add.rs deleted file mode 100644 index 3fec66f35fb..00000000000 --- a/tests/ui/early-ret-binop-add.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#![allow(unreachable_code)] - -use std::ops::Add; - -fn wsucc<T:Add<Output=T> + Copy>(n: T) -> T { n + { return n } } - -pub fn main() { } diff --git a/tests/ui/elide-errors-on-mismatched-tuple.rs b/tests/ui/elide-errors-on-mismatched-tuple.rs deleted file mode 100644 index 7d87b0a7756..00000000000 --- a/tests/ui/elide-errors-on-mismatched-tuple.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Hide irrelevant E0277 errors (#50333) - -trait T {} - -struct A; -impl T for A {} -impl A { - fn new() -> Self { - Self {} - } -} - -fn main() { - let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three - //~^ ERROR mismatched types - let ts: Vec<&dyn T> = vec![&a, &b, &c]; - // There is no E0277 error above, as `a`, `b` and `c` are `TyErr` -} diff --git a/tests/ui/elided-test.rs b/tests/ui/elided-test.rs deleted file mode 100644 index 2bedc25e17b..00000000000 --- a/tests/ui/elided-test.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Since we're not compiling a test runner this function should be elided -// and the build will fail because main doesn't exist -#[test] -fn main() { -} //~ ERROR `main` function not found in crate `elided_test` diff --git a/tests/ui/elided-test.stderr b/tests/ui/elided-test.stderr deleted file mode 100644 index 7aebe5d8264..00000000000 --- a/tests/ui/elided-test.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0601]: `main` function not found in crate `elided_test` - --> $DIR/elided-test.rs:5:2 - | -LL | } - | ^ consider adding a `main` function to `$DIR/elided-test.rs` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0601`. diff --git a/tests/ui/else-if.rs b/tests/ui/else-if.rs deleted file mode 100644 index 2161b28c58c..00000000000 --- a/tests/ui/else-if.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -pub fn main() { - if 1 == 2 { - assert!((false)); - } else if 2 == 3 { - assert!((false)); - } else if 3 == 4 { assert!((false)); } else { assert!((true)); } - if 1 == 2 { assert!((false)); } else if 2 == 2 { assert!((true)); } - if 1 == 2 { - assert!((false)); - } else if 2 == 2 { - if 1 == 1 { - assert!((true)); - } else { if 2 == 1 { assert!((false)); } else { assert!((false)); } } - } - if 1 == 2 { - assert!((false)); - } else { if 1 == 2 { assert!((false)); } else { assert!((true)); } } -} diff --git a/tests/ui/expr/early-return-in-binop.rs b/tests/ui/expr/early-return-in-binop.rs new file mode 100644 index 00000000000..389d25210f7 --- /dev/null +++ b/tests/ui/expr/early-return-in-binop.rs @@ -0,0 +1,19 @@ +//! Test early return within binary operation expressions + +//@ run-pass + +#![allow(dead_code)] +#![allow(unreachable_code)] + +use std::ops::Add; + +/// Function that performs addition with an early return in the right operand +fn add_with_early_return<T: Add<Output = T> + Copy>(n: T) -> T { + n + { return n } +} + +pub fn main() { + // Test with different numeric types to ensure generic behavior works + let _result1 = add_with_early_return(42i32); + let _result2 = add_with_early_return(3.14f64); +} diff --git a/tests/ui/extern/issue-47725.rs b/tests/ui/extern/issue-47725.rs index 9ec55be5872..012673b9159 100644 --- a/tests/ui/extern/issue-47725.rs +++ b/tests/ui/extern/issue-47725.rs @@ -17,12 +17,9 @@ extern "C" { #[link_name] //~^ ERROR malformed `link_name` attribute input //~| HELP must be of the form -//~| WARN attribute should be applied to a foreign function or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -//~| HELP try `#[link(name = "...")]` instead +//~| NOTE expected this to be of the form `link_name = "..." extern "C" { fn bar() -> u32; } -//~^^^ NOTE not a foreign function or static fn main() {} diff --git a/tests/ui/extern/issue-47725.stderr b/tests/ui/extern/issue-47725.stderr index 0d3b77b4608..53d6b4927f8 100644 --- a/tests/ui/extern/issue-47725.stderr +++ b/tests/ui/extern/issue-47725.stderr @@ -1,8 +1,11 @@ -error: malformed `link_name` attribute input +error[E0539]: malformed `link_name` attribute input --> $DIR/issue-47725.rs:17:1 | LL | #[link_name] - | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` + | ^^^^^^^^^^^^ + | | + | expected this to be of the form `link_name = "..."` + | help: must be of the form: `#[link_name = "name"]` warning: attribute should be applied to a foreign function or static --> $DIR/issue-47725.rs:3:1 @@ -38,23 +41,6 @@ help: try `#[link(name = "foobar")]` instead LL | #[link_name = "foobar"] | ^^^^^^^^^^^^^^^^^^^^^^^ -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-47725.rs:17:1 - | -LL | #[link_name] - | ^^^^^^^^^^^^ -... -LL | / extern "C" { -LL | | fn bar() -> u32; -LL | | } - | |_- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -help: try `#[link(name = "...")]` instead - --> $DIR/issue-47725.rs:17:1 - | -LL | #[link_name] - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error; 3 warnings emitted +error: aborting due to 1 previous error; 2 warnings emitted +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index d2b1d71ab87..02b9e2f06ee 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -387,6 +387,14 @@ LL | #![link()] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 + | +LL | #![cold] + | ^^^^^^^^ cannot be applied to crates + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + warning: attribute should be applied to a foreign function or static --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 | @@ -403,14 +411,6 @@ LL | #![link_section = "1800"] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 - | -LL | #![cold] - | ^^^^^^^^ cannot be applied to crates - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - warning: `#[must_use]` has no effect when applied to a module --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 | diff --git a/tests/ui/logging-only-prints-once.rs b/tests/ui/fmt/debug-single-call.rs index bb8c29694b5..b59a766c71a 100644 --- a/tests/ui/logging-only-prints-once.rs +++ b/tests/ui/fmt/debug-single-call.rs @@ -1,9 +1,12 @@ +//! Test that Debug::fmt is called exactly once during formatting. +//! +//! This is a regression test for PR https://github.com/rust-lang/rust/pull/10715 + //@ run-pass //@ needs-threads use std::cell::Cell; -use std::fmt; -use std::thread; +use std::{fmt, thread}; struct Foo(Cell<isize>); diff --git a/tests/ui/generics/unconstrained-type-params-inherent-impl.rs b/tests/ui/generics/unconstrained-type-params-inherent-impl.rs new file mode 100644 index 00000000000..c971de0d1f2 --- /dev/null +++ b/tests/ui/generics/unconstrained-type-params-inherent-impl.rs @@ -0,0 +1,32 @@ +//! Test for unconstrained type parameters in inherent implementations + +struct MyType; + +struct MyType1<T>(T); + +trait Bar { + type Out; +} + +impl<T> MyType { + //~^ ERROR the type parameter `T` is not constrained + // T is completely unused - this should fail +} + +impl<T> MyType1<T> { + // OK: T is used in the self type `MyType1<T>` +} + +impl<T, U> MyType1<T> { + //~^ ERROR the type parameter `U` is not constrained + // T is used in self type, but U is unconstrained - this should fail +} + +impl<T, U> MyType1<T> +where + T: Bar<Out = U>, +{ + // OK: T is used in self type, U is constrained through the where clause +} + +fn main() {} diff --git a/tests/ui/impl-unused-tps-inherent.stderr b/tests/ui/generics/unconstrained-type-params-inherent-impl.stderr index 43f63cf968c..19b02ad396c 100644 --- a/tests/ui/impl-unused-tps-inherent.stderr +++ b/tests/ui/generics/unconstrained-type-params-inherent-impl.stderr @@ -1,14 +1,14 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps-inherent.rs:9:6 + --> $DIR/unconstrained-type-params-inherent-impl.rs:11:6 | LL | impl<T> MyType { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps-inherent.rs:17:8 + --> $DIR/unconstrained-type-params-inherent-impl.rs:20:9 | -LL | impl<T,U> MyType1<T> { - | ^ unconstrained type parameter +LL | impl<T, U> MyType1<T> { + | ^ unconstrained type parameter error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 01427c78dd9..e17737d1860 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,17 +1,17 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/normalize-tait-in-const.rs:27:33 + --> $DIR/normalize-tait-in-const.rs:27:35 | LL | const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) { - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/normalize-tait-in-const.rs:27:33 + --> $DIR/normalize-tait-in-const.rs:27:35 | LL | const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) { - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/impl-unused-rps-in-assoc-type.rs b/tests/ui/impl-unused-rps-in-assoc-type.rs deleted file mode 100644 index ea41997a698..00000000000 --- a/tests/ui/impl-unused-rps-in-assoc-type.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Test that lifetime parameters must be constrained if they appear in -// an associated type def'n. Issue #22077. - -trait Fun { - type Output; - fn call<'x>(&'x self) -> Self::Output; -} - -struct Holder { x: String } - -impl<'a> Fun for Holder { //~ ERROR E0207 - type Output = &'a str; - fn call<'b>(&'b self) -> &'b str { - &self.x[..] - } -} - -fn main() { } diff --git a/tests/ui/impl-unused-tps-inherent.rs b/tests/ui/impl-unused-tps-inherent.rs deleted file mode 100644 index 83a228e551a..00000000000 --- a/tests/ui/impl-unused-tps-inherent.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct MyType; - -struct MyType1<T>(T); - -trait Bar { - type Out; -} - -impl<T> MyType { - //~^ ERROR the type parameter `T` is not constrained -} - -impl<T> MyType1<T> { - // OK, T is used in `Foo<T>`. -} - -impl<T,U> MyType1<T> { - //~^ ERROR the type parameter `U` is not constrained -} - -impl<T,U> MyType1<T> where T: Bar<Out=U> { - // OK, T is used in `Foo<T>`. -} - -fn main() { } diff --git a/tests/ui/implicit-method-bind.rs b/tests/ui/implicit-method-bind.rs deleted file mode 100644 index 5e27516a89a..00000000000 --- a/tests/ui/implicit-method-bind.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - let _f = 10i32.abs; //~ ERROR attempted to take value of method -} diff --git a/tests/ui/implicit-method-bind.stderr b/tests/ui/implicit-method-bind.stderr deleted file mode 100644 index e9357113f36..00000000000 --- a/tests/ui/implicit-method-bind.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0615]: attempted to take value of method `abs` on type `i32` - --> $DIR/implicit-method-bind.rs:2:20 - | -LL | let _f = 10i32.abs; - | ^^^ method, not a field - | -help: use parentheses to call the method - | -LL | let _f = 10i32.abs(); - | ++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/double-type-import.rs b/tests/ui/imports/duplicate-use-bindings.rs index 6b1eb65d5ae..8cec23ea732 100644 --- a/tests/ui/double-type-import.rs +++ b/tests/ui/imports/duplicate-use-bindings.rs @@ -1,3 +1,5 @@ +//! Test that duplicate use bindings in same namespace produce error + mod foo { pub use self::bar::X; use self::bar::X; diff --git a/tests/ui/double-type-import.stderr b/tests/ui/imports/duplicate-use-bindings.stderr index 8a8fe05ec19..1d4f1fc82db 100644 --- a/tests/ui/double-type-import.stderr +++ b/tests/ui/imports/duplicate-use-bindings.stderr @@ -1,5 +1,5 @@ error[E0252]: the name `X` is defined multiple times - --> $DIR/double-type-import.rs:3:9 + --> $DIR/duplicate-use-bindings.rs:5:9 | LL | pub use self::bar::X; | ------------ previous import of the type `X` here diff --git a/tests/ui/integral-indexing.rs b/tests/ui/indexing/indexing-integral-types.rs index e20553af8a2..a91696a6fd5 100644 --- a/tests/ui/integral-indexing.rs +++ b/tests/ui/indexing/indexing-integral-types.rs @@ -1,16 +1,20 @@ +//! Test that only usize can be used for indexing arrays and slices. + pub fn main() { let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5]; let s: String = "abcdef".to_string(); + + // Valid indexing with usize v[3_usize]; v[3]; - v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` - v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` + v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` + v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` v[3u32]; //~ ERROR the type `[isize]` cannot be indexed by `u32` v[3i32]; //~ ERROR the type `[isize]` cannot be indexed by `i32` s.as_bytes()[3_usize]; s.as_bytes()[3]; - s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` - s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` + s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` + s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` s.as_bytes()[3u32]; //~ ERROR the type `[u8]` cannot be indexed by `u32` s.as_bytes()[3i32]; //~ ERROR the type `[u8]` cannot be indexed by `i32` } diff --git a/tests/ui/integral-indexing.stderr b/tests/ui/indexing/indexing-integral-types.stderr index 26253e078cb..b63991ec2c4 100644 --- a/tests/ui/integral-indexing.stderr +++ b/tests/ui/indexing/indexing-integral-types.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `[isize]` cannot be indexed by `u8` - --> $DIR/integral-indexing.rs:6:7 + --> $DIR/indexing-integral-types.rs:10:7 | LL | v[3u8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -11,7 +11,7 @@ LL | v[3u8]; = note: required for `Vec<isize>` to implement `Index<u8>` error[E0277]: the type `[isize]` cannot be indexed by `i8` - --> $DIR/integral-indexing.rs:7:7 + --> $DIR/indexing-integral-types.rs:11:7 | LL | v[3i8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -23,7 +23,7 @@ LL | v[3i8]; = note: required for `Vec<isize>` to implement `Index<i8>` error[E0277]: the type `[isize]` cannot be indexed by `u32` - --> $DIR/integral-indexing.rs:8:7 + --> $DIR/indexing-integral-types.rs:12:7 | LL | v[3u32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -35,7 +35,7 @@ LL | v[3u32]; = note: required for `Vec<isize>` to implement `Index<u32>` error[E0277]: the type `[isize]` cannot be indexed by `i32` - --> $DIR/integral-indexing.rs:9:7 + --> $DIR/indexing-integral-types.rs:13:7 | LL | v[3i32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -47,7 +47,7 @@ LL | v[3i32]; = note: required for `Vec<isize>` to implement `Index<i32>` error[E0277]: the type `[u8]` cannot be indexed by `u8` - --> $DIR/integral-indexing.rs:12:18 + --> $DIR/indexing-integral-types.rs:16:18 | LL | s.as_bytes()[3u8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -59,7 +59,7 @@ LL | s.as_bytes()[3u8]; = note: required for `[u8]` to implement `Index<u8>` error[E0277]: the type `[u8]` cannot be indexed by `i8` - --> $DIR/integral-indexing.rs:13:18 + --> $DIR/indexing-integral-types.rs:17:18 | LL | s.as_bytes()[3i8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -71,7 +71,7 @@ LL | s.as_bytes()[3i8]; = note: required for `[u8]` to implement `Index<i8>` error[E0277]: the type `[u8]` cannot be indexed by `u32` - --> $DIR/integral-indexing.rs:14:18 + --> $DIR/indexing-integral-types.rs:18:18 | LL | s.as_bytes()[3u32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -83,7 +83,7 @@ LL | s.as_bytes()[3u32]; = note: required for `[u8]` to implement `Index<u32>` error[E0277]: the type `[u8]` cannot be indexed by `i32` - --> $DIR/integral-indexing.rs:15:18 + --> $DIR/indexing-integral-types.rs:19:18 | LL | s.as_bytes()[3i32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` diff --git a/tests/ui/inlined-main.rs b/tests/ui/inlined-main.rs deleted file mode 100644 index 731ac0dddca..00000000000 --- a/tests/ui/inlined-main.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ run-pass - -#[inline(always)] -fn main() {} diff --git a/tests/ui/inner-attrs-on-impl.rs b/tests/ui/inner-attrs-on-impl.rs deleted file mode 100644 index 1dce1cdd261..00000000000 --- a/tests/ui/inner-attrs-on-impl.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass - -struct Foo; - -impl Foo { - #![cfg(false)] - - fn method(&self) -> bool { false } -} - -impl Foo { - #![cfg(not(FALSE))] - - // check that we don't eat attributes too eagerly. - #[cfg(false)] - fn method(&self) -> bool { false } - - fn method(&self) -> bool { true } -} - - -pub fn main() { - assert!(Foo.method()); -} diff --git a/tests/ui/inner-module.rs b/tests/ui/inner-module.rs deleted file mode 100644 index 111f2cab857..00000000000 --- a/tests/ui/inner-module.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -mod inner { - pub mod inner2 { - pub fn hello() { println!("hello, modular world"); } - } - pub fn hello() { inner2::hello(); } -} - -pub fn main() { inner::hello(); inner::inner2::hello(); } diff --git a/tests/ui/inner-static-type-parameter.rs b/tests/ui/inner-static-type-parameter.rs deleted file mode 100644 index a1994e7529c..00000000000 --- a/tests/ui/inner-static-type-parameter.rs +++ /dev/null @@ -1,11 +0,0 @@ -// see #9186 - -enum Bar<T> { What } //~ ERROR parameter `T` is never used - -fn foo<T>() { - static a: Bar<T> = Bar::What; -//~^ ERROR can't use generic parameters from outer item -} - -fn main() { -} diff --git a/tests/ui/auxiliary/msvc-data-only-lib.rs b/tests/ui/linkage-attr/auxiliary/msvc-static-data-import-lib.rs index b8a8f905e8b..b8a8f905e8b 100644 --- a/tests/ui/auxiliary/msvc-data-only-lib.rs +++ b/tests/ui/linkage-attr/auxiliary/msvc-static-data-import-lib.rs diff --git a/tests/ui/link-section.rs b/tests/ui/linkage-attr/link-section-placement.rs index a8de8c2e1e7..6a143bfedb4 100644 --- a/tests/ui/link-section.rs +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -1,8 +1,9 @@ +//! Test placement of functions and statics in custom link sections + //@ run-pass // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] - #![allow(non_upper_case_globals)] #[cfg(not(target_vendor = "apple"))] #[link_section = ".moretext"] diff --git a/tests/ui/linkage-attr/msvc-static-data-import.rs b/tests/ui/linkage-attr/msvc-static-data-import.rs new file mode 100644 index 00000000000..e53eb404ef6 --- /dev/null +++ b/tests/ui/linkage-attr/msvc-static-data-import.rs @@ -0,0 +1,18 @@ +//! Test that static data from external crates can be imported on MSVC targets. +//! +//! On Windows MSVC targets, static data from external rlibs must be imported +//! through `__imp_<symbol>` stubs to ensure proper linking. Without this, +//! the linker would fail with "unresolved external symbol" errors when trying +//! to reference static data from another crate. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/26591>. +//! Fixed in <https://github.com/rust-lang/rust/pull/28646>. + +//@ run-pass +//@ aux-build:msvc-static-data-import-lib.rs + +extern crate msvc_static_data_import_lib; + +fn main() { + println!("The answer is {}!", msvc_static_data_import_lib::FOO); +} diff --git a/tests/ui/missing_debug_impls.rs b/tests/ui/lint/missing-debug-implementations-lint.rs index 3abc0706887..8a93f052f9c 100644 --- a/tests/ui/missing_debug_impls.rs +++ b/tests/ui/lint/missing-debug-implementations-lint.rs @@ -1,3 +1,7 @@ +//! Test the `missing_debug_implementations` lint that warns about public types without Debug. +//! +//! See https://github.com/rust-lang/rust/issues/20855 + //@ compile-flags: --crate-type lib #![deny(missing_debug_implementations)] #![allow(unused)] @@ -10,7 +14,6 @@ pub enum A {} //~ ERROR type does not implement `Debug` pub enum B {} pub enum C {} - impl fmt::Debug for C { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Ok(()) @@ -23,15 +26,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug` pub struct Bar; pub struct Baz; - impl fmt::Debug for Baz { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Ok(()) } } +// Private types should not trigger the lint struct PrivateStruct; - enum PrivateEnum {} #[derive(Debug)] diff --git a/tests/ui/missing_debug_impls.stderr b/tests/ui/lint/missing-debug-implementations-lint.stderr index 0538f207b44..288ab981034 100644 --- a/tests/ui/missing_debug_impls.stderr +++ b/tests/ui/lint/missing-debug-implementations-lint.stderr @@ -1,17 +1,17 @@ error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation - --> $DIR/missing_debug_impls.rs:7:1 + --> $DIR/missing-debug-implementations-lint.rs:11:1 | LL | pub enum A {} | ^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/missing_debug_impls.rs:2:9 + --> $DIR/missing-debug-implementations-lint.rs:6:9 | LL | #![deny(missing_debug_implementations)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation - --> $DIR/missing_debug_impls.rs:20:1 + --> $DIR/missing-debug-implementations-lint.rs:23:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/unused/must-use-macros.fixed b/tests/ui/lint/unused/must-use-macros.fixed new file mode 100644 index 00000000000..609d0c6392b --- /dev/null +++ b/tests/ui/lint/unused/must-use-macros.fixed @@ -0,0 +1,60 @@ +// Makes sure the suggestions of the `unused_must_use` lint are not inside +// +// See <https://github.com/rust-lang/rust/issues/143025> + +//@ check-pass +//@ run-rustfix + +#![expect(unused_macros)] +#![warn(unused_must_use)] + +fn main() { + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a == $b + }; + } + + // FIXME(Urgau): For some unknown reason the spans we get are not + // recorded to be from any expansions, preventing us from either + // suggesting in front of the macro or not at all. + // cmp!(1, 1); + } + + { + macro_rules! cmp { + ($a:ident, $b:ident) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + let a = 1; + let b = 1; + let _ = cmp!(a, b); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:expr, $b:expr) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + let _ = cmp!(1, 1); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a.eq(&$b) + }; + } + + let _ = cmp!(1, 1); + //~^ WARN unused return value + //~| SUGGESTION let _ + } +} diff --git a/tests/ui/lint/unused/must-use-macros.rs b/tests/ui/lint/unused/must-use-macros.rs new file mode 100644 index 00000000000..63e246ed374 --- /dev/null +++ b/tests/ui/lint/unused/must-use-macros.rs @@ -0,0 +1,60 @@ +// Makes sure the suggestions of the `unused_must_use` lint are not inside +// +// See <https://github.com/rust-lang/rust/issues/143025> + +//@ check-pass +//@ run-rustfix + +#![expect(unused_macros)] +#![warn(unused_must_use)] + +fn main() { + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a == $b + }; + } + + // FIXME(Urgau): For some unknown reason the spans we get are not + // recorded to be from any expansions, preventing us from either + // suggesting in front of the macro or not at all. + // cmp!(1, 1); + } + + { + macro_rules! cmp { + ($a:ident, $b:ident) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + let a = 1; + let b = 1; + cmp!(a, b); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:expr, $b:expr) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + cmp!(1, 1); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a.eq(&$b) + }; + } + + cmp!(1, 1); + //~^ WARN unused return value + //~| SUGGESTION let _ + } +} diff --git a/tests/ui/lint/unused/must-use-macros.stderr b/tests/ui/lint/unused/must-use-macros.stderr new file mode 100644 index 00000000000..2ad174e10b5 --- /dev/null +++ b/tests/ui/lint/unused/must-use-macros.stderr @@ -0,0 +1,48 @@ +warning: unused comparison that must be used + --> $DIR/must-use-macros.rs:28:17 + | +LL | $a == $b + | ^^^^^^^^ the comparison produces a value +... +LL | cmp!(a, b); + | ---------- in this macro invocation + | +note: the lint level is defined here + --> $DIR/must-use-macros.rs:9:9 + | +LL | #![warn(unused_must_use)] + | ^^^^^^^^^^^^^^^ + = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = cmp!(a, b); + | +++++++ + +warning: unused comparison that must be used + --> $DIR/must-use-macros.rs:41:17 + | +LL | $a == $b + | ^^^^^^^^ the comparison produces a value +... +LL | cmp!(1, 1); + | ---------- in this macro invocation + | + = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = cmp!(1, 1); + | +++++++ + +warning: unused return value of `std::cmp::PartialEq::eq` that must be used + --> $DIR/must-use-macros.rs:56:9 + | +LL | cmp!(1, 1); + | ^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = cmp!(1, 1); + | +++++++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/unused/unused-attr-duplicate.rs b/tests/ui/lint/unused/unused-attr-duplicate.rs index 407af40654e..bf94a42f6e0 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.rs +++ b/tests/ui/lint/unused/unused-attr-duplicate.rs @@ -102,4 +102,10 @@ pub fn no_mangle_test() {} #[used] //~ ERROR unused attribute static FOO: u32 = 0; +#[link_section = ".text"] +//~^ ERROR unused attribute +//~| WARN this was previously accepted +#[link_section = ".bss"] +pub extern "C" fn example() {} + fn main() {} diff --git a/tests/ui/lint/unused/unused-attr-duplicate.stderr b/tests/ui/lint/unused/unused-attr-duplicate.stderr index a18581192ea..feae8528cf7 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.stderr +++ b/tests/ui/lint/unused/unused-attr-duplicate.stderr @@ -90,19 +90,6 @@ LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: unused attribute - --> $DIR/unused-attr-duplicate.rs:86:5 - | -LL | #[link_name = "this_does_not_exist"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:88:5 - | -LL | #[link_name = "rust_dbg_extern_identity_u32"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: unused attribute --> $DIR/unused-attr-duplicate.rs:14:1 | LL | #![crate_name = "unused_attr_duplicate2"] @@ -253,6 +240,19 @@ LL | #[track_caller] | ^^^^^^^^^^^^^^^ error: unused attribute + --> $DIR/unused-attr-duplicate.rs:86:5 + | +LL | #[link_name = "this_does_not_exist"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:88:5 + | +LL | #[link_name = "rust_dbg_extern_identity_u32"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute --> $DIR/unused-attr-duplicate.rs:92:1 | LL | #[export_name = "exported_symbol_name"] @@ -289,5 +289,18 @@ note: attribute also specified here LL | #[used] | ^^^^^^^ -error: aborting due to 23 previous errors +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:105:1 + | +LL | #[link_section = ".text"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:108:1 + | +LL | #[link_section = ".bss"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: aborting due to 24 previous errors diff --git a/tests/ui/log-err-phi.rs b/tests/ui/log-err-phi.rs deleted file mode 100644 index 1bb97758782..00000000000 --- a/tests/ui/log-err-phi.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -pub fn main() { - if false { - println!("{}", "foobar"); - } -} diff --git a/tests/ui/log-knows-the-names-of-variants.rs b/tests/ui/log-knows-the-names-of-variants.rs deleted file mode 100644 index cb82cb4878a..00000000000 --- a/tests/ui/log-knows-the-names-of-variants.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#[derive(Debug)] -enum foo { - a(usize), - b(String), - c, -} - -#[derive(Debug)] -enum bar { - d, e, f -} - -pub fn main() { - assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22))); - assert_eq!("c".to_string(), format!("{:?}", foo::c)); - assert_eq!("d".to_string(), format!("{:?}", bar::d)); -} diff --git a/tests/ui/loud_ui.rs b/tests/ui/loud_ui.rs deleted file mode 100644 index 2a73e49e172..00000000000 --- a/tests/ui/loud_ui.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ should-fail - -// this test ensures that when we forget to use -// any `//~ ERROR` comments whatsoever, that the test doesn't succeed - -fn main() {} diff --git a/tests/ui/macros/must-use-in-macro-55516.stderr b/tests/ui/macros/must-use-in-macro-55516.stderr index 7bf4aaab51c..b93d40d7e5a 100644 --- a/tests/ui/macros/must-use-in-macro-55516.stderr +++ b/tests/ui/macros/must-use-in-macro-55516.stderr @@ -7,7 +7,10 @@ LL | write!(&mut example, "{}", 42); = note: this `Result` may be an `Err` variant, which should be handled = note: `-W unused-must-use` implied by `-W unused` = help: to override `-W unused` add `#[allow(unused_must_use)]` - = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = write!(&mut example, "{}", 42); + | +++++++ warning: 1 warning emitted diff --git a/tests/ui/maximal_mir_to_hir_coverage.rs b/tests/ui/maximal_mir_to_hir_coverage.rs deleted file mode 100644 index e57c83d007e..00000000000 --- a/tests/ui/maximal_mir_to_hir_coverage.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Zmaximal-hir-to-mir-coverage -//@ run-pass - -// Just making sure this flag is accepted and doesn't crash the compiler - -fn main() { - let x = 1; - let y = x + 1; - println!("{y}"); -} diff --git a/tests/ui/maybe-bounds.rs b/tests/ui/maybe-bounds.rs deleted file mode 100644 index 02ed45c656f..00000000000 --- a/tests/ui/maybe-bounds.rs +++ /dev/null @@ -1,9 +0,0 @@ -trait Tr: ?Sized {} -//~^ ERROR `?Trait` is not permitted in supertraits - -type A1 = dyn Tr + (?Sized); -//~^ ERROR `?Trait` is not permitted in trait object types -type A2 = dyn for<'a> Tr + (?Sized); -//~^ ERROR `?Trait` is not permitted in trait object types - -fn main() {} diff --git a/tests/ui/method-output-diff-issue-127263.rs b/tests/ui/method-output-diff-issue-127263.rs deleted file mode 100644 index 85a903e2453..00000000000 --- a/tests/ui/method-output-diff-issue-127263.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn bar() {} -fn foo(x: i32) -> u32 { - 0 -} -fn main() { - let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308] - let f: fn(i32) = foo; //~ ERROR mismatched types [E0308] -} diff --git a/tests/ui/methods/method-missing-call.rs b/tests/ui/methods/method-missing-call.rs deleted file mode 100644 index 7ce1e9a4f1b..00000000000 --- a/tests/ui/methods/method-missing-call.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Tests to make sure that parens are needed for method calls without arguments. -// outputs text to make sure either an anonymous function is provided or -// open-close '()' parens are given - - -struct Point { - x: isize, - y: isize -} -impl Point { - fn new() -> Point { - Point{x:0, y:0} - } - fn get_x(&self) -> isize { - self.x - } -} - -fn main() { - let point: Point = Point::new(); - let px: isize = point - .get_x;//~ ERROR attempted to take value of method `get_x` on type `Point` - - // Ensure the span is useful - let ys = &[1,2,3,4,5,6,7]; - let a = ys.iter() - .map(|x| x) - .filter(|&&x| x == 1) - .filter_map; //~ ERROR attempted to take value of method `filter_map` on type -} diff --git a/tests/ui/methods/method-missing-call.stderr b/tests/ui/methods/method-missing-call.stderr deleted file mode 100644 index bc508461b69..00000000000 --- a/tests/ui/methods/method-missing-call.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0615]: attempted to take value of method `get_x` on type `Point` - --> $DIR/method-missing-call.rs:22:26 - | -LL | .get_x; - | ^^^^^ method, not a field - | -help: use parentheses to call the method - | -LL | .get_x(); - | ++ - -error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-missing-call.rs:27:20: 27:23}>, {closure@$DIR/method-missing-call.rs:28:23: 28:28}>` - --> $DIR/method-missing-call.rs:29:16 - | -LL | .filter_map; - | ^^^^^^^^^^ method, not a field - | -help: use parentheses to call the method - | -LL | .filter_map(_); - | +++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/methods/method-value-without-call.rs b/tests/ui/methods/method-value-without-call.rs new file mode 100644 index 00000000000..43bee4864b4 --- /dev/null +++ b/tests/ui/methods/method-value-without-call.rs @@ -0,0 +1,33 @@ +//! Test taking a method value without parentheses + +struct Point { + x: isize, + y: isize, +} + +impl Point { + fn new() -> Point { + Point { x: 0, y: 0 } + } + + fn get_x(&self) -> isize { + self.x + } +} + +fn main() { + // Test with primitive type method + let _f = 10i32.abs; //~ ERROR attempted to take value of method + + // Test with custom type method + let point: Point = Point::new(); + let px: isize = point.get_x; //~ ERROR attempted to take value of method `get_x` on type `Point` + + // Test with method chains - ensure the span is useful + let ys = &[1, 2, 3, 4, 5, 6, 7]; + let a = ys + .iter() + .map(|x| x) + .filter(|&&x| x == 1) + .filter_map; //~ ERROR attempted to take value of method `filter_map` on type +} diff --git a/tests/ui/methods/method-value-without-call.stderr b/tests/ui/methods/method-value-without-call.stderr new file mode 100644 index 00000000000..0c3870e2868 --- /dev/null +++ b/tests/ui/methods/method-value-without-call.stderr @@ -0,0 +1,36 @@ +error[E0615]: attempted to take value of method `abs` on type `i32` + --> $DIR/method-value-without-call.rs:20:20 + | +LL | let _f = 10i32.abs; + | ^^^ method, not a field + | +help: use parentheses to call the method + | +LL | let _f = 10i32.abs(); + | ++ + +error[E0615]: attempted to take value of method `get_x` on type `Point` + --> $DIR/method-value-without-call.rs:24:27 + | +LL | let px: isize = point.get_x; + | ^^^^^ method, not a field + | +help: use parentheses to call the method + | +LL | let px: isize = point.get_x(); + | ++ + +error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-value-without-call.rs:30:14: 30:17}>, {closure@$DIR/method-value-without-call.rs:31:17: 31:22}>` + --> $DIR/method-value-without-call.rs:32:10 + | +LL | .filter_map; + | ^^^^^^^^^^ method, not a field + | +help: use parentheses to call the method + | +LL | .filter_map(_); + | +++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/mismatched_types/elide-on-tuple-mismatch.rs b/tests/ui/mismatched_types/elide-on-tuple-mismatch.rs new file mode 100644 index 00000000000..c36d041d296 --- /dev/null +++ b/tests/ui/mismatched_types/elide-on-tuple-mismatch.rs @@ -0,0 +1,25 @@ +//! Regression test for issue #50333: elide irrelevant E0277 errors on tuple mismatch + +// Hide irrelevant E0277 errors (#50333) + +trait T {} + +struct A; + +impl T for A {} + +impl A { + fn new() -> Self { + Self {} + } +} + +fn main() { + // This creates a tuple type mismatch: 2-element tuple destructured into 3 variables + let (a, b, c) = (A::new(), A::new()); + //~^ ERROR mismatched types + + // This line should NOT produce an E0277 error about `Sized` trait bounds, + // because `a`, `b`, and `c` are `TyErr` due to the mismatch above + let _ts: Vec<&dyn T> = vec![&a, &b, &c]; +} diff --git a/tests/ui/elide-errors-on-mismatched-tuple.stderr b/tests/ui/mismatched_types/elide-on-tuple-mismatch.stderr index f852a223b42..7de45eb40ca 100644 --- a/tests/ui/elide-errors-on-mismatched-tuple.stderr +++ b/tests/ui/mismatched_types/elide-on-tuple-mismatch.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> $DIR/elide-errors-on-mismatched-tuple.rs:14:9 + --> $DIR/elide-on-tuple-mismatch.rs:19:9 | -LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three +LL | let (a, b, c) = (A::new(), A::new()); | ^^^^^^^^^ -------------------- this expression has type `(A, A)` | | | expected a tuple with 2 elements, found one with 3 elements diff --git a/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs new file mode 100644 index 00000000000..e28ca3e55b5 --- /dev/null +++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs @@ -0,0 +1,16 @@ +//! This test checks that when there's a type mismatch between a function item and +//! a function pointer, the error message focuses on the actual type difference +//! (return types, argument types) rather than the confusing "pointer vs item" distinction. +//! +//! See https://github.com/rust-lang/rust/issues/127263 + +fn bar() {} + +fn foo(x: i32) -> u32 { + 0 +} + +fn main() { + let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308] + let f: fn(i32) = foo; //~ ERROR mismatched types [E0308] +} diff --git a/tests/ui/method-output-diff-issue-127263.stderr b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr index 35b86114f16..8d63f2ea2d3 100644 --- a/tests/ui/method-output-diff-issue-127263.stderr +++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/method-output-diff-issue-127263.rs:6:26 + --> $DIR/fn-pointer-mismatch-diagnostics.rs:14:26 | LL | let b: fn() -> u32 = bar; | ----------- ^^^ expected fn pointer, found fn item @@ -10,7 +10,7 @@ LL | let b: fn() -> u32 = bar; found fn item `fn() -> () {bar}` error[E0308]: mismatched types - --> $DIR/method-output-diff-issue-127263.rs:7:22 + --> $DIR/fn-pointer-mismatch-diagnostics.rs:15:22 | LL | let f: fn(i32) = foo; | ------- ^^^ expected fn pointer, found fn item diff --git a/tests/ui/integral-variable-unification-error.rs b/tests/ui/mismatched_types/int-float-type-mismatch.rs index 8d1621321e8..b45d02730d9 100644 --- a/tests/ui/integral-variable-unification-error.rs +++ b/tests/ui/mismatched_types/int-float-type-mismatch.rs @@ -1,3 +1,6 @@ +//! Check that a type mismatch error is reported when trying +//! to unify a {float} value assignment to an {integer} variable. + fn main() { let mut x //~ NOTE expected due to the type of this binding = diff --git a/tests/ui/integral-variable-unification-error.stderr b/tests/ui/mismatched_types/int-float-type-mismatch.stderr index 1caa6042fd2..43b8609a49d 100644 --- a/tests/ui/integral-variable-unification-error.stderr +++ b/tests/ui/mismatched_types/int-float-type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/integral-variable-unification-error.rs:5:9 + --> $DIR/int-float-type-mismatch.rs:8:9 | LL | let mut x | ----- expected due to the type of this binding diff --git a/tests/ui/mod-subitem-as-enum-variant.rs b/tests/ui/mod-subitem-as-enum-variant.rs deleted file mode 100644 index 959024c46f4..00000000000 --- a/tests/ui/mod-subitem-as-enum-variant.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod Mod { - pub struct FakeVariant<T>(pub T); -} - -fn main() { - Mod::FakeVariant::<i32>(0); - Mod::<i32>::FakeVariant(0); - //~^ ERROR type arguments are not allowed on module `Mod` [E0109] -} diff --git a/tests/ui/modules/nested-modules-basic.rs b/tests/ui/modules/nested-modules-basic.rs new file mode 100644 index 00000000000..12eccec2808 --- /dev/null +++ b/tests/ui/modules/nested-modules-basic.rs @@ -0,0 +1,19 @@ +//! Basic test for nested module functionality and path resolution + +//@ run-pass + +mod inner { + pub mod inner2 { + pub fn hello() { + println!("hello, modular world"); + } + } + pub fn hello() { + inner2::hello(); + } +} + +pub fn main() { + inner::hello(); + inner::inner2::hello(); +} diff --git a/tests/ui/monomorphize-abi-alignment.rs b/tests/ui/monomorphize-abi-alignment.rs deleted file mode 100644 index 62df1aca357..00000000000 --- a/tests/ui/monomorphize-abi-alignment.rs +++ /dev/null @@ -1,35 +0,0 @@ -//@ run-pass - -#![allow(non_upper_case_globals)] -#![allow(dead_code)] -/*! - * On x86_64-linux-gnu and possibly other platforms, structs get 8-byte "preferred" alignment, - * but their "ABI" alignment (i.e., what actually matters for data layout) is the largest alignment - * of any field. (Also, `u64` has 8-byte ABI alignment; this is not always true). - * - * On such platforms, if monomorphize uses the "preferred" alignment, then it will unify - * `A` and `B`, even though `S<A>` and `S<B>` have the field `t` at different offsets, - * and apply the wrong instance of the method `unwrap`. - */ - -#[derive(Copy, Clone)] -struct S<T> { i:u8, t:T } - -impl<T> S<T> { - fn unwrap(self) -> T { - self.t - } -} - -#[derive(Copy, Clone, PartialEq, Debug)] -struct A((u32, u32)); - -#[derive(Copy, Clone, PartialEq, Debug)] -struct B(u64); - -pub fn main() { - static Ca: S<A> = S { i: 0, t: A((13, 104)) }; - static Cb: S<B> = S { i: 0, t: B(31337) }; - assert_eq!(Ca.unwrap(), A((13, 104))); - assert_eq!(Cb.unwrap(), B(31337)); -} diff --git a/tests/ui/msvc-data-only.rs b/tests/ui/msvc-data-only.rs deleted file mode 100644 index 15d799085fe..00000000000 --- a/tests/ui/msvc-data-only.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -//@ aux-build:msvc-data-only-lib.rs - -extern crate msvc_data_only_lib; - -fn main() { - println!("The answer is {} !", msvc_data_only_lib::FOO); -} diff --git a/tests/ui/msvc-opt-minsize.rs b/tests/ui/msvc-opt-minsize.rs deleted file mode 100644 index c1be168a05d..00000000000 --- a/tests/ui/msvc-opt-minsize.rs +++ /dev/null @@ -1,31 +0,0 @@ -// A previously outdated version of LLVM caused compilation failures on Windows -// specifically with optimization level `z`. After the update to a more recent LLVM -// version, this test checks that compilation and execution both succeed. -// See https://github.com/rust-lang/rust/issues/45034 - -//@ ignore-cross-compile -// Reason: the compiled binary is executed -//@ only-windows -// Reason: the observed bug only occurs on Windows -//@ run-pass -//@ compile-flags: -C opt-level=z - -#![feature(test)] -extern crate test; - -fn foo(x: i32, y: i32) -> i64 { - (x + y) as i64 -} - -#[inline(never)] -fn bar() { - let _f = Box::new(0); - // This call used to trigger an LLVM bug in opt-level z where the base - // pointer gets corrupted, see issue #45034 - let y: fn(i32, i32) -> i64 = test::black_box(foo); - test::black_box(y(1, 2)); -} - -fn main() { - bar(); -} diff --git a/tests/ui/multibyte.rs b/tests/ui/multibyte.rs deleted file mode 100644 index d585a791fb9..00000000000 --- a/tests/ui/multibyte.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -// - -// Test that multibyte characters don't crash the compiler -pub fn main() { - println!("마이너스 사인이 없으면"); -} diff --git a/tests/ui/multiline-comment.rs b/tests/ui/multiline-comment.rs deleted file mode 100644 index 98174882032..00000000000 --- a/tests/ui/multiline-comment.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - -/* - * This is a multi-line oldcomment. - */ -pub fn main() { } diff --git a/tests/ui/parser/bounds-type.stderr b/tests/ui/parser/bounds-type.stderr index 0d929c76f02..7c3e92a50da 100644 --- a/tests/ui/parser/bounds-type.stderr +++ b/tests/ui/parser/bounds-type.stderr @@ -21,10 +21,10 @@ LL | T: [const] ?Tr, | there is not a well-defined meaning for a `[const] ?` trait error: `[const]` may only modify trait bounds, not lifetime bounds - --> $DIR/bounds-type.rs:16:6 + --> $DIR/bounds-type.rs:16:8 | LL | T: [const] 'a, - | ^^^^^^^^^ + | ^^^^^^^ error: `const` may only modify trait bounds, not lifetime bounds --> $DIR/bounds-type.rs:17:8 diff --git a/tests/ui/parser/multiline-comments-basic.rs b/tests/ui/parser/multiline-comments-basic.rs new file mode 100644 index 00000000000..1aa2a531f5c --- /dev/null +++ b/tests/ui/parser/multiline-comments-basic.rs @@ -0,0 +1,10 @@ +//! Test that basic multiline comments are parsed correctly. +//! +//! Feature implementation test for <https://github.com/rust-lang/rust/issues/66>. + +//@ run-pass + +/* + * This is a multi-line comment. + */ +pub fn main() {} diff --git a/tests/ui/double-ref.rs b/tests/ui/parser/reference-whitespace-parsing.rs index eecf68ff209..7109c5911ae 100644 --- a/tests/ui/double-ref.rs +++ b/tests/ui/parser/reference-whitespace-parsing.rs @@ -1,3 +1,5 @@ +//! Test parsing of multiple references with various whitespace arrangements + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/parser/unicode-multibyte-chars-no-ice.rs b/tests/ui/parser/unicode-multibyte-chars-no-ice.rs new file mode 100644 index 00000000000..b1bb0c66ae2 --- /dev/null +++ b/tests/ui/parser/unicode-multibyte-chars-no-ice.rs @@ -0,0 +1,9 @@ +//! Test that multibyte Unicode characters don't crash the compiler. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/4780>. + +//@ run-pass + +pub fn main() { + println!("마이너스 사인이 없으면"); +} diff --git a/tests/ui/max-min-classes.rs b/tests/ui/resolve/struct-function-same-name.rs index 338a3156a9a..bb2837d7ca6 100644 --- a/tests/ui/max-min-classes.rs +++ b/tests/ui/resolve/struct-function-same-name.rs @@ -1,3 +1,5 @@ +//! Test that a struct and function can have the same name +//! //@ run-pass #![allow(non_snake_case)] @@ -23,7 +25,7 @@ impl Product for Foo { } fn Foo(x: isize, y: isize) -> Foo { - Foo { x: x, y: y } + Foo { x, y } } pub fn main() { diff --git a/tests/ui/lexical-scoping.rs b/tests/ui/resolve/type-param-local-var-shadowing.rs index f858369f7ce..e08379e2acf 100644 --- a/tests/ui/lexical-scoping.rs +++ b/tests/ui/resolve/type-param-local-var-shadowing.rs @@ -1,8 +1,13 @@ +//! Test that items in subscopes correctly shadow type parameters and local variables +//! +//! Regression test for https://github.com/rust-lang/rust/issues/23880 + //@ run-pass -// Tests that items in subscopes can shadow type parameters and local variables (see issue #23880). #![allow(unused)] -struct Foo<X> { x: Box<X> } +struct Foo<X> { + x: Box<X>, +} impl<Bar> Foo<Bar> { fn foo(&self) { type Bar = i32; diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index 4c28568a739..01fed8537d0 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -85,6 +85,9 @@ fn main() { let r = simd_round(h); assert_eq!(x, r); + let r = simd_round_ties_even(h); + assert_eq!(z, r); + let r = simd_trunc(h); assert_eq!(z, r); } diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index fdf06b7882e..caec607d6fe 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -43,6 +43,10 @@ fn main() { simd_shl(y, y); simd_shr(x, x); simd_shr(y, y); + simd_funnel_shl(x, x, x); + simd_funnel_shl(y, y, y); + simd_funnel_shr(x, x, x); + simd_funnel_shr(y, y, y); simd_and(x, x); simd_and(y, y); simd_or(x, x); @@ -73,6 +77,10 @@ fn main() { //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shr(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_funnel_shl(0, 0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_funnel_shr(0, 0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_and(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_or(0, 0); @@ -95,6 +103,10 @@ fn main() { //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_shr(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_funnel_shl(z, z, z); + //~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_funnel_shr(z, z, z); + //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_and(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_or(z, z); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index 76db6d5328f..a27a8d721fb 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,147 +1,171 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:64:9 + --> $DIR/generic-arithmetic-2.rs:68:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:66:9 + --> $DIR/generic-arithmetic-2.rs:70:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:68:9 + --> $DIR/generic-arithmetic-2.rs:72:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:70:9 + --> $DIR/generic-arithmetic-2.rs:74:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:72:9 + --> $DIR/generic-arithmetic-2.rs:76:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:74:9 + --> $DIR/generic-arithmetic-2.rs:78:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_funnel_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:80:9 + | +LL | simd_funnel_shl(0, 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_funnel_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:82:9 + | +LL | simd_funnel_shr(0, 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:76:9 + --> $DIR/generic-arithmetic-2.rs:84:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:78:9 + --> $DIR/generic-arithmetic-2.rs:86:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:80:9 + --> $DIR/generic-arithmetic-2.rs:88:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:83:9 + --> $DIR/generic-arithmetic-2.rs:91:9 | LL | simd_neg(0); | ^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:85:9 + --> $DIR/generic-arithmetic-2.rs:93:9 | LL | simd_bswap(0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:87:9 + --> $DIR/generic-arithmetic-2.rs:95:9 | LL | simd_bitreverse(0); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:89:9 + --> $DIR/generic-arithmetic-2.rs:97:9 | LL | simd_ctlz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:91:9 + --> $DIR/generic-arithmetic-2.rs:99:9 | LL | simd_cttz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:94:9 + --> $DIR/generic-arithmetic-2.rs:102:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:96:9 + --> $DIR/generic-arithmetic-2.rs:104:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_funnel_shl` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:106:9 + | +LL | simd_funnel_shl(z, z, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_funnel_shr` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:108:9 + | +LL | simd_funnel_shr(z, z, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:98:9 + --> $DIR/generic-arithmetic-2.rs:110:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:100:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:102:9 + --> $DIR/generic-arithmetic-2.rs:114:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:104:9 + --> $DIR/generic-arithmetic-2.rs:116:9 | LL | simd_bswap(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:106:9 + --> $DIR/generic-arithmetic-2.rs:118:9 | LL | simd_bitreverse(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:108:9 + --> $DIR/generic-arithmetic-2.rs:120:9 | LL | simd_ctlz(z); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:110:9 + --> $DIR/generic-arithmetic-2.rs:122:9 | LL | simd_ctpop(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:112:9 + --> $DIR/generic-arithmetic-2.rs:124:9 | LL | simd_cttz(z); | ^^^^^^^^^^^^ -error: aborting due to 24 previous errors +error: aborting due to 28 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index 3f0325d690b..4c97fb2141d 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -83,6 +83,80 @@ fn main() { all_eq!(simd_shr(simd_shl(y1, y2), y2), y1); all_eq!(simd_shr(simd_shl(y2, y1), y1), y2); + all_eq!( + simd_funnel_shl(x1, x2, x1), + i32x4([ + (1 << 1) | (2 >> 31), + (2 << 2) | (3 >> 30), + (3 << 3) | (4 >> 29), + (4 << 4) | (5 >> 28) + ]) + ); + all_eq!( + simd_funnel_shl(x2, x1, x1), + i32x4([ + (2 << 1) | (1 >> 31), + (3 << 2) | (2 >> 30), + (4 << 3) | (3 >> 29), + (5 << 4) | (4 >> 28) + ]) + ); + all_eq!( + simd_funnel_shl(y1, y2, y1), + U32::<4>([ + (1 << 1) | (2 >> 31), + (2 << 2) | (3 >> 30), + (3 << 3) | (4 >> 29), + (4 << 4) | (5 >> 28) + ]) + ); + all_eq!( + simd_funnel_shl(y2, y1, y1), + U32::<4>([ + (2 << 1) | (1 >> 31), + (3 << 2) | (2 >> 30), + (4 << 3) | (3 >> 29), + (5 << 4) | (4 >> 28) + ]) + ); + + all_eq!( + simd_funnel_shr(x1, x2, x1), + i32x4([ + (1 << 31) | (2 >> 1), + (2 << 30) | (3 >> 2), + (3 << 29) | (4 >> 3), + (4 << 28) | (5 >> 4) + ]) + ); + all_eq!( + simd_funnel_shr(x2, x1, x1), + i32x4([ + (2 << 31) | (1 >> 1), + (3 << 30) | (2 >> 2), + (4 << 29) | (3 >> 3), + (5 << 28) | (4 >> 4) + ]) + ); + all_eq!( + simd_funnel_shr(y1, y2, y1), + U32::<4>([ + (1 << 31) | (2 >> 1), + (2 << 30) | (3 >> 2), + (3 << 29) | (4 >> 3), + (4 << 28) | (5 >> 4) + ]) + ); + all_eq!( + simd_funnel_shr(y2, y1, y1), + U32::<4>([ + (2 << 31) | (1 >> 1), + (3 << 30) | (2 >> 2), + (4 << 29) | (3 >> 3), + (5 << 28) | (4 >> 4) + ]) + ); + // ensure we get logical vs. arithmetic shifts correct let (a, b, c, d) = (-12, -123, -1234, -12345); all_eq!(simd_shr(i32x4([a, b, c, d]), x1), i32x4([a >> 1, b >> 2, c >> 3, d >> 4])); diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr index d36a0a1c2dc..ea3ec16ac1e 100644 --- a/tests/ui/specialization/const_trait_impl.stderr +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -1,55 +1,55 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const_trait_impl.rs:34:7 + --> $DIR/const_trait_impl.rs:34:9 | LL | impl<T: [const] Default> const A for T { - | ^^^^^^^^^ can't be applied to `Default` + | ^^^^^^^ can't be applied to `Default` | note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const_trait_impl.rs:40:7 + --> $DIR/const_trait_impl.rs:40:9 | LL | impl<T: [const] Default + [const] Sup> const A for T { - | ^^^^^^^^^ can't be applied to `Default` + | ^^^^^^^ can't be applied to `Default` | note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const_trait_impl.rs:46:7 + --> $DIR/const_trait_impl.rs:46:9 | LL | impl<T: [const] Default + [const] Sub> const A for T { - | ^^^^^^^^^ can't be applied to `Default` + | ^^^^^^^ can't be applied to `Default` | note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const_trait_impl.rs:40:7 + --> $DIR/const_trait_impl.rs:40:9 | LL | impl<T: [const] Default + [const] Sup> const A for T { - | ^^^^^^^^^ can't be applied to `Default` + | ^^^^^^^ can't be applied to `Default` | note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const_trait_impl.rs:34:7 + --> $DIR/const_trait_impl.rs:34:9 | LL | impl<T: [const] Default> const A for T { - | ^^^^^^^^^ can't be applied to `Default` + | ^^^^^^^ can't be applied to `Default` | note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const_trait_impl.rs:46:7 + --> $DIR/const_trait_impl.rs:46:9 | LL | impl<T: [const] Default + [const] Sub> const A for T { - | ^^^^^^^^^ can't be applied to `Default` + | ^^^^^^^ can't be applied to `Default` | note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL diff --git a/tests/ui/statics/static-generic-param-soundness.rs b/tests/ui/statics/static-generic-param-soundness.rs new file mode 100644 index 00000000000..aabcca514d3 --- /dev/null +++ b/tests/ui/statics/static-generic-param-soundness.rs @@ -0,0 +1,20 @@ +//! Originally, inner statics in generic functions were generated only once, causing the same +//! static to be shared across all generic instantiations. This created a soundness hole where +//! different types could be coerced through thread-local storage in safe code. +//! +//! This test checks that generic parameters from outer scopes cannot be used in inner statics, +//! preventing this soundness issue. +//! +//! See https://github.com/rust-lang/rust/issues/9186 + +enum Bar<T> { + //~^ ERROR parameter `T` is never used + What, +} + +fn foo<T>() { + static a: Bar<T> = Bar::What; + //~^ ERROR can't use generic parameters from outer item +} + +fn main() {} diff --git a/tests/ui/inner-static-type-parameter.stderr b/tests/ui/statics/static-generic-param-soundness.stderr index 88d33b44c59..47554c7fcb0 100644 --- a/tests/ui/inner-static-type-parameter.stderr +++ b/tests/ui/statics/static-generic-param-soundness.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/inner-static-type-parameter.rs:6:19 + --> $DIR/static-generic-param-soundness.rs:16:19 | LL | fn foo<T>() { | - type parameter from outer item @@ -9,9 +9,9 @@ LL | static a: Bar<T> = Bar::What; = note: a `static` is a separate item from the item that contains it error[E0392]: type parameter `T` is never used - --> $DIR/inner-static-type-parameter.rs:3:10 + --> $DIR/static-generic-param-soundness.rs:10:10 | -LL | enum Bar<T> { What } +LL | enum Bar<T> { | ^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` diff --git a/tests/ui/stats/macro-stats.rs b/tests/ui/stats/macro-stats.rs index ee265d682fd..d986904ddd6 100644 --- a/tests/ui/stats/macro-stats.rs +++ b/tests/ui/stats/macro-stats.rs @@ -49,12 +49,17 @@ fn opt(x: Option<u32>) { } } -macro_rules! this_is_a_really_really_long_macro_name { +macro_rules! long_name_that_fits_on_a_single_line { + () => {} +} +long_name_that_fits_on_a_single_line!(); + +macro_rules! long_name_that_doesnt_fit_on_one_line { ($t:ty) => { fn f(_: $t) {} } } -this_is_a_really_really_long_macro_name!(u32!()); // AstFragmentKind::{Items,Ty} +long_name_that_doesnt_fit_on_one_line!(u32!()); // AstFragmentKind::{Items,Ty} macro_rules! trait_tys { () => { diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index 00c6b55c6a2..8d0fdb8958a 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -15,12 +15,13 @@ macro-stats #[derive(Copy)] 1 2 2.0 macro-stats p! 1 3 3.0 32 32.0 macro-stats trait_impl_tys! 1 2 2.0 28 28.0 macro-stats foreign_item! 1 1 1.0 21 21.0 -macro-stats this_is_a_really_really_long_macro_name! +macro-stats long_name_that_doesnt_fit_on_one_line! macro-stats 1 1 1.0 18 18.0 macro-stats impl_const! 1 1 1.0 17 17.0 macro-stats trait_tys! 1 2 2.0 15 15.0 macro-stats n99! 2 2 1.0 4 2.0 macro-stats none! 1 1 1.0 4 4.0 macro-stats u32! 1 1 1.0 3 3.0 +macro-stats long_name_that_fits_on_a_single_line! 1 1 1.0 0 0.0 macro-stats #[test] 1 1 1.0 0 0.0 macro-stats =================================================================================== diff --git a/tests/ui/test-attrs/test-function-elided-no-main.rs b/tests/ui/test-attrs/test-function-elided-no-main.rs new file mode 100644 index 00000000000..97654581567 --- /dev/null +++ b/tests/ui/test-attrs/test-function-elided-no-main.rs @@ -0,0 +1,8 @@ +//! Test that #[test] functions are elided when not running tests, causing missing main error + +#[test] +fn main() { + // This function would normally serve as main, but since it's marked with #[test], + // it gets elided when not running tests +} +//~^ ERROR `main` function not found in crate `test_function_elided_no_main` diff --git a/tests/ui/test-attrs/test-function-elided-no-main.stderr b/tests/ui/test-attrs/test-function-elided-no-main.stderr new file mode 100644 index 00000000000..0bae690be2b --- /dev/null +++ b/tests/ui/test-attrs/test-function-elided-no-main.stderr @@ -0,0 +1,9 @@ +error[E0601]: `main` function not found in crate `test_function_elided_no_main` + --> $DIR/test-function-elided-no-main.rs:7:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/test-function-elided-no-main.rs` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr index f450bc6c9ab..ebd816ac9a5 100644 --- a/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/conditionally-const-and-const-params.rs:8:13 + --> $DIR/conditionally-const-and-const-params.rs:8:15 | LL | fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> { - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-and-const-params.rs:8:8 @@ -11,10 +11,10 @@ LL | fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> { | ^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-and-const-params.rs:26:9 + --> $DIR/conditionally-const-and-const-params.rs:26:11 | LL | fn bar<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-and-const-params.rs:26:4 diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr index 62319689861..d0dd9502915 100644 --- a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:7:24 + --> $DIR/conditionally-const-invalid-places.rs:7:26 | LL | fn non_const_function<T: [const] Trait>() {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:7:4 @@ -11,66 +11,66 @@ LL | fn non_const_function<T: [const] Trait>() {} | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:9:16 + --> $DIR/conditionally-const-invalid-places.rs:9:18 | LL | struct Struct<T: [const] Trait> { field: T } - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:10:21 + --> $DIR/conditionally-const-invalid-places.rs:10:23 | LL | struct TupleStruct<T: [const] Trait>(T); - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:11:20 + --> $DIR/conditionally-const-invalid-places.rs:11:22 | LL | struct UnitStruct<T: [const] Trait>; - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:14:12 + --> $DIR/conditionally-const-invalid-places.rs:14:14 | LL | enum Enum<T: [const] Trait> { Variant(T) } - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:16:14 + --> $DIR/conditionally-const-invalid-places.rs:16:16 | LL | union Union<T: [const] Trait> { field: T } - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:19:12 + --> $DIR/conditionally-const-invalid-places.rs:19:14 | LL | type Type<T: [const] Trait> = T; - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:21:17 + --> $DIR/conditionally-const-invalid-places.rs:21:19 | LL | const CONSTANT<T: [const] Trait>: () = (); - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:25:16 + --> $DIR/conditionally-const-invalid-places.rs:25:18 | LL | type Type<T: [const] Trait>: [const] Trait; - | ^^^^^^^^^ + | ^^^^^^^ | note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:25:5 @@ -79,10 +79,10 @@ LL | type Type<T: [const] Trait>: [const] Trait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:25:32 + --> $DIR/conditionally-const-invalid-places.rs:25:34 | LL | type Type<T: [const] Trait>: [const] Trait; - | ^^^^^^^^^ + | ^^^^^^^ | note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:25:5 @@ -91,10 +91,10 @@ LL | type Type<T: [const] Trait>: [const] Trait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:28:28 + --> $DIR/conditionally-const-invalid-places.rs:28:30 | LL | fn non_const_function<T: [const] Trait>(); - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:28:8 @@ -103,18 +103,18 @@ LL | fn non_const_function<T: [const] Trait>(); | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:29:21 + --> $DIR/conditionally-const-invalid-places.rs:29:23 | LL | const CONSTANT<T: [const] Trait>: (); - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:34:16 + --> $DIR/conditionally-const-invalid-places.rs:34:18 | LL | type Type<T: [const] Trait> = (); - | ^^^^^^^^^ + | ^^^^^^^ | note: associated types in non-const impls cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:34:5 @@ -123,10 +123,10 @@ LL | type Type<T: [const] Trait> = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:36:28 + --> $DIR/conditionally-const-invalid-places.rs:36:30 | LL | fn non_const_function<T: [const] Trait>() {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:36:8 @@ -135,18 +135,18 @@ LL | fn non_const_function<T: [const] Trait>() {} | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:37:21 + --> $DIR/conditionally-const-invalid-places.rs:37:23 | LL | const CONSTANT<T: [const] Trait>: () = (); - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:44:16 + --> $DIR/conditionally-const-invalid-places.rs:44:18 | LL | type Type<T: [const] Trait> = (); - | ^^^^^^^^^ + | ^^^^^^^ | note: inherent associated types cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:44:5 @@ -155,10 +155,10 @@ LL | type Type<T: [const] Trait> = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:46:28 + --> $DIR/conditionally-const-invalid-places.rs:46:30 | LL | fn non_const_function<T: [const] Trait>() {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:46:8 @@ -167,18 +167,18 @@ LL | fn non_const_function<T: [const] Trait>() {} | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:47:21 + --> $DIR/conditionally-const-invalid-places.rs:47:23 | LL | const CONSTANT<T: [const] Trait>: () = (); - | ^^^^^^^^^ + | ^^^^^^^ | = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:52:13 + --> $DIR/conditionally-const-invalid-places.rs:52:15 | LL | trait Child0: [const] Trait {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:52:1 @@ -187,10 +187,10 @@ LL | trait Child0: [const] Trait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:53:24 + --> $DIR/conditionally-const-invalid-places.rs:53:26 | LL | trait Child1 where Self: [const] Trait {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:53:1 @@ -199,10 +199,10 @@ LL | trait Child1 where Self: [const] Trait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:56:7 + --> $DIR/conditionally-const-invalid-places.rs:56:9 | LL | impl<T: [const] Trait> Trait for T {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this impl is not `const`, so it cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:56:1 @@ -211,10 +211,10 @@ LL | impl<T: [const] Trait> Trait for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:59:7 + --> $DIR/conditionally-const-invalid-places.rs:59:9 | LL | impl<T: [const] Trait> Struct<T> {} - | ^^^^^^^^^ + | ^^^^^^^ | note: inherent impls cannot have `[const]` trait bounds --> $DIR/conditionally-const-invalid-places.rs:59:1 diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr index c0af644d3de..901c2cbd8a7 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/const-bound-on-not-const-associated-fn.rs:11:38 + --> $DIR/const-bound-on-not-const-associated-fn.rs:11:40 | LL | fn do_something_else() where Self: [const] MyTrait; - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/const-bound-on-not-const-associated-fn.rs:11:8 @@ -11,10 +11,10 @@ LL | fn do_something_else() where Self: [const] MyTrait; | ^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/const-bound-on-not-const-associated-fn.rs:22:30 + --> $DIR/const-bound-on-not-const-associated-fn.rs:22:32 | LL | pub fn foo(&self) where T: [const] MyTrait { - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/const-bound-on-not-const-associated-fn.rs:22:12 diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr index 2ff5fb74031..6c68e4ec3ac 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr @@ -1,8 +1,8 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-bounds-non-const-trait.rs:6:19 + --> $DIR/const-bounds-non-const-trait.rs:6:21 | LL | const fn perform<T: [const] NonConst>() {} - | ^^^^^^^^^ can't be applied to `NonConst` + | ^^^^^^^ can't be applied to `NonConst` | help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations | @@ -10,10 +10,10 @@ LL | #[const_trait] trait NonConst {} | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-bounds-non-const-trait.rs:6:19 + --> $DIR/const-bounds-non-const-trait.rs:6:21 | LL | const fn perform<T: [const] NonConst>() {} - | ^^^^^^^^^ can't be applied to `NonConst` + | ^^^^^^^ can't be applied to `NonConst` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr index cc9d9bd6022..fdfe3b95d55 100644 --- a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr +++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr @@ -1,27 +1,27 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-parse-not-item.rs:7:20 + --> $DIR/const-closure-parse-not-item.rs:7:25 | LL | const fn test() -> impl [const] Fn() { - | ^^^^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-parse-not-item.rs:7:20 + --> $DIR/const-closure-parse-not-item.rs:7:25 | LL | const fn test() -> impl [const] Fn() { - | ^^^^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-parse-not-item.rs:7:20 + --> $DIR/const-closure-parse-not-item.rs:7:25 | LL | const fn test() -> impl [const] Fn() { - | ^^^^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr index 7a146b9d8a1..89b202b3438 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr @@ -1,17 +1,17 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-trait-method-fail.rs:14:30 + --> $DIR/const-closure-trait-method-fail.rs:14:32 | LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-trait-method-fail.rs:14:30 + --> $DIR/const-closure-trait-method-fail.rs:14:32 | LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.stderr b/tests/ui/traits/const-traits/const-closure-trait-method.stderr index 6c003f87ada..6de25dc11ef 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method.stderr @@ -1,17 +1,17 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-trait-method.rs:14:30 + --> $DIR/const-closure-trait-method.rs:14:32 | LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closure-trait-method.rs:14:30 + --> $DIR/const-closure-trait-method.rs:14:32 | LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/traits/const-traits/const-closures.stderr b/tests/ui/traits/const-traits/const-closures.stderr index c76a73418a5..19869b47085 100644 --- a/tests/ui/traits/const-traits/const-closures.stderr +++ b/tests/ui/traits/const-traits/const-closures.stderr @@ -1,74 +1,74 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:8:10 + --> $DIR/const-closures.rs:8:12 | LL | F: [const] FnOnce() -> u8, - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:9:10 + --> $DIR/const-closures.rs:9:12 | LL | F: [const] FnMut() -> u8, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:10:10 + --> $DIR/const-closures.rs:10:12 | LL | F: [const] Fn() -> u8, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:8:10 + --> $DIR/const-closures.rs:8:12 | LL | F: [const] FnOnce() -> u8, - | ^^^^^^^^^ can't be applied to `FnOnce` + | ^^^^^^^ can't be applied to `FnOnce` | note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:9:10 + --> $DIR/const-closures.rs:9:12 | LL | F: [const] FnMut() -> u8, - | ^^^^^^^^^ can't be applied to `FnMut` + | ^^^^^^^ can't be applied to `FnMut` | note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:10:10 + --> $DIR/const-closures.rs:10:12 | LL | F: [const] Fn() -> u8, - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:23:18 + --> $DIR/const-closures.rs:23:20 | LL | const fn answer<F: [const] Fn() -> u8>(f: &F) -> u8 { - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/const-closures.rs:23:18 + --> $DIR/const-closures.rs:23:20 | LL | const fn answer<F: [const] Fn() -> u8>(f: &F) -> u8 { - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr index c58e2765168..090555c6377 100644 --- a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr +++ b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr @@ -5,10 +5,10 @@ LL | let _: &dyn const Trait; | ^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/const-trait-bounds-trait-objects.rs:10:13 + --> $DIR/const-trait-bounds-trait-objects.rs:10:17 | LL | let _: &dyn [const] Trait; - | ^^^^^^^^^^^ + | ^^^^^^^ | = note: trait objects cannot have `[const]` trait bounds @@ -19,10 +19,10 @@ LL | const fn handle(_: &dyn const NonConst) {} | ^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/const-trait-bounds-trait-objects.rs:17:19 + --> $DIR/const-trait-bounds-trait-objects.rs:17:23 | LL | const fn take(_: &dyn [const] NonConst) {} - | ^^^^^^^^^^^ + | ^^^^^^^ | = note: trait objects cannot have `[const]` trait bounds diff --git a/tests/ui/traits/const-traits/feature-gate.stock.stderr b/tests/ui/traits/const-traits/feature-gate.stock.stderr index 37d76e7f387..f9d966f0362 100644 --- a/tests/ui/traits/const-traits/feature-gate.stock.stderr +++ b/tests/ui/traits/const-traits/feature-gate.stock.stderr @@ -9,10 +9,10 @@ LL | impl const T for S {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:13:13 + --> $DIR/feature-gate.rs:13:15 | LL | const fn f<A: [const] T>() {} - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -29,10 +29,10 @@ LL | fn g<A: const T>() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:18:12 + --> $DIR/feature-gate.rs:18:17 | LL | discard! { impl [const] T } - | ^^^^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr index f340eaab0e3..78d7b962cc4 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr @@ -9,29 +9,29 @@ LL | const move || { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/ice-112822-expected-type-for-param.rs:3:20 + --> $DIR/ice-112822-expected-type-for-param.rs:3:25 | LL | const fn test() -> impl [const] Fn() { - | ^^^^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/ice-112822-expected-type-for-param.rs:3:20 + --> $DIR/ice-112822-expected-type-for-param.rs:3:25 | LL | const fn test() -> impl [const] Fn() { - | ^^^^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/ice-112822-expected-type-for-param.rs:3:20 + --> $DIR/ice-112822-expected-type-for-param.rs:3:25 | LL | const fn test() -> impl [const] Fn() { - | ^^^^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr index d8d73173ec4..1eccb16b46e 100644 --- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr +++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr @@ -1,17 +1,17 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/ice-123664-unexpected-bound-var.rs:4:25 + --> $DIR/ice-123664-unexpected-bound-var.rs:4:27 | LL | const fn with_positive<F: [const] Fn()>() {} - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/ice-123664-unexpected-bound-var.rs:4:25 + --> $DIR/ice-123664-unexpected-bound-var.rs:4:27 | LL | const fn with_positive<F: [const] Fn()>() {} - | ^^^^^^^^^ can't be applied to `Fn` + | ^^^^^^^ can't be applied to `Fn` | note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr index 8211b2b49bf..e7f10e73c69 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr @@ -1,17 +1,17 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/non-const-op-in-closure-in-const.rs:10:42 + --> $DIR/non-const-op-in-closure-in-const.rs:10:44 | LL | impl<A, B> const Convert<B> for A where B: [const] From<A> { - | ^^^^^^^^^ can't be applied to `From` + | ^^^^^^^ can't be applied to `From` | note: `From` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/non-const-op-in-closure-in-const.rs:10:42 + --> $DIR/non-const-op-in-closure-in-const.rs:10:44 | LL | impl<A, B> const Convert<B> for A where B: [const] From<A> { - | ^^^^^^^^^ can't be applied to `From` + | ^^^^^^^ can't be applied to `From` | note: `From` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr index 11f73cbf0c9..19f072b289e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-2.rs:11:1 @@ -11,10 +11,10 @@ LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | @@ -22,10 +22,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -34,10 +34,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr index 1767672e180..4921f78d3ac 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr @@ -1,8 +1,8 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | @@ -10,10 +10,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -22,10 +22,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -34,10 +34,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -46,10 +46,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr index 63c33a00234..a151349822e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:10 + --> $DIR/super-traits-fail-2.rs:11:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-2.rs:11:1 diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr index c6a06d074c9..eb1beb41e37 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 @@ -11,30 +11,30 @@ LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | @@ -42,10 +42,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -54,10 +54,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -66,10 +66,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | @@ -77,10 +77,10 @@ LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr index c6a06d074c9..eb1beb41e37 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 @@ -11,30 +11,30 @@ LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | @@ -42,10 +42,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -54,10 +54,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -66,10 +66,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | @@ -77,10 +77,10 @@ LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr index feca029aa6c..7c465731a99 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr @@ -1,18 +1,18 @@ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr index feca029aa6c..7c465731a99 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr @@ -1,18 +1,18 @@ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index d9112c91776..89e090b7d1c 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 @@ -11,10 +11,10 @@ LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | @@ -22,10 +22,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -34,10 +34,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -46,10 +46,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | @@ -57,10 +57,10 @@ LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr index 3520b61a81c..683eeb73850 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -1,8 +1,8 @@ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | @@ -10,10 +10,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -22,10 +22,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -34,10 +34,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -46,10 +46,10 @@ LL | #[const_trait] trait Foo { | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ can't be applied to `Foo` + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr index d714118df62..39cfdfe2030 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:10 + --> $DIR/super-traits-fail-3.rs:23:12 | LL | trait Bar: [const] Foo {} - | ^^^^^^^^^ + | ^^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 @@ -11,10 +11,10 @@ LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | @@ -22,10 +22,10 @@ LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error: `[const]` can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:32:15 + --> $DIR/super-traits-fail-3.rs:32:17 | LL | const fn foo<T: [const] Bar>(x: &T) { - | ^^^^^^^^^ can't be applied to `Bar` + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/syntactical-unstable.stderr b/tests/ui/traits/const-traits/syntactical-unstable.stderr index 657773d9121..b8cc8e69f75 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.stderr +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr @@ -2,9 +2,9 @@ error[E0658]: use of unstable const library feature `unstable` --> $DIR/syntactical-unstable.rs:13:20 | LL | trait Foo: [const] MyTrait { - | --------- ^^^^^^^ - | | - | trait is not stable as const yet + | ------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date @@ -13,9 +13,9 @@ error[E0658]: use of unstable const library feature `unstable` --> $DIR/syntactical-unstable.rs:19:45 | LL | const fn where_clause<T>() where T: [const] MyTrait {} - | --------- ^^^^^^^ - | | - | trait is not stable as const yet + | ------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date @@ -24,9 +24,9 @@ error[E0658]: use of unstable const library feature `unstable` --> $DIR/syntactical-unstable.rs:22:53 | LL | const fn nested<T>() where T: Deref<Target: [const] MyTrait> {} - | --------- ^^^^^^^ - | | - | trait is not stable as const yet + | ------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date @@ -35,9 +35,9 @@ error[E0658]: use of unstable const library feature `unstable` --> $DIR/syntactical-unstable.rs:25:33 | LL | const fn rpit() -> impl [const] MyTrait { Local } - | ------------ ^^^^^^^ - | | - | trait is not stable as const yet + | ------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date @@ -55,9 +55,9 @@ error[E0658]: use of unstable const library feature `unstable` --> $DIR/syntactical-unstable.rs:15:24 | LL | type Item: [const] MyTrait; - | --------- ^^^^^^^ - | | - | trait is not stable as const yet + | ------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui/traits/const-traits/trait-where-clause.stderr b/tests/ui/traits/const-traits/trait-where-clause.stderr index 04c67903ef5..dda91e6bca1 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause.stderr @@ -1,8 +1,8 @@ error: `[const]` is not allowed here - --> $DIR/trait-where-clause.rs:8:22 + --> $DIR/trait-where-clause.rs:8:24 | LL | fn b() where Self: [const] Bar; - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/trait-where-clause.rs:8:8 @@ -11,10 +11,10 @@ LL | fn b() where Self: [const] Bar; | ^ error: `[const]` is not allowed here - --> $DIR/trait-where-clause.rs:10:11 + --> $DIR/trait-where-clause.rs:10:13 | LL | fn c<T: [const] Bar>(); - | ^^^^^^^^^ + | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/trait-where-clause.rs:10:8 diff --git a/tests/ui/impl-unused-tps.rs b/tests/ui/traits/constrained-type-params-trait-impl.rs index a5836db3c8e..301bbdb2ccb 100644 --- a/tests/ui/impl-unused-tps.rs +++ b/tests/ui/traits/constrained-type-params-trait-impl.rs @@ -1,3 +1,11 @@ +//! Comprehensive test for type parameter constraints in trait implementations +//! +//! This tests various scenarios of type parameter usage in trait implementations: +//! - Properly constrained parameters through trait bounds +//! - Unconstrained parameters that should cause compilation errors +//! - Complex constraint scenarios with `where` clauses and associated types +//! - Conflicting implementations detection + trait Foo<A> { fn get(&self, A: &A) {} } @@ -7,34 +15,34 @@ trait Bar { } impl<T> Foo<T> for [isize; 0] { - // OK, T is used in `Foo<T>`. + // OK: T is used in the trait bound `Foo<T>` } impl<T, U> Foo<T> for [isize; 1] { //~^ ERROR the type parameter `U` is not constrained + // T is constrained by `Foo<T>`, but U is completely unused } impl<T, U> Foo<T> for [isize; 2] where T: Bar<Out = U>, { - // OK, `U` is now constrained by the output type parameter. + // OK: T is constrained by `Foo<T>`, U is constrained by the where clause } impl<T: Bar<Out = U>, U> Foo<T> for [isize; 3] { - // OK, same as above but written differently. + // OK: Same as above but using bound syntax instead of where clause } impl<T, U> Foo<T> for U { //~^ ERROR conflicting implementations of trait `Foo<_>` for type `[isize; 0]` + // This conflicts with the first impl when U = [isize; 0] } impl<T, U> Bar for T { //~^ ERROR the type parameter `U` is not constrained - type Out = U; - - // Using `U` in an associated type within the impl is not good enough! + // Using U only in associated type definition is insufficient for constraint } impl<T, U> Bar for T @@ -43,7 +51,7 @@ where { //~^^^^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates //~| ERROR conflicting implementations of trait `Bar` - // This crafty self-referential attempt is still no good. + // Self-referential constraint doesn't properly constrain U } impl<T, U, V> Foo<T> for T @@ -53,9 +61,7 @@ where //~^^^^ ERROR the type parameter `U` is not constrained //~| ERROR the type parameter `V` is not constrained //~| ERROR conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]` - - // Here, `V` is bound by an output type parameter, but the inputs - // are not themselves constrained. + // V is bound through output type, but U and V are not properly constrained as inputs } impl<T, U, V> Foo<(T, U)> for T @@ -63,7 +69,7 @@ where (T, U): Bar<Out = V>, { //~^^^^ ERROR conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]` - // As above, but both T and U ARE constrained. + // Both T and U are constrained through `Foo<(T, U)>`, but creates conflicting impl } fn main() {} diff --git a/tests/ui/impl-unused-tps.stderr b/tests/ui/traits/constrained-type-params-trait-impl.stderr index eff5ffff9b6..2175129a8df 100644 --- a/tests/ui/impl-unused-tps.stderr +++ b/tests/ui/traits/constrained-type-params-trait-impl.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Foo<_>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:28:1 + --> $DIR/constrained-type-params-trait-impl.rs:37:1 | LL | impl<T> Foo<T> for [isize; 0] { | ----------------------------- first implementation here @@ -8,7 +8,7 @@ LL | impl<T, U> Foo<T> for U { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]` error[E0119]: conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:49:1 + --> $DIR/constrained-type-params-trait-impl.rs:57:1 | LL | impl<T> Foo<T> for [isize; 0] { | ----------------------------- first implementation here @@ -19,7 +19,7 @@ LL | | (T, U): Bar<Out = V>, | |_________________________^ conflicting implementation for `[isize; 0]` error[E0119]: conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:61:1 + --> $DIR/constrained-type-params-trait-impl.rs:67:1 | LL | impl<T> Foo<T> for [isize; 0] { | ----------------------------- first implementation here @@ -30,37 +30,37 @@ LL | | (T, U): Bar<Out = V>, | |_________________________^ conflicting implementation for `[isize; 0]` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:13:9 + --> $DIR/constrained-type-params-trait-impl.rs:21:9 | LL | impl<T, U> Foo<T> for [isize; 1] { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:32:9 + --> $DIR/constrained-type-params-trait-impl.rs:42:9 | LL | impl<T, U> Bar for T { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:40:9 + --> $DIR/constrained-type-params-trait-impl.rs:48:9 | LL | impl<T, U> Bar for T | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:49:9 + --> $DIR/constrained-type-params-trait-impl.rs:57:9 | LL | impl<T, U, V> Foo<T> for T | ^ unconstrained type parameter error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:49:12 + --> $DIR/constrained-type-params-trait-impl.rs:57:12 | LL | impl<T, U, V> Foo<T> for T | ^ unconstrained type parameter error[E0119]: conflicting implementations of trait `Bar` - --> $DIR/impl-unused-tps.rs:40:1 + --> $DIR/constrained-type-params-trait-impl.rs:48:1 | LL | impl<T, U> Bar for T { | -------------------- first implementation here diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.rs b/tests/ui/traits/dispatch-from-dyn-invalid-impls.rs index b1d4b261bab..f5f66ca69cf 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.rs +++ b/tests/ui/traits/dispatch-from-dyn-invalid-impls.rs @@ -1,20 +1,30 @@ +//! Test various invalid implementations of DispatchFromDyn trait. +//! +//! DispatchFromDyn is a special trait used by the compiler for dyn-compatible dynamic dispatch. +//! This checks that the compiler correctly rejects invalid implementations: +//! - Structs with extra non-coercible fields +//! - Structs with multiple pointer fields +//! - Structs with no coercible fields +//! - Structs with repr(C) or other incompatible representations +//! - Structs with over-aligned fields + #![feature(unsize, dispatch_from_dyn)] -use std::{ - ops::DispatchFromDyn, - marker::{Unsize, PhantomData}, -}; +use std::marker::{PhantomData, Unsize}; +use std::ops::DispatchFromDyn; +// Extra field prevents DispatchFromDyn struct WrapperWithExtraField<T>(T, i32); impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> //~^ ERROR [E0378] where - T: DispatchFromDyn<U>, -{} - + T: DispatchFromDyn<U> +{ +} -struct MultiplePointers<T: ?Sized>{ +// Multiple pointer fields create ambiguous coercion +struct MultiplePointers<T: ?Sized> { ptr1: *const T, ptr2: *const T, } @@ -22,10 +32,11 @@ struct MultiplePointers<T: ?Sized>{ impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> //~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced where - T: Unsize<U>, -{} - + T: Unsize<U> +{ +} +// No coercible fields (only PhantomData) struct NothingToCoerce<T: ?Sized> { data: PhantomData<T>, } @@ -33,23 +44,28 @@ struct NothingToCoerce<T: ?Sized> { impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} //~^ ERROR implementing `DispatchFromDyn` requires a field to be coerced +// repr(C) is incompatible with DispatchFromDyn #[repr(C)] struct HasReprC<T: ?Sized>(Box<T>); impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> //~^ ERROR [E0378] where - T: Unsize<U>, -{} + T: Unsize<U> +{ +} +// Over-aligned fields are incompatible #[repr(align(64))] struct OverAlignedZst; + struct OverAligned<T: ?Sized>(Box<T>, OverAlignedZst); impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> //~^ ERROR [E0378] - where - T: Unsize<U>, -{} +where + T: Unsize<U> +{ +} fn main() {} diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.stderr b/tests/ui/traits/dispatch-from-dyn-invalid-impls.stderr index 93ec6bbe089..676da0ce81f 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.stderr +++ b/tests/ui/traits/dispatch-from-dyn-invalid-impls.stderr @@ -1,25 +1,25 @@ error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else - --> $DIR/invalid_dispatch_from_dyn_impls.rs:10:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:19:1 | LL | / impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> LL | | LL | | where -LL | | T: DispatchFromDyn<U>, - | |__________________________^ +LL | | T: DispatchFromDyn<U> + | |_________________________^ | = note: extra field `1` of type `i32` is not allowed error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:22:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:32:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> LL | | LL | | where -LL | | T: Unsize<U>, - | |_________________^ +LL | | T: Unsize<U> + | |________________^ | note: the trait `DispatchFromDyn` may only be implemented when a single field is being coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:18:5 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:28:5 | LL | ptr1: *const T, | ^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | ptr2: *const T, | ^^^^^^^^^^^^^^ error[E0374]: implementing `DispatchFromDyn` requires a field to be coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:33:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:44:1 | LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,22 +35,22 @@ LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingT = note: expected a single field to be coerced, none found error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]` - --> $DIR/invalid_dispatch_from_dyn_impls.rs:39:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:51:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> LL | | LL | | where -LL | | T: Unsize<U>, - | |_________________^ +LL | | T: Unsize<U> + | |________________^ error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else - --> $DIR/invalid_dispatch_from_dyn_impls.rs:49:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:64:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> LL | | -LL | | where -LL | | T: Unsize<U>, - | |_____________________^ +LL | | where +LL | | T: Unsize<U> + | |________________^ | = note: extra field `1` of type `OverAlignedZst` is not allowed diff --git a/tests/ui/issue-11881.rs b/tests/ui/traits/encoder-trait-bounds-regression.rs index 1abe0797203..292b921cdf7 100644 --- a/tests/ui/issue-11881.rs +++ b/tests/ui/traits/encoder-trait-bounds-regression.rs @@ -1,14 +1,23 @@ +//! Regression test for issue #11881 +//! +//! Originally, the compiler would ICE when trying to parameterize on certain encoder types +//! due to issues with higher-ranked trait bounds and lifetime inference. This test checks +//! that various encoder patterns work correctly: +//! - Generic encoders with associated error types +//! - Higher-ranked trait bounds (for<'r> Encodable<JsonEncoder<'r>>) +//! - Multiple encoder implementations for the same type +//! - Polymorphic encoding functions + //@ run-pass #![allow(unused_must_use)] #![allow(dead_code)] #![allow(unused_imports)] -use std::fmt; -use std::io::prelude::*; use std::io::Cursor; -use std::slice; +use std::io::prelude::*; use std::marker::PhantomData; +use std::{fmt, slice}; trait Encoder { type Error; @@ -45,7 +54,6 @@ impl Encoder for OpaqueEncoder { type Error = (); } - struct Foo { baz: bool, } @@ -69,7 +77,6 @@ impl<S: Encoder> Encodable<S> for Bar { enum WireProtocol { JSON, Opaque, - // ... } fn encode_json<T: for<'a> Encodable<JsonEncoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) { diff --git a/tests/ui/traits/eval-caching-error-region.rs b/tests/ui/traits/eval-caching-error-region.rs new file mode 100644 index 00000000000..831b5ab80c1 --- /dev/null +++ b/tests/ui/traits/eval-caching-error-region.rs @@ -0,0 +1,23 @@ +// Regression test for #132882. + +use std::ops::Add; + +pub trait Numoid: Sized +where + &'missing Self: Add<Self>, + //~^ ERROR use of undeclared lifetime name `'missing` +{ +} + +// Proving `N: Numoid`'s well-formedness causes us to have to prove `&'missing N: Add<N>`. +// Since `'missing` is a region error, that will lead to us consider the predicate to hold, +// since it references errors. Since the freshener turns error regions into fresh regions, +// this means that subsequent lookups of `&'?0 N: Add<N>` will also hit this cache entry +// even if candidate assembly can't assemble anything for `&'?0 N: Add<?1>` anyways. This +// led to an ICE. +pub fn compute<N: Numoid>(a: N) { + let _ = &a + a; + //~^ ERROR cannot add `N` to `&N` +} + +fn main() {} diff --git a/tests/ui/traits/eval-caching-error-region.stderr b/tests/ui/traits/eval-caching-error-region.stderr new file mode 100644 index 00000000000..6365d242d2e --- /dev/null +++ b/tests/ui/traits/eval-caching-error-region.stderr @@ -0,0 +1,33 @@ +error[E0261]: use of undeclared lifetime name `'missing` + --> $DIR/eval-caching-error-region.rs:7:6 + | +LL | &'missing Self: Add<Self>, + | ^^^^^^^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'missing` lifetime + | +LL | for<'missing> &'missing Self: Add<Self>, + | +++++++++++++ +help: consider introducing lifetime `'missing` here + | +LL | pub trait Numoid<'missing>: Sized + | ++++++++++ + +error[E0369]: cannot add `N` to `&N` + --> $DIR/eval-caching-error-region.rs:19:16 + | +LL | let _ = &a + a; + | -- ^ - N + | | + | &N + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | pub fn compute<N: Numoid>(a: N) where &N: Add<N> { + | ++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0261, E0369. +For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs new file mode 100644 index 00000000000..04963c98765 --- /dev/null +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs @@ -0,0 +1,18 @@ +//! Test that ?Trait bounds are forbidden in supertraits and trait object types. +//! +//! While `?Sized` and other maybe bounds are allowed in type parameter bounds and where clauses, +//! they are explicitly forbidden in certain syntactic positions: +//! - As supertraits in trait definitions +//! - In trait object type expressions +//! +//! See https://github.com/rust-lang/rust/issues/20503 + +trait Tr: ?Sized {} +//~^ ERROR `?Trait` is not permitted in supertraits + +type A1 = dyn Tr + (?Sized); +//~^ ERROR `?Trait` is not permitted in trait object types +type A2 = dyn for<'a> Tr + (?Sized); +//~^ ERROR `?Trait` is not permitted in trait object types + +fn main() {} diff --git a/tests/ui/maybe-bounds.stderr b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr index 230d11fd0ae..bd0baa580bd 100644 --- a/tests/ui/maybe-bounds.stderr +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr @@ -1,5 +1,5 @@ error[E0658]: `?Trait` is not permitted in supertraits - --> $DIR/maybe-bounds.rs:1:11 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:10:11 | LL | trait Tr: ?Sized {} | ^^^^^^ @@ -9,7 +9,7 @@ LL | trait Tr: ?Sized {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/maybe-bounds.rs:4:20 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20 | LL | type A1 = dyn Tr + (?Sized); | ^^^^^^^^ @@ -18,7 +18,7 @@ LL | type A1 = dyn Tr + (?Sized); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/maybe-bounds.rs:6:28 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:15:28 | LL | type A2 = dyn for<'a> Tr + (?Sized); | ^^^^^^^^ diff --git a/tests/ui/transmute/diverging-fn-transmute.rs b/tests/ui/transmute/diverging-fn-transmute.rs new file mode 100644 index 00000000000..aca82037a0c --- /dev/null +++ b/tests/ui/transmute/diverging-fn-transmute.rs @@ -0,0 +1,10 @@ +//! Regression test for issue #35849: transmute with panic in diverging function + +fn assert_sizeof() -> ! { + unsafe { + ::std::mem::transmute::<f64, [u8; 8]>(panic!()) + //~^ ERROR mismatched types + } +} + +fn main() {} diff --git a/tests/ui/diverging-fn-tail-35849.stderr b/tests/ui/transmute/diverging-fn-transmute.stderr index 614f9b9cb5d..b9aeae7ed62 100644 --- a/tests/ui/diverging-fn-tail-35849.stderr +++ b/tests/ui/transmute/diverging-fn-transmute.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/diverging-fn-tail-35849.rs:3:9 + --> $DIR/diverging-fn-transmute.rs:5:9 | LL | fn assert_sizeof() -> ! { | - expected `!` because of return type diff --git a/tests/ui/type-alias-enum-variants/module-type-args-error.rs b/tests/ui/type-alias-enum-variants/module-type-args-error.rs new file mode 100644 index 00000000000..9f7dae4f4f5 --- /dev/null +++ b/tests/ui/type-alias-enum-variants/module-type-args-error.rs @@ -0,0 +1,16 @@ +//! Test that type arguments are properly rejected on modules. +//! +//! Related PR: https://github.com/rust-lang/rust/pull/56225 (RFC 2338 implementation) + +mod Mod { + pub struct FakeVariant<T>(pub T); +} + +fn main() { + // This should work fine - normal generic struct constructor + Mod::FakeVariant::<i32>(0); + + // This should error - type arguments not allowed on modules + Mod::<i32>::FakeVariant(0); + //~^ ERROR type arguments are not allowed on module `Mod` [E0109] +} diff --git a/tests/ui/mod-subitem-as-enum-variant.stderr b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr index 92d972eba42..4c59d19eaa7 100644 --- a/tests/ui/mod-subitem-as-enum-variant.stderr +++ b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr @@ -1,5 +1,5 @@ error[E0109]: type arguments are not allowed on module `Mod` - --> $DIR/mod-subitem-as-enum-variant.rs:7:11 + --> $DIR/module-type-args-error.rs:14:11 | LL | Mod::<i32>::FakeVariant(0); | --- ^^^ type argument not allowed |
