File tree Expand file tree Collapse file tree 4 files changed +52
-1
lines changed
test/run-make/rustc-macro-dep-files Expand file tree Collapse file tree 4 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ impl FromStr for TokenStream {
139139 __internal:: with_parse_sess ( |sess| {
140140 let src = src. to_string ( ) ;
141141 let cfg = Vec :: new ( ) ;
142- let name = "rustc-macro source code" . to_string ( ) ;
142+ let name = "< rustc-macro source code> " . to_string ( ) ;
143143 let mut parser = parse:: new_parser_from_source_str ( sess, cfg, name,
144144 src) ;
145145 let mut ret = TokenStream { inner : Vec :: new ( ) } ;
Original file line number Diff line number Diff line change 1+ -include ../tools.mk
2+
3+ all :
4+ $(RUSTC ) foo.rs
5+ $(RUSTC ) bar.rs --emit dep-info
6+ grep " rustc-macro source" $(TMPDIR ) /bar.d && exit 1 || exit 0
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ feature( rustc_macro) ]
12+
13+ #[ macro_use]
14+ extern crate foo;
15+
16+ #[ derive( A ) ]
17+ struct A ;
18+
19+ fn main ( ) {
20+ let _b = B ;
21+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #![ crate_type = "rustc-macro" ]
12+ #![ feature( rustc_macro) ]
13+ #![ feature( rustc_macro_lib) ]
14+
15+ extern crate rustc_macro;
16+
17+ use rustc_macro:: TokenStream ;
18+
19+ #[ rustc_macro_derive( A ) ]
20+ pub fn derive ( input : TokenStream ) -> TokenStream {
21+ let input = input. to_string ( ) ;
22+ assert ! ( input. contains( "struct A;" ) ) ;
23+ "struct B;" . parse ( ) . unwrap ( )
24+ }
You can’t perform that action at this time.
0 commit comments