File tree 5 files changed +93
-43
lines changed
5 files changed +93
-43
lines changed 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
+ // aux-build:two_macros.rs
12
+
13
+ #![ feature( use_extern_macros) ]
14
+
15
+ extern crate two_macros;
16
+
17
+ mod foo {
18
+ pub mod bar {
19
+ pub use two_macros:: m;
20
+ }
21
+ }
22
+
23
+ fn f ( ) {
24
+ use foo:: * ; //~ NOTE could also resolve to the name imported here
25
+ bar:: m! { //~ ERROR ambiguous
26
+ //~| NOTE macro-expanded items do not shadow when used in a macro invocation path
27
+ mod bar { pub use two_macros:: m; } //~ NOTE could resolve to the name defined here
28
+ //~^^^ NOTE in this expansion
29
+ }
30
+ }
31
+
32
+ pub mod baz { //~ NOTE could also resolve to the name defined here
33
+ pub use two_macros:: m;
34
+ }
35
+
36
+ fn g ( ) {
37
+ baz:: m! { //~ ERROR ambiguous
38
+ //~| NOTE macro-expanded items do not shadow when used in a macro invocation path
39
+ mod baz { pub use two_macros:: m; } //~ NOTE could resolve to the name defined here
40
+ //~^^^ NOTE in this expansion
41
+ }
42
+ }
Original file line number Diff line number Diff line change 9
9
// except according to those terms.
10
10
11
11
fn main ( ) {
12
- globnar:: brotz!( ) ; //~ ERROR expected macro name without module separators
13
- :: foo!( ) ; //~ ERROR expected macro name without module separators
14
- foo :: < T > !( ) ; //~ ERROR expected macro name without module separators
12
+ globnar:: brotz!( ) ; //~ ERROR non-ident macro paths are experimental
13
+ :: foo!( ) ; //~ ERROR non-ident macro paths are experimental
14
+ foo :: < T > !( ) ; //~ ERROR type parameters are not allowed on macros
15
15
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 9
9
// except according to those terms.
10
10
11
11
#[ macro_export]
12
- macro_rules! macro_one { ( ) => ( "one" ) }
12
+ macro_rules! macro_one { ( $ ( $t : tt ) * ) => ( $ ( $t ) * ) }
13
13
14
14
#[ macro_export]
15
- macro_rules! macro_two { ( ) => ( "two" ) }
15
+ macro_rules! macro_two { ( $ ( $t : tt ) * ) => ( $ ( $t ) * ) }
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
+ // aux-build:two_macros.rs
12
+
13
+ #![ feature( use_extern_macros) ]
14
+
15
+ extern crate two_macros;
16
+
17
+ :: two_macros:: macro_one!( ) ;
18
+ two_macros:: macro_one!( ) ;
19
+
20
+ mod foo { pub use two_macros:: macro_one as bar; }
21
+
22
+ trait T {
23
+ foo:: bar!( ) ;
24
+ :: foo:: bar!( ) ;
25
+ }
26
+
27
+ struct S {
28
+ x : foo:: bar!( i32 ) ,
29
+ y : :: foo:: bar!( i32 ) ,
30
+ }
31
+
32
+ impl S {
33
+ foo:: bar!( ) ;
34
+ :: foo:: bar!( ) ;
35
+ }
36
+
37
+ fn main ( ) {
38
+ foo:: bar!( ) ;
39
+ :: foo:: bar!( ) ;
40
+
41
+ let _ = foo:: bar!( 0 ) ;
42
+ let _ = :: foo:: bar!( 0 ) ;
43
+
44
+ let foo:: bar!( _) = 0 ;
45
+ let :: foo:: bar!( _) = 0 ;
46
+ }
You can’t perform that action at this time.
0 commit comments