@@ -1775,30 +1775,34 @@ impl<'a> Parser<'a> {
17751775 span,
17761776 "macros that expand to items must be delimited with braces or followed by a semicolon" ,
17771777 ) ;
1778- if self . unclosed_delims . is_empty ( ) {
1779- let DelimSpan { open, close } = match args {
1780- MacArgs :: Empty | MacArgs :: Eq ( ..) => unreachable ! ( ) ,
1781- MacArgs :: Delimited ( dspan, ..) => * dspan,
1782- } ;
1783- err. multipart_suggestion (
1784- "change the delimiters to curly braces" ,
1785- vec ! [ ( open, "{" . to_string( ) ) , ( close, '}' . to_string( ) ) ] ,
1786- Applicability :: MaybeIncorrect ,
1787- ) ;
1788- } else {
1778+ // FIXME: This will make us not emit the help even for declarative
1779+ // macros within the same crate (that we can fix), which is sad.
1780+ if !span. from_expansion ( ) {
1781+ if self . unclosed_delims . is_empty ( ) {
1782+ let DelimSpan { open, close } = match args {
1783+ MacArgs :: Empty | MacArgs :: Eq ( ..) => unreachable ! ( ) ,
1784+ MacArgs :: Delimited ( dspan, ..) => * dspan,
1785+ } ;
1786+ err. multipart_suggestion (
1787+ "change the delimiters to curly braces" ,
1788+ vec ! [ ( open, "{" . to_string( ) ) , ( close, '}' . to_string( ) ) ] ,
1789+ Applicability :: MaybeIncorrect ,
1790+ ) ;
1791+ } else {
1792+ err. span_suggestion (
1793+ span,
1794+ "change the delimiters to curly braces" ,
1795+ " { /* items */ }" ,
1796+ Applicability :: HasPlaceholders ,
1797+ ) ;
1798+ }
17891799 err. span_suggestion (
1790- span,
1791- "change the delimiters to curly braces " ,
1792- " { /* items */ }" ,
1793- Applicability :: HasPlaceholders ,
1800+ span. shrink_to_hi ( ) ,
1801+ "add a semicolon " ,
1802+ ';' ,
1803+ Applicability :: MaybeIncorrect ,
17941804 ) ;
17951805 }
1796- err. span_suggestion (
1797- span. shrink_to_hi ( ) ,
1798- "add a semicolon" ,
1799- ';' ,
1800- Applicability :: MaybeIncorrect ,
1801- ) ;
18021806 err. emit ( ) ;
18031807 }
18041808
0 commit comments