Skip to content

Commit

Permalink
Add ui test where fallback impl conflicts with handwritten Display
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 15, 2023
1 parent 02c6a55 commit b94add8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/ui/fallback-impl-with-display.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::fmt::{self, Display};
use thiserror::Error;

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

impl Display for MyError {
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}

fn main() {}
16 changes: 16 additions & 0 deletions tests/ui/fallback-impl-with-display.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error: expected attribute arguments in parentheses: #[error(...)]
--> tests/ui/fallback-impl-with-display.rs:5:3
|
5 | #[error]
| ^^^^^

error[E0119]: conflicting implementations of trait `std::fmt::Display` for type `MyError`
--> tests/ui/fallback-impl-with-display.rs:4:10
|
4 | #[derive(Error, Debug)]
| ^^^^^ conflicting implementation for `MyError`
...
8 | impl Display for MyError {
| ------------------------ first implementation here
|
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit b94add8

Please sign in to comment.