Skip to content

Commit db03b58

Browse files
committed
remove move_val_init leftovers
1 parent 1862135 commit db03b58

File tree

10 files changed

+36
-398
lines changed

10 files changed

+36
-398
lines changed

Diff for: compiler/rustc_mir/src/transform/check_unsafety.rs

-8
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,13 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
223223
// Check for raw pointer `Deref`.
224224
for (base, proj) in place.iter_projections() {
225225
if proj == ProjectionElem::Deref {
226-
let source_info = self.source_info; // Backup source_info so we can restore it later.
227-
if base.projection.is_empty() && decl.internal {
228-
// Internal locals are used in the `move_val_init` desugaring.
229-
// We want to check unsafety against the source info of the
230-
// desugaring, rather than the source info of the RHS.
231-
self.source_info = self.body.local_decls[place.local].source_info;
232-
}
233226
let base_ty = base.ty(self.body, self.tcx).ty;
234227
if base_ty.is_unsafe_ptr() {
235228
self.require_unsafe(
236229
UnsafetyViolationKind::GeneralAndConstFn,
237230
UnsafetyViolationDetails::DerefOfRawPointer,
238231
)
239232
}
240-
self.source_info = source_info; // Restore backed-up source_info.
241233
}
242234
}
243235

Diff for: compiler/rustc_mir_build/src/build/expr/into.rs

+34-74
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
1010
use rustc_hir as hir;
1111
use rustc_middle::middle::region;
1212
use rustc_middle::mir::*;
13-
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
14-
use rustc_span::symbol::sym;
15-
use rustc_target::spec::abi::Abi;
13+
use rustc_middle::ty::{CanonicalUserTypeAnnotation};
1614

1715
use std::slice;
1816

@@ -185,79 +183,41 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
185183
},
186184
)
187185
}
188-
ExprKind::Call { ty, fun, args, from_hir_call, fn_span } => {
189-
let intrinsic = match *ty.kind() {
190-
ty::FnDef(def_id, _) => {
191-
let f = ty.fn_sig(this.hir.tcx());
192-
if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic {
193-
Some(this.hir.tcx().item_name(def_id))
194-
} else {
195-
None
196-
}
197-
}
198-
_ => None,
199-
};
186+
ExprKind::Call { ty: _, fun, args, from_hir_call, fn_span } => {
200187
let fun = unpack!(block = this.as_local_operand(block, fun));
201-
if let Some(sym::move_val_init) = intrinsic {
202-
// `move_val_init` has "magic" semantics - the second argument is
203-
// always evaluated "directly" into the first one.
204-
205-
let mut args = args.into_iter();
206-
let ptr = args.next().expect("0 arguments to `move_val_init`");
207-
let val = args.next().expect("1 argument to `move_val_init`");
208-
assert!(args.next().is_none(), ">2 arguments to `move_val_init`");
209-
210-
let ptr = this.hir.mirror(ptr);
211-
let ptr_ty = ptr.ty;
212-
// Create an *internal* temp for the pointer, so that unsafety
213-
// checking won't complain about the raw pointer assignment.
214-
let ptr_temp = this
215-
.local_decls
216-
.push(LocalDecl::with_source_info(ptr_ty, source_info).internal());
217-
let ptr_temp = Place::from(ptr_temp);
218-
// No need for a scope, ptr_temp doesn't need drop
219-
let block = unpack!(this.into(ptr_temp, None, block, ptr));
220-
// Maybe we should provide a scope here so that
221-
// `move_val_init` wouldn't leak on panic even with an
222-
// arbitrary `val` expression, but `schedule_drop`,
223-
// borrowck and drop elaboration all prevent us from
224-
// dropping `ptr_temp.deref()`.
225-
this.into(this.hir.tcx().mk_place_deref(ptr_temp), None, block, val)
226-
} else {
227-
let args: Vec<_> = args
228-
.into_iter()
229-
.map(|arg| unpack!(block = this.as_local_call_operand(block, arg)))
230-
.collect();
231-
232-
let success = this.cfg.start_new_block();
233-
234-
this.record_operands_moved(&args);
235-
236-
debug!("into_expr: fn_span={:?}", fn_span);
237-
238-
this.cfg.terminate(
239-
block,
240-
source_info,
241-
TerminatorKind::Call {
242-
func: fun,
243-
args,
244-
cleanup: None,
245-
// FIXME(varkor): replace this with an uninhabitedness-based check.
246-
// This requires getting access to the current module to call
247-
// `tcx.is_ty_uninhabited_from`, which is currently tricky to do.
248-
destination: if expr.ty.is_never() {
249-
None
250-
} else {
251-
Some((destination, success))
252-
},
253-
from_hir_call,
254-
fn_span,
188+
let args: Vec<_> = args
189+
.into_iter()
190+
.map(|arg| unpack!(block = this.as_local_call_operand(block, arg)))
191+
.collect();
192+
193+
let success = this.cfg.start_new_block();
194+
195+
this.record_operands_moved(&args);
196+
197+
debug!("into_expr: fn_span={:?}", fn_span);
198+
199+
this.cfg.terminate(
200+
block,
201+
source_info,
202+
TerminatorKind::Call {
203+
func: fun,
204+
args,
205+
cleanup: None,
206+
// FIXME(varkor): replace this with an uninhabitedness-based check.
207+
// This requires getting access to the current module to call
208+
// `tcx.is_ty_uninhabited_from`, which is currently tricky to do.
209+
destination: if expr.ty.is_never() {
210+
None
211+
} else {
212+
Some((destination, success))
255213
},
256-
);
257-
this.diverge_from(block);
258-
schedule_drop(this);
259-
success.unit()
260-
}
214+
from_hir_call,
215+
fn_span,
216+
},
217+
);
218+
this.diverge_from(block);
219+
schedule_drop(this);
220+
success.unit()
261221
}
262222
ExprKind::Use { source } => this.into(destination, scope, block, source),
263223
ExprKind::Borrow { arg, borrow_kind } => {

Diff for: compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ symbols! {
713713
more_struct_aliases,
714714
movbe_target_feature,
715715
move_ref_pattern,
716-
move_val_init,
717716
mul,
718717
mul_assign,
719718
mul_with_overflow,

Diff for: compiler/rustc_typeck/src/check/intrinsic.rs

-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
159159
}
160160
sym::forget => (1, vec![param(0)], tcx.mk_unit()),
161161
sym::transmute => (2, vec![param(0)], param(1)),
162-
sym::move_val_init => (1, vec![tcx.mk_mut_ptr(param(0)), param(0)], tcx.mk_unit()),
163162
sym::prefetch_read_data
164163
| sym::prefetch_write_data
165164
| sym::prefetch_read_instruction

Diff for: src/test/codegen/intrinsics/move-val-init.rs

-19
This file was deleted.

Diff for: src/test/ui/intrinsics/intrinsic-move-val-cleanups.rs

-191
This file was deleted.

0 commit comments

Comments
 (0)