diff options
| author | varkor <github@varkor.com> | 2019-05-30 23:44:28 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2019-05-31 01:19:59 +0100 |
| commit | 7e92607f5a622e6fd9b32492a70217762cb709c4 (patch) | |
| tree | 3e7742bf9b84072d98314745b2fa1e0778d59a2a /src/test/ui/const-generics | |
| parent | eb0afe1845c970f6dd16bc53fa7f3464ee76daff (diff) | |
| download | rust-7e92607f5a622e6fd9b32492a70217762cb709c4.tar.gz rust-7e92607f5a622e6fd9b32492a70217762cb709c4.zip | |
Fix unwrapping usize issue in HasMutInterior
Diffstat (limited to 'src/test/ui/const-generics')
| -rw-r--r-- | src/test/ui/const-generics/mut-ref-const-param-array.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/const-generics/mut-ref-const-param-array.stderr | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.rs b/src/test/ui/const-generics/mut-ref-const-param-array.rs new file mode 100644 index 00000000000..f930fb87963 --- /dev/null +++ b/src/test/ui/const-generics/mut-ref-const-param-array.rs @@ -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]); +} diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.stderr b/src/test/ui/const-generics/mut-ref-const-param-array.stderr new file mode 100644 index 00000000000..261d3578a11 --- /dev/null +++ b/src/test/ui/const-generics/mut-ref-const-param-array.stderr @@ -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)] + | ^^^^^^^^^^^^^^ + |
