@@ -249,7 +249,8 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
249
249
250
250
/// Converts a `macro_rules!` invocation into a syntax extension.
251
251
pub fn compile < ' cx > ( cx : & ' cx mut ExtCtxt ,
252
- def : & ast:: MacroDef ) -> SyntaxExtension {
252
+ def : & ast:: MacroDef ,
253
+ imported : bool ) -> SyntaxExtension {
253
254
254
255
let lhs_nm = gensym_ident ( "lhs" ) ;
255
256
let rhs_nm = gensym_ident ( "rhs" ) ;
@@ -305,7 +306,9 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
305
306
MatchedSeq ( ref s, _) => {
306
307
s. iter ( ) . map ( |m| match * * m {
307
308
MatchedNonterminal ( NtTT ( ref tt) ) => {
308
- valid &= check_lhs_nt_follows ( cx, tt) ;
309
+ if !imported {
310
+ valid &= check_lhs_nt_follows ( cx, tt) ;
311
+ }
309
312
( * * tt) . clone ( )
310
313
}
311
314
_ => cx. span_bug ( def. span , "wrong-structured lhs" )
@@ -314,16 +317,18 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
314
317
_ => cx. span_bug ( def. span , "wrong-structured lhs" )
315
318
} ;
316
319
317
- ' a: for ( i, lhs) in lhses. iter ( ) . enumerate ( ) {
318
- for lhs_ in lhses[ i + 1 ..] . iter ( ) {
319
- if !check_lhs_firsts ( cx, lhs, lhs_) {
320
- cx. struct_span_warn ( def. span , "macro is not future-proof" )
321
- . span_help ( lhs. get_span ( ) , "parsing of this arm is ambiguous..." )
322
- . span_help ( lhs_. get_span ( ) , "with the parsing of this arm." )
323
- . help ( "the behaviour of this macro might change in the future" )
324
- . emit ( ) ;
325
- //valid = false;
326
- break ' a;
320
+ if !imported {
321
+ ' a: for ( i, lhs) in lhses. iter ( ) . enumerate ( ) {
322
+ for lhs_ in lhses[ i + 1 ..] . iter ( ) {
323
+ if !check_lhs_firsts ( cx, lhs, lhs_) {
324
+ cx. struct_span_warn ( def. span , "macro is not future-proof" )
325
+ . span_help ( lhs. get_span ( ) , "parsing of this arm is ambiguous..." )
326
+ . span_help ( lhs_. get_span ( ) , "with the parsing of this arm." )
327
+ . help ( "the behaviour of this macro might change in the future" )
328
+ . emit ( ) ;
329
+ //valid = false;
330
+ break ' a;
331
+ }
327
332
}
328
333
}
329
334
}
0 commit comments