File tree 3 files changed +45
-0
lines changed 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -5973,6 +5973,10 @@ impl<'a> Parser<'a> {
5973
5973
fn parse_view_path ( & mut self ) -> P < ViewPath > {
5974
5974
let lo = self . span . lo ;
5975
5975
5976
+ // Allow a leading :: because the paths are absolute either way.
5977
+ // This occurs with "use $crate::..." in macros.
5978
+ self . eat ( & token:: ModSep ) ;
5979
+
5976
5980
if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
5977
5981
// use {foo,bar}
5978
5982
let idents = self . parse_unspanned_seq (
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 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
+ fn main ( ) {
12
+ use :: std:: mem;
13
+ mem:: drop ( 2 u) ;
14
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 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( macro_rules) ]
12
+
13
+ pub fn increment ( x : uint ) -> uint {
14
+ x + 1
15
+ }
16
+
17
+ #[ macro_export]
18
+ macro_rules! increment {
19
+ ( $x: expr) => ( {
20
+ use $crate:: increment;
21
+ increment( $x)
22
+ } )
23
+ }
24
+
25
+ fn main ( ) {
26
+ assert_eq ! ( increment!( 3 ) , 4 ) ;
27
+ }
You can’t perform that action at this time.
0 commit comments