Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error when trait bound not satisfied for function argument should point at argument #41781

Closed
jdm opened this issue May 6, 2017 · 1 comment · Fixed by #64498
Closed

Error when trait bound not satisfied for function argument should point at argument #41781

jdm opened this issue May 6, 2017 · 1 comment · Fixed by #64498
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics

Comments

@jdm
Copy link
Contributor

jdm commented May 6, 2017

trait T {}

fn function<U: T>(u: U) {}

fn main() {
    function(0u32);
}

This yields:

error[E0277]: the trait bound `u32: T` is not satisfied
 --> <anon>:6:5
  |
6 |     function(0u32);
  |     ^^^^^^^^ the trait `T` is not implemented for `u32`
  |
  = note: required by `function`

error: aborting due to previous error

When there are multiple arguments, this is much less helpful than if the span pointed at the argument in question.

@jdm jdm added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 6, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 27, 2017
@estebank estebank added the WG-diagnostics Working group: Diagnostics label Dec 13, 2017
@estebank
Copy link
Contributor

Current output:

error[E0277]: the trait bound `u32: T` is not satisfied
 --> src/main.rs:6:5
  |
6 |     function(0u32);
  |     ^^^^^^^^ the trait `T` is not implemented for `u32`
  |
note: required by `function`
 --> src/main.rs:3:1
  |
3 | fn function<U: T>(u: U) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^

Centril added a commit to Centril/rust that referenced this issue Sep 20, 2019
When possible point at argument causing item obligation failure

Fix rust-lang#41781, fix rust-lang#42855, fix rust-lang#46658, fix rust-lang#48099, fix rust-lang#63143.
@bors bors closed this as completed in 7225264 Sep 20, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants