Auto merge of #1323 - RalfJung:noref, r=RalfJung
avoid a bunch of as_ref/as_mut
This commit is contained in:
commit
c827d1fd9c
@ -115,7 +115,7 @@ fn list_targets() -> impl Iterator<Item = cargo_metadata::Target> {
|
|||||||
get_arg_flag_value("--manifest-path").map(|m| Path::new(&m).canonicalize().unwrap());
|
get_arg_flag_value("--manifest-path").map(|m| Path::new(&m).canonicalize().unwrap());
|
||||||
|
|
||||||
let mut cmd = cargo_metadata::MetadataCommand::new();
|
let mut cmd = cargo_metadata::MetadataCommand::new();
|
||||||
if let Some(manifest_path) = manifest_path.as_ref() {
|
if let Some(manifest_path) = &manifest_path {
|
||||||
cmd.manifest_path(manifest_path);
|
cmd.manifest_path(manifest_path);
|
||||||
}
|
}
|
||||||
let mut metadata = if let Ok(metadata) = cmd.exec() {
|
let mut metadata = if let Ok(metadata) = cmd.exec() {
|
||||||
@ -131,7 +131,7 @@ fn list_targets() -> impl Iterator<Item = cargo_metadata::Target> {
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|package| {
|
.position(|package| {
|
||||||
let package_manifest_path = Path::new(&package.manifest_path);
|
let package_manifest_path = Path::new(&package.manifest_path);
|
||||||
if let Some(manifest_path) = manifest_path.as_ref() {
|
if let Some(manifest_path) = &manifest_path {
|
||||||
package_manifest_path == manifest_path
|
package_manifest_path == manifest_path
|
||||||
} else {
|
} else {
|
||||||
let current_dir = current_dir.as_ref().expect("could not read current directory");
|
let current_dir = current_dir.as_ref().expect("could not read current directory");
|
||||||
@ -368,8 +368,8 @@ path = "lib.rs"
|
|||||||
command.env("XARGO_HOME", &dir);
|
command.env("XARGO_HOME", &dir);
|
||||||
command.env("XARGO_RUST_SRC", &rust_src);
|
command.env("XARGO_RUST_SRC", &rust_src);
|
||||||
// Handle target flag.
|
// Handle target flag.
|
||||||
if let Some(target) = target.as_ref() {
|
if let Some(target) = &target {
|
||||||
command.arg("--target").arg(&target);
|
command.arg("--target").arg(target);
|
||||||
}
|
}
|
||||||
// Finally run it!
|
// Finally run it!
|
||||||
if command.status().expect("failed to run xargo").success().not() {
|
if command.status().expect("failed to run xargo").success().not() {
|
||||||
@ -379,7 +379,7 @@ path = "lib.rs"
|
|||||||
// That should be it! But we need to figure out where xargo built stuff.
|
// That should be it! But we need to figure out where xargo built stuff.
|
||||||
// Unfortunately, it puts things into a different directory when the
|
// Unfortunately, it puts things into a different directory when the
|
||||||
// architecture matches the host.
|
// architecture matches the host.
|
||||||
let is_host = match target.as_ref() {
|
let is_host = match &target {
|
||||||
None => true,
|
None => true,
|
||||||
Some(target) => target == &rustc_version::version_meta().unwrap().host,
|
Some(target) => target == &rustc_version::version_meta().unwrap().host,
|
||||||
};
|
};
|
||||||
@ -404,12 +404,12 @@ fn main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some("miri") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
|
if let Some("miri") = std::env::args().nth(1).as_deref() {
|
||||||
// This arm is for when `cargo miri` is called. We call `cargo check` for each applicable target,
|
// This arm is for when `cargo miri` is called. We call `cargo check` for each applicable target,
|
||||||
// but with the `RUSTC` env var set to the `cargo-miri` binary so that we come back in the other branch,
|
// but with the `RUSTC` env var set to the `cargo-miri` binary so that we come back in the other branch,
|
||||||
// and dispatch the invocations to `rustc` and `miri`, respectively.
|
// and dispatch the invocations to `rustc` and `miri`, respectively.
|
||||||
in_cargo_miri();
|
in_cargo_miri();
|
||||||
} else if let Some("rustc") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
|
} else if let Some("rustc") = std::env::args().nth(1).as_deref() {
|
||||||
// This arm is executed when `cargo-miri` runs `cargo check` with the `RUSTC_WRAPPER` env var set to itself:
|
// This arm is executed when `cargo-miri` runs `cargo check` with the `RUSTC_WRAPPER` env var set to itself:
|
||||||
// dependencies get dispatched to `rustc`, the final test/binary to `miri`.
|
// dependencies get dispatched to `rustc`, the final test/binary to `miri`.
|
||||||
inside_cargo_rustc();
|
inside_cargo_rustc();
|
||||||
|
@ -429,7 +429,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
|
|||||||
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
|
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
|
||||||
let alloc = alloc.into_owned();
|
let alloc = alloc.into_owned();
|
||||||
let (stacks, base_tag) =
|
let (stacks, base_tag) =
|
||||||
if let Some(stacked_borrows) = memory_extra.stacked_borrows.as_ref() {
|
if let Some(stacked_borrows) = &memory_extra.stacked_borrows {
|
||||||
let (stacks, base_tag) =
|
let (stacks, base_tag) =
|
||||||
Stacks::new_allocation(id, alloc.size, Rc::clone(stacked_borrows), kind);
|
Stacks::new_allocation(id, alloc.size, Rc::clone(stacked_borrows), kind);
|
||||||
(Some(stacks), base_tag)
|
(Some(stacks), base_tag)
|
||||||
@ -440,7 +440,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
|
|||||||
let mut stacked_borrows = memory_extra.stacked_borrows.as_ref().map(|sb| sb.borrow_mut());
|
let mut stacked_borrows = memory_extra.stacked_borrows.as_ref().map(|sb| sb.borrow_mut());
|
||||||
let alloc: Allocation<Tag, Self::AllocExtra> = alloc.with_tags_and_extra(
|
let alloc: Allocation<Tag, Self::AllocExtra> = alloc.with_tags_and_extra(
|
||||||
|alloc| {
|
|alloc| {
|
||||||
if let Some(stacked_borrows) = stacked_borrows.as_mut() {
|
if let Some(stacked_borrows) = &mut stacked_borrows {
|
||||||
// Only globals may already contain pointers at this point
|
// Only globals may already contain pointers at this point
|
||||||
assert_eq!(kind, MiriMemoryKind::Global.into());
|
assert_eq!(kind, MiriMemoryKind::Global.into());
|
||||||
stacked_borrows.global_base_ptr(alloc)
|
stacked_borrows.global_base_ptr(alloc)
|
||||||
@ -455,7 +455,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn tag_global_base_pointer(memory_extra: &MemoryExtra, id: AllocId) -> Self::PointerTag {
|
fn tag_global_base_pointer(memory_extra: &MemoryExtra, id: AllocId) -> Self::PointerTag {
|
||||||
if let Some(stacked_borrows) = memory_extra.stacked_borrows.as_ref() {
|
if let Some(stacked_borrows) = &memory_extra.stacked_borrows {
|
||||||
stacked_borrows.borrow_mut().global_base_ptr(id)
|
stacked_borrows.borrow_mut().global_base_ptr(id)
|
||||||
} else {
|
} else {
|
||||||
Tag::Untagged
|
Tag::Untagged
|
||||||
@ -518,7 +518,7 @@ impl AllocationExtra<Tag> for AllocExtra {
|
|||||||
ptr: Pointer<Tag>,
|
ptr: Pointer<Tag>,
|
||||||
size: Size,
|
size: Size,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_ref() {
|
if let Some(stacked_borrows) = &alloc.extra.stacked_borrows {
|
||||||
stacked_borrows.memory_read(ptr, size)
|
stacked_borrows.memory_read(ptr, size)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -531,7 +531,7 @@ impl AllocationExtra<Tag> for AllocExtra {
|
|||||||
ptr: Pointer<Tag>,
|
ptr: Pointer<Tag>,
|
||||||
size: Size,
|
size: Size,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_mut() {
|
if let Some(stacked_borrows) = &mut alloc.extra.stacked_borrows {
|
||||||
stacked_borrows.memory_written(ptr, size)
|
stacked_borrows.memory_written(ptr, size)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -544,7 +544,7 @@ impl AllocationExtra<Tag> for AllocExtra {
|
|||||||
ptr: Pointer<Tag>,
|
ptr: Pointer<Tag>,
|
||||||
size: Size,
|
size: Size,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_mut() {
|
if let Some(stacked_borrows) = &mut alloc.extra.stacked_borrows {
|
||||||
stacked_borrows.memory_deallocated(ptr, size)
|
stacked_borrows.memory_deallocated(ptr, size)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -123,7 +123,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||||||
let this = self.eval_context_mut();
|
let this = self.eval_context_mut();
|
||||||
|
|
||||||
trace!("handle_stack_pop(extra = {:?}, unwinding = {})", extra, unwinding);
|
trace!("handle_stack_pop(extra = {:?}, unwinding = {})", extra, unwinding);
|
||||||
if let Some(stacked_borrows) = this.memory.extra.stacked_borrows.as_ref() {
|
if let Some(stacked_borrows) = &this.memory.extra.stacked_borrows {
|
||||||
stacked_borrows.borrow_mut().end_call(extra.call_id);
|
stacked_borrows.borrow_mut().end_call(extra.call_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user