get_arg_flag_value("--manifest-path").map(|m| Path::new(&m).canonicalize().unwrap());
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);
}
let mut metadata = if let Ok(metadata) = cmd.exec() {
.iter()
.position(|package| {
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
} else {
let current_dir = current_dir.as_ref().expect("could not read current directory");
command.env("XARGO_HOME", &dir);
command.env("XARGO_RUST_SRC", &rust_src);
// Handle target flag.
- if let Some(target) = target.as_ref() {
- command.arg("--target").arg(&target);
+ if let Some(target) = &target {
+ command.arg("--target").arg(target);
}
// Finally run it!
if command.status().expect("failed to run xargo").success().not() {
// That should be it! But we need to figure out where xargo built stuff.
// Unfortunately, it puts things into a different directory when the
// architecture matches the host.
- let is_host = match target.as_ref() {
+ let is_host = match &target {
None => true,
Some(target) => target == &rustc_version::version_meta().unwrap().host,
};
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,
// 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.
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:
// dependencies get dispatched to `rustc`, the final test/binary to `miri`.
inside_cargo_rustc();
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
let alloc = alloc.into_owned();
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) =
Stacks::new_allocation(id, alloc.size, Rc::clone(stacked_borrows), kind);
(Some(stacks), base_tag)
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(
|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
assert_eq!(kind, MiriMemoryKind::Global.into());
stacked_borrows.global_base_ptr(alloc)
#[inline(always)]
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)
} else {
Tag::Untagged
ptr: Pointer<Tag>,
size: Size,
) -> 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)
} else {
Ok(())
ptr: Pointer<Tag>,
size: Size,
) -> 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)
} else {
Ok(())
ptr: Pointer<Tag>,
size: Size,
) -> 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)
} else {
Ok(())
let this = self.eval_context_mut();
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);
}