Skip to content

Commit

Permalink
Merge pull request #265 from dtolnay/fallbackfixme
Browse files Browse the repository at this point in the history
Add test looking for invalid input to still generate an impl
  • Loading branch information
dtolnay authored Dec 15, 2023
2 parents 1c6c4bb + b010e52 commit 0444cd5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/ui/invalid-input-impl-anyway.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use thiserror::Error;

#[derive(Error, Debug)]
#[error]
pub struct MyError;

fn main() {
// FIXME: there should be no error on the following line. Thiserror should
// emit an Error impl regardless of the bad attribute.
_ = &MyError as &dyn std::error::Error;
}
13 changes: 13 additions & 0 deletions tests/ui/invalid-input-impl-anyway.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: expected attribute arguments in parentheses: #[error(...)]
--> tests/ui/invalid-input-impl-anyway.rs:4:3
|
4 | #[error]
| ^^^^^

error[E0277]: the trait bound `MyError: std::error::Error` is not satisfied
--> tests/ui/invalid-input-impl-anyway.rs:10:9
|
10 | _ = &MyError as &dyn std::error::Error;
| ^^^^^^^^ the trait `std::error::Error` is not implemented for `MyError`
|
= note: required for the cast from `&MyError` to `&dyn std::error::Error`

0 comments on commit 0444cd5

Please sign in to comment.