Skip to content

Bad second error about Copy reference #50480

Closed
@remexre

Description

@remexre

The code

#[derive(Clone, Copy)]
struct Foo<'a>(&'a NotDefined);

fn main() {}

results in

error[E0412]: cannot find type `NotDefined` in this scope
 --> src/main.rs:2:20
  |
2 | struct Foo<'a>(&'a NotDefined);
  |                    ^^^^^^^^^^ not found in this scope

error[E0204]: the trait `Copy` may not be implemented for this type
 --> src/main.rs:1:17
  |
1 | #[derive(Clone, Copy)]
  |                 ^^^^
2 | struct Foo<'a>(&'a NotDefined);
  |                --------------- this field does not implement `Copy`

Many warnings can end up between these two, so somebody who starts reading errors from the bottom up can become very confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions