@@ -15,10 +15,10 @@ use crate::imports::{Import, NameResolution};
15
15
use crate :: late:: { ConstantHasGenerics , NoConstantGenericsReason , PathSource , Rib , RibKind } ;
16
16
use crate :: macros:: { MacroRulesScope , sub_namespace_match} ;
17
17
use 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,
22
22
} ;
23
23
24
24
#[ derive( Copy , Clone ) ]
@@ -697,13 +697,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
697
697
// Skip ambiguity errors for extern flag bindings "overridden"
698
698
// by extern item bindings.
699
699
// 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
+
704
706
if let Some ( kind) = ambiguity_error_kind
705
- && !issue_145575_hack
707
+ && !is_issue_145575_hack ( )
706
708
{
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
+
707
728
let misc = |f : Flags | {
708
729
if f. contains ( Flags :: MISC_SUGGEST_CRATE ) {
709
730
AmbiguityErrorMisc :: SuggestCrate
@@ -720,7 +741,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
720
741
ident : orig_ident,
721
742
b1 : innermost_binding,
722
743
b2 : binding,
723
- warning : false ,
744
+ warning,
724
745
misc1 : misc ( innermost_flags) ,
725
746
misc2 : misc ( flags) ,
726
747
} ) ;
@@ -1064,7 +1085,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1064
1085
ident,
1065
1086
b1 : binding,
1066
1087
b2 : shadowed_glob,
1067
- warning : false ,
1088
+ warning : None ,
1068
1089
misc1 : AmbiguityErrorMisc :: None ,
1069
1090
misc2 : AmbiguityErrorMisc :: None ,
1070
1091
} ) ;
0 commit comments