Skip to content

Commit 93f3d08

Browse files
committed
Don't emit errors containing type error as another (more useful) error must have been emitted already
1 parent 0382c00 commit 93f3d08

12 files changed

+13
-74
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,10 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
540540
}
541541

542542
if let Some((prev_span, prev_ty)) = self.found {
543-
if *concrete_type != prev_ty {
543+
if *concrete_type != prev_ty
544+
&& !concrete_type.references_error()
545+
&& !prev_ty.references_error()
546+
{
544547
debug!("find_opaque_ty_constraints: span={:?}", span);
545548
// Found different concrete types for the opaque type.
546549
let mut err = self.tcx.sess.struct_span_err(

src/test/ui/generator/layout-error.min_tait.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,7 @@ LL | static POOL: Task<F> = Task::new();
2222
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
2323
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
2424

25-
error: concrete type differs from previous defining opaque type use
26-
--> $DIR/layout-error.rs:31:24
27-
|
28-
LL | Task::spawn(&POOL, || cb());
29-
| ^^^^^^^ expected `[type error]`, got `impl Future`
30-
|
31-
note: previous use here
32-
--> $DIR/layout-error.rs:30:5
33-
|
34-
LL | static POOL: Task<F> = Task::new();
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36-
37-
error: aborting due to 4 previous errors
25+
error: aborting due to 3 previous errors
3826

3927
Some errors have detailed explanations: E0425, E0658.
4028
For more information about an error, try `rustc --explain E0425`.

src/test/ui/generator/layout-error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ fn main() {
2929
// Check that statics are inhabited computes they layout.
3030
static POOL: Task<F> = Task::new(); //[min_tait]~ ERROR not permitted here
3131
Task::spawn(&POOL, || cb()); //[min_tait]~ ERROR type alias impl trait is not permitted here
32-
//[min_tait]~^ ERROR concrete type differs from previous
3332
}

src/test/ui/generator/metadata-sufficient-for-layout.full_tait.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_binding
1616
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
1717

1818
error: fatal error triggered by #[rustc_error]
19-
--> $DIR/metadata-sufficient-for-layout.rs:29:1
19+
--> $DIR/metadata-sufficient-for-layout.rs:28:1
2020
|
2121
LL | fn main() {}
2222
| ^^^^^^^^^

src/test/ui/generator/metadata-sufficient-for-layout.min_tait.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ LL | static A: Option<F> = None;
77
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
88
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
99

10-
error: concrete type differs from previous defining opaque type use
11-
--> $DIR/metadata-sufficient-for-layout.rs:25:1
12-
|
13-
LL | fn f() -> F { metadata_sufficient_for_layout::g() }
14-
| ^^^^^^^^^^^ expected `[type error]`, got `impl Generator`
15-
|
16-
note: previous use here
17-
--> $DIR/metadata-sufficient-for-layout.rs:22:1
18-
|
19-
LL | static A: Option<F> = None;
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
21-
22-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
2311

2412
For more information about this error, try `rustc --explain E0658`.

src/test/ui/generator/metadata-sufficient-for-layout.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ static A: Option<F> = None;
2323
//[min_tait]~^ ERROR not permitted here
2424

2525
fn f() -> F { metadata_sufficient_for_layout::g() }
26-
//[min_tait]~^ ERROR concrete type differs
2726

2827
#[rustc_error]
2928
fn main() {} //[full_tait]~ ERROR

src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.min_tait.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ LL | let null = || -> Opaque { 0 };
77
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
88
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
99

10-
error: concrete type differs from previous defining opaque type use
11-
--> $DIR/issue-52843-closure-constrain.rs:13:16
12-
|
13-
LL | let null = || -> Opaque { 0 };
14-
| ^^^^^^^^^^^^^^^^^^ expected `String`, got `[type error]`
15-
|
16-
note: previous use here
17-
--> $DIR/issue-52843-closure-constrain.rs:12:5
18-
|
19-
LL | fn _unused() -> Opaque { String::new() }
20-
| ^^^^^^^^^^^^^^^^^^^^^^
21-
22-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
2311

2412
For more information about this error, try `rustc --explain E0658`.

src/test/ui/type-alias-impl-trait/issue-52843-closure-constrain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ fn main() {
1111
type Opaque = impl Debug;
1212
fn _unused() -> Opaque { String::new() }
1313
let null = || -> Opaque { 0 }; //[min_tait]~ ERROR: not permitted here
14-
//~^ ERROR: concrete type differs from previous defining opaque type use
14+
//[full_tait]~^ ERROR: concrete type differs from previous defining opaque type use
1515
println!("{:?}", null());
1616
}

src/test/ui/type-alias-impl-trait/issue-60407.min_tait.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ LL | static mut TEST: Option<Debuggable> = None;
77
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
88
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
99

10-
error: concrete type differs from previous defining opaque type use
11-
--> $DIR/issue-60407.rs:16:1
12-
|
13-
LL | fn foo() -> Debuggable {
14-
| ^^^^^^^^^^^^^^^^^^^^^^ expected `[type error]`, got `u32`
15-
|
16-
note: previous use here
17-
--> $DIR/issue-60407.rs:9:1
18-
|
19-
LL | static mut TEST: Option<Debuggable> = None;
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21-
22-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
2311

2412
For more information about this error, try `rustc --explain E0658`.

src/test/ui/type-alias-impl-trait/issue-60407.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ fn main() { //[full_tait]~ ERROR
1313
unsafe { TEST = Some(foo()) }
1414
}
1515

16-
fn foo() -> Debuggable { //[min_tait]~ ERROR concrete type differs
16+
fn foo() -> Debuggable {
1717
0u32
1818
}

0 commit comments

Comments
 (0)