@@ -15,10 +15,10 @@ use crate::imports::{Import, NameResolution};
1515use crate :: late:: { ConstantHasGenerics , NoConstantGenericsReason , PathSource , Rib , RibKind } ;
1616use crate :: macros:: { MacroRulesScope , sub_namespace_match} ;
1717use crate :: {
18- AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , BindingKey , CmResolver , Determinacy ,
19- Finalize , ImportKind , LexicalScopeBinding , Module , ModuleKind , ModuleOrUniformRoot ,
20- NameBinding , NameBindingKind , ParentScope , PathResult , PrivacyError , Res , ResolutionError ,
21- Resolver , Scope , ScopeSet , Segment , Stage , Used , Weak , errors,
18+ AmbiguityError , AmbiguityErrorMisc , AmbiguityKind , AmbiguityWarning , BindingKey , CmResolver ,
19+ Determinacy , Finalize , ImportKind , LexicalScopeBinding , Module , ModuleKind ,
20+ ModuleOrUniformRoot , NameBinding , NameBindingKind , ParentScope , PathResult , PrivacyError , Res ,
21+ ResolutionError , Resolver , Scope , ScopeSet , Segment , Stage , Used , Weak , errors,
2222} ;
2323
2424#[ derive( Copy , Clone ) ]
@@ -704,13 +704,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
704704 // Skip ambiguity errors for extern flag bindings "overridden"
705705 // by extern item bindings.
706706 // FIXME: Remove with lang team approval.
707- let issue_145575_hack = Some ( binding)
708- == extern_prelude_flag_binding
709- && extern_prelude_item_binding. is_some ( )
710- && extern_prelude_item_binding != Some ( innermost_binding) ;
707+ let is_issue_145575_hack = || {
708+ Some ( binding) == extern_prelude_flag_binding
709+ && extern_prelude_item_binding. is_some ( )
710+ && extern_prelude_item_binding != Some ( innermost_binding)
711+ } ;
712+
711713 if let Some ( kind) = ambiguity_error_kind
712- && !issue_145575_hack
714+ && !is_issue_145575_hack ( )
713715 {
716+ // Turn ambiguity errors for core vs std panic into warnings.
717+ // 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+ ) ;
728+
729+ let warning = if is_issue_147319_hack {
730+ Some ( AmbiguityWarning :: PanicImport )
731+ } else {
732+ None
733+ } ;
734+
714735 let misc = |f : Flags | {
715736 if f. contains ( Flags :: MISC_SUGGEST_CRATE ) {
716737 AmbiguityErrorMisc :: SuggestCrate
@@ -727,7 +748,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
727748 ident : orig_ident,
728749 b1 : innermost_binding,
729750 b2 : binding,
730- warning : false ,
751+ warning,
731752 misc1 : misc ( innermost_flags) ,
732753 misc2 : misc ( flags) ,
733754 } ) ;
@@ -1071,7 +1092,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10711092 ident,
10721093 b1 : binding,
10731094 b2 : shadowed_glob,
1074- warning : false ,
1095+ warning : None ,
10751096 misc1 : AmbiguityErrorMisc :: None ,
10761097 misc2 : AmbiguityErrorMisc :: None ,
10771098 } ) ;
0 commit comments