- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
#[derive(Debug)]
pub struct X;
impl Add for X {} // trigger unused import
fn main() {}After #44215, this gives the following error message:
error[E0405]: cannot find trait `Add` in this scope
 --> x.rs:4:6
  |
4 | impl Add for X {} // trigger unused import
  |      ^^^ not found in this scope
  |
help: possible candidate is found in another module, you can import it into scope
  |
2 | use std::ops::Add; // <--- LINE 2 HERE
  |
error: cannot continue compilation due to previous error
This suggests placing the use-statement at line 2, which is between the #[derive] and the pub struct X; line, while we want to place the use statement before the #[derive].
cc @oli-obk
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.