File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
compiler/rustc_ty_utils/src Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 44use std:: ops:: ControlFlow ;
55
66use rustc_hir:: { def:: DefKind , def_id:: LocalDefId } ;
7- use rustc_middle:: ty:: TyCtxt ;
7+ use rustc_middle:: ty:: { self , TyCtxt } ;
88use rustc_span:: Span ;
99use rustc_type_ir:: visit:: TypeVisitable ;
1010
@@ -58,7 +58,16 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
5858 // Look at field types
5959 DefKind :: Struct | DefKind :: Union | DefKind :: Enum => {
6060 let span = tcx. def_ident_span ( item) . unwrap ( ) ;
61- visitor. visit ( span, tcx. type_of ( item) . instantiate_identity ( ) ) ;
61+ let ty = tcx. type_of ( item) . instantiate_identity ( ) ;
62+ visitor. visit ( span, ty) ;
63+ let ty:: Adt ( def, args) = ty. kind ( ) else {
64+ span_bug ! ( span, "invalid type for {kind:?}: {:#?}" , ty. kind( ) )
65+ } ;
66+ for field in def. all_fields ( ) {
67+ let span = tcx. def_ident_span ( field. did ) . unwrap ( ) ;
68+ let ty = field. ty ( tcx, args) ;
69+ visitor. visit ( span, ty) ;
70+ }
6271 for ( pred, span) in tcx. predicates_of ( item) . instantiate_identity ( tcx) {
6372 visitor. visit ( span, pred) ?;
6473 }
You can’t perform that action at this time.
0 commit comments