/// Allow negative trait implementations.
(active, negative_impls, "1.44.0", Some(68318), None),
- /// Lazily evaluate constants. Which allows constants to depend on type parameters.
- (active, lazy_normalization_consts, "1.44.0", Some(60471), None),
-
/// Allows the use of `#[target_feature]` on safe functions.
(active, target_feature_11, "1.45.0", Some(69098), None),
sym::raw_dylib,
sym::const_trait_impl,
sym::const_trait_bound_opt_out,
- sym::lazy_normalization_consts,
];
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
return self.unify_const_variable(!a_is_expected, vid, a);
}
- (ty::ConstKind::Unevaluated(..), _)
- if self.tcx.features().lazy_normalization_consts =>
- {
+ (ty::ConstKind::Unevaluated(..), _) if self.tcx.features().const_generics => {
relation.const_equate_obligation(a, b);
return Ok(b);
}
- (_, ty::ConstKind::Unevaluated(..))
- if self.tcx.features().lazy_normalization_consts =>
- {
+ (_, ty::ConstKind::Unevaluated(..)) if self.tcx.features().const_generics => {
relation.const_equate_obligation(a, b);
return Ok(a);
}
}
}
}
- ty::ConstKind::Unevaluated(..) if self.tcx().features().lazy_normalization_consts => {
- Ok(c)
- }
+ ty::ConstKind::Unevaluated(..) if self.tcx().features().const_generics => Ok(c),
_ => relate::super_relate_consts(self, c, c),
}
}
}
}
}
- ty::ConstKind::Unevaluated(..) if self.tcx().features().lazy_normalization_consts => {
- Ok(a)
- }
+ ty::ConstKind::Unevaluated(..) if self.tcx().features().const_generics => Ok(a),
_ => relate::super_relate_consts(self, a, a),
}
}
match relation.relate(&sz_a, &sz_b) {
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
// FIXME(lazy_normalization_consts) Implement improved diagnostics for mismatched array
- // length?
- Err(err) if relation.tcx().features().lazy_normalization_consts => Err(err),
+ // length?
+ Err(err) if relation.tcx().features().const_generics => Err(err),
Err(err) => {
// Check whether the lengths are both concrete/known values,
// but are unequal, for better diagnostics.
label_break_value,
lang,
lang_items,
- lazy_normalization_consts,
let_chains,
lhs,
lib,
}
fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
- if self.selcx.tcx().features().lazy_normalization_consts {
+ if self.selcx.tcx().features().const_generics {
constant
} else {
let constant = constant.super_fold_with(self);
// HACK(eddyb) this provides the correct generics when
// `feature(const_generics)` is enabled, so that const expressions
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
- if tcx.features().const_generics || tcx.features().lazy_normalization_consts {
+ if tcx.features().const_generics {
Some(parent_def_id.to_def_id())
} else {
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
+<<<<<<< HEAD
//~^ WARN the feature `const_generics` is incomplete
#![feature(lazy_normalization_consts)]
//~^ WARN the feature `lazy_normalization_consts` is incomplete
+=======
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+>>>>>>> merge lazy_normalization_consts into const_generics
#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
- --> $DIR/array-size-in-generic-struct-param.rs:3:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:7:38
+ --> $DIR/array-size-in-generic-struct-param.rs:5:38
|
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
| ^^^^^^^^^^^^
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:16:5
+ --> $DIR/array-size-in-generic-struct-param.rs:14: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; 2 warnings emitted
+error: aborting due to 2 previous errors; 1 warning emitted
LL | x = Const::<{ [4] }> {};
| ^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `4usize`
|
- = note: expected struct `Const<[3usize]>`
- found struct `Const<[4usize]>`
+ = note: expected type `[3usize]`
+ found type `[4usize]`
error: aborting due to previous error; 1 warning emitted
--> $DIR/fn-const-param-infer.rs:16:31
|
LL | let _: Checked<not_one> = Checked::<not_two>;
- | ---------------- ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}`
|
- = note: expected struct `Checked<{not_one as fn(usize) -> bool}>`
- found struct `Checked<{not_two as fn(usize) -> bool}>`
+ = note: expected type `{not_one as fn(usize) -> bool}`
+ found type `{not_two as fn(usize) -> bool}`
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:20:24
--> $DIR/fn-const-param-infer.rs:25:40
|
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
- | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}`
|
- = note: expected struct `Checked<{generic::<u32> as fn(usize) -> bool}>`
- found struct `Checked<{generic::<u16> as fn(usize) -> bool}>`
+ = note: expected type `{generic::<u32> as fn(usize) -> bool}`
+ found type `{generic::<u16> as fn(usize) -> bool}`
error: aborting due to 4 previous errors; 1 warning emitted
-//~^ WARN the feature `const_generics` is incomplete
#![feature(lazy_normalization_consts)]
//~^ WARN the feature `lazy_normalization_consts` is incomplete
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete
// build-pass
--- /dev/null
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+ --> $DIR/issue-61336-1.rs:1:12
+ |
+LL | #![feature(const_generics)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
-//~^ WARN the feature `const_generics` is incomplete
#![feature(lazy_normalization_consts)]
//~^ WARN the feature `lazy_normalization_consts` is incomplete
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
[x; { N }]
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
- --> $DIR/issue-61336-2.rs:3:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
- --> $DIR/issue-61336-2.rs:11:5
+ --> $DIR/issue-61336-2.rs:9:5
|
LL | [x; { N }]
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error; 2 warnings emitted
+error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
- --> $DIR/issue-61336.rs:3:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
- --> $DIR/issue-61336.rs:11:5
+ --> $DIR/issue-61336.rs:9:5
|
LL | [x; N]
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
| ^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error; 2 warnings emitted
+error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-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)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: 2 warnings emitted
+warning: 1 warning emitted
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
-#![feature(lazy_normalization_consts)]
-//~^ WARN the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
trait Foo {}
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
- --> $DIR/issue-61935.rs:5:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: 2 warnings emitted
+warning: 1 warning emitted
impl<const X: usize> ArrayHolder<X> {
pub const fn new() -> Self {
ArrayHolder([0; Self::SIZE])
- //~^ ERROR: mismatched types
- //~| ERROR constant expression depends on a generic parameter
+ //~^ ERROR constant expression depends on a generic parameter
}
}
-error[E0308]: mismatched types
- --> $DIR/issue-62504.rs:18:21
- |
-LL | ArrayHolder([0; Self::SIZE])
- | ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE`
- |
- = note: expected array `[u32; X]`
- found array `[u32; _]`
-
error: constant expression depends on a generic parameter
--> $DIR/issue-62504.rs:18:25
|
|
= note: this may fail depending on what value the parameter takes
-error: aborting due to 2 previous errors
+error: aborting due to previous error
-For more information about this error, try `rustc --explain E0308`.
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
-#![feature(lazy_normalization_consts)]
-//~^ WARN the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
trait Baz {
type Quaks;
|
= note: `#[warn(incomplete_features)]` on by default
-warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
- --> $DIR/issue-67185-1.rs:5:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: 2 warnings emitted
+warning: 1 warning emitted
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
-#![feature(lazy_normalization_consts)]
-//~^ WARN the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
trait Baz {
type Quaks;
|
= note: `#[warn(incomplete_features)]` on by default
-warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
- --> $DIR/issue-67185-2.rs:3:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:17:1
+ --> $DIR/issue-67185-2.rs:15:1
|
LL | / trait Foo
LL | |
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:17:1
+ --> $DIR/issue-67185-2.rs:15:1
|
LL | / trait Foo
LL | |
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:27:6
+ --> $DIR/issue-67185-2.rs:25:6
|
LL | trait Foo
| --- required by a bound in this
<[u16; 4] as Bar>
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:27:6
+ --> $DIR/issue-67185-2.rs:25:6
|
LL | trait Foo
| --- required by a bound in this
<[u16; 4] as Bar>
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:31:14
+ --> $DIR/issue-67185-2.rs:29:14
|
LL | trait Foo
| --- required by a bound in this
<[u16; 4] as Bar>
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:31:14
+ --> $DIR/issue-67185-2.rs:29:14
|
LL | trait Foo
| --- required by a bound in this
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
-error: aborting due to 6 previous errors; 2 warnings emitted
+error: aborting due to 6 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.
#![feature(const_generics)]
#![allow(incomplete_features)]
-trait Bar<O> {}
-impl<O> Bar<O> for [u8; O] {}
-//~^ ERROR expected value, found type parameter `O`
+trait Bar<T> {}
+impl<T> Bar<T> for [u8; T] {}
+//~^ ERROR expected value, found type parameter `T`
-struct Foo<const O: usize> {}
-impl<const O: usize> Foo<O>
+struct Foo<const T: usize> {}
+impl<const T: usize> Foo<T>
where
- [u8; O]: Bar<[(); O]>,
+ [u8; T]: Bar<[(); T]>,
{
fn foo() {}
}
// run-pass
#![feature(const_generics)]
-#![feature(lazy_normalization_consts)]
#![allow(incomplete_features)]
trait Foo {}
// check-pass
#![allow(incomplete_features)]
-#![feature(const_generics, lazy_normalization_consts)]
+#![feature(const_generics)]
pub trait Foo<const B: bool> {}
pub fn bar<T: Foo<{ true }>>() {}
+++ /dev/null
-// 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([()]);
-}
+++ /dev/null
-warning: the feature `const_generics` is incomplete and may cause the compiler to crash
- --> $DIR/lazy-normalization-feature-gate.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.rs:6:1: 6:72>::{{constant}}#0`
- --> $DIR/lazy-normalization-feature-gate.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.rs:6:1: 6:72>::{{constant}}#0`...
- --> $DIR/lazy-normalization-feature-gate.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.rs:6:1: 6:72>::{{constant}}#0`...
- --> $DIR/lazy-normalization-feature-gate.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.rs:6:1: 6:72>::{{constant}}#0`...
- --> $DIR/lazy-normalization-feature-gate.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.rs:6:1: 6:72>::{{constant}}#0`...
- --> $DIR/lazy-normalization-feature-gate.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.rs:6:1: 6:72>::{{constant}}#0`, completing the cycle
-note: cycle used when processing `<impl at $DIR/lazy-normalization-feature-gate.rs:6:1: 6:72>`
- --> $DIR/lazy-normalization-feature-gate.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`.
--> $DIR/raw-ptr-const-param.rs:7:40
|
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
- | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
|
- = note: expected struct `Const<{0xf as *const u32}>`
- found struct `Const<{0xa as *const u32}>`
+ = note: expected type `{0xf as *const u32}`
+ found type `{0xa as *const u32}`
error: aborting due to previous error; 1 warning emitted
--> $DIR/types-mismatch-const-args.rs:13:41
|
LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
- | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32`
|
- = note: expected struct `A<'_, _, 2u32, _>`
- found struct `A<'_, _, 4u32, _>`
+ = note: expected type `2u32`
+ found type `4u32`
error[E0308]: mismatched types
--> $DIR/types-mismatch-const-args.rs:15:41
| |
| expected due to this
|
- = note: expected struct `A<'a, u16, _, _>`
- found struct `A<'b, u32, _, _>`
+ = note: expected struct `A<'a, u16, {2u32}, {3u32}>`
+ found struct `A<'b, u32, {2u32}, {3u32}>`
error: aborting due to 2 previous errors; 1 warning emitted
LL | fn concrete_const() -> OneConst<{123}> {
| ^^^^^^^^^^^^^^^
|
-note: used non-generic constant `123usize` for generic parameter
+note: used non-generic constant `{123}` for generic parameter
--> $DIR/generic_nondefining_use.rs:10:21
|
LL | type OneConst<const X: usize> = impl Debug;