@@ -109,11 +109,7 @@ fn map_error<'tcx>(
109109 "encountered unexpected unsized field in layout of {ty:?}: {field:#?}"
110110 ) ) ;
111111 }
112- if cx. tcx ( ) . features ( ) . trivial_bounds ( ) {
113- LayoutError :: TooGeneric ( ty)
114- } else {
115- LayoutError :: Unknown ( ty)
116- }
112+ LayoutError :: Unknown ( ty)
117113 }
118114 LayoutCalculatorError :: EmptyUnion => {
119115 // This is always a compile error.
@@ -327,7 +323,7 @@ fn layout_of_uncached<'tcx>(
327323
328324 let count = count
329325 . try_to_target_usize ( tcx)
330- . ok_or_else ( || error ( cx, LayoutError :: Unknown ( ty) ) ) ?;
326+ . ok_or_else ( || error ( cx, LayoutError :: TooGeneric ( ty) ) ) ?;
331327 let element = cx. layout_of ( element) ?;
332328 let size = element
333329 . size
@@ -677,6 +673,9 @@ fn layout_of_uncached<'tcx>(
677673
678674 // Types with no meaningful known layout.
679675 ty:: Alias ( ..) => {
676+ if ty. has_param ( ) {
677+ return Err ( error ( cx, LayoutError :: TooGeneric ( ty) ) ) ;
678+ }
680679 // NOTE(eddyb) `layout_of` query should've normalized these away,
681680 // if that was possible, so there's no reason to try again here.
682681 return Err ( error ( cx, LayoutError :: Unknown ( ty) ) ) ;
@@ -686,7 +685,11 @@ fn layout_of_uncached<'tcx>(
686685 bug ! ( "Layout::compute: unexpected type `{}`" , ty)
687686 }
688687
689- ty:: Placeholder ( ..) | ty:: Param ( _) => {
688+ ty:: Param ( _) => {
689+ return Err ( error ( cx, LayoutError :: TooGeneric ( ty) ) ) ;
690+ }
691+
692+ ty:: Placeholder ( ..) => {
690693 return Err ( error ( cx, LayoutError :: Unknown ( ty) ) ) ;
691694 }
692695 } )
0 commit comments