File tree 1 file changed +11
-2
lines changed
compiler/rustc_ty_utils/src
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 4
4
use std:: ops:: ControlFlow ;
5
5
6
6
use rustc_hir:: { def:: DefKind , def_id:: LocalDefId } ;
7
- use rustc_middle:: ty:: TyCtxt ;
7
+ use rustc_middle:: ty:: { self , TyCtxt } ;
8
8
use rustc_span:: Span ;
9
9
use rustc_type_ir:: visit:: TypeVisitable ;
10
10
@@ -58,7 +58,16 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
58
58
// Look at field types
59
59
DefKind :: Struct | DefKind :: Union | DefKind :: Enum => {
60
60
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
+ }
62
71
for ( pred, span) in tcx. predicates_of ( item) . instantiate_identity ( tcx) {
63
72
visitor. visit ( span, pred) ?;
64
73
}
You can’t perform that action at this time.
0 commit comments