Skip to content

Commit

Permalink
Add "in this derive macro expansion" to missing Display errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 7, 2024
1 parent 714229d commit 07e7d99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ fn impl_enum(input: Enum) -> TokenStream {
// deprecated type without triggering deprecation warning on the generated impl.
fn call_site_ident(ident: &Ident) -> Ident {
let mut ident = ident.clone();
ident.set_span(Span::call_site());
ident.set_span(ident.span().resolved_at(Span::call_site()));
ident
}

Expand Down
6 changes: 4 additions & 2 deletions tests/ui/missing-display.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
error[E0277]: `MyError` doesn't implement `std::fmt::Display`
--> tests/ui/missing-display.rs:3:10
--> tests/ui/missing-display.rs:4:10
|
3 | #[derive(Error, Debug)]
| ^^^^^ `MyError` cannot be formatted with the default formatter
| ----- in this derive macro expansion
4 | pub enum MyError {
| ^^^^^^^ `MyError` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `MyError`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
Expand Down

0 comments on commit 07e7d99

Please sign in to comment.