|
1 | 1 | //! See docs in `build/expr/mod.rs`. |
2 | 2 |
|
3 | 3 | use rustc_abi::FieldIdx; |
4 | | -use rustc_hir::lang_items::LangItem; |
5 | 4 | use rustc_index::{Idx, IndexVec}; |
6 | 5 | use rustc_middle::bug; |
7 | 6 | use rustc_middle::middle::region; |
@@ -121,65 +120,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { |
121 | 120 | } |
122 | 121 | block.and(Rvalue::UnaryOp(op, arg)) |
123 | 122 | } |
124 | | - ExprKind::Box { value } => { |
125 | | - let value_ty = this.thir[value].ty; |
126 | | - let tcx = this.tcx; |
127 | | - let source_info = this.source_info(expr_span); |
128 | | - |
129 | | - let size = tcx.require_lang_item(LangItem::SizeOf, expr_span); |
130 | | - let size = Operand::unevaluated_constant(tcx, size, &[value_ty.into()], expr_span); |
131 | | - |
132 | | - let align = tcx.require_lang_item(LangItem::AlignOf, expr_span); |
133 | | - let align = |
134 | | - Operand::unevaluated_constant(tcx, align, &[value_ty.into()], expr_span); |
135 | | - |
136 | | - // malloc some memory of suitable size and align: |
137 | | - let exchange_malloc = Operand::function_handle( |
138 | | - tcx, |
139 | | - tcx.require_lang_item(LangItem::ExchangeMalloc, expr_span), |
140 | | - [], |
141 | | - expr_span, |
142 | | - ); |
143 | | - let storage = this.temp(Ty::new_mut_ptr(tcx, tcx.types.u8), expr_span); |
144 | | - let success = this.cfg.start_new_block(); |
145 | | - this.cfg.terminate( |
146 | | - block, |
147 | | - source_info, |
148 | | - TerminatorKind::Call { |
149 | | - func: exchange_malloc, |
150 | | - args: [ |
151 | | - Spanned { node: size, span: DUMMY_SP }, |
152 | | - Spanned { node: align, span: DUMMY_SP }, |
153 | | - ] |
154 | | - .into(), |
155 | | - destination: storage, |
156 | | - target: Some(success), |
157 | | - unwind: UnwindAction::Continue, |
158 | | - call_source: CallSource::Misc, |
159 | | - fn_span: expr_span, |
160 | | - }, |
161 | | - ); |
162 | | - this.diverge_from(block); |
163 | | - block = success; |
164 | | - |
165 | | - let result = this.local_decls.push(LocalDecl::new(expr.ty, expr_span)); |
166 | | - this.cfg |
167 | | - .push(block, Statement::new(source_info, StatementKind::StorageLive(result))); |
168 | | - if let Some(scope) = scope.temp_lifetime { |
169 | | - // schedule a shallow free of that memory, lest we unwind: |
170 | | - this.schedule_drop_storage_and_value(expr_span, scope, result); |
171 | | - } |
172 | | - |
173 | | - // Transmute `*mut u8` to the box (thus far, uninitialized): |
174 | | - let box_ = Rvalue::ShallowInitBox(Operand::Move(storage), value_ty); |
175 | | - this.cfg.push_assign(block, source_info, Place::from(result), box_); |
176 | | - |
177 | | - // initialize the box contents: |
178 | | - block = this |
179 | | - .expr_into_dest(this.tcx.mk_place_deref(Place::from(result)), block, value) |
180 | | - .into_block(); |
181 | | - block.and(Rvalue::Use(Operand::Move(Place::from(result)))) |
182 | | - } |
183 | 123 | ExprKind::Cast { source } => { |
184 | 124 | let source_expr = &this.thir[source]; |
185 | 125 |
|
|
0 commit comments