Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Errors with incorrectly typed parameters to trait functions incorrectly point to function #46658

Closed
mqudsi opened this issue Dec 11, 2017 · 3 comments · Fixed by #64498
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics

Comments

@mqudsi
Copy link
Contributor

mqudsi commented Dec 11, 2017

When a parameter of an unexpected type is passed to a trait function, the resulting error message points to the function and not the parameter. Since the function is defined elsewhere (perhaps in another crate altogether), clearly the error is with the parameter and the error message should be altered to reflect that by pointing to the parameter.

Example:

debug!("expected signature: {}", base64::encode(&hmac.result()));

generates the following error:

   Compiling messagebridge v0.2.0 (file:///Users/mqudsi/Projects/messagebridge)
error[E0277]: the trait bound `crypto::mac::MacResult: std::convert::AsRef<[u8]>` is not satisfied
   --> src/incoming.rs:141:42
    |
141 |         debug!("expected signature: {}", base64::encode(&hmac.result()));
    |                                          ^^^^^^^^^^^^^^ the trait `std::convert::AsRef<[u8]>` is not implemented for `crypto::mac::MacResult`
    |
    = note: required by `base64::encode`

error: aborting due to previous error

error: Could not compile `messagebridge`.

To learn more, run the command again with --verbose.

The text of the error message is correct (it is describing the problem with the parameter) but the arrows point to the impl fn and not the parameter.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. E-needs-mentor WG-diagnostics Working group: Diagnostics labels Dec 11, 2017
@AgustinCB
Copy link
Contributor

I can take a look at this!

@mqudsi
Copy link
Contributor Author

mqudsi commented Dec 13, 2017

Thanks, @AgustinCB

@estebank
Copy link
Contributor

CC #48099

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants