diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-05-01 23:16:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-01 23:16:32 +0200 |
| commit | 14c3ee906b4e88cb80b027fb7fd32c2fb53944bd (patch) | |
| tree | b5aac15033d3da9e492cb982d480cc91289a76fa /src/test | |
| parent | 7f65393b9abf5e70d0b9a8080558f17c5625bd40 (diff) | |
| parent | a08bccb3c142fb98193eed202dbdde85386dd91a (diff) | |
| download | rust-14c3ee906b4e88cb80b027fb7fd32c2fb53944bd.tar.gz rust-14c3ee906b4e88cb80b027fb7fd32c2fb53944bd.zip | |
Rollup merge of #71018 - lcnr:custom-const-param, r=eddyb
handle ConstValue::ByRef in relate fixes #68615 r? @eddyb
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/const-generics/different_byref.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/const-generics/different_byref.stderr | 20 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-68615-adt.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-68615-array.rs | 11 |
4 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/different_byref.rs b/src/test/ui/const-generics/different_byref.rs new file mode 100644 index 00000000000..c52a5b8061d --- /dev/null +++ b/src/test/ui/const-generics/different_byref.rs @@ -0,0 +1,11 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +struct Const<const V: [usize; 1]> {} + +fn main() { + let mut x = Const::<{ [3] }> {}; + x = Const::<{ [4] }> {}; + //~^ ERROR mismatched types + +} diff --git a/src/test/ui/const-generics/different_byref.stderr b/src/test/ui/const-generics/different_byref.stderr new file mode 100644 index 00000000000..9ea2aace89a --- /dev/null +++ b/src/test/ui/const-generics/different_byref.stderr @@ -0,0 +1,20 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/different_byref.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/different_byref.rs:8:9 + | +LL | x = Const::<{ [4] }> {}; + | ^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `4usize` + | + = note: expected struct `Const<[3usize]>` + found struct `Const<[4usize]>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.rs b/src/test/ui/const-generics/issues/issue-68615-adt.rs new file mode 100644 index 00000000000..140bb28ec5a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-adt.rs @@ -0,0 +1,11 @@ +// check-pass +#![feature(const_generics)] +#![allow(incomplete_features)] + +struct Const<const V: [usize; 0]> {} +type MyConst = Const<{ [] }>; + +fn main() { + let _x = Const::<{ [] }> {}; + let _y = MyConst {}; +} diff --git a/src/test/ui/const-generics/issues/issue-68615-array.rs b/src/test/ui/const-generics/issues/issue-68615-array.rs new file mode 100644 index 00000000000..c384bc1e36d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-array.rs @@ -0,0 +1,11 @@ +// check-pass +#![feature(const_generics)] +#![allow(incomplete_features)] + +struct Foo<const V: [usize; 0] > {} + +type MyFoo = Foo<{ [] }>; + +fn main() { + let _ = Foo::<{ [] }> {}; +} |
