1- use clippy_utils:: diagnostics:: span_lint_and_then ;
1+ use clippy_utils:: diagnostics:: span_lint_hir_and_then ;
22use clippy_utils:: macros:: { is_panic, root_macro_call_first_node} ;
33use 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 } ;
55use rustc_hir as hir;
66use rustc_lint:: { LateContext , LateLintPass } ;
77use rustc_session:: declare_lint_pass;
@@ -135,22 +135,22 @@ fn check_expr<'a>(cx: &LateContext<'a>, expr: &'a hir::Expr<'a>) {
135135 && is_ok_wild_or_dotdot_pattern ( cx, pat)
136136 && let Some ( op) = should_lint ( cx, init) =>
137137 {
138- emit_lint ( cx, cond. span , op, & [ pat. span ] ) ;
138+ emit_lint ( cx, cond. span , cond . hir_id , op, & [ pat. span ] ) ;
139139 } ,
140140 // we will capture only the case where the match is Ok( ) or Err( )
141141 // prefer to match the minimum possible, and expand later if needed
142142 // to avoid false positives on something as used as this
143143 hir:: ExprKind :: Match ( expr, [ arm1, arm2] , hir:: MatchSource :: Normal ) if let Some ( op) = should_lint ( cx, expr) => {
144144 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 ] ) ;
146146 }
147147 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 ] ) ;
149149 }
150150 } ,
151151 hir:: ExprKind :: Match ( _, _, hir:: MatchSource :: Normal ) => { } ,
152152 _ 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, & [ ] ) ;
154154 } ,
155155 _ => { } ,
156156 } ;
@@ -279,7 +279,7 @@ fn check_io_mode(cx: &LateContext<'_>, call: &hir::Expr<'_>) -> Option<IoOp> {
279279 }
280280}
281281
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 ] ) {
283283 let ( msg, help) = match op {
284284 IoOp :: AsyncRead ( false ) => (
285285 "read amount is not handled" ,
@@ -301,7 +301,7 @@ fn emit_lint(cx: &LateContext<'_>, span: Span, op: IoOp, wild_cards: &[Span]) {
301301 IoOp :: SyncWrite ( true ) | IoOp :: AsyncWrite ( true ) => ( "written amount is not handled" , None ) ,
302302 } ;
303303
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| {
305305 if let Some ( help_str) = help {
306306 diag. help ( help_str) ;
307307 }
0 commit comments