Skip to content

Commit

Permalink
Auto merge of #125852 - bvanjoi:improve-tip-for-invisible-trait, r=co…
Browse files Browse the repository at this point in the history
…mpiler-errors

improve tip for inaccessible traits

Improve the tips when the candidate method is from an inaccessible trait.

For example:

```rs
mod m {
  trait Trait {
    fn f() {}
  }
  impl<T> Trait for T {}
}

fn main() {
  struct S;
  S::f();
}
```

The difference between before and now is:

```diff
error[E0599]: no function or associated item named `f` found for struct `S` in the current scope
  --> ./src/main.rs:88:6
   |
LL |   struct S;
   |   -------- function or associated item `f` not found for this struct
LL |   S::f();
   |      ^ function or associated item not found in `S`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
- help: trait `Trait` which provides `f` is implemented but not in scope; perhaps you want to import it
+ help: trait `crate::m::Trait` which provides `f` is implemented but not reachable
   |
- LL + use crate::m::Trait;
   |
```
  • Loading branch information
bors committed Jun 19, 2024
2 parents 658ece3 + f764eb8 commit be080ca
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit be080ca

Please sign in to comment.