Fix unwrapping usize issue in HasMutInterior
This commit is contained in:
parent
eb0afe1845
commit
7e92607f5a
3 changed files with 28 additions and 2 deletions
|
@ -316,8 +316,9 @@ impl Qualif for HasMutInterior {
|
|||
} else if let ty::Array(_, len) = ty.sty {
|
||||
// FIXME(eddyb) the `cx.mode == Mode::Fn` condition
|
||||
// seems unnecessary, given that this is merely a ZST.
|
||||
if !(len.unwrap_usize(cx.tcx) == 0 && cx.mode == Mode::Fn) {
|
||||
return true;
|
||||
match len.assert_usize(cx.tcx) {
|
||||
Some(0) if cx.mode == Mode::Fn => {},
|
||||
_ => return true,
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
|
|
19
src/test/ui/const-generics/mut-ref-const-param-array.rs
Normal file
19
src/test/ui/const-generics/mut-ref-const-param-array.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
use std::ops::AddAssign;
|
||||
|
||||
fn inc<T: AddAssign + Clone, const N: usize>(v: &mut [T; N]) -> &mut [T; N] {
|
||||
for x in v.iter_mut() {
|
||||
*x += x.clone();
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut v = [1, 2, 3];
|
||||
inc(&mut v);
|
||||
assert_eq!(v, [2, 4, 6]);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/mut-ref-const-param-array.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
Loading…
Reference in a new issue