@@ -17,10 +17,10 @@ use crate::late::{
1717} ;
1818use crate :: macros:: { MacroRulesScope , sub_namespace_match} ;
1919use crate :: {
20- AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , BindingKey , CmResolver , Determinacy ,
21- Finalize , ImportKind , LexicalScopeBinding , Module , ModuleKind , ModuleOrUniformRoot ,
22- NameBinding , NameBindingKind , ParentScope , PathResult , PrivacyError , Res , ResolutionError ,
23- Resolver , Scope , ScopeSet , Segment , Stage , Used , Weak , errors,
20+ AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , AmbiguityWarning , BindingKey , CmResolver ,
21+ Determinacy , Finalize , ImportKind , LexicalScopeBinding , Module , ModuleKind ,
22+ ModuleOrUniformRoot , NameBinding , NameBindingKind , ParentScope , PathResult , PrivacyError , Res ,
23+ ResolutionError , Resolver , Scope , ScopeSet , Segment , Stage , Used , Weak , errors,
2424} ;
2525
2626#[ derive( Copy , Clone ) ]
@@ -705,13 +705,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
705705 // Skip ambiguity errors for extern flag bindings "overridden"
706706 // by extern item bindings.
707707 // FIXME: Remove with lang team approval.
708- let issue_145575_hack = Some ( binding)
709- == extern_prelude_flag_binding
710- && extern_prelude_item_binding. is_some ( )
711- && extern_prelude_item_binding != Some ( innermost_binding) ;
708+ let is_issue_145575_hack = || {
709+ Some ( binding) == extern_prelude_flag_binding
710+ && extern_prelude_item_binding. is_some ( )
711+ && extern_prelude_item_binding != Some ( innermost_binding)
712+ } ;
713+
712714 if let Some ( kind) = ambiguity_error_kind
713- && !issue_145575_hack
715+ && !is_issue_145575_hack ( )
714716 {
717+ // Turn ambiguity errors for core vs std panic into warnings.
718+ // FIXME: Remove with lang team approval.
719+ let is_issue_147319_hack = matches ! (
720+ ( binding. res( ) , innermost_binding. res( ) ) ,
721+ (
722+ Res :: Def ( DefKind :: Macro ( _) , def_id_core) ,
723+ Res :: Def ( DefKind :: Macro ( _) , def_id_std)
724+ ) if this. tcx. def_path_debug_str( def_id_core)
725+ == "core[234c]::macros::panic"
726+ && this. tcx. def_path_debug_str( def_id_std)
727+ == "std[d474]::macros::panic"
728+ ) ;
729+
730+ let warning = if is_issue_147319_hack {
731+ Some ( AmbiguityWarning :: PanicImport )
732+ } else {
733+ None
734+ } ;
735+
715736 let misc = |f : Flags | {
716737 if f. contains ( Flags :: MISC_SUGGEST_CRATE ) {
717738 AmbiguityErrorMisc :: SuggestCrate
@@ -728,7 +749,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
728749 ident : orig_ident,
729750 b1 : innermost_binding,
730751 b2 : binding,
731- warning : false ,
752+ warning,
732753 misc1 : misc ( innermost_flags) ,
733754 misc2 : misc ( flags) ,
734755 } ) ;
@@ -1072,7 +1093,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10721093 ident,
10731094 b1 : binding,
10741095 b2 : shadowed_glob,
1075- warning : false ,
1096+ warning : None ,
10761097 misc1 : AmbiguityErrorMisc :: None ,
10771098 misc2 : AmbiguityErrorMisc :: None ,
10781099 } ) ;
0 commit comments