Open
Description
I tried this code:
#![warn(rust_2024_prelude_collisions)]
pub mod prelude {
pub use crate::inner::FExt as _;
}
pub mod inner {
pub trait FExt {
fn into_future(self) -> StreamFuture
where
Self: Sized,
{
StreamFuture
}
}
pub struct StreamFuture;
pub struct F;
impl FExt for F {}
}
use crate::prelude::*;
pub fn f() {
let _ = crate::inner::F.into_future();
}
This generates a suggestion to modify the code like this:
@@ -23,5 +23,5 @@
use crate::prelude::*;
pub fn f() {
- let _ = crate::inner::F.into_future();
+ let _ = FExt::into_future(crate::inner::F);
}
However, this fails to compile with the following error:
error[E0433]: failed to resolve: use of undeclared type `FExt`
--> src/lib.rs:26:13
|
26 | let _ = FExt::into_future(crate::inner::F);
| ^^^^ use of undeclared type `FExt`
|
help: consider importing one of these traits
|
23 + use crate::inner::FExt;
|
23 + use f::FExt;
|
warning: unused import: `crate::prelude::*`
--> src/lib.rs:23:5
|
23 | use crate::prelude::*;
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
For more information about this error, try `rustc --explain E0433`.
Because the _
import does not give the trait a name.
This comes up in real-life with importing use futures::prelude::*
.
I'm not sure what the best solution to this would be. Perhaps it could detect a similar scenario, and fully qualify the path to the trait (like futures::StreamExt::into_future
). Or just always fully qualify it?
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (59cec72a5 2024-11-08)
binary: rustc
commit-hash: 59cec72a57af178767a7b8e7f624b06cc50f1087
commit-date: 2024-11-08
host: aarch64-apple-darwin
release: 1.84.0-nightly
LLVM version: 19.1.3
Metadata
Metadata
Assignees
Labels
Area: The 2024 editionArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Name/path resolution done by `rustc_resolve` specificallyArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: An error or lint that should account for edition differences.Diagnostics: A structured suggestion resulting in incorrect code.Issue: This issue has been reviewed and triaged by the Edition team.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team