@@ -15,7 +15,7 @@ use rustc_index::vec::Idx;
1515use rustc_middle:: mir:: AssertKind ;
1616use rustc_middle:: mir:: { self , SwitchTargets } ;
1717use 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 } ;
1919use rustc_middle:: ty:: { self , Instance , Ty , TypeFoldable } ;
2020use rustc_span:: source_map:: Span ;
2121use rustc_span:: { sym, Symbol } ;
@@ -476,15 +476,20 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
476476 UninitValid => !layout. might_permit_raw_init ( bx, /*zero:*/ false ) ,
477477 } ;
478478 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+ } )
488493 } ) ;
489494 let msg = bx. const_str ( Symbol :: intern ( & msg_str) ) ;
490495 let location = self . get_caller_location ( bx, source_info) . immediate ( ) ;
0 commit comments