Closed
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