Skip to content
Open
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
17 changes: 17 additions & 0 deletions tests/ui/proc-macro/auxiliary/sub-error-diag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(proc_macro_diagnostic)]

extern crate proc_macro;

use proc_macro::{Diagnostic, Level, Span};

#[proc_macro_attribute]
pub fn proc_emit_err(
_: proc_macro::TokenStream,
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
Diagnostic::new(Level::Error, "Parent message")
.span_error(Span::call_site(), "Child message")
.emit();

input
}
13 changes: 13 additions & 0 deletions tests/ui/proc-macro/sub-error-diag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ proc-macro: sub-error-diag.rs

// Regression test for issue https://github.com/rust-lang/rust/issues/145305, which used to cause an ICE
// due to an assertion in the compiler that errors could not be subdiagnostics.

extern crate sub_error_diag;

//~? ERROR: Parent message
#[sub_error_diag::proc_emit_err]
//~^ ERROR: Child message
fn foo() {}

fn main() {}
11 changes: 11 additions & 0 deletions tests/ui/proc-macro/sub-error-diag.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: Parent message
|
error: Child message
--> $DIR/sub-error-diag.rs:9:1
|
LL | #[sub_error_diag::proc_emit_err]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `sub_error_diag::proc_emit_err` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

Loading