Skip to content

Commit c654940

Browse files
authored
Merge pull request #648 from RalfJung/avoid-full-slice
avoid [..]
2 parents 8201866 + a9b03f9 commit c654940

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/bin/cargo-miri.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn setup(ask_user: bool) {
201201
// Let's see if it is already installed.
202202
if std::env::var("XARGO_RUST_SRC").is_err() {
203203
let sysroot = Command::new("rustc").args(&["--print", "sysroot"]).output().unwrap().stdout;
204-
let sysroot = std::str::from_utf8(&sysroot[..]).unwrap();
204+
let sysroot = std::str::from_utf8(&sysroot).unwrap();
205205
let src = Path::new(sysroot.trim_end_matches('\n')).join("lib").join("rustlib").join("src");
206206
if !src.exists() {
207207
if ask_user {
@@ -336,7 +336,7 @@ fn in_cargo_miri() {
336336
// So after the first `--`, we add `-Zcargo-miri-marker`.
337337
let mut cmd = Command::new("cargo");
338338
cmd.arg("rustc");
339-
match (subcommand, &kind[..]) {
339+
match (subcommand, kind.as_str()) {
340340
(MiriCommand::Run, "bin") => {
341341
// FIXME: we just run all the binaries here.
342342
// We should instead support `cargo miri --bin foo`.

src/fn_call.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
6060
let this = self.eval_context_mut();
6161
let attrs = this.tcx.get_attrs(def_id);
6262
let link_name = match attr::first_attr_value_str_by_name(&attrs, "link_name") {
63-
Some(name) => name.as_str(),
64-
None => this.tcx.item_name(def_id).as_str(),
63+
Some(name) => name.as_str().get(),
64+
None => this.tcx.item_name(def_id).as_str().get(),
6565
};
6666
// Strip linker suffixes (seen on 32-bit macOS).
6767
let link_name = link_name.trim_end_matches("$UNIX2003");
6868
let tcx = &{this.tcx.tcx};
6969

7070
// First: functions that could diverge.
71-
match &link_name[..] {
71+
match link_name {
7272
"__rust_start_panic" | "panic_impl" => {
7373
return err!(MachineError("the evaluated program panicked".to_string()));
7474
}
@@ -82,7 +82,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
8282
// Next: functions that assume a ret and dest.
8383
let dest = dest.expect("we already checked for a dest");
8484
let ret = ret.expect("dest is `Some` but ret is `None`");
85-
match &link_name[..] {
85+
match link_name {
8686
"malloc" => {
8787
let size = this.read_scalar(args[0])?.to_usize(this)?;
8888
if size == 0 {

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
175175
layout::FieldPlacement::Arbitrary { .. } => {
176176
// Gather the subplaces and sort them before visiting.
177177
let mut places = fields.collect::<EvalResult<'tcx, Vec<MPlaceTy<'tcx, Borrow>>>>()?;
178-
places[..].sort_by_key(|place| place.ptr.get_ptr_offset(self.ecx()));
178+
places.sort_by_key(|place| place.ptr.get_ptr_offset(self.ecx()));
179179
self.walk_aggregate(place, places.into_iter().map(Ok))
180180
}
181181
layout::FieldPlacement::Union { .. } => {

src/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
2727
// (as opposed to through a place), we have to remember to erase any tag
2828
// that might still hang around!
2929

30-
let intrinsic_name = &this.tcx.item_name(instance.def_id()).as_str()[..];
30+
let intrinsic_name = this.tcx.item_name(instance.def_id()).as_str().get();
3131
match intrinsic_name {
3232
"arith_offset" => {
3333
let offset = this.read_scalar(args[1])?.to_isize(this)?;

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,17 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
461461
) -> EvalResult<'tcx, Cow<'tcx, Allocation<Borrow, Self::AllocExtra>>> {
462462
let attrs = tcx.get_attrs(def_id);
463463
let link_name = match attr::first_attr_value_str_by_name(&attrs, "link_name") {
464-
Some(name) => name.as_str(),
465-
None => tcx.item_name(def_id).as_str(),
464+
Some(name) => name.as_str().get(),
465+
None => tcx.item_name(def_id).as_str().get(),
466466
};
467467

468-
let alloc = match &link_name[..] {
468+
let alloc = match link_name {
469469
"__cxa_thread_atexit_impl" => {
470470
// This should be all-zero, pointer-sized.
471471
let size = tcx.data_layout.pointer_size;
472472
let data = vec![0; size.bytes() as usize];
473473
let extra = AllocationExtra::memory_allocated(size, memory_extra);
474-
Allocation::from_bytes(&data[..], tcx.data_layout.pointer_align.abi, extra)
474+
Allocation::from_bytes(&data, tcx.data_layout.pointer_align.abi, extra)
475475
}
476476
_ => return err!(Unimplemented(
477477
format!("can't access foreign static: {}", link_name),

0 commit comments

Comments
 (0)