diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 6ab7f6618633..d16990cb44c4 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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)) } diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr index 8a1ffe180623..2ebd063af18a 100644 --- a/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr +++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr @@ -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 diff --git a/src/test/ui/const-generics/issues/issue-61336-2.stderr b/src/test/ui/const-generics/issues/issue-61336-2.stderr index 3e169f6592f1..c779ac10671a 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.stderr @@ -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(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`. diff --git a/src/test/ui/const-generics/issues/issue-61336.stderr b/src/test/ui/const-generics/issues/issue-61336.stderr index d619226a854d..7d7cec2c1791 100644 --- a/src/test/ui/const-generics/issues/issue-61336.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.stderr @@ -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(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`. diff --git a/src/test/ui/const-generics/issues/issue-61747.stderr b/src/test/ui/const-generics/issues/issue-61747.stderr index 8f4c389bb04e..5eb468cc2726 100644 --- a/src/test/ui/const-generics/issues/issue-61747.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.stderr @@ -7,13 +7,11 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #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 diff --git a/src/test/ui/const-generics/issues/issue-61935.stderr b/src/test/ui/const-generics/issues/issue-61935.stderr index 0cc620738c71..ec0db0401b41 100644 --- a/src/test/ui/const-generics/issues/issue-61935.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.stderr @@ -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 + diff --git a/src/test/ui/const-generics/issues/issue-66205.stderr b/src/test/ui/const-generics/issues/issue-66205.stderr index 2bd013e8b41f..416b675b56d2 100644 --- a/src/test/ui/const-generics/issues/issue-66205.stderr +++ b/src/test/ui/const-generics/issues/issue-66205.stderr @@ -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 }>(); | ^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-67185-1.stderr b/src/test/ui/const-generics/issues/issue-67185-1.stderr index 257949340d0f..2472693afcba 100644 --- a/src/test/ui/const-generics/issues/issue-67185-1.stderr +++ b/src/test/ui/const-generics/issues/issue-67185-1.stderr @@ -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 + diff --git a/src/test/ui/const-generics/issues/issue-67185-2.stderr b/src/test/ui/const-generics/issues/issue-67185-2.stderr index c8620fc268ff..76d2622e9af0 100644 --- a/src/test/ui/const-generics/issues/issue-67185-2.stderr +++ b/src/test/ui/const-generics/issues/issue-67185-2.stderr @@ -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 | ::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 | [::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 | | [::Quaks; 2]: Bar, -LL | | ::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 | [::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 | | [::Quaks; 2]: Bar, -LL | | ::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 | ::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`. diff --git a/src/test/ui/const-generics/lazy-normalization/issue-71922.rs b/src/test/ui/const-generics/lazy-normalization/issue-71922.rs new file mode 100644 index 000000000000..60597b8be620 --- /dev/null +++ b/src/test/ui/const-generics/lazy-normalization/issue-71922.rs @@ -0,0 +1,20 @@ +// run-pass +#![feature(const_generics)] +#![feature(lazy_normalization_consts)] +#![allow(incomplete_features)] +trait Foo {} + +impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} + +trait FooImpl {} + +impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {} + +impl FooImpl<{ 0u8 != 0u8 }> for [(); N] {} + +fn foo(_: T) {} + +fn main() { + foo([]); + foo([()]); +} diff --git a/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.rs b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.rs new file mode 100644 index 000000000000..2c6fbfe65d6e --- /dev/null +++ b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.rs @@ -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 Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} +//~^ ERROR cycle detected + +trait FooImpl {} + +impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {} + +impl FooImpl<{ 0u8 != 0u8 }> for [(); N] {} + +fn foo(_: T) {} + +fn main() { + foo([]); + foo([()]); +} diff --git a/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr new file mode 100644 index 000000000000..8a97ec0c5fc8 --- /dev/null +++ b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr @@ -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 `::{{constant}}#0` + --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 + | +LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} + | ^^^^^^^^^^ + | +note: ...which requires const-evaluating + checking `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 + | +LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} + | ^^^^^^^^^^ +note: ...which requires const-evaluating `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 + | +LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} + | ^^^^^^^^^^ +note: ...which requires type-checking `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 + | +LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} + | ^^^^^^^^^^ +note: ...which requires processing `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 + | +LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} + | ^^^^^^^^^^ + = note: ...which again requires const-evaluating + checking `::{{constant}}#0`, completing the cycle +note: cycle used when processing `` + --> $DIR/lazy-normalization-feature-gate-hack.rs:6:1 + | +LL | impl 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`.