visit impl self ty + trait

This commit is contained in:
Bastian Kauschke 2020-09-22 11:55:03 +02:00
parent b8402d6a6e
commit 3f9015b22d
2 changed files with 37 additions and 0 deletions

View File

@ -2098,6 +2098,18 @@ fn const_evaluatable_predicates_of<'tcx>(
let node = tcx.hir().get(hir_id);
let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() };
if let hir::Node::Item(item) = node {
if let hir::ItemKind::Impl { ref of_trait, ref self_ty, .. } = item.kind {
if let Some(of_trait) = of_trait {
warn!("const_evaluatable_predicates_of({:?}): visit impl trait_ref", def_id);
collector.visit_trait_ref(of_trait);
}
warn!("const_evaluatable_predicates_of({:?}): visit_self_ty", def_id);
collector.visit_ty(self_ty);
}
}
if let Some(generics) = node.generics() {
warn!("const_evaluatable_predicates_of({:?}): visit_generics", def_id);
collector.visit_generics(generics);

View File

@ -0,0 +1,25 @@
// check-pass
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
use std::mem::size_of;
struct Foo<T, const N: usize>(T);
impl<T> Foo<T, { size_of::<T>() }> {
fn test() {
let _: [u8; std::mem::size_of::<T>()];
}
}
trait Bar<const N: usize> {
fn test_me();
}
impl<T> Bar<{ size_of::<T>() }> for Foo<T, 3> {
fn test_me() {
let _: [u8; std::mem::size_of::<T>()];
}
}
fn main() {}