@@ -109,11 +109,7 @@ fn map_error<'tcx>(
109
109
"encountered unexpected unsized field in layout of {ty:?}: {field:#?}"
110
110
) ) ;
111
111
}
112
- if cx. tcx ( ) . features ( ) . trivial_bounds ( ) {
113
- LayoutError :: TooGeneric ( ty)
114
- } else {
115
- LayoutError :: Unknown ( ty)
116
- }
112
+ LayoutError :: Unknown ( ty)
117
113
}
118
114
LayoutCalculatorError :: EmptyUnion => {
119
115
// This is always a compile error.
@@ -327,7 +323,7 @@ fn layout_of_uncached<'tcx>(
327
323
328
324
let count = count
329
325
. try_to_target_usize ( tcx)
330
- . ok_or_else ( || error ( cx, LayoutError :: Unknown ( ty) ) ) ?;
326
+ . ok_or_else ( || error ( cx, LayoutError :: TooGeneric ( ty) ) ) ?;
331
327
let element = cx. layout_of ( element) ?;
332
328
let size = element
333
329
. size
@@ -677,6 +673,9 @@ fn layout_of_uncached<'tcx>(
677
673
678
674
// Types with no meaningful known layout.
679
675
ty:: Alias ( ..) => {
676
+ if ty. has_param ( ) {
677
+ return Err ( error ( cx, LayoutError :: TooGeneric ( ty) ) ) ;
678
+ }
680
679
// NOTE(eddyb) `layout_of` query should've normalized these away,
681
680
// if that was possible, so there's no reason to try again here.
682
681
return Err ( error ( cx, LayoutError :: Unknown ( ty) ) ) ;
@@ -686,7 +685,11 @@ fn layout_of_uncached<'tcx>(
686
685
bug ! ( "Layout::compute: unexpected type `{}`" , ty)
687
686
}
688
687
689
- ty:: Placeholder ( ..) | ty:: Param ( _) => {
688
+ ty:: Param ( _) => {
689
+ return Err ( error ( cx, LayoutError :: TooGeneric ( ty) ) ) ;
690
+ }
691
+
692
+ ty:: Placeholder ( ..) => {
690
693
return Err ( error ( cx, LayoutError :: Unknown ( ty) ) ) ;
691
694
}
692
695
} )
0 commit comments