-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-visibilityArea: Visibility / privacyArea: Visibility / privacyC-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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
Summary
snafu re-exports std::error::Error, which makes clippy show snafu::Error in diagnostics instead of std::error::Error.
cargo check will convert it into StdError.
Reproducer
Code:
trait JustTrait {}
#[derive(Debug)]
struct JustError;
impl std::fmt::Display for JustError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
impl std::error::Error for JustError {}
fn foo() -> impl JustTrait {
Box::new(JustError) as Box<dyn std::error::Error>
}Current output:
error[E0277]: the trait bound `std::boxed::Box<dyn snafu::Error>: JustTrait` is not satisfied
--> src/main.rs:125:13
|
125 | fn foo() -> impl JustTrait {
| ^^^^^^^^^^^^^^ the trait `JustTrait` is not implemented for `std::boxed::Box<dyn snafu::Error>`
126 | Box::new(JustError) as Box<dyn std::error::Error>
| ------------------------------------------------- return type was inferred to be `std::boxed::Box<dyn snafu::Error>` here
|
help: this trait has no implementations, consider adding one
--> src/main.rs:112:1
|
112 | trait JustTrait {}
| ^^^^^^^^^^^^^^^
Desired output:
cargo check output:
error[E0277]: the trait bound `Box<dyn StdError>: JustTrait` is not satisfied
--> src/main.rs:125:13
|
125 | fn foo() -> impl JustTrait {
| ^^^^^^^^^^^^^^ the trait `JustTrait` is not implemented for `Box<dyn StdError>`
126 | Box::new(JustError) as Box<dyn std::error::Error>
| ------------------------------------------------- return type was inferred to be `Box<dyn StdError>` here
|
help: this trait has no implementations, consider adding one
--> src/main.rs:112:1
|
112 | trait JustTrait {}
| ^^^^^^^^^^^^^^^
Version
rustc 1.95.0-nightly (3a70d0349 2026-02-27)
binary: rustc
commit-hash: 3a70d0349fa378a10c3748f1a48742e61505020f
commit-date: 2026-02-27
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0
Additional Labels
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-visibilityArea: Visibility / privacyArea: Visibility / privacyC-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.