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+ #![ feature( proc_macro_quote) ]
2+
3+ extern crate proc_macro;
4+ use proc_macro:: * ;
5+
6+ #[ proc_macro_derive( UnusedAssign ) ]
7+ pub fn generate ( ts : TokenStream ) -> TokenStream {
8+ let mut ts = ts. into_iter ( ) ;
9+ let _pub = ts. next ( ) ;
10+ let _struct = ts. next ( ) ;
11+ let name = ts. next ( ) . unwrap ( ) ;
12+ let TokenTree :: Group ( fields) = ts. next ( ) . unwrap ( ) else { panic ! ( ) } ;
13+ let mut fields = fields. stream ( ) . into_iter ( ) ;
14+ let field = fields. next ( ) . unwrap ( ) ;
15+
16+ quote ! {
17+ impl Drop for $name {
18+ fn drop( & mut self ) {
19+ let Self { $field } = self ;
20+ }
21+ }
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ //@ proc-macro: aux_issue_147648.rs
3+
4+ #![ deny( unused_assignments) ]
5+ #![ allow( dead_code) ]
6+ #![ allow( unused_variables) ]
7+
8+ extern crate aux_issue_147648;
9+ use aux_issue_147648:: UnusedAssign ;
10+
11+ #[ derive( UnusedAssign ) ]
12+ pub struct MyError {
13+ source_code : ( ) ,
14+ }
15+
16+ fn main ( ) {
17+ let _error = MyError { source_code : ( ) } ;
18+ }
You can’t perform that action at this time.
0 commit comments