rust/tests/ui/trait-bounds
Matthias Krüger aa184c558f
Rollup merge of #122195 - jieyouxu:impl-return-note, r=fmease
Note that the caller chooses a type for type param

```
error[E0308]: mismatched types
  --> $DIR/return-impl-trait.rs:23:5
   |
LL | fn other_bounds<T>() -> T
   |                 -       -
   |                 |       |
   |                 |       expected `T` because of return type
   |                 |       help: consider using an impl return type: `impl Trait`
   |                 expected this type parameter
...
LL |     ()
   |     ^^ expected type parameter `T`, found `()`
   |
   = note: expected type parameter `T`
                   found unit type `()`
   = note: the caller chooses the type of T which can be different from ()
```

Tried to see if "expected this type parameter" can be replaced, but that goes all the way to `rustc_infer` so seems not worth the effort and can affect other diagnostics.

Revives #112088 and #104755.
2024-03-22 20:31:28 +01:00
..
apit-unsized.rs
apit-unsized.stderr
argument-with-unnecessary-method-call.rs
argument-with-unnecessary-method-call.stderr
enum-unit-variant-trait-bound.rs
enum-unit-variant-trait-bound.stderr
ice-unsized-struct-arg-issue-121612.rs Add missing regression tests 2024-03-09 12:01:19 +05:30
ice-unsized-struct-arg-issue-121612.stderr Add missing regression tests 2024-03-09 12:01:19 +05:30
ice-unsized-struct-arg-issue2-121424.rs Add missing regression tests 2024-03-09 12:01:19 +05:30
ice-unsized-struct-arg-issue2-121424.stderr Add missing regression tests 2024-03-09 12:01:19 +05:30
ice-unsized-tuple-const-issue-121443.rs
ice-unsized-tuple-const-issue-121443.stderr
impl-bound-with-references-error.rs
impl-bound-with-references-error.stderr
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
issue-119530-sugg-from-fn.rs
issue-119530-sugg-from-fn.stderr
mismatch-fn-trait.rs
mismatch-fn-trait.stderr
restrict-assoc-type-of-generic-bound.fixed
restrict-assoc-type-of-generic-bound.rs
restrict-assoc-type-of-generic-bound.stderr Note that type param is chosen by caller when suggesting return impl Trait 2024-03-16 23:20:42 +00:00
shadowed-path-in-trait-bound-suggestion.fixed
shadowed-path-in-trait-bound-suggestion.rs
shadowed-path-in-trait-bound-suggestion.stderr
suggest-maybe-sized-bound.rs
suggest-maybe-sized-bound.stderr
super-assoc-mismatch.rs
super-assoc-mismatch.stderr Provide structured suggestion for #![feature(foo)] 2024-03-18 16:08:58 +00:00
unsized-bound.rs
unsized-bound.stderr