Repository navigation
Wrong span for E0277 error message "trait bound is not satisfied" #98645
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-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
Activity
Thanks for the report! I have transferred this to the rust-lang/rust repository as this is a rustc issue.
I bisected this to nightly-2021-10-27. There are several PRs which are candidates there 29b1248...e269e6b
The most likely look like either #90282, #90299, or #90075.
The previous error message looked like:
error[E0277]: the trait bound `Thing: From<u32>` is not satisfied --> src/main.rs:21:33 | 21 | BigThing::new(value, other, thing.try_into().unwrap()) | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<u32>` is not implemented for `Thing` | | | required by a bound introduced by this call | = note: required because of the requirements on the impl of `Into<Thing>` for `u32` = note: required because of the requirements on the impl of `TryFrom<u32>` for `Thing` = note: required because of the requirements on the impl of `TryInto<Thing>` for `u32` For more information about this error, try `rustc --explain E0277`.Reacted by sharif- changed the title
[-]`cargo check` error message says that wrong variable doesn't satisfy trait bound[/-][+]Wrong span for E0277 error message "trait bound is not satisfied"[/+]on Jun 28, 2022 - addedA-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.
on Jun 28, 2022 This is probably #90181
- added 2 commits that reference this issue
on Jun 29, 2022
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-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.
Problem
I had an error in my code where I tried to convert a
u32to an enum usingtry_intowithout implementing it first. My code essentially looked like this:This code generates the following error message:
The compiler correctly notes that I have not implemented
TryIntoonThingforu32, but it tells me that I haven't satisfied that trait bound forvalue, notthing. This problem does not occur if I use a struct initializer, only if I use a function.Steps
cargo checkPossible Solution(s)
My guess here is that when showing an error for trait bound in a function argument, the checker defaults to the first argument. I'm not familiar with
cargocode though so that's just speculation.Notes
I am using the nightly compiler, but the same problem occurs on stable.
Version