File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //! Make sure that proc-macros which panic with a payload other than
2+ //! `String` or `&'static str` do not ICE.
3+ //@ proc-macro: any-panic-payload.rs
4+
5+ extern crate any_panic_payload;
6+
7+ use any_panic_payload:: * ;
8+
9+ cause_panic ! ( ) ; //~ ERROR proc macro panicked
10+
11+ #[ cause_panic_attr] //~ ERROR custom attribute panicked
12+ struct A ;
13+
14+ #[ derive( CausePanic ) ] //~ ERROR proc-macro derive panicked
15+ struct B ;
16+
17+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: proc macro panicked
2+ --> $DIR/any-panic-payload.rs:9:1
3+ |
4+ LL | cause_panic!();
5+ | ^^^^^^^^^^^^^^
6+
7+ error: custom attribute panicked
8+ --> $DIR/any-panic-payload.rs:11:1
9+ |
10+ LL | #[cause_panic_attr]
11+ | ^^^^^^^^^^^^^^^^^^^
12+
13+ error: proc-macro derive panicked
14+ --> $DIR/any-panic-payload.rs:14:10
15+ |
16+ LL | #[derive(CausePanic)]
17+ | ^^^^^^^^^^
18+
19+ error: aborting due to 3 previous errors
20+
Original file line number Diff line number Diff line change 1+ extern crate proc_macro;
2+
3+ use proc_macro:: TokenStream ;
4+
5+ fn boom ( ) -> TokenStream {
6+ std:: panic:: panic_any ( 42 )
7+ }
8+
9+ #[ proc_macro]
10+ pub fn cause_panic ( _: TokenStream ) -> TokenStream {
11+ boom ( )
12+ }
13+
14+ #[ proc_macro_attribute]
15+ pub fn cause_panic_attr ( _: TokenStream , _: TokenStream ) -> TokenStream {
16+ boom ( )
17+ }
18+
19+ #[ proc_macro_derive( CausePanic ) ]
20+ pub fn cause_panic_derive ( _: TokenStream ) -> TokenStream {
21+ boom ( )
22+ }
You can’t perform that action at this time.
0 commit comments