File tree Expand file tree Collapse file tree 5 files changed +25
-33
lines changed Expand file tree Collapse file tree 5 files changed +25
-33
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ mod compile_error;
3737mod concat;
3838mod concat_bytes;
3939mod concat_idents;
40- mod deref_pat;
4140mod derive;
4241mod deriving;
4342mod edition_panic;
@@ -85,7 +84,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
8584 concat_idents: concat_idents:: expand_concat_idents,
8685 const_format_args: format:: expand_format_args,
8786 core_panic: edition_panic:: expand_panic,
88- deref: deref_pat:: expand_deref_pat,
8987 env: env:: expand_env,
9088 file: source_util:: expand_file,
9189 format_args: format:: expand_format_args,
Original file line number Diff line number Diff line change @@ -1939,11 +1939,10 @@ impl<'a> Parser<'a> {
19391939 /// Parse `builtin # ident(args,*)`.
19401940 fn parse_expr_builtin ( & mut self ) -> PResult < ' a , P < Expr > > {
19411941 self . parse_builtin ( |this, lo, ident| {
1942- if ident. name == sym:: offset_of {
1943- return Ok ( Some ( this. parse_expr_offset_of ( lo) ?) ) ;
1944- }
1945-
1946- Ok ( None )
1942+ Ok ( match ident. name {
1943+ sym:: offset_of => Some ( this. parse_expr_offset_of ( lo) ?) ,
1944+ _ => None ,
1945+ } )
19471946 } )
19481947 }
19491948
Original file line number Diff line number Diff line change @@ -498,11 +498,14 @@ impl<'a> Parser<'a> {
498498 } else {
499499 PatKind :: Lit ( const_expr)
500500 }
501+ } else if self . is_builtin ( ) {
502+ self . parse_pat_builtin ( ) ?
503+ }
501504 // Don't eagerly error on semantically invalid tokens when matching
502505 // declarative macros, as the input to those doesn't have to be
503506 // semantically valid. For attribute/derive proc macros this is not the
504507 // case, so doing the recovery for them is fine.
505- } else if self . can_be_ident_pat ( )
508+ else if self . can_be_ident_pat ( )
506509 || ( self . is_lit_bad_ident ( ) . is_some ( ) && self . may_recover ( ) )
507510 {
508511 // Parse `ident @ pat`
@@ -1119,6 +1122,21 @@ impl<'a> Parser<'a> {
11191122 . contains ( & self . token . kind )
11201123 }
11211124
1125+ fn parse_pat_builtin ( & mut self ) -> PResult < ' a , PatKind > {
1126+ self . parse_builtin ( |self_, _lo, ident| {
1127+ Ok ( match ident. name {
1128+ // builtin#deref(PAT)
1129+ sym:: deref => Some ( ast:: PatKind :: Deref ( self_. parse_pat_allow_top_alt (
1130+ None ,
1131+ RecoverComma :: Yes ,
1132+ RecoverColon :: Yes ,
1133+ CommaRecoveryMode :: LikelyTuple ,
1134+ ) ?) ) ,
1135+ _ => None ,
1136+ } )
1137+ } )
1138+ }
1139+
11221140 /// Parses `box pat`
11231141 fn parse_pat_box ( & mut self ) -> PResult < ' a , PatKind > {
11241142 let box_span = self . prev_token . span ;
Original file line number Diff line number Diff line change @@ -1716,14 +1716,14 @@ pub(crate) mod builtin {
17161716
17171717 #[ cfg( not( bootstrap) ) ]
17181718 /// Unstable placeholder for type ascription.
1719- #[ rustc_builtin_macro ]
1719+ #[ allow_internal_unstable ( builtin_syntax ) ]
17201720 #[ unstable(
17211721 feature = "deref_patterns" ,
17221722 issue = "87121" ,
17231723 reason = "placeholder syntax for deref patterns"
17241724 ) ]
17251725 pub macro deref( $pat: pat) {
1726- /* compiler built-in */
1726+ builtin # deref ( $pat )
17271727 }
17281728
17291729 /// Unstable implementation detail of the `rustc` compiler, do not use.
You can’t perform that action at this time.
0 commit comments