mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Normalize type_const items even with feature generic_const_exprs
This commit is contained in:
@@ -433,7 +433,12 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
let tcx = self.selcx.tcx();
|
||||
if tcx.features().generic_const_exprs() || !needs_normalization(self.selcx.infcx, &ct) {
|
||||
|
||||
if tcx.features().generic_const_exprs()
|
||||
// Normalize type_const items even with feature `generic_const_exprs`.
|
||||
&& !matches!(ct.kind(), ty::ConstKind::Unevaluated(uv) if tcx.is_type_const(uv.def))
|
||||
|| !needs_normalization(self.selcx.infcx, &ct)
|
||||
{
|
||||
return ct;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//@ known-bug: #138089
|
||||
//@ needs-rustc-debug-assertions
|
||||
|
||||
#![feature(generic_const_exprs)]
|
||||
#![feature(min_generic_const_args)]
|
||||
#![feature(inherent_associated_types)]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//@ needs-rustc-debug-assertions
|
||||
|
||||
#![feature(min_generic_const_args)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
#[type_const]
|
||||
const A: u8 = A;
|
||||
//~^ ERROR overflow normalizing the unevaluated constant `A`
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error[E0275]: overflow normalizing the unevaluated constant `A`
|
||||
--> $DIR/cyclic-type-const-151251.rs:8:1
|
||||
|
|
||||
LL | const A: u8 = A;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0275`.
|
||||
Reference in New Issue
Block a user