-
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
On type mismatch involving associated type, suggest constraint #71108
Merged
bors
merged 11 commits into
rust-lang:master
from
estebank:suggest-proj-type-mismatch-constraint
May 4, 2020
Merged
On type mismatch involving associated type, suggest constraint #71108
bors
merged 11 commits into
rust-lang:master
from
estebank:suggest-proj-type-mismatch-constraint
May 4, 2020
Commits on May 3, 2020
-
On type mismatch involving associated type, suggest constraint
When an associated type is found when a specific type was expected, if possible provide a structured suggestion constraining the associated type in a bound. ``` error[E0271]: type mismatch resolving `<T as Foo>::Y == i32` --> $DIR/associated-types-multiple-types-one-trait.rs:13:5 | LL | want_y(t); | ^^^^^^ expected `i32`, found associated type ... LL | fn want_y<T:Foo<Y=i32>>(t: &T) { } | ----- required by this bound in `want_y` | = note: expected type `i32` found associated type `<T as Foo>::Y` help: consider constraining the associated type `<T as Foo>::Y` to `i32` | LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T) | ^^^^^^^^^ ``` ``` error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:12:9 | LL | qux(x.func()) | ^^^^^^^^ expected `usize`, found associated type | = note: expected type `usize` found associated type `<impl Trait as Trait>::A` help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize` | LL | fn foo(x: impl Trait<A = usize>) { | ^^^^^^^^^^ ```
Configuration menu - View commit details
-
Copy full SHA for 3a795fb - Browse repository at this point
Copy the full SHA 3a795fbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 31b3566 - Browse repository at this point
Copy the full SHA 31b3566View commit details -
Configuration menu - View commit details
-
Copy full SHA for ee96b8b - Browse repository at this point
Copy the full SHA ee96b8bView commit details -
Point at associated types when they have a default type
Associated types with a default type in a trait can't be relied upon to remain of that default type when in use, so literals of that type can't be used in the trait's items. Point at the associated type and state that information. Reduce verbosity for associated consts of the wrong type.
Configuration menu - View commit details
-
Copy full SHA for 299bd12 - Browse repository at this point
Copy the full SHA 299bd12View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6648a08 - Browse repository at this point
Copy the full SHA 6648a08View commit details -
Configuration menu - View commit details
-
Copy full SHA for b0085c8 - Browse repository at this point
Copy the full SHA b0085c8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9bb5b54 - Browse repository at this point
Copy the full SHA 9bb5b54View commit details -
Configuration menu - View commit details
-
Copy full SHA for 74b7ed7 - Browse repository at this point
Copy the full SHA 74b7ed7View commit details -
Configuration menu - View commit details
-
Copy full SHA for de3b4d4 - Browse repository at this point
Copy the full SHA de3b4d4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3c872e2 - Browse repository at this point
Copy the full SHA 3c872e2View commit details
Commits on May 4, 2020
-
Configuration menu - View commit details
-
Copy full SHA for b368229 - Browse repository at this point
Copy the full SHA b368229View commit details
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.