Skip to content

Commit 418eddf

Browse files
committed
Improve is_issue_147319_hack check
1 parent a2e4e4a commit 418eddf

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind, PartialRe
66
use rustc_middle::{bug, span_bug};
77
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
88
use rustc_session::parse::feature_err;
9+
use rustc_span::edition::Edition;
910
use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
1011
use rustc_span::{Ident, Span, kw, sym};
1112
use tracing::{debug, instrument};
@@ -715,16 +716,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
715716
{
716717
// Turn ambiguity errors for core vs std panic into warnings.
717718
// FIXME: Remove with lang team approval.
718-
let is_issue_147319_hack = matches!(
719-
(binding.res(), innermost_binding.res()),
720-
(
721-
Res::Def(DefKind::Macro(_), def_id_core),
722-
Res::Def(DefKind::Macro(_), def_id_std)
723-
) if this.tcx.def_path_debug_str(def_id_core)
724-
== "core[234c]::macros::panic"
725-
&& this.tcx.def_path_debug_str(def_id_std)
726-
== "std[d474]::macros::panic"
727-
);
719+
let is_issue_147319_hack = ctxt.edition()
720+
<= Edition::Edition2024
721+
&& matches!(orig_ident.name, sym::panic)
722+
&& this.is_builtin_macro(binding.res())
723+
&& this.is_builtin_macro(innermost_binding.res());
728724

729725
let warning = if is_issue_147319_hack {
730726
Some(AmbiguityWarning::PanicImport)

0 commit comments

Comments
 (0)