@@ -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 ) ]
@@ -697,13 +697,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
697697 // Skip ambiguity errors for extern flag bindings "overridden"
698698 // by extern item bindings.
699699 // FIXME: Remove with lang team approval.
700- let issue_145575_hack = Some ( binding)
701- == extern_prelude_flag_binding
702- && extern_prelude_item_binding. is_some ( )
703- && extern_prelude_item_binding != Some ( innermost_binding) ;
700+ let is_issue_145575_hack = || {
701+ Some ( binding) == extern_prelude_flag_binding
702+ && extern_prelude_item_binding. is_some ( )
703+ && extern_prelude_item_binding != Some ( innermost_binding)
704+ } ;
705+
704706 if let Some ( kind) = ambiguity_error_kind
705- && !issue_145575_hack
707+ && !is_issue_145575_hack ( )
706708 {
709+ // Turn ambiguity errors for core vs std panic into warnings.
710+ // FIXME: Remove with lang team approval.
711+ let is_issue_147319_hack = matches ! (
712+ ( binding. res( ) , innermost_binding. res( ) ) ,
713+ (
714+ Res :: Def ( DefKind :: Macro ( _) , def_id_core) ,
715+ Res :: Def ( DefKind :: Macro ( _) , def_id_std)
716+ ) if this. tcx. def_path_debug_str( def_id_core)
717+ == "core[234c]::macros::panic"
718+ && this. tcx. def_path_debug_str( def_id_std)
719+ == "std[d474]::macros::panic"
720+ ) ;
721+
722+ let warning = if is_issue_147319_hack {
723+ Some ( AmbiguityWarning :: PanicImport )
724+ } else {
725+ None
726+ } ;
727+
707728 let misc = |f : Flags | {
708729 if f. contains ( Flags :: MISC_SUGGEST_CRATE ) {
709730 AmbiguityErrorMisc :: SuggestCrate
@@ -720,7 +741,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
720741 ident : orig_ident,
721742 b1 : innermost_binding,
722743 b2 : binding,
723- warning : false ,
744+ warning,
724745 misc1 : misc ( innermost_flags) ,
725746 misc2 : misc ( flags) ,
726747 } ) ;
@@ -1064,7 +1085,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10641085 ident,
10651086 b1 : binding,
10661087 b2 : shadowed_glob,
1067- warning : false ,
1088+ warning : None ,
10681089 misc1 : AmbiguityErrorMisc :: None ,
10691090 misc2 : AmbiguityErrorMisc :: None ,
10701091 } ) ;
0 commit comments