about summary refs log tree commit diff
path: root/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-09-29 03:16:11 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-10-13 19:13:56 +0000
commit781e86477cf71c7850d4d1f169c58d7e398654f7 (patch)
tree0a825a39f8c331e5dd1f611867d3efe79d8958f7 /tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
parentdf4379b4eb5357263f0cf75475953f9b5c48c31f (diff)
downloadrust-781e86477cf71c7850d4d1f169c58d7e398654f7.tar.gz
rust-781e86477cf71c7850d4d1f169c58d7e398654f7.zip
Suggest trait bounds for used associated type on type param
Fix #101351.

When an associated type on a type parameter is used, and the type
parameter isn't constrained by the correct trait, suggest the
appropriate trait bound:

```
error[E0220]: associated type `Associated` not found for `T`
 --> file.rs:6:15
  |
6 |     field: T::Associated,
  |               ^^^^^^^^^^ there is a similarly named associated type `Associated` in the trait `Foo`
  |
help: consider restricting type parameter `T`
  |
5 | struct Generic<T: Foo> {
  |                 +++++
  ```

When an associated type on a type parameter has a typo, suggest fixing
it:

```
error[E0220]: associated type `Baa` not found for `T`
  --> $DIR/issue-55673.rs:9:8
   |
LL |     T::Baa: std::fmt::Debug,
   |        ^^^ there is a similarly named associated type `Bar` in the trait `Foo`
   |
help: change the associated type name to use `Bar` from `Foo`
   |
LL |     T::Bar: std::fmt::Debug,
   |        ~~~
```
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs')
0 files changed, 0 insertions, 0 deletions