Skip to content

Commit ae5a239

Browse files
committed
Avoid ?Sized local E0282 errors to provide better output and suggestions
1 parent 8ec1c38 commit ae5a239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+205
-219
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15051505
// begin with in those cases.
15061506
if self.tcx.lang_items().sized_trait() == Some(data.trait_ref.def_id) {
15071507
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0282, &[])
1508-
.emit();
1508+
.delay_as_bug();
15091509
return;
15101510
}
15111511
// Try to find possible types that would satisfy the bounds in the type param to

src/test/ui/async-await/issues/issue-65159.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
async fn copy() -> Result<()> //~ ERROR wrong number of type arguments
66
{
77
Ok(())
8-
//~^ ERROR type annotations needed
98
}
109

1110
fn main() { }

src/test/ui/async-await/issues/issue-65159.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ error[E0107]: wrong number of type arguments: expected 2, found 1
44
LL | async fn copy() -> Result<()>
55
| ^^^^^^^^^^ expected 2 type arguments
66

7-
error[E0282]: type annotations needed
8-
--> $DIR/issue-65159.rs:7:5
9-
|
10-
LL | Ok(())
11-
| ^^ cannot infer type for type parameter `E` declared on the enum `Result`
12-
13-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
148

15-
Some errors have detailed explanations: E0107, E0282.
16-
For more information about an error, try `rustc --explain E0107`.
9+
For more information about this error, try `rustc --explain E0107`.

src/test/ui/closures/issue-52437.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
fn main() {
22
[(); &(&'static: loop { |x| {}; }) as *const _ as usize]
33
//~^ ERROR: invalid label name `'static`
4-
//~| ERROR: type annotations needed
54
//~| ERROR mismatched types
65
}

src/test/ui/closures/issue-52437.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error: invalid label name `'static`
44
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
55
| ^^^^^^^
66

7-
error[E0282]: type annotations needed
8-
--> $DIR/issue-52437.rs:2:30
9-
|
10-
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
11-
| ^ consider giving this closure parameter a type
12-
137
error[E0308]: mismatched types
148
--> $DIR/issue-52437.rs:2:5
159
|
@@ -18,7 +12,6 @@ LL | fn main() {
1812
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
1913
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]`
2014

21-
error: aborting due to 3 previous errors
15+
error: aborting due to 2 previous errors
2216

23-
Some errors have detailed explanations: E0282, E0308.
24-
For more information about an error, try `rustc --explain E0282`.
17+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/consts/issue-52432.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
fn main() {
44
[(); &(static |x| {}) as *const _ as usize];
55
//~^ ERROR: closures cannot be static
6-
//~| ERROR: type annotations needed
76
[(); &(static || {}) as *const _ as usize];
87
//~^ ERROR: closures cannot be static
98
//~| ERROR evaluation of constant value failed

src/test/ui/consts/issue-52432.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,18 @@ LL | [(); &(static |x| {}) as *const _ as usize];
55
| ^^^^^^^^^^
66

77
error[E0697]: closures cannot be static
8-
--> $DIR/issue-52432.rs:7:12
8+
--> $DIR/issue-52432.rs:6:12
99
|
1010
LL | [(); &(static || {}) as *const _ as usize];
1111
| ^^^^^^^^^
1212

13-
error[E0282]: type annotations needed
14-
--> $DIR/issue-52432.rs:4:20
15-
|
16-
LL | [(); &(static |x| {}) as *const _ as usize];
17-
| ^ consider giving this closure parameter a type
18-
1913
error[E0080]: evaluation of constant value failed
20-
--> $DIR/issue-52432.rs:7:10
14+
--> $DIR/issue-52432.rs:6:10
2115
|
2216
LL | [(); &(static || {}) as *const _ as usize];
2317
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
2418

25-
error: aborting due to 4 previous errors
19+
error: aborting due to 3 previous errors
2620

27-
Some errors have detailed explanations: E0080, E0282, E0697.
21+
Some errors have detailed explanations: E0080, E0697.
2822
For more information about an error, try `rustc --explain E0080`.

src/test/ui/consts/issue-64662.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
enum Foo {
22
A = foo(), //~ ERROR: type annotations needed
3-
B = foo(), //~ ERROR: type annotations needed
3+
B = foo(), // We don't emit an error here, but if the one above is fixed, we will.
44
}
55

66
const fn foo<T>() -> isize {

src/test/ui/consts/issue-64662.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0282]: type annotations needed
44
LL | A = foo(),
55
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
66

7-
error[E0282]: type annotations needed
8-
--> $DIR/issue-64662.rs:3:9
9-
|
10-
LL | B = foo(),
11-
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
12-
13-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
148

159
For more information about this error, try `rustc --explain E0282`.

src/test/ui/error-codes/E0401.stderr

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,22 @@ LL | fn helper(sel: &Self) -> u8 {
3232
| use of generic parameter from outer function
3333
| use a type here instead
3434

35-
error[E0282]: type annotations needed
35+
error[E0283]: type annotations needed
3636
--> $DIR/E0401.rs:11:5
3737
|
38+
LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) {
39+
| ------ required by this bound in `bfnr`
40+
...
3841
LL | bfnr(x);
39-
| ^^^^ cannot infer type for type parameter `U` declared on the function `bfnr`
42+
| ^^^^ cannot infer type for type parameter `V` declared on the function `bfnr`
43+
|
44+
= note: cannot satisfy `_: Baz<_>`
45+
help: consider specifying the type arguments in the function call
46+
|
47+
LL | bfnr::<U, V, W>(x);
48+
| ^^^^^^^^^^^
4049

4150
error: aborting due to 4 previous errors
4251

43-
Some errors have detailed explanations: E0282, E0401.
44-
For more information about an error, try `rustc --explain E0282`.
52+
Some errors have detailed explanations: E0283, E0401.
53+
For more information about an error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)