diff --git a/compiler/rustc_error_codes/src/error_codes/E0634.md b/compiler/rustc_error_codes/src/error_codes/E0634.md index 0c4ed2596e2aa..9950a119a6cb1 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0634.md +++ b/compiler/rustc_error_codes/src/error_codes/E0634.md @@ -4,11 +4,11 @@ Erroneous code examples: ```compile_fail,E0634 #[repr(packed, packed(2))] // error! -struct Company(i32); +struct Company1(i32); #[repr(packed(2))] // error! #[repr(packed)] -struct Company(i32); +struct Company2(i32); ``` You cannot use conflicting `packed` hints on a same type. If you want to pack a diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 17ee1c5dbb61f..037a517224338 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -470,7 +470,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { false => E0260, }, _ => match (old_binding.is_import_user_facing(), new_binding.is_import_user_facing()) { - (false, false) => E0428, + (false, false) => { + // Duplicated types wreak havoc on other errors, like impls selecting the wrong + // type causing wrong number of generic params and other assorted number of + // irrelevant nonsense, so avoid advancing to the next compiler stage. + self.raise_fatal_after_resolve = true; + E0428 + } (true, true) => E0252, _ => E0255, }, @@ -2872,7 +2878,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { break; } } - err.emit(); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 43aa2d2041eec..fc25a97db392b 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1554,6 +1554,11 @@ pub struct Resolver<'ra, 'tcx> { // for APITs, so we don't want to leak details of resolution into these names. impl_trait_names: FxHashMap = default::fx_hash_map(), + /// When enabled, after reporting every error we will `FatalError.raise()` to avoid advancing + /// to the next compiler stage. Only used when encountering resolution errors that cause lots of + /// unnecessary knock down errors. + raise_fatal_after_resolve: bool = false, + /// Stores `#[diagnostic::on_unknown]` attributes placed on module declarations. on_unknown_data: FxHashMap = default::fx_hash_map(), features: &'tcx Features, @@ -2087,6 +2092,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Don't mutate the cstore or stable crate id map from here on. self.tcx.untracked().freeze_cstore(); + if self.raise_fatal_after_resolve { + rustc_errors::FatalError.raise(); + } } fn traits_in_scope( diff --git a/tests/crashes/120873.rs b/tests/crashes/120873.rs deleted file mode 100644 index 45bc0bd457b10..0000000000000 --- a/tests/crashes/120873.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #120873 -#[repr(packed)] - -struct Dealigned(u8, T); - -#[derive(PartialEq)] -#[repr(C)] -struct Dealigned(u8, T); diff --git a/tests/crashes/155482-2.rs b/tests/crashes/155482-2.rs new file mode 100644 index 0000000000000..38cef9c101c1f --- /dev/null +++ b/tests/crashes/155482-2.rs @@ -0,0 +1,12 @@ +//@ known-bug: #155482 +//@ only-x86_64 +#![feature(generic_assert)] +fn main() { + std::arch::x86_64::_mm_shuffle_ps( + todo!(), + todo!(), + const { + assert!(X != 2); + }, + ) +} diff --git a/tests/crashes/155482.rs b/tests/crashes/155482.rs index a2182f83d737c..3db4e5fd06587 100644 --- a/tests/crashes/155482.rs +++ b/tests/crashes/155482.rs @@ -1,7 +1,9 @@ //@ known-bug: #155482 -trait TraitA < AsA = impl TraitB < { -#[derive(Hash)] - enum A; - struct A; +//@ only-x86_64 +#![feature(generic_assert)] +fn main() { + const I = 0; + std::arch::x86_64::_mm_shuffle_ps(todo!(), todo!(), const { + assert!(N != 0); + }); } ->> ; diff --git a/tests/ui/consts/const-item-no-type/in-macro.rs b/tests/ui/consts/const-item-no-type/in-macro.rs index 887549926b918..c79dcf7dad153 100644 --- a/tests/ui/consts/const-item-no-type/in-macro.rs +++ b/tests/ui/consts/const-item-no-type/in-macro.rs @@ -4,7 +4,6 @@ macro_rules! suite { const A = "A".$fn(); //~^ ERROR the name `A` is defined multiple times //~| ERROR missing type for `const` item - //~| ERROR missing type for item )* } } diff --git a/tests/ui/consts/const-item-no-type/in-macro.stderr b/tests/ui/consts/const-item-no-type/in-macro.stderr index e2da412137433..cdb9d9e06981d 100644 --- a/tests/ui/consts/const-item-no-type/in-macro.stderr +++ b/tests/ui/consts/const-item-no-type/in-macro.stderr @@ -31,21 +31,6 @@ help: provide a type for the item LL | const A: = "A".$fn(); | ++++++++ -error[E0121]: missing type for item - --> $DIR/in-macro.rs:4:20 - | -LL | const A = "A".$fn(); - | ^ not allowed in type signatures -... -LL | / suite! { -LL | | len; -LL | | is_empty; -LL | | } - | |_- in this macro invocation - | - = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0121, E0428. -For more information about an error, try `rustc --explain E0121`. +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr index 30aad09279447..e1453502f03a4 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr @@ -8,17 +8,6 @@ LL | reuse foo; | = note: `foo` must be defined only once in the value namespace of this block -error: complex const arguments must be placed inside of a `const` block - --> $DIR/hir-crate-items-before-lowering-ices.rs:11:37 - | -LL | core::direct_const_arg!({ - | _____________________________________^ -LL | | fn foo() {} -LL | | reuse foo; -LL | | 2 -LL | | }), - | |_____________^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs b/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs index 5689a29cafe11..fd28ad3bff661 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs @@ -8,7 +8,7 @@ mod ice_155125 { struct S; impl S< - core::direct_const_arg!({ //[ice_155125]~ ERROR: complex const arguments must be placed inside of a `const` block + core::direct_const_arg!({ fn foo() {} reuse foo; //[ice_155125]~ ERROR: the name `foo` is defined multiple times 2 diff --git a/tests/ui/delegation/inside-const-body-ice-155300.rs b/tests/ui/delegation/inside-const-body-ice-155300.rs index 2d13007bc807b..364c573979973 100644 --- a/tests/ui/delegation/inside-const-body-ice-155300.rs +++ b/tests/ui/delegation/inside-const-body-ice-155300.rs @@ -6,7 +6,6 @@ pub struct S; impl S< core::direct_const_arg!({ - //~^ ERROR: complex const arguments must be placed inside of a `const` block fn foo() {} reuse foo::<> as bar; reuse bar; diff --git a/tests/ui/delegation/inside-const-body-ice-155300.stderr b/tests/ui/delegation/inside-const-body-ice-155300.stderr index f0cb830109f8a..16f44e19c20d5 100644 --- a/tests/ui/delegation/inside-const-body-ice-155300.stderr +++ b/tests/ui/delegation/inside-const-body-ice-155300.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `bar` is defined multiple times - --> $DIR/inside-const-body-ice-155300.rs:12:13 + --> $DIR/inside-const-body-ice-155300.rs:11:13 | LL | reuse foo::<> as bar; | --------------------- previous definition of the value `bar` here @@ -8,18 +8,6 @@ LL | reuse bar; | = note: `bar` must be defined only once in the value namespace of this block -error: complex const arguments must be placed inside of a `const` block - --> $DIR/inside-const-body-ice-155300.rs:8:33 - | -LL | core::direct_const_arg!({ - | _________________________________^ -LL | | -LL | | fn foo() {} -LL | | reuse foo::<> as bar; -... | -LL | | }), - | |_________^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/delegation/unlowered-path-ice-154820.rs b/tests/ui/delegation/unlowered-path-ice-154820.rs index b9246313a3f0a..e360812fb5dcb 100644 --- a/tests/ui/delegation/unlowered-path-ice-154820.rs +++ b/tests/ui/delegation/unlowered-path-ice-154820.rs @@ -1,7 +1,6 @@ #![feature(fn_delegation)] -reuse foo:: < { //~ ERROR: failed to resolve delegation callee - //~^ ERROR: function takes 0 generic arguments but 1 generic argument was supplied +reuse foo:: < { fn foo() {} reuse foo; //~^ ERROR: the name `foo` is defined multiple times diff --git a/tests/ui/delegation/unlowered-path-ice-154820.stderr b/tests/ui/delegation/unlowered-path-ice-154820.stderr index b690237e3ac9e..f931bc9bf0b7f 100644 --- a/tests/ui/delegation/unlowered-path-ice-154820.stderr +++ b/tests/ui/delegation/unlowered-path-ice-154820.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `foo` is defined multiple times - --> $DIR/unlowered-path-ice-154820.rs:6:5 + --> $DIR/unlowered-path-ice-154820.rs:5:5 | LL | fn foo() {} | -------- previous definition of the value `foo` here @@ -8,33 +8,6 @@ LL | reuse foo; | = note: `foo` must be defined only once in the value namespace of this block -error: failed to resolve delegation callee - --> $DIR/unlowered-path-ice-154820.rs:3:7 - | -LL | reuse foo:: < { - | ^^^ - -error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/unlowered-path-ice-154820.rs:3:7 - | -LL | reuse foo:: < { - | _______^^^- - | | | - | | expected 0 generic arguments -LL | | -LL | | fn foo() {} -LL | | reuse foo; -... | -LL | | >; - | |___- help: remove the unnecessary generics - | -note: function defined here, with 0 generic parameters - --> $DIR/unlowered-path-ice-154820.rs:3:7 - | -LL | reuse foo:: < { - | ^^^ - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0107, E0428. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/delegation/wrong-fn-kind-ice-159127.rs b/tests/ui/delegation/wrong-fn-kind-ice-159127.rs index e117826ef099c..13d155e5ff57f 100644 --- a/tests/ui/delegation/wrong-fn-kind-ice-159127.rs +++ b/tests/ui/delegation/wrong-fn-kind-ice-159127.rs @@ -3,7 +3,6 @@ impl core::direct_const_arg!({ - //~^ ERROR: expected type, found `direct_const_arg!()` constant fn foo() {} reuse foo::<>as bar; reuse bar; diff --git a/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr b/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr index bc218f39ab65a..482ad3049df4a 100644 --- a/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr +++ b/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `bar` is defined multiple times - --> $DIR/wrong-fn-kind-ice-159127.rs:9:9 + --> $DIR/wrong-fn-kind-ice-159127.rs:8:9 | LL | reuse foo::<>as bar; | -------------------- previous definition of the value `bar` here @@ -8,17 +8,6 @@ LL | reuse bar; | = note: `bar` must be defined only once in the value namespace of this block -error: expected type, found `direct_const_arg!()` constant - --> $DIR/wrong-fn-kind-ice-159127.rs:5:5 - | -LL | / core::direct_const_arg!({ -LL | | -LL | | fn foo() {} -LL | | reuse foo::<>as bar; -... | -LL | | }) - | |______^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs index f4193f18352d0..27794bdafa215 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs @@ -3,12 +3,7 @@ struct NonGeneric {} #[derive(Default)] -//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied -//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied struct NonGeneric<'a, const N: usize> {} -//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied -//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied -//~| ERROR: lifetime parameter `'a` is never used -//~| ERROR: the name `NonGeneric` is defined multiple times +//~^ ERROR: the name `NonGeneric` is defined multiple times pub fn main() {} diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr index 0d6aaaf5186d3..9cb0a56d44aca 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `NonGeneric` is defined multiple times - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:1 + --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:6:1 | LL | struct NonGeneric {} | ----------------- previous definition of the type `NonGeneric` here @@ -9,70 +9,6 @@ LL | struct NonGeneric<'a, const N: usize> {} | = note: `NonGeneric` must be defined only once in the type namespace of this module -error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10 - | -LL | #[derive(Default)] - | ^^^^^^^ expected 0 lifetime arguments -... -LL | struct NonGeneric<'a, const N: usize> {} - | -- help: remove the lifetime argument - | -note: struct defined here, with 0 lifetime parameters - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8 - | -LL | struct NonGeneric {} - | ^^^^^^^^^^ - -error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10 - | -LL | #[derive(Default)] - | ^^^^^^^ expected 0 generic arguments - | -note: struct defined here, with 0 generic parameters - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8 - | -LL | struct NonGeneric {} - | ^^^^^^^^^^ - -error[E0392]: lifetime parameter `'a` is never used - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:19 - | -LL | struct NonGeneric<'a, const N: usize> {} - | ^^ unused lifetime parameter - | - = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` - -error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8 - | -LL | struct NonGeneric<'a, const N: usize> {} - | ^^^^^^^^^^ -- help: remove the lifetime argument - | | - | expected 0 lifetime arguments - | -note: struct defined here, with 0 lifetime parameters - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8 - | -LL | struct NonGeneric {} - | ^^^^^^^^^^ - -error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8 - | -LL | struct NonGeneric<'a, const N: usize> {} - | ^^^^^^^^^^ - help: remove the unnecessary generic argument - | | - | expected 0 generic arguments - | -note: struct defined here, with 0 generic parameters - --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8 - | -LL | struct NonGeneric {} - | ^^^^^^^^^^ - -error: aborting due to 6 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0107, E0392, E0428. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs index e946c0c5350ed..408780b187fb5 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs @@ -8,12 +8,7 @@ struct NotSM; #[derive(PartialEq, Eq)] -//~^ ERROR: struct takes 0 generic arguments struct NotSM(T); -//~^ ERROR: struct takes 0 generic arguments -//~| ERROR: struct takes 0 generic arguments -//~| ERROR: struct takes 0 generic arguments -//~| ERROR: the name `NotSM` is defined multiple times -//~| ERROR: no field `0` +//~^ ERROR: the name `NotSM` is defined multiple times fn main() {} diff --git a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr index e80cf35d81e1d..e12acc708eb70 100644 --- a/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr +++ b/tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `NotSM` is defined multiple times - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:1 + --> $DIR/multiple-types-with-same-name-and-derive.rs:11:1 | LL | struct NotSM; | ------------- previous definition of the type `NotSM` here @@ -9,63 +9,6 @@ LL | struct NotSM(T); | = note: `NotSM` must be defined only once in the type namespace of this module -error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8 - | -LL | struct NotSM(T); - | ^^^^^ expected 0 generic arguments - | -note: struct defined here, with 0 generic parameters - --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 - | -LL | struct NotSM; - | ^^^^^ - -error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:10:10 - | -LL | #[derive(PartialEq, Eq)] - | ^^^^^^^^^ expected 0 generic arguments - | -note: struct defined here, with 0 generic parameters - --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 - | -LL | struct NotSM; - | ^^^^^ - -error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8 - | -LL | struct NotSM(T); - | ^^^^^ expected 0 generic arguments - | -note: struct defined here, with 0 generic parameters - --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 - | -LL | struct NotSM; - | ^^^^^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8 - | -LL | struct NotSM(T); - | ^^^^^ expected 0 generic arguments - | -note: struct defined here, with 0 generic parameters - --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8 - | -LL | struct NotSM; - | ^^^^^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0609]: no field `0` on type `&NotSM` - --> $DIR/multiple-types-with-same-name-and-derive.rs:12:17 - | -LL | struct NotSM(T); - | ^ unknown field - -error: aborting due to 6 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0107, E0428, E0609. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/enum/enum-and-module-in-same-scope.rs b/tests/ui/enum/enum-and-module-in-same-scope.rs index 8e69c89d792ff..cc6e199bd7ca0 100644 --- a/tests/ui/enum/enum-and-module-in-same-scope.rs +++ b/tests/ui/enum/enum-and-module-in-same-scope.rs @@ -5,7 +5,6 @@ enum Foo { mod Foo { //~ ERROR the name `Foo` is defined multiple times pub static X: isize = 42; fn f() { f() } // Check that this does not result in a resolution error - //~^ WARN cannot return without recursing } fn main() {} diff --git a/tests/ui/enum/enum-and-module-in-same-scope.stderr b/tests/ui/enum/enum-and-module-in-same-scope.stderr index f1c02af595ffd..0293acd6201b2 100644 --- a/tests/ui/enum/enum-and-module-in-same-scope.stderr +++ b/tests/ui/enum/enum-and-module-in-same-scope.stderr @@ -9,17 +9,6 @@ LL | mod Foo { | = note: `Foo` must be defined only once in the type namespace of this module -warning: function cannot return without recursing - --> $DIR/enum-and-module-in-same-scope.rs:7:5 - | -LL | fn f() { f() } // Check that this does not result in a resolution error - | ^^^^^^ --- recursive call site - | | - | cannot return without recursing - | - = help: a `loop` may express intention better if this is on purpose - = note: `#[warn(unconditional_recursion)]` on by default - -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs index 6db0c88f6c005..20aacc528b81a 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs @@ -5,7 +5,7 @@ trait Bar { fn method() -> impl Sized; //~ ERROR: the name `method` is defined multiple times } -impl Bar for () { //~ ERROR: not all trait items implemented, missing: `method` +impl Bar for () { fn method() -> impl Sized { 42 } diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr index faa65f45d33cb..662cf22c4f00f 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr @@ -69,16 +69,7 @@ LL | | 42 LL | | } | |_____^ duplicate definition -error[E0046]: not all trait items implemented, missing: `method` - --> $DIR/rpitit-duplicate-associated-fn.rs:8:1 - | -LL | fn method() -> impl Sized; - | -------------------------- `method` from trait -... -LL | impl Bar for () { - | ^^^^^^^^^^^^^^^ missing `method` in implementation - -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0046, E0201, E0428. -For more information about an error, try `rustc --explain E0046`. +Some errors have detailed explanations: E0201, E0428. +For more information about an error, try `rustc --explain E0201`. diff --git a/tests/ui/privacy/effective_visibilities_invariants.rs b/tests/ui/privacy/effective_visibilities_invariants.rs index af5a2bed6ab24..92cb24e9da7df 100644 --- a/tests/ui/privacy/effective_visibilities_invariants.rs +++ b/tests/ui/privacy/effective_visibilities_invariants.rs @@ -2,9 +2,9 @@ #![feature(staged_api)] //~ ERROR module has missing stability attribute -pub mod m {} //~ ERROR module has missing stability attribute +pub mod a {} //~ ERROR module has missing stability attribute -pub mod m { //~ ERROR the name `m` is defined multiple times +pub mod b { //~ ERROR module has missing stability attribute mod inner {} type Inner = u8; } diff --git a/tests/ui/privacy/effective_visibilities_invariants.stderr b/tests/ui/privacy/effective_visibilities_invariants.stderr index 97bee1e2d8d36..1ee25606cf27a 100644 --- a/tests/ui/privacy/effective_visibilities_invariants.stderr +++ b/tests/ui/privacy/effective_visibilities_invariants.stderr @@ -1,20 +1,9 @@ -error[E0428]: the name `m` is defined multiple times - --> $DIR/effective_visibilities_invariants.rs:7:1 - | -LL | pub mod m {} - | --------- previous definition of the module `m` here -LL | -LL | pub mod m { - | ^^^^^^^^^ `m` redefined here - | - = note: `m` must be defined only once in the type namespace of this module - error: module has missing stability attribute --> $DIR/effective_visibilities_invariants.rs:3:1 | LL | / #![feature(staged_api)] LL | | -LL | | pub mod m {} +LL | | pub mod a {} ... | LL | | fn main() {} | |____________^ @@ -22,9 +11,14 @@ LL | | fn main() {} error: module has missing stability attribute --> $DIR/effective_visibilities_invariants.rs:5:1 | -LL | pub mod m {} +LL | pub mod a {} + | ^^^^^^^^^ + +error: module has missing stability attribute + --> $DIR/effective_visibilities_invariants.rs:7:1 + | +LL | pub mod b { | ^^^^^^^^^ error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0428`. diff --git a/tests/crashes/123690.rs b/tests/ui/resolve/duplicated-enum-variant.rs similarity index 95% rename from tests/crashes/123690.rs rename to tests/ui/resolve/duplicated-enum-variant.rs index 3af70e20aee18..732726c5b7a25 100644 --- a/tests/crashes/123690.rs +++ b/tests/ui/resolve/duplicated-enum-variant.rs @@ -1,4 +1,6 @@ -//@ known-bug: #123690 +// Regression test for #123690. If we allow the compiler to advance past `rustc_resolve`, it causes +// an ICE. + fn more_discriminant_overflow() { pub enum Infallible {} @@ -229,7 +231,7 @@ fn more_discriminant_overflow() { _D5(X), _D6(X), _D7(X), - _D8(X), + _D8(X), //~ ERROR: the name `_D8` is defined multiple times _D9(X), _DA(X), _DB(X), @@ -276,3 +278,5 @@ fn more_discriminant_overflow() { if let E2::V1 { .. } = E2::V3:: {} } + +fn main() {} diff --git a/tests/ui/resolve/duplicated-enum-variant.stderr b/tests/ui/resolve/duplicated-enum-variant.stderr new file mode 100644 index 0000000000000..e52ec8b729b78 --- /dev/null +++ b/tests/ui/resolve/duplicated-enum-variant.stderr @@ -0,0 +1,14 @@ +error[E0428]: the name `_D8` is defined multiple times + --> $DIR/duplicated-enum-variant.rs:234:9 + | +LL | _D8(X), + | ------ previous definition of the type `_D8` here +... +LL | _D8(X), + | ^^^^^^ `_D8` redefined here + | + = note: `_D8` must be defined only once in the type namespace of this enum + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/resolve/duplicated-item-in-const-generics.rs b/tests/ui/resolve/duplicated-item-in-const-generics.rs new file mode 100644 index 0000000000000..b3903864e8dfb --- /dev/null +++ b/tests/ui/resolve/duplicated-item-in-const-generics.rs @@ -0,0 +1,8 @@ +// Regression test for #155482. If we allow the compiler to advance past `rustc_resolve`, it causes +// an ICE. +trait TraitA < AsA = impl TraitB < { //~ ERROR: cannot find trait `TraitB` in this scope +#[derive(Hash)] + enum A; //~ ERROR: expected `{}`, found `;` + struct A; //~ ERROR: the name `A` is defined multiple times +} +>> ; //~ ERROR: expected `{}`, found `;` diff --git a/tests/ui/resolve/duplicated-item-in-const-generics.stderr b/tests/ui/resolve/duplicated-item-in-const-generics.stderr new file mode 100644 index 0000000000000..e27137a3e6db4 --- /dev/null +++ b/tests/ui/resolve/duplicated-item-in-const-generics.stderr @@ -0,0 +1,36 @@ +error: expected `{}`, found `;` + --> $DIR/duplicated-item-in-const-generics.rs:5:9 + | +LL | enum A; + | ^ + | + = help: try using `{}` instead + +error: expected `{}`, found `;` + --> $DIR/duplicated-item-in-const-generics.rs:8:4 + | +LL | >> ; + | ^ + | + = help: try using `{}` instead + +error[E0428]: the name `A` is defined multiple times + --> $DIR/duplicated-item-in-const-generics.rs:6:3 + | +LL | enum A; + | ------- previous definition of the type `A` here +LL | struct A; + | ^^^^^^^^^^^^ `A` redefined here + | + = note: `A` must be defined only once in the type namespace of this block + +error[E0405]: cannot find trait `TraitB` in this scope + --> $DIR/duplicated-item-in-const-generics.rs:3:27 + | +LL | trait TraitA < AsA = impl TraitB < { + | ^^^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0405, E0428. +For more information about an error, try `rustc --explain E0405`. diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.rs b/tests/ui/resolve/multiple_definitions_attribute_merging.rs index 9f1bff51a3d4c..ee8798fc3a0a8 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.rs +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.rs @@ -1,20 +1,15 @@ //! This test ICEs because the `repr(packed)` attributes //! end up on the `Dealigned` struct's attribute list, but the //! derive didn't see that. - -//@known-bug: #120873 -//@ failure-status: 101 -//@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" -//@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" -//@ rustc-env:RUST_BACKTRACE=0 +//! +//! Because we now `Fatal.raise()` in resolve when encountering +//! duplicated names, the ICE in #120873 no longer happens. #[repr(packed)] struct Dealigned(u8, T); #[derive(PartialEq)] #[repr(C)] -struct Dealigned(u8, T); +struct Dealigned(u8, T); //~ ERROR: the name `Dealigned` is defined multiple times fn main() {} diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr index 63bdcfddf3ca2..b8dfb7fcae02a 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `Dealigned` is defined multiple times - --> $DIR/multiple_definitions_attribute_merging.rs:18:1 + --> $DIR/multiple_definitions_attribute_merging.rs:13:1 | LL | struct Dealigned(u8, T); | --------------------------- previous definition of the type `Dealigned` here @@ -7,23 +7,8 @@ LL | struct Dealigned(u8, T); LL | struct Dealigned(u8, T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Dealigned` redefined here | - = error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:LL:CC: builtin derive created an unaligned reference - --> $DIR/multiple_definitions_attribute_merging.rs:18:25 - | -LL | #[derive(PartialEq)] - | --------- in this derive macro expansion -LL | #[repr(C)] -LL | struct Dealigned(u8, T); - | ^ - - -builtin derive created an unaligned reference -error: the compiler unexpectedly panicked. This is a bug + = note: `Dealigned` must be defined only once in the type namespace of this module -query stack during panic: -#0 [mir_built] building MIR for `::eq` -#1 [check_unsafety] unsafety-checking `::eq` -... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/static/duplicated-fields-issue-124464.rs b/tests/ui/static/duplicated-fields-issue-124464.rs index 60609edbfebb6..2997dcd600bc7 100644 --- a/tests/ui/static/duplicated-fields-issue-124464.rs +++ b/tests/ui/static/duplicated-fields-issue-124464.rs @@ -3,8 +3,6 @@ enum TestOption { TestSome(T), - TestSome(T), -//~^ ERROR the name `TestSome` is defined multiple times } pub struct Request { diff --git a/tests/ui/static/duplicated-fields-issue-124464.stderr b/tests/ui/static/duplicated-fields-issue-124464.stderr index a36192ae8d69d..5a2f3a74e6a61 100644 --- a/tests/ui/static/duplicated-fields-issue-124464.stderr +++ b/tests/ui/static/duplicated-fields-issue-124464.stderr @@ -1,22 +1,11 @@ -error[E0428]: the name `TestSome` is defined multiple times - --> $DIR/duplicated-fields-issue-124464.rs:6:5 - | -LL | TestSome(T), - | ----------- previous definition of the type `TestSome` here -LL | TestSome(T), - | ^^^^^^^^^^^ `TestSome` redefined here - | - = note: `TestSome` must be defined only once in the type namespace of this enum - error[E0124]: field `bar` is already declared - --> $DIR/duplicated-fields-issue-124464.rs:12:5 + --> $DIR/duplicated-fields-issue-124464.rs:10:5 | LL | bar: TestOption, | -------------------- `bar` first declared here LL | bar: u8, | ^^^^^^^ field already declared -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0124, E0428. -For more information about an error, try `rustc --explain E0124`. +For more information about this error, try `rustc --explain E0124`. diff --git a/tests/ui/traits/issue-106072.rs b/tests/ui/traits/issue-106072.rs index 6b04004621d82..73b4ce8fbb9b0 100644 --- a/tests/ui/traits/issue-106072.rs +++ b/tests/ui/traits/issue-106072.rs @@ -1,4 +1,4 @@ -#[derive(Clone)] //~ ERROR: expected a type, found a trait -struct Foo; //~ ERROR: expected a type, found a trait +#[derive(Clone)] +struct Foo; trait Foo {} //~ ERROR: the name `Foo` is defined multiple times fn main() {} diff --git a/tests/ui/traits/issue-106072.stderr b/tests/ui/traits/issue-106072.stderr index 57661fda73079..db37d02ece1f6 100644 --- a/tests/ui/traits/issue-106072.stderr +++ b/tests/ui/traits/issue-106072.stderr @@ -8,21 +8,6 @@ LL | trait Foo {} | = note: `Foo` must be defined only once in the type namespace of this module -error[E0782]: expected a type, found a trait - --> $DIR/issue-106072.rs:2:8 - | -LL | #[derive(Clone)] - | ----- in this derive macro expansion -LL | struct Foo; - | ^^^ - -error[E0782]: expected a type, found a trait - --> $DIR/issue-106072.rs:1:10 - | -LL | #[derive(Clone)] - | ^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0428, E0782. -For more information about an error, try `rustc --explain E0428`. +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.rs b/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.rs index 1d17909e26a92..5f5ce47b68beb 100644 --- a/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.rs +++ b/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.rs @@ -14,7 +14,6 @@ trait FooMut { let collection = vec![_I].iter().map(|x| ()); //~^ ERROR: cannot find value `_I` in this scope self.bar(collection); - //~^ ERROR: `&'b _` is not an iterator } } diff --git a/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr b/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr index 7f160b1b7e951..799021598f481 100644 --- a/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr +++ b/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr @@ -11,6 +11,7 @@ LL | | LL | | where LL | | I: Iterator, ... | +LL | | self.bar(collection); LL | | } | |_____^ `bar` redefined here | @@ -22,25 +23,7 @@ error[E0425]: cannot find value `_I` in this scope LL | let collection = vec![_I].iter().map(|x| ()); | ^^ not found in this scope -error[E0277]: `&'b _` is not an iterator - --> $DIR/iterator-item-suggest-no-ice.rs:16:18 - | -LL | self.bar(collection); - | --- ^^^^^^^^^^ `&'b _` is not an iterator - | | - | required by a bound introduced by this call - | - = help: the trait `for<'b> Iterator` is not implemented for `&'b _` -note: required by a bound in `FooMut::bar` - --> $DIR/iterator-item-suggest-no-ice.rs:7:24 - | -LL | fn bar(&self, _: I) - | --- required by a bound in this associated function -LL | where -LL | for<'b> &'b I: Iterator; - | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `FooMut::bar` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0425, E0428. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0425, E0428. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/traits/non_lifetime_binders/bad-bounds.rs b/tests/ui/traits/non_lifetime_binders/bad-bounds.rs index 4fccaf1d84f3c..65fa514ce6570 100644 --- a/tests/ui/traits/non_lifetime_binders/bad-bounds.rs +++ b/tests/ui/traits/non_lifetime_binders/bad-bounds.rs @@ -6,8 +6,8 @@ fn produce() -> for; //~ ERROR the name `A` is defined multiple times + enum B {} + struct A; }>> Trait {} //~ ERROR cannot find trait `Trait` in this scope fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/bad-bounds.stderr b/tests/ui/traits/non_lifetime_binders/bad-bounds.stderr index ffc238c3f3436..0fd41a209783c 100644 --- a/tests/ui/traits/non_lifetime_binders/bad-bounds.stderr +++ b/tests/ui/traits/non_lifetime_binders/bad-bounds.stderr @@ -1,13 +1,3 @@ -error[E0428]: the name `A` is defined multiple times - --> $DIR/bad-bounds.rs:10:5 - | -LL | enum A {} - | ------ previous definition of the type `A` here -LL | struct A; - | ^^^^^^^^^^^^ `A` redefined here - | - = note: `A` must be defined only once in the type namespace of this block - error[E0404]: expected trait, found type parameter `A` --> $DIR/bad-bounds.rs:6:24 | @@ -17,7 +7,7 @@ LL | fn produce() -> for; LL | | }>> Trait {} | |__^ not a trait @@ -35,12 +25,12 @@ LL | fn produce() -> for; LL | | }>> Trait {} | |__^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0404, E0405, E0428. +Some errors have detailed explanations: E0404, E0405. For more information about an error, try `rustc --explain E0404`.