File tree 2 files changed +18
-4
lines changed
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -4744,8 +4744,8 @@ impl<'a> Parser<'a> {
4744
4744
let lo = self . span ;
4745
4745
let pth = self . parse_path ( PathStyle :: Mod ) ?;
4746
4746
let bang_err = self . expect ( & token:: Not ) ;
4747
- if let Err ( mut err) = err {
4748
- if let Err ( mut bang_err) = bang_err {
4747
+ match ( err, bang_err ) {
4748
+ ( Err ( mut err ) , Err ( mut bang_err) ) => {
4749
4749
// Given this code `pub path(`, it seems like this is not setting the
4750
4750
// visibility of a macro invocation, but rather a mistyped method declaration.
4751
4751
// Create a diagnostic pointing out that `fn` is missing.
@@ -4758,11 +4758,13 @@ impl<'a> Parser<'a> {
4758
4758
// pub path(
4759
4759
// ^^ `sp` below will point to this
4760
4760
let sp = prev_span. between ( self . prev_span ) ;
4761
- err = self . diagnostic ( )
4761
+ let mut err = self . diagnostic ( )
4762
4762
. struct_span_err ( sp, "missing `fn` for method declaration" ) ;
4763
4763
err. span_label ( sp, & "missing `fn`" ) ;
4764
+ return Err ( err) ;
4764
4765
}
4765
- return Err ( err) ;
4766
+ ( Err ( err) , _) | ( _, Err ( err) ) => return Err ( err) ,
4767
+ ( _, _) => ( )
4766
4768
}
4767
4769
4768
4770
// eat a matched-delimiter token tree:
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 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
+ impl X { not_a_macro_invocation }
12
+ //~^ ERROR expected one of `!` or `::`, found `}`
You can’t perform that action at this time.
0 commit comments