Skip to content

stray #[derive( in possible candidate is found in another module diagnostic #44566

Closed
@arielb1

Description

@arielb1

Meta

This occurs in 539f208 (from 13-09) and 1.21 beta, but not on stable

STR

#[derive(Debug)]
pub struct X;

impl Add for X {} // trigger unused import

fn main() {}

Expected result

On stable, you get a correct candidate suggestion:

   Compiling playground v0.0.1 (file:///playground)
error[E0405]: cannot find trait `Add` in this scope
 --> src/main.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
  |
1 | use std::ops::Add;
  |

Actual Result

The suggestion contains a stray derive:

   Compiling playground v0.0.1 (file:///playground)
error[E0405]: cannot find trait `Add` in this scope
 --> src/main.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
  |
1 | #[derive(use std::ops::Add; <--- STRAY DERIVE IN SUGGESTION
  |

cc @jseyfried @estebank

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions