forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#90709 - estebank:erase-known-type-params, r…
…=nagisa Only shown relevant type params in E0283 label When we point at a binding to suggest giving it a type, erase all the type for ADTs that have been resolved, leaving only the ones that could not be inferred. For small shallow types this is not a problem, but for big nested types with lots of params, this can otherwise cause a lot of unnecessary visual output.
- Loading branch information
Showing
5 changed files
with
201 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
fn main() { | ||
let foo = foo(1, ""); //~ ERROR E0283 | ||
} | ||
fn baz() { | ||
let bar = bar(1, ""); //~ ERROR E0283 | ||
} | ||
|
||
struct Bar<T, K, N: Default> { | ||
t: T, | ||
k: K, | ||
n: N, | ||
} | ||
|
||
fn bar<T, K, Z: Default>(t: T, k: K) -> Bar<T, K, Z> { | ||
Bar { t, k, n: Default::default() } | ||
} | ||
|
||
struct Foo<T, K, N: Default, M: Default> { | ||
t: T, | ||
k: K, | ||
n: N, | ||
m: M, | ||
} | ||
|
||
fn foo<T, K, W: Default, Z: Default>(t: T, k: K) -> Foo<T, K, W, Z> { | ||
Foo { t, k, n: Default::default(), m: Default::default() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
error[E0283]: type annotations needed for `Foo<i32, &str, W, Z>` | ||
--> $DIR/erase-type-params-in-label.rs:2:15 | ||
| | ||
LL | let foo = foo(1, ""); | ||
| --- ^^^ cannot infer type for type parameter `W` declared on the function `foo` | ||
| | | ||
| consider giving `foo` the explicit type `Foo<_, _, W, Z>`, where the type parameter `W` is specified | ||
| | ||
= note: cannot satisfy `_: Default` | ||
note: required by a bound in `foo` | ||
--> $DIR/erase-type-params-in-label.rs:25:17 | ||
| | ||
LL | fn foo<T, K, W: Default, Z: Default>(t: T, k: K) -> Foo<T, K, W, Z> { | ||
| ^^^^^^^ required by this bound in `foo` | ||
help: consider specifying the type arguments in the function call | ||
| | ||
LL | let foo = foo::<T, K, W, Z>(1, ""); | ||
| ++++++++++++++ | ||
|
||
error[E0283]: type annotations needed for `Bar<i32, &str, Z>` | ||
--> $DIR/erase-type-params-in-label.rs:5:15 | ||
| | ||
LL | let bar = bar(1, ""); | ||
| --- ^^^ cannot infer type for type parameter `Z` declared on the function `bar` | ||
| | | ||
| consider giving `bar` the explicit type `Bar<_, _, Z>`, where the type parameter `Z` is specified | ||
| | ||
= note: cannot satisfy `_: Default` | ||
note: required by a bound in `bar` | ||
--> $DIR/erase-type-params-in-label.rs:14:17 | ||
| | ||
LL | fn bar<T, K, Z: Default>(t: T, k: K) -> Bar<T, K, Z> { | ||
| ^^^^^^^ required by this bound in `bar` | ||
help: consider specifying the type arguments in the function call | ||
| | ||
LL | let bar = bar::<T, K, Z>(1, ""); | ||
| +++++++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0283`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters