@@ -5,6 +5,7 @@ use rustc_ast::{
55 self as ast, BareFnTy , BoundAsyncness , BoundConstness , BoundPolarity , DUMMY_NODE_ID , FnRetTy ,
66 GenericBound , GenericBounds , GenericParam , Generics , Lifetime , MacCall , MutTy , Mutability ,
77 PolyTraitRef , PreciseCapturingArg , TraitBoundModifiers , TraitObjectSyntax , Ty , TyKind ,
8+ UnsafeBinderTy ,
89} ;
910use rustc_errors:: { Applicability , PResult } ;
1011use rustc_span:: symbol:: { Ident , kw, sym} ;
@@ -361,6 +362,8 @@ impl<'a> Parser<'a> {
361362 TyKind :: Err ( guar)
362363 }
363364 }
365+ } else if self . check_keyword ( kw:: Unsafe ) {
366+ self . parse_unsafe_binder_ty ( ) ?
364367 } else {
365368 let msg = format ! ( "expected type, found {}" , super :: token_descr( & self . token) ) ;
366369 let mut err = self . dcx ( ) . struct_span_err ( self . token . span , msg) ;
@@ -382,6 +385,15 @@ impl<'a> Parser<'a> {
382385 if allow_qpath_recovery { self . maybe_recover_from_bad_qpath ( ty) } else { Ok ( ty) }
383386 }
384387
388+ fn parse_unsafe_binder_ty ( & mut self ) -> PResult < ' a , TyKind > {
389+ assert ! ( self . eat_keyword( kw:: Unsafe ) ) ;
390+ self . expect_lt ( ) ?;
391+ let generic_params = self . parse_generic_params ( ) ?;
392+ self . expect_gt ( ) ?;
393+
394+ Ok ( TyKind :: UnsafeBinder ( P ( UnsafeBinderTy { generic_params, inner_ty : self . parse_ty ( ) ? } ) ) )
395+ }
396+
385397 /// Parse an anonymous struct or union (only for field definitions):
386398 /// ```ignore (feature-not-ready)
387399 /// #[repr(C)]
0 commit comments