diff options
| author | Ben Lewis <benlewisj@gmail.com> | 2020-01-04 13:42:02 +1300 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-05-17 11:01:23 +0200 |
| commit | 3ef831069a7bb249f2ce5bfb8abeaac21a0e9183 (patch) | |
| tree | 518eb45423e71917e12d7fd1f34c3958f85ac5ca /src | |
| parent | 4cfdd2178e999960358e15b8c36e89c13b4f21c0 (diff) | |
| download | rust-3ef831069a7bb249f2ce5bfb8abeaac21a0e9183.tar.gz rust-3ef831069a7bb249f2ce5bfb8abeaac21a0e9183.zip | |
Add lazy normalization tests
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-61935.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-61935.stderr (renamed from src/test/ui/const-generics/issues/issue-61336-1.stderr) | 3 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67185-1.rs | 32 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67185-1.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67185-2.rs | 34 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67185-2.stderr | 61 | ||||
| -rw-r--r-- | src/test/ui/const-generics/lazy-normalization/issue-71986.rs | 8 |
7 files changed, 167 insertions, 3 deletions
diff --git a/src/test/ui/const-generics/issues/issue-61935.rs b/src/test/ui/const-generics/issues/issue-61935.rs new file mode 100644 index 00000000000..35fb435b812 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61935.rs @@ -0,0 +1,24 @@ +// check-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait Foo {} + +impl<const N: usize> Foo for [(); N] + where + Self:FooImpl<{N==0}> +{} + +trait FooImpl<const IS_ZERO: bool>{} + +impl FooImpl<true> for [(); 0] {} + +impl<const N:usize> FooImpl<false> for [();N] {} + +fn foo(_: impl Foo) {} + +fn main() { + foo([]); + foo([()]); +} diff --git a/src/test/ui/const-generics/issues/issue-61336-1.stderr b/src/test/ui/const-generics/issues/issue-61935.stderr index b2c69d57c40..5ada50c3449 100644 --- a/src/test/ui/const-generics/issues/issue-61336-1.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.stderr @@ -1,5 +1,4 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61336-1.rs:1:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ @@ -7,5 +6,3 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information -warning: 1 warning emitted - diff --git a/src/test/ui/const-generics/issues/issue-67185-1.rs b/src/test/ui/const-generics/issues/issue-67185-1.rs new file mode 100644 index 00000000000..89e0b7f62da --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-1.rs @@ -0,0 +1,32 @@ +// check-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait Baz { + type Quaks; +} +impl Baz for u8 { + type Quaks = [u16; 3]; +} + +trait Bar {} +impl Bar for [u16; 3] {} +impl Bar for [[u16; 3]; 2] {} + +trait Foo + where + [<u8 as Baz>::Quaks; 2]: Bar, + <u8 as Baz>::Quaks: Bar, +{ +} + +struct FooImpl; + +impl Foo for FooImpl {} + +fn f(_: impl Foo) {} + +fn main() { + f(FooImpl) +} diff --git a/src/test/ui/const-generics/issues/issue-67185-1.stderr b/src/test/ui/const-generics/issues/issue-67185-1.stderr new file mode 100644 index 00000000000..01c09763314 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-1.stderr @@ -0,0 +1,8 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-67185-1.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + diff --git a/src/test/ui/const-generics/issues/issue-67185-2.rs b/src/test/ui/const-generics/issues/issue-67185-2.rs new file mode 100644 index 00000000000..af797721324 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-2.rs @@ -0,0 +1,34 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait Baz { + type Quaks; +} +impl Baz for u8 { + type Quaks = [u16; 3]; +} + +trait Bar {} +impl Bar for [u16; 4] {} +impl Bar for [[u16; 3]; 3] {} + +trait Foo //~ ERROR mismatched types + where + [<u8 as Baz>::Quaks; 2]: Bar, + <u8 as Baz>::Quaks: Bar, +{ +} + +struct FooImpl; + +impl Foo for FooImpl {} +//~^ ERROR mismatched types +//~^^ ERROR mismatched types + +fn f(_: impl Foo) {} +//~^ ERROR mismatched types +//~^^ ERROR mismatched types + +fn main() { + f(FooImpl) +} diff --git a/src/test/ui/const-generics/issues/issue-67185-2.stderr b/src/test/ui/const-generics/issues/issue-67185-2.stderr new file mode 100644 index 00000000000..3a46d8fece8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-2.stderr @@ -0,0 +1,61 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-67185-2.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/issue-67185-2.rs:15:1 + | +LL | / trait Foo +LL | | where +LL | | [<u8 as Baz>::Quaks; 2]: Bar, +LL | | <u8 as Baz>::Quaks: Bar, +LL | | { +LL | | } + | |_^ expected `3usize`, found `4usize` + | + = note: expected type `3usize` + found type `4usize` + +error[E0308]: mismatched types + --> $DIR/issue-67185-2.rs:24:6 + | +LL | impl Foo for FooImpl {} + | ^^^ expected `3usize`, found `4usize` + | + = note: expected type `3usize` + found type `4usize` + +error[E0308]: mismatched types + --> $DIR/issue-67185-2.rs:24:6 + | +LL | impl Foo for FooImpl {} + | ^^^ expected `2usize`, found `3usize` + | + = note: expected type `2usize` + found type `3usize` + +error[E0308]: mismatched types + --> $DIR/issue-67185-2.rs:28:1 + | +LL | fn f(_: impl Foo) {} + | ^^^^^^^^^^^^^^^^^^^^ expected `2usize`, found `3usize` + | + = note: expected type `2usize` + found type `3usize` + +error[E0308]: mismatched types + --> $DIR/issue-67185-2.rs:28:1 + | +LL | fn f(_: impl Foo) {} + | ^^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `4usize` + | + = note: expected type `3usize` + found type `4usize` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/lazy-normalization/issue-71986.rs b/src/test/ui/const-generics/lazy-normalization/issue-71986.rs new file mode 100644 index 00000000000..a07bf2a1a54 --- /dev/null +++ b/src/test/ui/const-generics/lazy-normalization/issue-71986.rs @@ -0,0 +1,8 @@ +// check-pass +#![allow(incomplete_features)] +#![feature(const_generics, lazy_normalization_consts)] + +pub trait Foo<const B: bool> {} +pub fn bar<T: Foo<{ true }>>() {} + +fn main() {} |
