@@ -11,7 +11,9 @@ use rustc_middle::ty::layout::{
1111 self , FnAbiError , FnAbiOf , FnAbiOfHelpers , FnAbiRequest , LayoutError , LayoutOf ,
1212 LayoutOfHelpers , TyAndLayout ,
1313} ;
14- use rustc_middle:: ty:: { self , GenericArgsRef , Ty , TyCtxt , TypeFoldable , TypingEnv , Variance } ;
14+ use rustc_middle:: ty:: {
15+ self , GenericArgsRef , Ty , TyCtxt , TypeFoldable , TypeVisitableExt , TypingEnv , Variance ,
16+ } ;
1517use rustc_middle:: { mir, span_bug} ;
1618use rustc_span:: Span ;
1719use rustc_target:: callconv:: FnAbi ;
@@ -84,10 +86,31 @@ impl<'tcx, M: Machine<'tcx>> LayoutOfHelpers<'tcx> for InterpCx<'tcx, M> {
8486 #[ inline]
8587 fn handle_layout_err (
8688 & self ,
87- err : LayoutError < ' tcx > ,
89+ mut err : LayoutError < ' tcx > ,
8890 _: Span ,
8991 _: Ty < ' tcx > ,
9092 ) -> InterpErrorKind < ' tcx > {
93+ // FIXME(#149283): This is really hacky and is only used to hide type
94+ // system bugs. We use it as a temporary fix for #149081.
95+ //
96+ // While it's expected that we sometimes get ambiguity errors when
97+ // entering another generic environment while the current environment
98+ // itself is still generic, we should never fail to entirely prove
99+ // something.
100+ match err {
101+ LayoutError :: NormalizationFailure ( ty, _) => {
102+ if ty. has_non_region_param ( ) {
103+ err = LayoutError :: TooGeneric ( ty) ;
104+ }
105+ }
106+
107+ LayoutError :: Unknown ( _)
108+ | LayoutError :: SizeOverflow ( _)
109+ | LayoutError :: InvalidSimd { .. }
110+ | LayoutError :: TooGeneric ( _)
111+ | LayoutError :: ReferencesError ( _)
112+ | LayoutError :: Cycle ( _) => { }
113+ }
91114 err_inval ! ( Layout ( err) )
92115 }
93116}
@@ -112,7 +135,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
112135 /// and allows wrapping the actual [LayoutOf::layout_of] with a tracing span.
113136 /// See [LayoutOf::layout_of] for the original documentation.
114137 #[ inline( always) ]
115- pub fn layout_of ( & self , ty : Ty < ' tcx > ) -> < Self as LayoutOfHelpers < ' tcx > >:: LayoutOfResult {
138+ pub fn layout_of ( & self , ty : Ty < ' tcx > ) -> Result < TyAndLayout < ' tcx > , InterpErrorKind < ' tcx > > {
116139 let _trace = enter_trace_span ! ( M , layouting:: layout_of, ty = ?ty. kind( ) ) ;
117140 LayoutOf :: layout_of ( self , ty)
118141 }
0 commit comments