File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
compiler/rustc_typeck/src
src/test/ui/const-generics/const_evaluatable_checked Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -2098,6 +2098,18 @@ fn const_evaluatable_predicates_of<'tcx>(
20982098 let node = tcx. hir ( ) . get ( hir_id) ;
20992099
21002100 let mut collector = ConstCollector { tcx, preds : FxIndexSet :: default ( ) } ;
2101+ if let hir:: Node :: Item ( item) = node {
2102+ if let hir:: ItemKind :: Impl { ref of_trait, ref self_ty, .. } = item. kind {
2103+ if let Some ( of_trait) = of_trait {
2104+ warn ! ( "const_evaluatable_predicates_of({:?}): visit impl trait_ref" , def_id) ;
2105+ collector. visit_trait_ref ( of_trait) ;
2106+ }
2107+
2108+ warn ! ( "const_evaluatable_predicates_of({:?}): visit_self_ty" , def_id) ;
2109+ collector. visit_ty ( self_ty) ;
2110+ }
2111+ }
2112+
21012113 if let Some ( generics) = node. generics ( ) {
21022114 warn ! ( "const_evaluatable_predicates_of({:?}): visit_generics" , def_id) ;
21032115 collector. visit_generics ( generics) ;
Original file line number Diff line number Diff line change 1+ // check-pass
2+ #![ feature( const_generics, const_evaluatable_checked) ]
3+ #![ allow( incomplete_features) ]
4+
5+ use std:: mem:: size_of;
6+
7+ struct Foo < T , const N : usize > ( T ) ;
8+
9+ impl < T > Foo < T , { size_of :: < T > ( ) } > {
10+ fn test ( ) {
11+ let _: [ u8 ; std:: mem:: size_of :: < T > ( ) ] ;
12+ }
13+ }
14+
15+ trait Bar < const N : usize > {
16+ fn test_me ( ) ;
17+ }
18+
19+ impl < T > Bar < { size_of :: < T > ( ) } > for Foo < T , 3 > {
20+ fn test_me ( ) {
21+ let _: [ u8 ; std:: mem:: size_of :: < T > ( ) ] ;
22+ }
23+ }
24+
25+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments