diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-04-12 11:29:23 +0400 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-04-12 11:29:23 +0400 |
| commit | de2edb226b213c414546b4e739356f0524b871f6 (patch) | |
| tree | e0ef406fb350f3a5636b157c9c229b16e4a38b2a /compiler/rustc_codegen_gcc/example/alloc_example.rs | |
| parent | fa723160318fac5f3fa6f4141cfc41c0606a3008 (diff) | |
| download | rust-de2edb226b213c414546b4e739356f0524b871f6.tar.gz rust-de2edb226b213c414546b4e739356f0524b871f6.zip | |
Fix wrong suggestions for `T:`
This commit fixes a corner case in `suggest_constraining_type_params`
that was causing incorrect suggestions.
For the following functions:
```rust
fn a<T:>(t: T) { [t, t]; }
fn b<T>(t: T) where T: { [t, t]; }
```
We previously suggested the following:
```text
...
help: consider restricting type parameter `T`
|
1 | fn a<T: Copy:>(t: T) { [t, t]; }
| ++++++
...
help: consider further restricting this bound
|
2 | fn b<T>(t: T) where T: + Copy { [t, t]; }
| ++++++
```
Note that neither `T: Copy:` not `where T: + Copy` is a correct bound.
With this commit the suggestions are correct:
```text
...
help: consider restricting type parameter `T`
|
1 | fn a<T: Copy>(t: T) { [t, t]; }
| ++++
...
help: consider further restricting this bound
|
2 | fn b<T>(t: T) where T: Copy { [t, t]; }
| ++++
```
Diffstat (limited to 'compiler/rustc_codegen_gcc/example/alloc_example.rs')
0 files changed, 0 insertions, 0 deletions
