fn f(slice: &[u8]) -> u8 {
(*slice)[0]
}
fn f(_1: &[u8]) -> u8 {
debug slice => _1; // in scope 0 at src/main.rs:1:6: 1:11
let mut _0: u8; // return place in scope 0 at src/main.rs:1:23: 1:25
let _2: usize; // in scope 0 at src/main.rs:2:14: 2:15
let mut _3: usize; // in scope 0 at src/main.rs:2:5: 2:16
let mut _4: bool; // in scope 0 at src/main.rs:2:5: 2:16
bb0: {
StorageLive(_2); // bb0[0]: scope 0 at src/main.rs:2:14: 2:15
_2 = const 0usize; // bb0[1]: scope 0 at src/main.rs:2:14: 2:15
// ty::Const
// + ty: usize
// + val: Value(Scalar(0x0000000000000000))
// mir::Constant
// + span: src/main.rs:2:14: 2:15
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
_3 = Len((*_1)); // bb0[2]: scope 0 at src/main.rs:2:5: 2:16
_4 = Lt(_2, _3); // bb0[3]: scope 0 at src/main.rs:2:5: 2:16
assert(move _4, "index out of bounds: the len is move _3 but the index is _2") -> bb1; // bb0[4]: scope 0 at src/main.rs:2:5: 2:16
}
bb1: {
_0 = (*_1)[_2]; // bb1[0]: scope 0 at src/main.rs:2:5: 2:16
StorageDead(_2); // bb1[1]: scope 0 at src/main.rs:3:1: 3:2
return; // bb1[2]: scope 0 at src/main.rs:3:2: 3:2
}
}
Note how it says "index out of bounds: the len is move _3 but the index is _2". The formatting arguments are inlined into the message.
It should either mirror the format! string syntax, or at least use braces around the arguments so that they don't look like they're part of the string itself.
This issue has been assigned to @robojumper via this comment.
Note how it says
"index out of bounds: the len is move _3 but the index is _2". The formatting arguments are inlined into the message.It should either mirror the
format!string syntax, or at least use braces around the arguments so that they don't look like they're part of the string itself.This issue has been assigned to @robojumper via this comment.