File tree Expand file tree Collapse file tree
compiler/rustc_middle/src/ty Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,9 +99,10 @@ pub(super) fn vtable_allocation_provider<'tcx>(
9999 // This confirms that the layout computation for &dyn Trait has an accurate sizing.
100100 assert ! ( vtable_entries. len( ) >= vtable_min_entries( tcx, poly_trait_ref) ) ;
101101
102- let layout = tcx
103- . layout_of ( ty:: TypingEnv :: fully_monomorphized ( ) . as_query_input ( ty) )
104- . expect ( "failed to build vtable representation" ) ;
102+ let layout = match tcx. layout_of ( ty:: TypingEnv :: fully_monomorphized ( ) . as_query_input ( ty) ) {
103+ Ok ( layout) => layout,
104+ Err ( e) => tcx. dcx ( ) . emit_fatal ( e. into_diagnostic ( ) ) ,
105+ } ;
105106 assert ! ( layout. is_sized( ) , "can't create a vtable for an unsized type" ) ;
106107 let size = layout. size . bytes ( ) ;
107108 let align = layout. align . bytes ( ) ;
Original file line number Diff line number Diff line change 1+ //@ compile-flags: --crate-type lib --emit=mir
2+ pub trait Trait { }
3+ impl < T > Trait for T { }
4+
5+ //~? ERROR: values of the type `[u8; usize::MAX]` are too big for the target architecture
6+ pub fn foo ( x : & [ u8 ; usize:: MAX ] ) -> & dyn Trait {
7+ x as & dyn Trait
8+ }
Original file line number Diff line number Diff line change 1+ error: values of the type `[u8; usize::MAX]` are too big for the target architecture
2+
3+ error: aborting due to 1 previous error
4+
You can’t perform that action at this time.
0 commit comments