Open
Description
Code
// main.rs
// mentioning `use testing` is important
use testing::{};
struct S1 {}
struct S2 {}
fn main() {
<S1 as MainTrait>::test();
}
// :Sized + return Self and no Sized and Box<Self> still trigger this
trait MainTrait {
fn test();
}
impl MainTrait for S2 {
fn test() {
todo!()
}
}
// lib.rs
pub trait LibTrait {}
Current output
Checking testing v0.1.0 (/home/ved-s/code/Rust/testing)
warning: unused import: `testing::{}`
--> src/main.rs:1:5
|
1 | use testing::{};
| ^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0277]: the trait bound `S1: MainTrait` is not satisfied
--> src/main.rs:8:6
|
8 | <S1 as MainTrait>::test();
| ^^ the trait `MainTrait` is not implemented for `S1`
|
note: there are multiple different versions of crate `testing` in the dependency graph
--> src/main.rs:12:1
|
1 | use testing::{};
| ------- one version of crate `testing` used here, as a direct dependency of the current crate
2 |
3 | struct S1 {}
| --------- this type doesn't implement the required trait
...
12 | trait MainTrait {
| ^^^^^^^^^^^^^^^ this is the required trait
|
::: /home/ved-s/code/Rust/testing/src/lib.rs:1:1
|
1 | pub trait LibTrait {}
| ------------------ this is the found trait
= help: you can use `cargo tree` to explore your dependency tree
For more information about this error, try `rustc --explain E0277`.
warning: `testing` (bin "testing") generated 1 warning
error: could not compile `testing` (bin "testing") due to 1 previous error; 1 warning emitted
Desired output
no `multiple different versions` note and pointing to the first trait in the lib.rs
Rationale and extra context
No response
Other cases
Rust Version
rustc 1.86.0-nightly (854f22563 2025-01-31)
binary: rustc
commit-hash: 854f22563c8daf92709fae18ee6aed52953835cd
commit-date: 2025-01-31
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Anything else?
No response