Fix const normalization for generic const items with trait assoc consts
This commit is contained in:
parent
ce0bf0b22b
commit
88f0ac34dc
2 changed files with 25 additions and 3 deletions
|
|
@ -376,10 +376,14 @@ impl<'a, 'tcx> QueryNormalizer<'a, 'tcx> {
|
|||
// `tcx.normalize_canonicalized_projection` may normalize to a type that
|
||||
// still has unevaluated consts, so keep normalizing here if that's the case.
|
||||
// Similarly, `tcx.normalize_canonicalized_free_alias` will only unwrap one layer
|
||||
// of type and we need to continue folding it to reveal the TAIT behind it.
|
||||
// of type/const and we need to continue folding it to reveal the TAIT behind it
|
||||
// or further normalize nested unevaluated consts.
|
||||
if res != term.to_term(tcx)
|
||||
&& (res.as_type().map_or(false, |t| t.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION))
|
||||
|| term.kind(tcx) == ty::AliasTermKind::FreeTy)
|
||||
&& (res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION)
|
||||
|| matches!(
|
||||
term.kind(tcx),
|
||||
ty::AliasTermKind::FreeTy | ty::AliasTermKind::FreeConst
|
||||
))
|
||||
{
|
||||
res.try_fold_with(self)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(generic_const_items, min_generic_const_args)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
type const CT<T: ?Sized>: usize = { <T as Trait>::N };
|
||||
|
||||
trait Trait {
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Trait for T {
|
||||
type const N:usize = 0;
|
||||
}
|
||||
|
||||
fn f(_x: [(); CT::<()>]) {}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue