Commit Graph

7 Commits

Author SHA1 Message Date
Matthias Krüger
8a13157c16
Rollup merge of #106702 - estebank:trait-bounds, r=compiler-errors
Conserve cause of `ImplDerivedObligation` in E0599

CC #86377.
2023-01-12 06:52:38 +01:00
Matthias Krüger
a8bd0c04b4
Rollup merge of #106167 - yanchen4791:issue-105544-fix, r=oli-obk
Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311

Fixes #105544

The problems: The suggestion given for E0311 has invalid syntax when the synthetic type parameter is used for Trait type in function declaration:
```rust
fn foo(d: impl Sized) -> impl Sized
```
instead of explicitly specified like the following:
```rust
fn foo<T: Sized>(d: T) -> impl Sized
```
In addition to the syntax error, the suggestions given for E0311 are not complete when multiple elided lifetimes are involved in lifetime bounds, not all involved parameters are given the named lifetime in the suggestions. For the following test case:
```
fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ {
    (d, p)
}
```
a good suggestion should add the lifetime 'a to both d and p, instead of d only:
```
fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ {
    (d, p)
}
```

The Solution: Fix the syntax problem in the suggestions when synthetic type parameter is used, and also add lifetimes for all involved parameters.
2023-01-12 06:52:34 +01:00
yanchen4791
621d412241
Fix invalid syntax in impl Trait parameter type suggestions for E0311 2023-01-11 14:49:55 -08:00
Michael Goulet
9a39d7e441 Note predicate span on ImplDerivedObligation 2023-01-11 19:46:45 +00:00
Esteban Küber
317adda649 Tweak output 2023-01-11 19:31:34 +00:00
Esteban Küber
fb5d215347 Conserve cause of ImplDerivedObligation in E0599
CC #86377.
2023-01-11 19:31:33 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00