Normalize type_const items even with feature generic_const_exprs
This commit is contained in:
parent
9f6cd6defb
commit
7510f747a8
4 changed files with 30 additions and 1 deletions
|
|
@ -433,7 +433,12 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, '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)]
|
||||
|
|
|
|||
11
tests/ui/const-generics/mgca/cyclic-type-const-151251.rs
Normal file
11
tests/ui/const-generics/mgca/cyclic-type-const-151251.rs
Normal file
|
|
@ -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() {}
|
||||
11
tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr
Normal file
11
tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr
Normal file
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue