@@ -538,13 +538,9 @@ impl LateLintPass<'_> for BadOptAccess {
538
538
}
539
539
}
540
540
541
- // some things i'm not sure about:
542
- // * is Warn the right level?
543
- // * the way i verify that the right method is being called (path + diag item check)
544
-
545
541
declare_tool_lint ! {
546
542
pub rustc:: SPAN_USE_EQ_CTXT ,
547
- Warn , // is this the right level?
543
+ Allow ,
548
544
"Use of `==` with `Span::ctxt` rather than `Span::eq_ctxt`" ,
549
545
report_in_external_macro: true
550
546
}
@@ -555,25 +551,18 @@ impl<'tcx> LateLintPass<'tcx> for SpanUseEqCtxt {
555
551
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & Expr < ' _ > ) {
556
552
if let ExprKind :: Binary ( BinOp { node : BinOpKind :: Eq , .. } , lhs, rhs) = expr. kind {
557
553
if is_span_ctxt_call ( cx, lhs) && is_span_ctxt_call ( cx, rhs) {
558
- cx. emit_spanned_lint (
559
- SPAN_USE_EQ_CTXT ,
560
- expr. span ,
561
- SpanUseEqCtxtDiag { msg : "fail" } ,
562
- ) ;
554
+ cx. emit_spanned_lint ( SPAN_USE_EQ_CTXT , expr. span , SpanUseEqCtxtDiag ) ;
563
555
}
564
556
}
565
557
}
566
558
}
567
559
568
560
fn is_span_ctxt_call ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
569
561
match & expr. kind {
570
- ExprKind :: MethodCall ( path, receiver, _, _) => {
571
- path. ident . name . as_str ( ) == "ctxt"
572
- && cx
573
- . typeck_results ( )
574
- . type_dependent_def_id ( receiver. hir_id )
575
- . is_some_and ( |did| cx. tcx . is_diagnostic_item ( sym:: Span , did) )
576
- }
562
+ ExprKind :: MethodCall ( ..) => cx
563
+ . typeck_results ( )
564
+ . type_dependent_def_id ( expr. hir_id )
565
+ . is_some_and ( |call_did| cx. tcx . is_diagnostic_item ( sym:: SpanCtxt , call_did) ) ,
577
566
578
567
_ => false ,
579
568
}
0 commit comments