@@ -2,14 +2,13 @@ use super::ty::AllowPlus;
22use super :: TokenType ;
33use super :: { BlockMode , Parser , PathStyle , Restrictions , SemiColonMode , SeqSep , TokenExpectType } ;
44
5+ use rustc_ast as ast;
56use rustc_ast:: ptr:: P ;
67use rustc_ast:: token:: { self , Lit , LitKind , TokenKind } ;
78use rustc_ast:: util:: parser:: AssocOp ;
8- use rustc_ast:: {
9- self as ast, AngleBracketedArg , AngleBracketedArgs , AnonConst , AttrVec , BinOpKind , BindingMode ,
10- Block , BlockCheckMode , Expr , ExprKind , GenericArg , Item , ItemKind , Mutability , Param , Pat ,
11- PatKind , Path , PathSegment , QSelf , Ty , TyKind ,
12- } ;
9+ use rustc_ast:: { AngleBracketedArg , AngleBracketedArgs , AnonConst , AttrVec } ;
10+ use rustc_ast:: { BinOpKind , BindingMode , Block , BlockCheckMode , Expr , ExprKind , GenericArg , Item } ;
11+ use rustc_ast:: { ItemKind , Mutability , Param , Pat , PatKind , Path , PathSegment , QSelf , Ty , TyKind } ;
1312use rustc_ast_pretty:: pprust;
1413use rustc_data_structures:: fx:: FxHashSet ;
1514use rustc_errors:: { pluralize, struct_span_err} ;
@@ -220,6 +219,7 @@ impl<'a> Parser<'a> {
220219 edible : & [ TokenKind ] ,
221220 inedible : & [ TokenKind ] ,
222221 ) -> PResult < ' a , bool /* recovered */ > {
222+ debug ! ( "expected_one_of_not_found(edible: {:?}, inedible: {:?})" , edible, inedible) ;
223223 fn tokens_to_string ( tokens : & [ TokenType ] ) -> String {
224224 let mut i = tokens. iter ( ) ;
225225 // This might be a sign we need a connect method on `Iterator`.
@@ -245,6 +245,7 @@ impl<'a> Parser<'a> {
245245 . collect :: < Vec < _ > > ( ) ;
246246 expected. sort_by_cached_key ( |x| x. to_string ( ) ) ;
247247 expected. dedup ( ) ;
248+
248249 let expect = tokens_to_string ( & expected[ ..] ) ;
249250 let actual = super :: token_descr ( & self . token ) ;
250251 let ( msg_exp, ( label_sp, label_exp) ) = if expected. len ( ) > 1 {
@@ -270,6 +271,16 @@ impl<'a> Parser<'a> {
270271 } ;
271272 self . last_unexpected_token_span = Some ( self . token . span ) ;
272273 let mut err = self . struct_span_err ( self . token . span , & msg_exp) ;
274+
275+ // Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens
276+ // there are unclosed angle brackets
277+ if self . unmatched_angle_bracket_count > 0
278+ && self . token . kind == TokenKind :: Eq
279+ && expected. iter ( ) . any ( |tok| matches ! ( tok, TokenType :: Token ( TokenKind :: Gt ) ) )
280+ {
281+ err. span_label ( self . prev_token . span , "maybe try to close unmatched angle bracket" ) ;
282+ }
283+
273284 let sp = if self . token == token:: Eof {
274285 // This is EOF; don't want to point at the following char, but rather the last token.
275286 self . prev_token . span
0 commit comments