-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.P-lowLow priorityLow priorityT-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
The following incorrect code:
#![derive(Debug)]
struct Coordinate(i32, i32);
fn main() {
println!("{:?}", Coordinate(4, 2));
}
generates the following output:
error: `derive` may only be applied to structs, enums and unions
--> src/main.rs:1:1
|
1 | #![derive(Debug)]
| ^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug)]`
error: cannot determine resolution for the derive macro `Debug`
--> src/main.rs:1:11
|
1 | #![derive(Debug)]
| ^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error[E0277]: `Coordinate` doesn't implement `std::fmt::Debug`
--> src/main.rs:5:22
|
5 | println!("{:?}", Coordinate(4, 2));
| ^^^^^^^^^^^^^^^^ `Coordinate` cannot be formatted using `{:?}`
|
= help: the trait `std::fmt::Debug` is not implemented for `Coordinate`
= note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug`
= note: required by `std::fmt::Debug::fmt`
We should not emit the second value, given it could detect that the following element is an ADT it could internally treat it as #[derive(Debug)]
so that no knock-down errors will happen.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.Category: This is a bug.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.P-lowLow priorityLow priorityT-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.