mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
visit impl self ty + trait
This commit is contained in:
parent
b8402d6a6e
commit
3f9015b22d
@ -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);
|
||||
|
@ -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() {}
|
Loading…
Reference in New Issue
Block a user