提交 c0e853f2 编写于 作者: E Ellen 提交者: lcnr

remove lazy_normalization_consts

上级 fcc2badf
......@@ -545,9 +545,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows capturing variables in scope using format_args!
(active, format_args_capture, "1.46.0", Some(67984), None),
/// Lazily evaluate constants. This allows constants to depend on type parameters.
(incomplete, lazy_normalization_consts, "1.46.0", Some(72219), None),
/// Allows `if let` guard in match arms.
(active, if_let_guard, "1.47.0", Some(51114), None),
......
......@@ -307,7 +307,7 @@ pub enum Res<Id = hir::HirId> {
/// We do however allow `Self` in repeat expression even if it is generic to not break code
/// which already works on stable while causing the `const_evaluatable_unchecked` future compat lint.
///
/// FIXME(lazy_normalization_consts): Remove this bodge once that feature is stable.
/// FIXME(generic_const_exprs): Remove this bodge once that feature is stable.
SelfTy(
/// Optionally, the trait associated with this `Self` type.
Option<DefId>,
......
......@@ -678,7 +678,7 @@ fn push_outlives(
fn const_equate(&mut self, _a: &'tcx Const<'tcx>, _b: &'tcx Const<'tcx>) {
span_bug!(
self.cause.span(self.infcx.tcx),
"lazy_normalization_consts: unreachable `const_equate`"
"generic_const_exprs: unreachable `const_equate`"
);
}
......
......@@ -1421,7 +1421,7 @@ pub fn borrowck_mode(self) -> BorrowckMode {
pub fn lazy_normalization(self) -> bool {
let features = self.features();
// Note: We do not enable lazy normalization for `min_const_generics`.
features.const_generics || features.lazy_normalization_consts
features.const_generics || features.generic_const_exprs
}
#[inline]
......
#![crate_name = "foo"]
#![feature(lazy_normalization_consts)]
#![feature(const_generics, generic_const_exprs)]
#![allow(incomplete_features)]
// Checking if `Send` is implemented for `Hasher` requires us to evaluate a `ConstEquate` predicate,
......
pub const fn sof<T>() -> usize {
10
}
fn test<T>() {
let _: [u8; sof::<T>()];
//~^ ERROR generic parameters may not be used in const operations
}
fn main() {}
error: generic parameters may not be used in const operations
--> $DIR/feature-gate-lazy_normalization_consts.rs:6:23
|
LL | let _: [u8; sof::<T>()];
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(const_generics)]` and `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
// check-pass
#![feature(lazy_normalization_consts)]
#![allow(incomplete_features)]
pub struct ArpIPv4<'a> {
_s: &'a u8
}
impl<'a> ArpIPv4<'a> {
const LENGTH: usize = 20;
pub fn to_buffer() -> [u8; Self::LENGTH] {
unimplemented!()
}
}
fn main() {}
#![feature(lazy_normalization_consts)]
//~^ WARN the feature `lazy_normalization_consts` is incomplete
trait ArraySizeTrait {
const SIZE: usize = 0;
}
impl<T: ?Sized> ArraySizeTrait for T {
const SIZE: usize = 1;
}
struct SomeArray<T: ArraySizeTrait> {
array: [u8; T::SIZE],
//~^ ERROR constant expression depends on a generic parameter
phantom: std::marker::PhantomData<T>,
}
fn main() {}
warning: the feature `lazy_normalization_consts` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-57739.rs:1:12
|
LL | #![feature(lazy_normalization_consts)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information
error: constant expression depends on a generic parameter
--> $DIR/issue-57739.rs:12:12
|
LL | array: [u8; T::SIZE],
| ^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error; 1 warning emitted
// check-pass
#![feature(lazy_normalization_consts)]
#![allow(incomplete_features)]
pub struct X<P, Q>(P, Q);
pub struct L<T: ?Sized>(T);
impl<T: ?Sized> L<T> {
const S: usize = 1;
}
impl<T> X<T, [u8; L::<T>::S]> {}
//~^ WARN cannot use constants which depend on generic parameters
//~| WARN this was previously accepted by the compiler but is being phased out
fn main() {}
warning: cannot use constants which depend on generic parameters in types
--> $DIR/issue-73980.rs:12:9
|
LL | impl<T> X<T, [u8; L::<T>::S]> {}
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(const_evaluatable_unchecked)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #76200 <https://github.com/rust-lang/rust/issues/76200>
warning: 1 warning emitted
// build-fail
// compile-flags:-Zpolymorphize=on
#![crate_type = "lib"]
#![feature(lazy_normalization_consts, rustc_attrs)]
//~^ WARN the feature `lazy_normalization_consts` is incomplete
#![feature(generic_const_exprs, rustc_attrs)]
//~^ WARN the feature `generic_const_exprs` is incomplete
#[rustc_polymorphize_error]
fn test<T>() {
......
warning: the feature `lazy_normalization_consts` is incomplete and may not be safe to use and/or cause compiler crashes
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/promoted-function-2.rs:4:12
|
LL | #![feature(lazy_normalization_consts, rustc_attrs)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![feature(generic_const_exprs, rustc_attrs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
error: item has unused generic parameters
--> $DIR/promoted-function-2.rs:8:4
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册