@@ -209,15 +209,15 @@ impl<'a> AstValidator<'a> {
209
209
210
210
// Mirrors `visit::walk_ty`, but tracks relevant state.
211
211
fn walk_ty ( & mut self , t : & ' a Ty ) {
212
- match t. kind {
212
+ match & t. kind {
213
213
TyKind :: ImplTrait ( ..) => {
214
214
self . with_impl_trait ( Some ( t. span ) , |this| visit:: walk_ty ( this, t) )
215
215
}
216
216
TyKind :: TraitObject ( ..) => self
217
217
. with_banned_tilde_const ( DisallowTildeConstContext :: TraitObject , |this| {
218
218
visit:: walk_ty ( this, t)
219
219
} ) ,
220
- TyKind :: Path ( ref qself, ref path) => {
220
+ TyKind :: Path ( qself, path) => {
221
221
// We allow these:
222
222
// - `Option<impl Trait>`
223
223
// - `option::Option<impl Trait>`
@@ -231,7 +231,7 @@ impl<'a> AstValidator<'a> {
231
231
// (for cases like `<impl Trait>::Foo>`)
232
232
// but we allow `impl Trait` in `GenericArgs`
233
233
// iff there are no more PathSegments.
234
- if let Some ( ref qself) = * qself {
234
+ if let Some ( qself) = qself {
235
235
// `impl Trait` in `qself` is always illegal
236
236
self . with_banned_impl_trait ( |this| this. visit_ty ( & qself. ty ) ) ;
237
237
}
@@ -738,8 +738,8 @@ impl<'a> AstValidator<'a> {
738
738
}
739
739
740
740
fn visit_ty_common ( & mut self , ty : & ' a Ty ) {
741
- match ty. kind {
742
- TyKind :: BareFn ( ref bfty) => {
741
+ match & ty. kind {
742
+ TyKind :: BareFn ( bfty) => {
743
743
self . check_fn_decl ( & bfty. decl , SelfSemantic :: No ) ;
744
744
Self :: check_decl_no_pat ( & bfty. decl , |span, _, _| {
745
745
struct_span_err ! (
@@ -756,10 +756,10 @@ impl<'a> AstValidator<'a> {
756
756
self . maybe_lint_missing_abi ( sig_span, ty. id ) ;
757
757
}
758
758
}
759
- TyKind :: TraitObject ( ref bounds, ..) => {
759
+ TyKind :: TraitObject ( bounds, ..) => {
760
760
let mut any_lifetime_bounds = false ;
761
761
for bound in bounds {
762
- if let GenericBound :: Outlives ( ref lifetime) = * bound {
762
+ if let GenericBound :: Outlives ( lifetime) = bound {
763
763
if any_lifetime_bounds {
764
764
struct_span_err ! (
765
765
self . session,
@@ -774,7 +774,7 @@ impl<'a> AstValidator<'a> {
774
774
}
775
775
}
776
776
}
777
- TyKind :: ImplTrait ( _, ref bounds) => {
777
+ TyKind :: ImplTrait ( _, bounds) => {
778
778
if self . is_impl_trait_banned {
779
779
struct_span_err ! (
780
780
self . session,
@@ -842,8 +842,8 @@ fn validate_generic_param_order(
842
842
let ( kind, bounds, span) = ( & param. kind , & param. bounds , ident. span ) ;
843
843
let ( ord_kind, ident) = match & param. kind {
844
844
GenericParamKind :: Lifetime => ( ParamKindOrd :: Lifetime , ident. to_string ( ) ) ,
845
- GenericParamKind :: Type { default : _ } => ( ParamKindOrd :: TypeOrConst , ident. to_string ( ) ) ,
846
- GenericParamKind :: Const { ref ty, kw_span : _ , default : _ } => {
845
+ GenericParamKind :: Type { .. } => ( ParamKindOrd :: TypeOrConst , ident. to_string ( ) ) ,
846
+ GenericParamKind :: Const { ty, .. } => {
847
847
let ty = pprust:: ty_to_string ( ty) ;
848
848
( ParamKindOrd :: TypeOrConst , format ! ( "const {}: {}" , ident, ty) )
849
849
}
@@ -948,8 +948,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
948
948
}
949
949
ExprKind :: Paren ( local_expr) => {
950
950
fn has_let_expr ( expr : & Expr ) -> bool {
951
- match expr. kind {
952
- ExprKind :: Binary ( _, ref lhs, ref rhs) => has_let_expr ( lhs) || has_let_expr ( rhs) ,
951
+ match & expr. kind {
952
+ ExprKind :: Binary ( _, lhs, rhs) => has_let_expr ( lhs) || has_let_expr ( rhs) ,
953
953
ExprKind :: Let ( ..) => true ,
954
954
_ => false ,
955
955
}
@@ -1005,18 +1005,18 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1005
1005
self . check_nomangle_item_asciionly ( item. ident , item. span ) ;
1006
1006
}
1007
1007
1008
- match item. kind {
1008
+ match & item. kind {
1009
1009
ItemKind :: Impl ( box Impl {
1010
1010
unsafety,
1011
1011
polarity,
1012
1012
defaultness : _,
1013
1013
constness,
1014
- ref generics,
1015
- of_trait : Some ( ref t) ,
1016
- ref self_ty,
1017
- ref items,
1014
+ generics,
1015
+ of_trait : Some ( t) ,
1016
+ self_ty,
1017
+ items,
1018
1018
} ) => {
1019
- self . with_in_trait_impl ( true , Some ( constness) , |this| {
1019
+ self . with_in_trait_impl ( true , Some ( * constness) , |this| {
1020
1020
this. invalid_visibility ( & item. vis , None ) ;
1021
1021
if let TyKind :: Err = self_ty. kind {
1022
1022
this. err_handler ( )
@@ -1027,7 +1027,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1027
1027
. help ( "use `auto trait Trait {}` instead" )
1028
1028
. emit ( ) ;
1029
1029
}
1030
- if let ( Unsafe :: Yes ( span) , ImplPolarity :: Negative ( sp) ) = ( unsafety, polarity) {
1030
+ if let ( & Unsafe :: Yes ( span) , & ImplPolarity :: Negative ( sp) ) = ( unsafety, polarity)
1031
+ {
1031
1032
struct_span_err ! (
1032
1033
this. session,
1033
1034
sp. to( t. path. span) ,
@@ -1061,7 +1062,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1061
1062
constness,
1062
1063
generics : _,
1063
1064
of_trait : None ,
1064
- ref self_ty,
1065
+ self_ty,
1065
1066
items : _,
1066
1067
} ) => {
1067
1068
let error = |annotation_span, annotation| {
@@ -1078,25 +1079,25 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1078
1079
& item. vis ,
1079
1080
Some ( InvalidVisibilityNote :: IndividualImplItems ) ,
1080
1081
) ;
1081
- if let Unsafe :: Yes ( span) = unsafety {
1082
+ if let & Unsafe :: Yes ( span) = unsafety {
1082
1083
error ( span, "unsafe" ) . code ( error_code ! ( E0197 ) ) . emit ( ) ;
1083
1084
}
1084
- if let ImplPolarity :: Negative ( span) = polarity {
1085
+ if let & ImplPolarity :: Negative ( span) = polarity {
1085
1086
error ( span, "negative" ) . emit ( ) ;
1086
1087
}
1087
- if let Defaultness :: Default ( def_span) = defaultness {
1088
+ if let & Defaultness :: Default ( def_span) = defaultness {
1088
1089
error ( def_span, "`default`" )
1089
1090
. note ( "only trait implementations may be annotated with `default`" )
1090
1091
. emit ( ) ;
1091
1092
}
1092
- if let Const :: Yes ( span) = constness {
1093
+ if let & Const :: Yes ( span) = constness {
1093
1094
error ( span, "`const`" )
1094
1095
. note ( "only trait implementations may be annotated with `const`" )
1095
1096
. emit ( ) ;
1096
1097
}
1097
1098
}
1098
- ItemKind :: Fn ( box Fn { defaultness, ref sig, ref generics, ref body } ) => {
1099
- self . check_defaultness ( item. span , defaultness) ;
1099
+ ItemKind :: Fn ( box Fn { defaultness, sig, generics, body } ) => {
1100
+ self . check_defaultness ( item. span , * defaultness) ;
1100
1101
1101
1102
if body. is_none ( ) {
1102
1103
self . session . emit_err ( FnWithoutBody {
@@ -1132,7 +1133,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1132
1133
& item. vis ,
1133
1134
Some ( InvalidVisibilityNote :: IndividualForeignItems ) ,
1134
1135
) ;
1135
- if let Unsafe :: Yes ( span) = unsafety {
1136
+ if let & Unsafe :: Yes ( span) = unsafety {
1136
1137
self . err_handler ( ) . span_err ( span, "extern block cannot be declared unsafe" ) ;
1137
1138
}
1138
1139
if abi. is_none ( ) {
@@ -1142,16 +1143,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1142
1143
self . extern_mod = old_item;
1143
1144
return ; // Avoid visiting again.
1144
1145
}
1145
- ItemKind :: Enum ( ref def, _) => {
1146
+ ItemKind :: Enum ( def, _) => {
1146
1147
for variant in & def. variants {
1147
1148
self . invalid_visibility ( & variant. vis , None ) ;
1148
1149
for field in variant. data . fields ( ) {
1149
1150
self . invalid_visibility ( & field. vis , None ) ;
1150
1151
}
1151
1152
}
1152
1153
}
1153
- ItemKind :: Trait ( box Trait { is_auto, ref generics, ref bounds, ref items, .. } ) => {
1154
- if is_auto == IsAuto :: Yes {
1154
+ ItemKind :: Trait ( box Trait { is_auto, generics, bounds, items, .. } ) => {
1155
+ if * is_auto == IsAuto :: Yes {
1155
1156
// Auto traits cannot have generics, super traits nor contain items.
1156
1157
self . deny_generic_params ( generics, item. ident . span ) ;
1157
1158
self . deny_super_traits ( bounds, item. ident . span ) ;
@@ -1171,8 +1172,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1171
1172
walk_list ! ( self , visit_attribute, & item. attrs) ;
1172
1173
return ; // Avoid visiting again
1173
1174
}
1174
- ItemKind :: Mod ( unsafety, ref mod_kind) => {
1175
- if let Unsafe :: Yes ( span) = unsafety {
1175
+ ItemKind :: Mod ( unsafety, mod_kind) => {
1176
+ if let & Unsafe :: Yes ( span) = unsafety {
1176
1177
self . err_handler ( ) . span_err ( span, "module cannot be declared unsafe" ) ;
1177
1178
}
1178
1179
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
@@ -1182,13 +1183,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1182
1183
self . check_mod_file_item_asciionly ( item. ident ) ;
1183
1184
}
1184
1185
}
1185
- ItemKind :: Union ( ref vdata, ..) => {
1186
+ ItemKind :: Union ( vdata, ..) => {
1186
1187
if vdata. fields ( ) . is_empty ( ) {
1187
1188
self . err_handler ( ) . span_err ( item. span , "unions cannot have zero fields" ) ;
1188
1189
}
1189
1190
}
1190
1191
ItemKind :: Const ( def, .., None ) => {
1191
- self . check_defaultness ( item. span , def) ;
1192
+ self . check_defaultness ( item. span , * def) ;
1192
1193
self . session . emit_err ( ConstWithoutBody {
1193
1194
span : item. span ,
1194
1195
replace_span : self . ending_semi_or_hi ( item. span ) ,
@@ -1200,14 +1201,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1200
1201
replace_span : self . ending_semi_or_hi ( item. span ) ,
1201
1202
} ) ;
1202
1203
}
1203
- ItemKind :: TyAlias ( box TyAlias {
1204
- defaultness,
1205
- where_clauses,
1206
- ref bounds,
1207
- ref ty,
1208
- ..
1209
- } ) => {
1210
- self . check_defaultness ( item. span , defaultness) ;
1204
+ ItemKind :: TyAlias ( box TyAlias { defaultness, where_clauses, bounds, ty, .. } ) => {
1205
+ self . check_defaultness ( item. span , * defaultness) ;
1211
1206
if ty. is_none ( ) {
1212
1207
self . session . emit_err ( TyAliasWithoutBody {
1213
1208
span : item. span ,
@@ -1266,8 +1261,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1266
1261
1267
1262
// Mirrors `visit::walk_generic_args`, but tracks relevant state.
1268
1263
fn visit_generic_args ( & mut self , generic_args : & ' a GenericArgs ) {
1269
- match * generic_args {
1270
- GenericArgs :: AngleBracketed ( ref data) => {
1264
+ match generic_args {
1265
+ GenericArgs :: AngleBracketed ( data) => {
1271
1266
self . check_generic_args_before_constraints ( data) ;
1272
1267
1273
1268
for arg in & data. args {
@@ -1283,7 +1278,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1283
1278
}
1284
1279
}
1285
1280
}
1286
- GenericArgs :: Parenthesized ( ref data) => {
1281
+ GenericArgs :: Parenthesized ( data) => {
1287
1282
walk_list ! ( self , visit_ty, & data. inputs) ;
1288
1283
if let FnRetTy :: Ty ( ty) = & data. output {
1289
1284
// `-> Foo` syntax is essentially an associated type binding,
@@ -1319,7 +1314,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1319
1314
validate_generic_param_order ( self . err_handler ( ) , & generics. params , generics. span ) ;
1320
1315
1321
1316
for predicate in & generics. where_clause . predicates {
1322
- if let WherePredicate :: EqPredicate ( ref predicate) = * predicate {
1317
+ if let WherePredicate :: EqPredicate ( predicate) = predicate {
1323
1318
deny_equality_constraints ( self , predicate, generics) ;
1324
1319
}
1325
1320
}
@@ -1368,7 +1363,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1368
1363
}
1369
1364
1370
1365
fn visit_param_bound ( & mut self , bound : & ' a GenericBound , ctxt : BoundKind ) {
1371
- if let GenericBound :: Trait ( ref poly, modify) = * bound {
1366
+ if let GenericBound :: Trait ( poly, modify) = bound {
1372
1367
match ( ctxt, modify) {
1373
1368
( BoundKind :: SuperTraits , TraitBoundModifier :: Maybe ) => {
1374
1369
let mut err = self
@@ -1573,8 +1568,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1573
1568
self . check_item_named ( item. ident , "const" ) ;
1574
1569
}
1575
1570
1576
- match item. kind {
1577
- AssocItemKind :: Type ( box TyAlias { ref generics, ref bounds, ref ty, .. } )
1571
+ match & item. kind {
1572
+ AssocItemKind :: Type ( box TyAlias { generics, bounds, ty, .. } )
1578
1573
if ctxt == AssocCtxt :: Trait =>
1579
1574
{
1580
1575
self . visit_vis ( & item. vis ) ;
@@ -1586,7 +1581,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1586
1581
} ) ;
1587
1582
walk_list ! ( self , visit_ty, ty) ;
1588
1583
}
1589
- AssocItemKind :: Fn ( box Fn { ref sig, ref generics, ref body, .. } )
1584
+ AssocItemKind :: Fn ( box Fn { sig, generics, body, .. } )
1590
1585
if self . in_const_trait_impl
1591
1586
|| ctxt == AssocCtxt :: Trait
1592
1587
|| matches ! ( sig. header. constness, Const :: Yes ( _) ) =>
0 commit comments