File tree 5 files changed +25
-33
lines changed
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;
37
37
mod concat;
38
38
mod concat_bytes;
39
39
mod concat_idents;
40
- mod deref_pat;
41
40
mod derive;
42
41
mod deriving;
43
42
mod edition_panic;
@@ -85,7 +84,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
85
84
concat_idents: concat_idents:: expand_concat_idents,
86
85
const_format_args: format:: expand_format_args,
87
86
core_panic: edition_panic:: expand_panic,
88
- deref: deref_pat:: expand_deref_pat,
89
87
env: env:: expand_env,
90
88
file: source_util:: expand_file,
91
89
format_args: format:: expand_format_args,
Original file line number Diff line number Diff line change @@ -1939,11 +1939,10 @@ impl<'a> Parser<'a> {
1939
1939
/// Parse `builtin # ident(args,*)`.
1940
1940
fn parse_expr_builtin ( & mut self ) -> PResult < ' a , P < Expr > > {
1941
1941
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
+ } )
1947
1946
} )
1948
1947
}
1949
1948
Original file line number Diff line number Diff line change @@ -498,11 +498,14 @@ impl<'a> Parser<'a> {
498
498
} else {
499
499
PatKind :: Lit ( const_expr)
500
500
}
501
+ } else if self . is_builtin ( ) {
502
+ self . parse_pat_builtin ( ) ?
503
+ }
501
504
// Don't eagerly error on semantically invalid tokens when matching
502
505
// declarative macros, as the input to those doesn't have to be
503
506
// semantically valid. For attribute/derive proc macros this is not the
504
507
// 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 ( )
506
509
|| ( self . is_lit_bad_ident ( ) . is_some ( ) && self . may_recover ( ) )
507
510
{
508
511
// Parse `ident @ pat`
@@ -1119,6 +1122,21 @@ impl<'a> Parser<'a> {
1119
1122
. contains ( & self . token . kind )
1120
1123
}
1121
1124
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
+
1122
1140
/// Parses `box pat`
1123
1141
fn parse_pat_box ( & mut self ) -> PResult < ' a , PatKind > {
1124
1142
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 {
1716
1716
1717
1717
#[ cfg( not( bootstrap) ) ]
1718
1718
/// Unstable placeholder for type ascription.
1719
- #[ rustc_builtin_macro ]
1719
+ #[ allow_internal_unstable ( builtin_syntax ) ]
1720
1720
#[ unstable(
1721
1721
feature = "deref_patterns" ,
1722
1722
issue = "87121" ,
1723
1723
reason = "placeholder syntax for deref patterns"
1724
1724
) ]
1725
1725
pub macro deref( $pat: pat) {
1726
- /* compiler built-in */
1726
+ builtin # deref ( $pat )
1727
1727
}
1728
1728
1729
1729
/// Unstable implementation detail of the `rustc` compiler, do not use.
You can’t perform that action at this time.
0 commit comments