-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Description
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics