File tree 2 files changed +9
-18
lines changed
2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -4708,26 +4708,21 @@ impl<'a> Parser<'a> {
4708
4708
if let Err ( mut bang_err) = bang_err {
4709
4709
// Given this code `pub path(`, it seems like this is not setting the
4710
4710
// visibility of a macro invocation, but rather a mistyped method declaration.
4711
- // Keep the macro diagnostic, but also provide a hint that `fn` might be
4712
- // missing. Don't complain about the missing `!` as a separate diagnostic, add
4713
- // label in the appropriate place as part of one unified diagnostic.
4711
+ // Create a diagnostic pointing out that `fn` is missing.
4714
4712
//
4715
4713
// x | pub path(&self) {
4716
- // | ^^^- - expected `!` here for a macro invocation
4717
- // | |
4718
- // | did you mean to write `fn` here for a method declaration?
4714
+ // | ^ missing `fn` for method declaration
4719
4715
4716
+ err. cancel ( ) ;
4720
4717
bang_err. cancel ( ) ;
4721
- err. span_label ( self . span , & "expected `!` here for a macro invocation" ) ;
4722
4718
// pub path(
4723
4719
// ^^ `sp` below will point to this
4724
4720
let sp = mk_sp ( prev_span. hi , self . prev_span . lo ) ;
4725
- err. span_label ( sp,
4726
- & "did you mean to write `fn` here for a method declaration?" ) ;
4721
+ err = self . diagnostic ( )
4722
+ . struct_span_err ( sp, "missing `fn` for method declaration" ) ;
4723
+ err. span_label ( sp, & "missing `fn`" ) ;
4727
4724
}
4728
4725
return Err ( err) ;
4729
- } else if let Err ( bang_err) = bang_err {
4730
- return Err ( bang_err) ;
4731
4726
}
4732
4727
4733
4728
// eat a matched-delimiter token tree:
Original file line number Diff line number Diff line change 1
- error: can't qualify macro invocation with `pub`
2
- --> $DIR/issue-40006.rs:14:5
1
+ error: missing `fn` for method declaration
2
+ --> $DIR/issue-40006.rs:14:8
3
3
|
4
4
14 | pub hello_method(&self) {
5
- | ^^^- - expected `!` here for a macro invocation
6
- | |
7
- | did you mean to write `fn` here for a method declaration?
8
- |
9
- = help: try adjusting the macro to put `pub` inside the invocation
5
+ | ^ missing `fn`
10
6
11
7
error: aborting due to previous error
12
8
You can’t perform that action at this time.
0 commit comments