1
- use clippy_utils:: diagnostics:: span_lint_and_then ;
1
+ use clippy_utils:: diagnostics:: span_lint_hir_and_then ;
2
2
use clippy_utils:: macros:: { is_panic, root_macro_call_first_node} ;
3
3
use clippy_utils:: { is_res_lang_ctor, is_trait_method, match_trait_method, paths, peel_blocks} ;
4
- use hir:: { ExprKind , PatKind } ;
4
+ use hir:: { ExprKind , HirId , PatKind } ;
5
5
use rustc_hir as hir;
6
6
use rustc_lint:: { LateContext , LateLintPass } ;
7
7
use rustc_session:: declare_lint_pass;
@@ -135,22 +135,22 @@ fn check_expr<'a>(cx: &LateContext<'a>, expr: &'a hir::Expr<'a>) {
135
135
&& is_ok_wild_or_dotdot_pattern ( cx, pat)
136
136
&& let Some ( op) = should_lint ( cx, init) =>
137
137
{
138
- emit_lint ( cx, cond. span , op, & [ pat. span ] ) ;
138
+ emit_lint ( cx, cond. span , cond . hir_id , op, & [ pat. span ] ) ;
139
139
} ,
140
140
// we will capture only the case where the match is Ok( ) or Err( )
141
141
// prefer to match the minimum possible, and expand later if needed
142
142
// to avoid false positives on something as used as this
143
143
hir:: ExprKind :: Match ( expr, [ arm1, arm2] , hir:: MatchSource :: Normal ) if let Some ( op) = should_lint ( cx, expr) => {
144
144
if non_consuming_ok_arm ( cx, arm1) && non_consuming_err_arm ( cx, arm2) {
145
- emit_lint ( cx, expr. span , op, & [ arm1. pat . span ] ) ;
145
+ emit_lint ( cx, expr. span , expr . hir_id , op, & [ arm1. pat . span ] ) ;
146
146
}
147
147
if non_consuming_ok_arm ( cx, arm2) && non_consuming_err_arm ( cx, arm1) {
148
- emit_lint ( cx, expr. span , op, & [ arm2. pat . span ] ) ;
148
+ emit_lint ( cx, expr. span , expr . hir_id , op, & [ arm2. pat . span ] ) ;
149
149
}
150
150
} ,
151
151
hir:: ExprKind :: Match ( _, _, hir:: MatchSource :: Normal ) => { } ,
152
152
_ if let Some ( op) = should_lint ( cx, expr) => {
153
- emit_lint ( cx, expr. span , op, & [ ] ) ;
153
+ emit_lint ( cx, expr. span , expr . hir_id , op, & [ ] ) ;
154
154
} ,
155
155
_ => { } ,
156
156
} ;
@@ -279,7 +279,7 @@ fn check_io_mode(cx: &LateContext<'_>, call: &hir::Expr<'_>) -> Option<IoOp> {
279
279
}
280
280
}
281
281
282
- fn emit_lint ( cx : & LateContext < ' _ > , span : Span , op : IoOp , wild_cards : & [ Span ] ) {
282
+ fn emit_lint ( cx : & LateContext < ' _ > , span : Span , at : HirId , op : IoOp , wild_cards : & [ Span ] ) {
283
283
let ( msg, help) = match op {
284
284
IoOp :: AsyncRead ( false ) => (
285
285
"read amount is not handled" ,
@@ -301,7 +301,7 @@ fn emit_lint(cx: &LateContext<'_>, span: Span, op: IoOp, wild_cards: &[Span]) {
301
301
IoOp :: SyncWrite ( true ) | IoOp :: AsyncWrite ( true ) => ( "written amount is not handled" , None ) ,
302
302
} ;
303
303
304
- span_lint_and_then ( cx, UNUSED_IO_AMOUNT , span, msg, |diag| {
304
+ span_lint_hir_and_then ( cx, UNUSED_IO_AMOUNT , at , span, msg, |diag| {
305
305
if let Some ( help_str) = help {
306
306
diag. help ( help_str) ;
307
307
}
0 commit comments