@@ -30,7 +30,6 @@ use rustc_data_structures::fx::FxIndexMap;
3030use rustc_errors:: { DiagCtxtHandle , LintBuffer } ;
3131use rustc_feature:: Features ;
3232use rustc_session:: Session ;
33- use rustc_session:: lint:: BuiltinLintDiag ;
3433use rustc_session:: lint:: builtin:: {
3534 DEPRECATED_WHERE_CLAUSE_LOCATION , MISSING_ABI , MISSING_UNSAFE_ON_EXTERN ,
3635 PATTERNS_IN_FNS_WITHOUT_BODY , UNUSED_VISIBILITIES ,
@@ -166,13 +165,13 @@ impl<'a> AstValidator<'a> {
166165 state. print_where_predicate ( p) ;
167166 }
168167
169- errors:: WhereClauseBeforeTypeAliasSugg :: Move {
168+ errors:: ModifyLeadingTyAliasWhereClause :: Move {
170169 left : span,
171170 snippet : state. s . eof ( ) ,
172171 right : ty_alias. after_where_clause . span . shrink_to_hi ( ) ,
173172 }
174173 } else {
175- errors:: WhereClauseBeforeTypeAliasSugg :: Remove { span }
174+ errors:: ModifyLeadingTyAliasWhereClause :: Remove { span }
176175 } ;
177176
178177 Err ( errors:: WhereClauseBeforeTypeAlias { span, sugg } )
@@ -230,14 +229,12 @@ impl<'a> AstValidator<'a> {
230229 } ) ;
231230 }
232231
233- fn check_decl_no_pat ( decl : & FnDecl , mut report_err : impl FnMut ( Span , Option < Ident > , bool ) ) {
232+ fn check_decl_no_pat ( decl : & FnDecl , mut report_err : impl FnMut ( Span , Option < Ident > ) ) {
234233 for Param { pat, .. } in & decl. inputs {
235234 match pat. kind {
236235 PatKind :: Missing | PatKind :: Ident ( BindingMode :: NONE , _, None ) | PatKind :: Wild => { }
237- PatKind :: Ident ( BindingMode :: MUT , ident, None ) => {
238- report_err ( pat. span , Some ( ident) , true )
239- }
240- _ => report_err ( pat. span , None , false ) ,
236+ PatKind :: Ident ( BindingMode :: MUT , ident, None ) => report_err ( pat. span , Some ( ident) ) ,
237+ _ => report_err ( pat. span , None ) ,
241238 }
242239 }
243240 }
@@ -929,7 +926,7 @@ impl<'a> AstValidator<'a> {
929926 TyKind :: FnPtr ( bfty) => {
930927 self . check_fn_ptr_safety ( bfty. decl_span , bfty. safety ) ;
931928 self . check_fn_decl ( & bfty. decl , SelfSemantic :: No ) ;
932- Self :: check_decl_no_pat ( & bfty. decl , |span, _, _ | {
929+ Self :: check_decl_no_pat ( & bfty. decl , |span, _| {
933930 self . dcx ( ) . emit_err ( errors:: PatternFnPointer { span } ) ;
934931 } ) ;
935932 if let Extern :: Implicit ( extern_span) = bfty. ext {
@@ -1355,7 +1352,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13551352 UNUSED_VISIBILITIES ,
13561353 item. id ,
13571354 item. vis . span ,
1358- BuiltinLintDiag :: UnusedVisibility ( item. vis . span ) ,
1355+ errors :: UnusedVisibility { span : item. vis . span } ,
13591356 )
13601357 }
13611358
@@ -1641,25 +1638,20 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
16411638
16421639 // Functions without bodies cannot have patterns.
16431640 if let FnKind :: Fn ( ctxt, _, Fn { body : None , sig, .. } ) = fk {
1644- Self :: check_decl_no_pat ( & sig. decl , |span, ident, mut_ident| {
1645- if mut_ident && matches ! ( ctxt, FnCtxt :: Assoc ( _) ) {
1646- if let Some ( ident) = ident {
1647- self . lint_buffer . buffer_lint (
1648- PATTERNS_IN_FNS_WITHOUT_BODY ,
1649- id,
1650- span,
1651- BuiltinLintDiag :: PatternsInFnsWithoutBody {
1652- span,
1653- ident,
1654- is_foreign : matches ! ( ctxt, FnCtxt :: Foreign ) ,
1655- } ,
1656- )
1657- }
1658- } else {
1659- match ctxt {
1660- FnCtxt :: Foreign => self . dcx ( ) . emit_err ( errors:: PatternInForeign { span } ) ,
1661- _ => self . dcx ( ) . emit_err ( errors:: PatternInBodiless { span } ) ,
1662- } ;
1641+ Self :: check_decl_no_pat ( & sig. decl , |span, mut_ident| match ctxt {
1642+ FnCtxt :: Assoc ( _) if let Some ( mut_ident) = mut_ident => {
1643+ self . lint_buffer . buffer_lint (
1644+ PATTERNS_IN_FNS_WITHOUT_BODY ,
1645+ id,
1646+ span,
1647+ errors:: PatternInBodilessLint { removal : span. until ( mut_ident. span ) } ,
1648+ ) ;
1649+ }
1650+ FnCtxt :: Foreign => {
1651+ self . dcx ( ) . emit_err ( errors:: PatternInForeign { span } ) ;
1652+ }
1653+ _ => {
1654+ self . dcx ( ) . emit_err ( errors:: PatternInBodiless { span } ) ;
16631655 }
16641656 } ) ;
16651657 }
@@ -1723,17 +1715,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
17231715 if let AssocItemKind :: Type ( ty_alias) = & item. kind
17241716 && let Err ( err) = self . check_type_alias_where_clause_location ( ty_alias)
17251717 {
1726- let sugg = match err. sugg {
1727- errors:: WhereClauseBeforeTypeAliasSugg :: Remove { .. } => None ,
1728- errors:: WhereClauseBeforeTypeAliasSugg :: Move { snippet, right, .. } => {
1729- Some ( ( right, snippet) )
1730- }
1731- } ;
17321718 self . lint_buffer . buffer_lint (
17331719 DEPRECATED_WHERE_CLAUSE_LOCATION ,
17341720 item. id ,
17351721 err. span ,
1736- BuiltinLintDiag :: DeprecatedWhereclauseLocation ( err. span , sugg) ,
1722+ errors :: DeprecatedWhereClauseLocation { sugg : err. sugg } ,
17371723 ) ;
17381724 }
17391725
0 commit comments