-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only shown relevant type params in E0283 label #90709
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
78e88f4
Only shown relevant type params in E0283 label
estebank 3fd15c8
Refer to uninferred `const` params by their name, instead of `{ _: _ }`
estebank 6a691b1
Refer to const params as "const params" and not "type params"
estebank 7271d1f
Add test with multiple type params failing inference
estebank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, ""); | ||
| ++++++++++++++ | ||
Comment on lines
+15
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Outstanding: changing this to also use |
||
|
||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly worried about the handling of
ty::Error
s that come in as part of the input as they become indistinguishable from those that are produced by thisTypeFolder
, but its probably fine…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that any naturally ocurring
ty::Error
should be displayed as_
anyways. Worst case scenario on the next wave of errors the user will be told to fill it in.