@@ -12,7 +12,7 @@ use crate::errors::{
12
12
IncorrectAwait , IncorrectSemicolon , IncorrectUseOfAwait , ParenthesesInForHead ,
13
13
ParenthesesInForHeadSugg , PatternMethodParamWithoutBody , QuestionMarkInType ,
14
14
QuestionMarkInTypeSugg , SelfParamNotFirst , StructLiteralBodyWithoutPath ,
15
- StructLiteralBodyWithoutPathSugg , SuggEscapeToUseAsIdentifier , SuggMisplacedGeneric ,
15
+ StructLiteralBodyWithoutPathSugg , SuggEscapeToUseAsIdentifier ,
16
16
SuggRemoveComma , UnexpectedConstInGenericParam , UnexpectedConstParamDeclaration ,
17
17
UnexpectedConstParamDeclarationSugg , UnmatchedAngleBrackets , UseEqInstead ,
18
18
} ;
@@ -326,38 +326,41 @@ impl<'a> Parser<'a> {
326
326
None
327
327
} ;
328
328
329
- let span = self . token . span ;
330
- let token = self . token . clone ( ) ;
331
- let suggest_misplaced_generic = if self . token == token:: Lt {
332
- // store the span before the generic calculation starts
333
- self . parse_generics ( ) . map_or ( None , |generic| {
334
- // at this point, token should be Ident with the fn name
335
-
336
- // FIXME: shreys the span should be the span of where the gneeric SHOULD go.
337
- // TODO: shreys what does this look like with invalid generic
338
- // TODO: shreys - what to do if no snippet? probably just HELP not suggestion
339
-
340
- let snippet = match self . sess . source_map ( ) . span_to_snippet ( generic. span ) {
341
- Ok ( snippet) => snippet,
342
- _ => "" . to_string ( )
343
- } ;
344
-
345
- Some ( SuggMisplacedGeneric { span : self . token . span . to ( generic. span . shrink_to_hi ( ) ) , snippet } )
346
- } )
347
-
348
- } else {
349
- None
350
- } ;
351
-
352
- // FIXME: write better rust
329
+ // FIXME: shreys write better rust
353
330
let err = ExpectedIdentifier {
354
- span : if suggest_misplaced_generic . is_some ( ) { span } else { self . token . span } ,
355
- token : if suggest_misplaced_generic . is_some ( ) { token } else { self . token . clone ( ) } ,
331
+ span : self . token . span ,
332
+ token : self . token . clone ( ) ,
356
333
suggest_raw,
357
334
suggest_remove_comma,
358
- suggest_misplaced_generic,
359
335
} ;
360
- err. into_diagnostic ( & self . sess . span_diagnostic )
336
+ let mut err = err. into_diagnostic ( & self . sess . span_diagnostic ) ;
337
+
338
+ if self . token == token:: Lt {
339
+ // HACK: shreys shut the compiler up about unused result
340
+ let _ = self . parse_generics ( )
341
+ . map ( |generic| {
342
+ // at this point, token should be Ident with the fn name
343
+
344
+ // FIXME: shreys the span should be the span of where the gneeric SHOULD go.
345
+ // TODO: shreys what does this look like with invalid generic
346
+ // TODO: shreys - what to do if no snippet? probably just HELP not suggestion
347
+
348
+ let snippet = match self . sess . source_map ( ) . span_to_snippet ( generic. span ) {
349
+ Ok ( snippet) => snippet,
350
+ _ => "" . to_string ( )
351
+ } ;
352
+
353
+ err. span_suggestion (
354
+ self . token . span . to ( generic. span . shrink_to_hi ( ) ) ,
355
+ "help: place the generic parameter list after the function name:" ,
356
+ snippet,
357
+ Applicability :: MachineApplicable
358
+ ) ;
359
+ } ) ;
360
+ }
361
+
362
+ err
363
+
361
364
}
362
365
363
366
pub ( super ) fn expected_one_of_not_found (
0 commit comments