Auto merge of #1323 - RalfJung:noref, r=RalfJung

avoid a bunch of as_ref/as_mut
This commit is contained in:
bors 2020-04-12 08:40:32 +00:00
commit c827d1fd9c
3 changed files with 14 additions and 14 deletions

View File

@ -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());
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() {
@ -131,7 +131,7 @@ fn list_targets() -> impl Iterator<Item = cargo_metadata::Target> {
.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");
@ -368,8 +368,8 @@ path = "lib.rs"
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() {
@ -379,7 +379,7 @@ path = "lib.rs"
// 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,
};
@ -404,12 +404,12 @@ fn main() {
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();

View File

@ -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 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)
@ -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 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)
@ -455,7 +455,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
#[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
@ -518,7 +518,7 @@ impl AllocationExtra<Tag> for AllocExtra {
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(())
@ -531,7 +531,7 @@ impl AllocationExtra<Tag> for AllocExtra {
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(())
@ -544,7 +544,7 @@ impl AllocationExtra<Tag> for AllocExtra {
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(())

View File

@ -123,7 +123,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
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);
}