@@ -538,13 +538,9 @@ impl LateLintPass<'_> for BadOptAccess {
538538 }
539539}
540540
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-
545541declare_tool_lint ! {
546542 pub rustc:: SPAN_USE_EQ_CTXT ,
547- Warn , // is this the right level?
543+ Allow ,
548544 "Use of `==` with `Span::ctxt` rather than `Span::eq_ctxt`" ,
549545 report_in_external_macro: true
550546}
@@ -555,25 +551,18 @@ impl<'tcx> LateLintPass<'tcx> for SpanUseEqCtxt {
555551 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & Expr < ' _ > ) {
556552 if let ExprKind :: Binary ( BinOp { node : BinOpKind :: Eq , .. } , lhs, rhs) = expr. kind {
557553 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 ) ;
563555 }
564556 }
565557 }
566558}
567559
568560fn is_span_ctxt_call ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
569561 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) ) ,
577566
578567 _ => false ,
579568 }
0 commit comments