-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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
Given the following code (Playground):
fn foo() where String: Copy {}
struct Bar;
impl Bar where String: Copy {}
The current output is:
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/lib.rs:1:1
|
1 | fn foo() where String: Copy {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
= help: see issue #48214
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/lib.rs:4:1
|
4 | impl Bar where String: Copy {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
= help: see issue #48214
Ideally the output should look like:
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/lib.rs:1:1
|
1 | fn foo() where String: Copy {}
| ^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
= help: see issue #48214
error[E0277]: the trait bound `String: Copy` is not satisfied
--> src/lib.rs:4:1
|
4 | impl Bar where String: Copy {}
| ^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
= help: see issue #48214
The difference is just the span. This is particularly useful for macros which are probably the main producers of trivial bounds. You want the "the trait bound not satisfied" error of emitted code to have a good span. But since rustc currently uses the span of the whole item, that's often not possible.
Related: #48214
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.