Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_expand/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ expand_trace_macro = trace_macro
expand_proc_macro_panicked =
proc macro panicked
.help = message: {$message}
expand_proc_macro_derive_tokens =
proc-macro derive produced unparseable tokens
7 changes: 7 additions & 0 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,10 @@ pub(crate) struct ProcMacroPanicked {
pub(crate) struct ProcMacroPanickedHelp {
pub message: String,
}

#[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_tokens)]
pub struct ProcMacroDeriveTokens {
#[primary_span]
pub span: Span,
}
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/proc_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl MultiItemModifier for DeriveProcMacro {

// fail if there have been errors emitted
if ecx.sess.parse_sess.span_diagnostic.err_count() > error_count_before {
ecx.struct_span_err(span, "proc-macro derive produced unparseable tokens").emit();
ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span });
}

ExpandResult::Ready(items)
Expand Down