@@ -15,7 +15,7 @@ use rustc_index::vec::Idx;
15
15
use rustc_middle:: mir:: AssertKind ;
16
16
use rustc_middle:: mir:: { self , SwitchTargets } ;
17
17
use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf } ;
18
- use rustc_middle:: ty:: print:: with_no_trimmed_paths;
18
+ use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths } ;
19
19
use rustc_middle:: ty:: { self , Instance , Ty , TypeFoldable } ;
20
20
use rustc_span:: source_map:: Span ;
21
21
use rustc_span:: { sym, Symbol } ;
@@ -476,15 +476,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
476
476
UninitValid => !layout. might_permit_raw_init ( bx, /*zero:*/ false ) ,
477
477
} ;
478
478
if do_panic {
479
- let msg_str = with_no_trimmed_paths ( || {
480
- if layout. abi . is_uninhabited ( ) {
481
- // Use this error even for the other intrinsics as it is more precise.
482
- format ! ( "attempted to instantiate uninhabited type `{}`" , ty)
483
- } else if intrinsic == ZeroValid {
484
- format ! ( "attempted to zero-initialize type `{}`, which is invalid" , ty)
485
- } else {
486
- format ! ( "attempted to leave type `{}` uninitialized, which is invalid" , ty)
487
- }
479
+ let msg_str = with_no_visible_paths ( || {
480
+ with_no_trimmed_paths ( || {
481
+ if layout. abi . is_uninhabited ( ) {
482
+ // Use this error even for the other intrinsics as it is more precise.
483
+ format ! ( "attempted to instantiate uninhabited type `{}`" , ty)
484
+ } else if intrinsic == ZeroValid {
485
+ format ! ( "attempted to zero-initialize type `{}`, which is invalid" , ty)
486
+ } else {
487
+ format ! (
488
+ "attempted to leave type `{}` uninitialized, which is invalid" ,
489
+ ty
490
+ )
491
+ }
492
+ } )
488
493
} ) ;
489
494
let msg = bx. const_str ( Symbol :: intern ( & msg_str) ) ;
490
495
let location = self . get_caller_location ( bx, source_info) . immediate ( ) ;
0 commit comments