rust/tests/ui/delegation/bad-resolve.rs
Esteban Küber dd52bfc76e Reword "crate not found" resolve message
```
error[E0432]: unresolved import `some_novel_crate`
 --> file.rs:1:5
  |
1 | use some_novel_crate::Type;
  |     ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate`
```

On resolve errors where there might be a missing crate, mention `cargo add foo`:

```
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope`
  --> $DIR/conflicting-impl-with-err.rs:4:11
   |
LL | impl From<nope::Thing> for Error {
   |           ^^^^ use of unresolved module or unlinked crate `nope`
   |
   = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml`
```
2025-01-24 01:19:50 +00:00

47 lines
1.4 KiB
Rust

#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
const C: u32 = 0;
type Type;
fn bar() {}
fn foo(&self, x: i32) -> i32 { x }
}
struct F;
impl Trait for F {
type Type = i32;
}
impl F {
fn foo(&self, x: i32) -> i32 { x }
}
struct S(F);
impl Trait for S {
//~^ ERROR not all trait items implemented, missing: `Type`
reuse <F as Trait>::C;
//~^ ERROR item `C` is an associated method, which doesn't match its trait `Trait`
//~| ERROR expected function, found associated constant `Trait::C`
reuse <F as Trait>::Type;
//~^ ERROR item `Type` is an associated method, which doesn't match its trait `Trait`
//~| ERROR expected method or associated constant, found associated type `Trait::Type`
reuse <F as Trait>::baz;
//~^ ERROR method `baz` is not a member of trait `Trait`
//~| ERROR cannot find method or associated constant `baz` in trait `Trait`
reuse <F as Trait>::bar;
reuse foo { &self.0 }
//~^ ERROR cannot find function `foo` in this scope
reuse Trait::foo2 { self.0 }
//~^ ERROR cannot find function `foo2` in trait `Trait`
//~| ERROR method `foo2` is not a member of trait `Trait`
}
mod prefix {}
reuse unresolved_prefix::{a, b, c}; //~ ERROR use of unresolved module or unlinked crate
reuse prefix::{self, super, crate}; //~ ERROR `crate` in paths can only be used in start position
fn main() {}