Skip to content

bad suggestion line for use statements with a derive #44995

Closed
@arielb1

Description

@arielb1
#[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

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions