Skip to content

Commit 97791a5

Browse files
committed
avoid ref in matches
1 parent aad2c5a commit 97791a5

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/bin/cargo-miri.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn list_targets() -> impl Iterator<Item = cargo_metadata::Target> {
115115
get_arg_flag_value("--manifest-path").map(|m| Path::new(&m).canonicalize().unwrap());
116116

117117
let mut cmd = cargo_metadata::MetadataCommand::new();
118-
if let Some(ref manifest_path) = manifest_path {
118+
if let Some(manifest_path) = manifest_path.as_ref() {
119119
cmd.manifest_path(manifest_path);
120120
}
121121
let mut metadata = if let Ok(metadata) = cmd.exec() {
@@ -131,7 +131,7 @@ fn list_targets() -> impl Iterator<Item = cargo_metadata::Target> {
131131
.iter()
132132
.position(|package| {
133133
let package_manifest_path = Path::new(&package.manifest_path);
134-
if let Some(ref manifest_path) = manifest_path {
134+
if let Some(manifest_path) = manifest_path.as_ref() {
135135
package_manifest_path == manifest_path
136136
} else {
137137
let current_dir = current_dir.as_ref().expect("could not read current directory");
@@ -368,7 +368,7 @@ path = "lib.rs"
368368
command.env("XARGO_HOME", &dir);
369369
command.env("XARGO_RUST_SRC", &rust_src);
370370
// Handle target flag.
371-
if let Some(ref target) = target {
371+
if let Some(target) = target.as_ref() {
372372
command.arg("--target").arg(&target);
373373
}
374374
// Finally run it!
@@ -379,9 +379,9 @@ path = "lib.rs"
379379
// That should be it! But we need to figure out where xargo built stuff.
380380
// Unfortunately, it puts things into a different directory when the
381381
// architecture matches the host.
382-
let is_host = match target {
382+
let is_host = match target.as_ref() {
383383
None => true,
384-
Some(target) => target == rustc_version::version_meta().unwrap().host,
384+
Some(target) => target == &rustc_version::version_meta().unwrap().host,
385385
};
386386
let sysroot = if is_host { dir.join("HOST") } else { PathBuf::from(dir) };
387387
std::env::set_var("MIRI_SYSROOT", &sysroot); // pass the env var to the processes we spawn, which will turn it into "--sysroot" flags
@@ -583,6 +583,6 @@ fn inside_cargo_rustc() {
583583
if !exit.success() {
584584
std::process::exit(exit.code().unwrap_or(42));
585585
},
586-
Err(ref e) => panic!("error running {:?}:\n{:?}", command, e),
586+
Err(e) => panic!("error running {:?}:\n{:?}", command, e),
587587
}
588588
}

src/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub fn report_error<'tcx, 'mir>(
5151
) -> Option<i64> {
5252
use InterpError::*;
5353

54-
let (title, helps) = match e.kind {
55-
MachineStop(ref info) => {
54+
let (title, helps) = match &e.kind {
55+
MachineStop(info) => {
5656
let info = info.downcast_ref::<TerminationInfo>().expect("invalid MachineStop payload");
5757
use TerminationInfo::*;
5858
let title = match info {

src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl AllocationExtra<Tag> for AllocExtra {
518518
ptr: Pointer<Tag>,
519519
size: Size,
520520
) -> InterpResult<'tcx> {
521-
if let Some(ref stacked_borrows) = alloc.extra.stacked_borrows {
521+
if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_ref() {
522522
stacked_borrows.memory_read(ptr, size)
523523
} else {
524524
Ok(())
@@ -531,7 +531,7 @@ impl AllocationExtra<Tag> for AllocExtra {
531531
ptr: Pointer<Tag>,
532532
size: Size,
533533
) -> InterpResult<'tcx> {
534-
if let Some(ref mut stacked_borrows) = alloc.extra.stacked_borrows {
534+
if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_mut() {
535535
stacked_borrows.memory_written(ptr, size)
536536
} else {
537537
Ok(())
@@ -544,7 +544,7 @@ impl AllocationExtra<Tag> for AllocExtra {
544544
ptr: Pointer<Tag>,
545545
size: Size,
546546
) -> InterpResult<'tcx> {
547-
if let Some(ref mut stacked_borrows) = alloc.extra.stacked_borrows {
547+
if let Some(stacked_borrows) = alloc.extra.stacked_borrows.as_mut() {
548548
stacked_borrows.memory_deallocated(ptr, size)
549549
} else {
550550
Ok(())

src/mono_hash_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<K: Hash + Eq, V> AllocMap<K, V> for MonoHashMap<K, V> {
6464
self.0.borrow().iter().filter_map(move |(k, v)| f(k, &*v)).collect()
6565
}
6666

67-
/// The most interesting method: Providing a shared ref without
67+
/// The most interesting method: Providing a shared reference without
6868
/// holding the `RefCell` open, and inserting new data if the key
6969
/// is not used yet.
7070
/// `vacant` is called if the key is not found in the map;

src/shims/panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
191191
let this = self.eval_context_mut();
192192

193193
match msg {
194-
BoundsCheck { ref index, ref len } => {
194+
BoundsCheck { index, len } => {
195195
// Forward to `panic_bounds_check` lang item.
196196

197197
// First arg: index.

src/shims/tls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> TlsData<'tcx> {
8787

8888
pub fn store_tls(&mut self, key: TlsKey, new_data: Option<Scalar<Tag>>) -> InterpResult<'tcx> {
8989
match self.keys.get_mut(&key) {
90-
Some(&mut TlsEntry { ref mut data, .. }) => {
90+
Some(TlsEntry { data, .. }) => {
9191
trace!("TLS key {} stored: {:?}", key, new_data);
9292
*data = new_data;
9393
Ok(())
@@ -139,12 +139,12 @@ impl<'tcx> TlsData<'tcx> {
139139
Some(key) => Excluded(key),
140140
None => Unbounded,
141141
};
142-
for (&key, &mut TlsEntry { ref mut data, dtor }) in
142+
for (&key, TlsEntry { data, dtor }) in
143143
thread_local.range_mut((start, Unbounded))
144144
{
145145
if let Some(data_scalar) = *data {
146146
if let Some(dtor) = dtor {
147-
let ret = Some((dtor, data_scalar, key));
147+
let ret = Some((*dtor, data_scalar, key));
148148
*data = None;
149149
return ret;
150150
}

0 commit comments

Comments
 (0)