@@ -5,6 +5,7 @@ use rustc_ast::{
5
5
self as ast, BareFnTy , BoundAsyncness , BoundConstness , BoundPolarity , DUMMY_NODE_ID , FnRetTy ,
6
6
GenericBound , GenericBounds , GenericParam , Generics , Lifetime , MacCall , MutTy , Mutability ,
7
7
PolyTraitRef , PreciseCapturingArg , TraitBoundModifiers , TraitObjectSyntax , Ty , TyKind ,
8
+ UnsafeBinderTy ,
8
9
} ;
9
10
use rustc_errors:: { Applicability , PResult } ;
10
11
use rustc_span:: symbol:: { Ident , kw, sym} ;
@@ -361,6 +362,8 @@ impl<'a> Parser<'a> {
361
362
TyKind :: Err ( guar)
362
363
}
363
364
}
365
+ } else if self . check_keyword ( kw:: Unsafe ) {
366
+ self . parse_unsafe_binder_ty ( ) ?
364
367
} else {
365
368
let msg = format ! ( "expected type, found {}" , super :: token_descr( & self . token) ) ;
366
369
let mut err = self . dcx ( ) . struct_span_err ( self . token . span , msg) ;
@@ -382,6 +385,15 @@ impl<'a> Parser<'a> {
382
385
if allow_qpath_recovery { self . maybe_recover_from_bad_qpath ( ty) } else { Ok ( ty) }
383
386
}
384
387
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
+
385
397
/// Parse an anonymous struct or union (only for field definitions):
386
398
/// ```ignore (feature-not-ready)
387
399
/// #[repr(C)]
0 commit comments