diff options
| author | bors <bors@rust-lang.org> | 2020-05-04 06:32:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-05-04 06:32:49 +0000 |
| commit | d6823ba1666fa5f65e5fdd17cfc78ff227c092f2 (patch) | |
| tree | ff83906186e0ccc897fc117fd332296249a83e65 /src/librustc_parse/parser/expr.rs | |
| parent | ff4df04799c406c8149a041c3163321758aac924 (diff) | |
| parent | b368229d9bbaa840e777d33e36e649967e7ecb04 (diff) | |
| download | rust-d6823ba1666fa5f65e5fdd17cfc78ff227c092f2.tar.gz rust-d6823ba1666fa5f65e5fdd17cfc78ff227c092f2.zip | |
Auto merge of #71108 - estebank:suggest-proj-type-mismatch-constraint, r=oli-obk
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>) {
| ^^^^^^^^^^
```
Fix #71035. Related to #70908.
Diffstat (limited to 'src/librustc_parse/parser/expr.rs')
0 files changed, 0 insertions, 0 deletions
