rust/tests/ui/trait-bounds
Matthias Krüger 6cb627b681
Rollup merge of #117505 - estebank:issue-117501, r=TaKO8Ki
Fix incorrect trait bound restriction suggestion

Suggest

```
error[E0308]: mismatched types
  --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12
   |
LL | pub fn foo<A: MyTrait, B>(a: A) -> B {
   |                        -           - expected `B` because of return type
   |                        |
   |                        expected this type parameter
LL |     return a.bar();
   |            ^^^^^^^ expected type parameter `B`, found associated type
   |
   = note: expected type parameter `B`
             found associated type `<A as MyTrait>::T`
help: consider further restricting this bound
   |
LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B {
   |                      +++++++
```

instead of

```
error[E0308]: mismatched types
  --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12
   |
LL | pub fn foo<A: MyTrait, B>(a: A) -> B {
   |                        -           - expected `B` because of return type
   |                        |
   |                        expected this type parameter
LL |     return a.bar();
   |            ^^^^^^^ expected type parameter `B`, found associated type
   |
   = note: expected type parameter `B`
             found associated type `<A as MyTrait>::T`
help: consider further restricting this bound
   |
LL | pub fn foo<A: MyTrait + <T = B>, B>(a: A) -> B {
   |                      +++++++++
```

Fix #117501.
2023-11-03 12:44:50 +01:00
..
apit-unsized.rs
apit-unsized.stderr
enum-unit-variant-trait-bound.rs
enum-unit-variant-trait-bound.stderr
impl-bound-with-references-error.rs
impl-bound-with-references-error.stderr Extend impl's def_span to include where clauses 2023-10-09 11:47:02 +00:00
impl-derived-implicit-sized-bound-2.rs
impl-derived-implicit-sized-bound-2.stderr
impl-derived-implicit-sized-bound.rs
impl-derived-implicit-sized-bound.stderr
impl-missing-where-clause-lifetimes-from-trait.rs
impl-missing-where-clause-lifetimes-from-trait.stderr
issue-75961.rs
issue-82038.rs
issue-82038.stderr
issue-93008.rs
issue-94680.rs
issue-94999.rs
issue-95640.rs
mismatch-fn-trait.rs
mismatch-fn-trait.stderr Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
restrict-assoc-type-of-generic-bound.fixed Fix incorrect trait bound restriction suggestion 2023-11-02 18:04:41 +00:00
restrict-assoc-type-of-generic-bound.rs Fix incorrect trait bound restriction suggestion 2023-11-02 18:04:41 +00:00
restrict-assoc-type-of-generic-bound.stderr Fix incorrect trait bound restriction suggestion 2023-11-02 18:04:41 +00:00
shadowed-path-in-trait-bound-suggestion.fixed
shadowed-path-in-trait-bound-suggestion.rs
shadowed-path-in-trait-bound-suggestion.stderr
unsized-bound.rs
unsized-bound.stderr