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 tweak suggestion for argument-position impl ?Sized 2023-06-15 12:00:57 +02:00
apit-unsized.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
enum-unit-variant-trait-bound.rs Walk through full path in point_at_path_if_possible 2023-08-25 19:05:38 +00:00
enum-unit-variant-trait-bound.stderr Walk through full path in point_at_path_if_possible 2023-08-25 19:05:38 +00:00
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 diagnostics: add test case for trait bounds diagnostic 2023-09-07 11:36:23 -07:00
issue-82038.stderr Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
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 Special-case item attributes in the suggestion output 2023-04-12 22:50:10 +00:00
unsized-bound.rs
unsized-bound.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00