@@ -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 {
@@ -1360,7 +1357,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13601357 UNUSED_VISIBILITIES ,
13611358 item. id ,
13621359 item. vis . span ,
1363- BuiltinLintDiag :: UnusedVisibility ( item. vis . span ) ,
1360+ errors :: UnusedVisibility { span : item. vis . span } ,
13641361 )
13651362 }
13661363
@@ -1646,25 +1643,20 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
16461643
16471644 // Functions without bodies cannot have patterns.
16481645 if let FnKind :: Fn ( ctxt, _, Fn { body : None , sig, .. } ) = fk {
1649- Self :: check_decl_no_pat ( & sig. decl , |span, ident, mut_ident| {
1650- if mut_ident && matches ! ( ctxt, FnCtxt :: Assoc ( _) ) {
1651- if let Some ( ident) = ident {
1652- self . lint_buffer . buffer_lint (
1653- PATTERNS_IN_FNS_WITHOUT_BODY ,
1654- id,
1655- span,
1656- BuiltinLintDiag :: PatternsInFnsWithoutBody {
1657- span,
1658- ident,
1659- is_foreign : matches ! ( ctxt, FnCtxt :: Foreign ) ,
1660- } ,
1661- )
1662- }
1663- } else {
1664- match ctxt {
1665- FnCtxt :: Foreign => self . dcx ( ) . emit_err ( errors:: PatternInForeign { span } ) ,
1666- _ => self . dcx ( ) . emit_err ( errors:: PatternInBodiless { span } ) ,
1667- } ;
1646+ Self :: check_decl_no_pat ( & sig. decl , |span, mut_ident| match ctxt {
1647+ FnCtxt :: Assoc ( _) if let Some ( mut_ident) = mut_ident => {
1648+ self . lint_buffer . buffer_lint (
1649+ PATTERNS_IN_FNS_WITHOUT_BODY ,
1650+ id,
1651+ span,
1652+ errors:: PatternInBodilessLint { removal : span. until ( mut_ident. span ) } ,
1653+ ) ;
1654+ }
1655+ FnCtxt :: Foreign => {
1656+ self . dcx ( ) . emit_err ( errors:: PatternInForeign { span } ) ;
1657+ }
1658+ _ => {
1659+ self . dcx ( ) . emit_err ( errors:: PatternInBodiless { span } ) ;
16681660 }
16691661 } ) ;
16701662 }
@@ -1728,17 +1720,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
17281720 if let AssocItemKind :: Type ( ty_alias) = & item. kind
17291721 && let Err ( err) = self . check_type_alias_where_clause_location ( ty_alias)
17301722 {
1731- let sugg = match err. sugg {
1732- errors:: WhereClauseBeforeTypeAliasSugg :: Remove { .. } => None ,
1733- errors:: WhereClauseBeforeTypeAliasSugg :: Move { snippet, right, .. } => {
1734- Some ( ( right, snippet) )
1735- }
1736- } ;
17371723 self . lint_buffer . buffer_lint (
17381724 DEPRECATED_WHERE_CLAUSE_LOCATION ,
17391725 item. id ,
17401726 err. span ,
1741- BuiltinLintDiag :: DeprecatedWhereclauseLocation ( err. span , sugg) ,
1727+ errors :: DeprecatedWhereClauseLocation { sugg : err. sugg } ,
17421728 ) ;
17431729 }
17441730
0 commit comments