update tests and add relevant feature gate test

This commit is contained in:
Bastian Kauschke 2020-05-05 22:47:54 +02:00
parent e1a8d322d0
commit afd7ea88fb
12 changed files with 124 additions and 33 deletions

View file

@ -1164,7 +1164,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
let parent_id = tcx.hir().get_parent_item(hir_id);
Some(tcx.hir().local_def_id(parent_id).to_def_id())
}
// FIXME(#43408) always enable this once we use `lazy_normalization` is
// FIXME(#43408) always enable this once `lazy_normalization` is
// stable enough and does not need a feature gate anymore.
Node::AnonConst(_) => {
let parent_id = tcx.hir().get_parent_item(hir_id);
@ -1193,7 +1193,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
}
}
}
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => {
Some(tcx.closure_base_def_id(def_id))
}

View file

@ -29,5 +29,5 @@ LL | arr: [u8; CFG.arr_size],
|
= note: this may fail depending on what value the parameter takes
error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors; 2 warnings emitted

View file

@ -14,7 +14,7 @@ LL | #![feature(lazy_normalization_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/issue-61336-2.rs:9:5
--> $DIR/issue-61336-2.rs:11:5
|
LL | [x; { N }]
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@ -25,6 +25,6 @@ help: consider restricting type parameter `T`
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error; 2 warnings emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -14,7 +14,7 @@ LL | #![feature(lazy_normalization_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
--> $DIR/issue-61336.rs:9:5
--> $DIR/issue-61336.rs:11:5
|
LL | [x; N]
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@ -25,6 +25,6 @@ help: consider restricting type parameter `T`
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error; 2 warnings emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -7,13 +7,11 @@ 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
<<<<<<< HEAD
warning: 1 warning emitted
=======
warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
--> $DIR/issue-61747.rs:5:12
|
LL | #![feature(lazy_normalization_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>>> Added `lazy_normalization_consts` feature, and removed the -Z flag.
warning: 2 warnings emitted

View file

@ -12,3 +12,5 @@ warning: the feature `lazy_normalization_consts` is incomplete and may cause the
LL | #![feature(lazy_normalization_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 2 warnings emitted

View file

@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-66205.rs:5:12
--> $DIR/issue-66205.rs:6:12
|
LL | fact::<{ N - 1 }>();
| ^^^^^^^^^

View file

@ -12,3 +12,5 @@ warning: the feature `lazy_normalization_consts` is incomplete and may cause the
LL | #![feature(lazy_normalization_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 2 warnings emitted

View file

@ -51,6 +51,12 @@ LL | | }
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:27:6
|
LL | trait Foo
| --- required by a bound in this
...
LL | <u8 as Baz>::Quaks: Bar,
| --- required by this bound in `Foo`
...
LL | impl Foo for FooImpl {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
|
@ -61,6 +67,12 @@ LL | impl Foo for FooImpl {}
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:27:6
|
LL | trait Foo
| --- required by a bound in this
...
LL | [<u8 as Baz>::Quaks; 2]: Bar,
| --- required by this bound in `Foo`
...
LL | impl Foo for FooImpl {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
@ -71,17 +83,14 @@ LL | impl Foo for FooImpl {}
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:31:14
|
LL | / trait Foo
LL | |
LL | | where
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
LL | | <u8 as Baz>::Quaks: Bar,
LL | | {
LL | | }
| |_- required by `Foo`
LL | trait Foo
| --- required by a bound in this
...
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
LL | [<u8 as Baz>::Quaks; 2]: Bar,
| --- required by this bound in `Foo`
...
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
@ -90,22 +99,19 @@ LL | fn f(_: impl Foo) {}
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:31:14
|
LL | / trait Foo
LL | |
LL | | where
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
LL | | <u8 as Baz>::Quaks: Bar,
LL | | {
LL | | }
| |_- required by `Foo`
LL | trait Foo
| --- required by a bound in this
...
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
LL | <u8 as Baz>::Quaks: Bar,
| --- required by this bound in `Foo`
...
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
error: aborting due to 6 previous errors
error: aborting due to 6 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,20 @@
// run-pass
#![feature(const_generics)]
#![feature(lazy_normalization_consts)]
#![allow(incomplete_features)]
trait Foo {}
impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
trait FooImpl<const IS_ZERO: bool> {}
impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {}
impl<const N: usize> FooImpl<{ 0u8 != 0u8 }> for [(); N] {}
fn foo<T: Foo>(_: T) {}
fn main() {
foo([]);
foo([()]);
}

View file

@ -0,0 +1,20 @@
// gate-test-lazy_normalization_consts
#![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 }> {}
//~^ ERROR cycle detected
trait FooImpl<const IS_ZERO: bool> {}
impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {}
impl<const N: usize> FooImpl<{ 0u8 != 0u8 }> for [(); N] {}
fn foo<T: Foo>(_: T) {}
fn main() {
foo([]);
foo([()]);
}

View file

@ -0,0 +1,44 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/lazy-normalization-feature-gate-hack.rs:2:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
error[E0391]: cycle detected when const-evaluating + checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`
--> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
|
LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
| ^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
--> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
|
LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
| ^^^^^^^^^^
note: ...which requires const-evaluating `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
--> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
|
LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
| ^^^^^^^^^^
note: ...which requires type-checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
--> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
|
LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
| ^^^^^^^^^^
note: ...which requires processing `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
--> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
|
LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
| ^^^^^^^^^^
= note: ...which again requires const-evaluating + checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`, completing the cycle
note: cycle used when processing `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>`
--> $DIR/lazy-normalization-feature-gate-hack.rs:6:1
|
LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0391`.