diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-09-22 11:55:03 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-09-24 09:04:26 +0200 |
| commit | 3f9015b22d774dd2af0c3c95dbfb0270d5e0bf7e (patch) | |
| tree | 13fc13260e5448b5fb0d16ddc1919c7e40792402 | |
| parent | b8402d6a6e6cadd3d877c952a2c5bbd694afbc2d (diff) | |
| download | rust-3f9015b22d774dd2af0c3c95dbfb0270d5e0bf7e.tar.gz rust-3f9015b22d774dd2af0c3c95dbfb0270d5e0bf7e.zip | |
visit impl self ty + trait
| -rw-r--r-- | compiler/rustc_typeck/src/collect.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs | 25 |
2 files changed, 37 insertions, 0 deletions
diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index d341e7eec41..a571bd58abc 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -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); diff --git a/src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs b/src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs new file mode 100644 index 00000000000..193a365f9b6 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs @@ -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() {} |
