@@ -27,10 +27,9 @@ use rustc_ast::*;
2727use rustc_ast_pretty:: pprust:: { self , State } ;
2828use rustc_attr_parsing:: validate_attr;
2929use rustc_data_structures:: fx:: FxIndexMap ;
30- use rustc_errors:: { DiagCtxtHandle , LintBuffer } ;
30+ use rustc_errors:: { DiagCtxtHandle , Diagnostic , 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 ,
@@ -1424,7 +1423,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14241423 UNUSED_VISIBILITIES ,
14251424 item. id ,
14261425 item. vis . span ,
1427- BuiltinLintDiag :: UnusedVisibility ( item. vis . span ) ,
1426+ errors :: UnusedVisibility { span : item. vis . span } ,
14281427 )
14291428 }
14301429
@@ -1731,14 +1730,19 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
17311730 Self :: check_decl_no_pat ( & sig. decl , |span, ident, mut_ident| {
17321731 if mut_ident && matches ! ( ctxt, FnCtxt :: Assoc ( _) ) {
17331732 if let Some ( ident) = ident {
1734- self . lint_buffer . buffer_lint (
1733+ let is_foreign = matches ! ( ctxt, FnCtxt :: Foreign ) ;
1734+ self . lint_buffer . dyn_buffer_lint (
17351735 PATTERNS_IN_FNS_WITHOUT_BODY ,
17361736 id,
17371737 span,
1738- BuiltinLintDiag :: PatternsInFnsWithoutBody {
1739- span,
1740- ident,
1741- is_foreign : matches ! ( ctxt, FnCtxt :: Foreign ) ,
1738+ move |dcx, level| {
1739+ let sub = errors:: PatternsInFnsWithoutBodySub { ident, span } ;
1740+ if is_foreign {
1741+ errors:: PatternsInFnsWithoutBody :: Foreign { sub }
1742+ } else {
1743+ errors:: PatternsInFnsWithoutBody :: Bodiless { sub }
1744+ }
1745+ . into_diag ( dcx, level)
17421746 } ,
17431747 )
17441748 }
@@ -1828,11 +1832,26 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
18281832 Some ( ( right, snippet) )
18291833 }
18301834 } ;
1831- self . lint_buffer . buffer_lint (
1835+ let left_sp = err. span ;
1836+ self . lint_buffer . dyn_buffer_lint (
18321837 DEPRECATED_WHERE_CLAUSE_LOCATION ,
18331838 item. id ,
18341839 err. span ,
1835- BuiltinLintDiag :: DeprecatedWhereclauseLocation ( err. span , sugg) ,
1840+ move |dcx, level| {
1841+ let suggestion = match sugg {
1842+ Some ( ( right_sp, sugg) ) => {
1843+ errors:: DeprecatedWhereClauseLocationSugg :: MoveToEnd {
1844+ left : left_sp,
1845+ right : right_sp,
1846+ sugg,
1847+ }
1848+ }
1849+ None => {
1850+ errors:: DeprecatedWhereClauseLocationSugg :: RemoveWhere { span : left_sp }
1851+ }
1852+ } ;
1853+ errors:: DeprecatedWhereClauseLocation { suggestion } . into_diag ( dcx, level)
1854+ } ,
18361855 ) ;
18371856 }
18381857
0 commit comments