@@ -15,7 +15,9 @@ use rustc_ast_pretty::pprust::{self, State};
1515use rustc_data_structures:: fx:: FxHashMap ;
1616use rustc_errors:: { error_code, pluralize, struct_span_err, Applicability } ;
1717use rustc_parse:: validate_attr;
18- use rustc_session:: lint:: builtin:: { MISSING_ABI , PATTERNS_IN_FNS_WITHOUT_BODY } ;
18+ use rustc_session:: lint:: builtin:: {
19+ DEPRECATED_WHERE_CLAUSE_LOCATION , MISSING_ABI , PATTERNS_IN_FNS_WITHOUT_BODY ,
20+ } ;
1921use rustc_session:: lint:: { BuiltinLintDiagnostics , LintBuffer } ;
2022use rustc_session:: Session ;
2123use rustc_span:: source_map:: Spanned ;
@@ -123,11 +125,11 @@ impl<'a> AstValidator<'a> {
123125 }
124126
125127 fn check_gat_where (
126- & self ,
128+ & mut self ,
129+ id : NodeId ,
127130 before_predicates : & [ WherePredicate ] ,
128131 where_clauses : ( ast:: TyAliasWhereClause , ast:: TyAliasWhereClause ) ,
129132 ) {
130- let sess = & self . session ;
131133 if !before_predicates. is_empty ( ) {
132134 let mut state = State :: new ( ) ;
133135 if !where_clauses. 1 . 0 {
@@ -145,14 +147,16 @@ impl<'a> AstValidator<'a> {
145147 state. print_where_predicate ( p) ;
146148 }
147149 let suggestion = state. s . eof ( ) ;
148- sess. struct_span_err ( where_clauses. 0 . 1 , "where clause not allowed here" )
149- . span_suggestion (
150+ self . lint_buffer . buffer_lint_with_diagnostic (
151+ DEPRECATED_WHERE_CLAUSE_LOCATION ,
152+ id,
153+ where_clauses. 0 . 1 ,
154+ "where clause not allowed here" ,
155+ BuiltinLintDiagnostics :: DeprecatedWhereclauseLocation (
150156 where_clauses. 1 . 1 . shrink_to_hi ( ) ,
151- "move it here" ,
152157 suggestion,
153- Applicability :: MachineApplicable ,
154- )
155- . emit ( ) ;
158+ ) ,
159+ ) ;
156160 }
157161 }
158162
@@ -1568,6 +1572,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
15681572 self . check_type_no_bounds ( bounds, "`impl`s" ) ;
15691573 if ty. is_some ( ) {
15701574 self . check_gat_where (
1575+ item. id ,
15711576 generics. where_clause . predicates . split_at ( * where_predicates_split) . 0 ,
15721577 * where_clauses,
15731578 ) ;
0 commit comments