1
Fork 0

Fix cases of conflicting two-phase borrows

This commit is contained in:
Matthew Jasper 2019-02-27 20:32:12 +00:00
parent 2d065712cf
commit 7eda723279
3 changed files with 7 additions and 6 deletions

View file

@ -266,7 +266,8 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst); OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst);
} }
PassMode::Direct(_) | PassMode::Indirect(_, None) | PassMode::Cast(_) => { PassMode::Direct(_) | PassMode::Indirect(_, None) | PassMode::Cast(_) => {
self.store(bx, next(), dst); let next_arg = next();
self.store(bx, next_arg, dst);
} }
} }
} }

View file

@ -164,7 +164,7 @@ impl MirPass for AddRetag {
if src_ty.is_region_ptr() { if src_ty.is_region_ptr() {
// The only `Misc` casts on references are those creating raw pointers. // The only `Misc` casts on references are those creating raw pointers.
assert!(dest_ty.is_unsafe_ptr()); assert!(dest_ty.is_unsafe_ptr());
(RetagKind::Raw, place) (RetagKind::Raw, place.clone())
} else { } else {
// Some other cast, no retag // Some other cast, no retag
continue continue
@ -182,7 +182,7 @@ impl MirPass for AddRetag {
_ => _ =>
RetagKind::Default, RetagKind::Default,
}; };
(kind, place) (kind, place.clone())
} }
// Do nothing for the rest // Do nothing for the rest
_ => continue, _ => continue,
@ -191,7 +191,7 @@ impl MirPass for AddRetag {
let source_info = block_data.statements[i].source_info; let source_info = block_data.statements[i].source_info;
block_data.statements.insert(i+1, Statement { block_data.statements.insert(i+1, Statement {
source_info, source_info,
kind: StatementKind::Retag(retag_kind, place.clone()), kind: StatementKind::Retag(retag_kind, place),
}); });
} }
} }

View file

@ -347,9 +347,9 @@ impl<'a, 'b> Context<'a, 'b> {
Named(name) => { Named(name) => {
match self.names.get(&name) { match self.names.get(&name) {
Some(idx) => { Some(&idx) => {
// Treat as positional arg. // Treat as positional arg.
self.verify_arg_type(Exact(*idx), ty) self.verify_arg_type(Exact(idx), ty)
} }
None => { None => {
let msg = format!("there is no argument named `{}`", name); let msg = format!("there is no argument named `{}`", name);