Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0634.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_resolve/src/diagnostics/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -2872,7 +2878,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
break;
}
}

err.emit();
}

Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeId, Symbol> = 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<LocalDefId, OnUnknownData> = default::fx_hash_map(),
features: &'tcx Features,
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 0 additions & 8 deletions tests/crashes/120873.rs

This file was deleted.

12 changes: 12 additions & 0 deletions tests/crashes/155482-2.rs
Original file line number Diff line number Diff line change
@@ -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);
},
)
}
12 changes: 7 additions & 5 deletions tests/crashes/155482.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//@ known-bug: #155482
trait TraitA < AsA = impl TraitB < {
#[derive(Hash)]
enum A;
struct A<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);
});
}
>> ;
1 change: 0 additions & 1 deletion tests/ui/consts/const-item-no-type/in-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)*
}
}
Expand Down
19 changes: 2 additions & 17 deletions tests/ui/consts/const-item-no-type/in-macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ help: provide a type for the item
LL | const A: <type> = "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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod ice_155125 {
struct S<const N: usize>;
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
Expand Down
1 change: 0 additions & 1 deletion tests/ui/delegation/inside-const-body-ice-155300.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub struct S<const N: usize>;
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;
Expand Down
16 changes: 2 additions & 14 deletions tests/ui/delegation/inside-const-body-ice-155300.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`.
3 changes: 1 addition & 2 deletions tests/ui/delegation/unlowered-path-ice-154820.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 3 additions & 30 deletions tests/ui/delegation/unlowered-path-ice-154820.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`.
1 change: 0 additions & 1 deletion tests/ui/delegation/wrong-fn-kind-ice-159127.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 2 additions & 13 deletions tests/ui/delegation/wrong-fn-kind-ice-159127.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
struct NotSM;

#[derive(PartialEq, Eq)]
//~^ ERROR: struct takes 0 generic arguments
struct NotSM<T>(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() {}
Loading
Loading