@@ -16,7 +16,7 @@ use rustc_index::vec::Idx;
1616use rustc_middle:: mir:: { self , AssertKind , SwitchTargets } ;
1717use rustc_middle:: ty:: layout:: { HasTyCtxt , LayoutOf , ValidityRequirement } ;
1818use rustc_middle:: ty:: print:: { with_no_trimmed_paths, with_no_visible_paths} ;
19- use rustc_middle:: ty:: { self , Instance , Ty , TypeVisitableExt } ;
19+ use rustc_middle:: ty:: { self , Instance , Ty } ;
2020use rustc_session:: config:: OptLevel ;
2121use rustc_span:: source_map:: Span ;
2222use rustc_span:: { sym, Symbol } ;
@@ -765,6 +765,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
765765 _ => None ,
766766 } ;
767767
768+ if let Some ( intrinsic @ ( sym:: copy_nonoverlapping | sym:: transmute) ) = intrinsic {
769+ bug ! ( "Intrinsic {intrinsic} should have been lowered before codegen" ) ;
770+ }
771+
768772 let extra_args = & args[ sig. inputs ( ) . skip_binder ( ) . len ( ) ..] ;
769773 let extra_args = bx. tcx ( ) . mk_type_list_from_iter ( extra_args. iter ( ) . map ( |op_arg| {
770774 let op_ty = op_arg. ty ( self . mir , bx. tcx ( ) ) ;
@@ -776,23 +780,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
776780 None => bx. fn_abi_of_fn_ptr ( sig, extra_args) ,
777781 } ;
778782
779- if intrinsic == Some ( sym:: transmute) {
780- return if let Some ( target) = target {
781- self . codegen_transmute ( bx, & args[ 0 ] , destination) ;
782- helper. funclet_br ( self , bx, target, mergeable_succ)
783- } else {
784- // If we are trying to transmute to an uninhabited type,
785- // it is likely there is no allotted destination. In fact,
786- // transmuting to an uninhabited type is UB, which means
787- // we can do what we like. Here, we declare that transmuting
788- // into an uninhabited type is impossible, so anything following
789- // it must be unreachable.
790- assert_eq ! ( fn_abi. ret. layout. abi, abi:: Abi :: Uninhabited ) ;
791- bx. unreachable ( ) ;
792- MergingSucc :: False
793- } ;
794- }
795-
796783 if let Some ( merging_succ) = self . codegen_panic_intrinsic (
797784 & helper,
798785 bx,
@@ -835,7 +822,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
835822
836823 match intrinsic {
837824 None | Some ( sym:: drop_in_place) => { }
838- Some ( sym:: copy_nonoverlapping) => unreachable ! ( ) ,
839825 Some ( intrinsic) => {
840826 let dest = match ret_dest {
841827 _ if fn_abi. ret . is_indirect ( ) => llargs[ 0 ] ,
@@ -1746,33 +1732,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
17461732 }
17471733 }
17481734
1749- fn codegen_transmute ( & mut self , bx : & mut Bx , src : & mir:: Operand < ' tcx > , dst : mir:: Place < ' tcx > ) {
1750- if let Some ( index) = dst. as_local ( ) {
1751- match self . locals [ index] {
1752- LocalRef :: Place ( place) => self . codegen_transmute_into ( bx, src, place) ,
1753- LocalRef :: UnsizedPlace ( _) => bug ! ( "transmute must not involve unsized locals" ) ,
1754- LocalRef :: Operand ( None ) => {
1755- let dst_layout = bx. layout_of ( self . monomorphized_place_ty ( dst. as_ref ( ) ) ) ;
1756- assert ! ( !dst_layout. ty. has_erasable_regions( ) ) ;
1757- let place = PlaceRef :: alloca ( bx, dst_layout) ;
1758- place. storage_live ( bx) ;
1759- self . codegen_transmute_into ( bx, src, place) ;
1760- let op = bx. load_operand ( place) ;
1761- place. storage_dead ( bx) ;
1762- self . locals [ index] = LocalRef :: Operand ( Some ( op) ) ;
1763- self . debug_introduce_local ( bx, index) ;
1764- }
1765- LocalRef :: Operand ( Some ( op) ) => {
1766- assert ! ( op. layout. is_zst( ) , "assigning to initialized SSAtemp" ) ;
1767- }
1768- }
1769- } else {
1770- let dst = self . codegen_place ( bx, dst. as_ref ( ) ) ;
1771- self . codegen_transmute_into ( bx, src, dst) ;
1772- }
1773- }
1774-
1775- fn codegen_transmute_into (
1735+ pub ( crate ) fn codegen_transmute_into (
17761736 & mut self ,
17771737 bx : & mut Bx ,
17781738 src : & mir:: Operand < ' tcx > ,
0 commit comments