Skip to content

Commit 15871a7

Browse files
committed
rustc: Check struct field types when heap memory lint checks are enabled
1 parent 91676f3 commit 15871a7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc/middle/lint.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,18 @@ fn check_item_heap(cx: ty::ctxt, it: @ast::item) {
786786
_ => ()
787787
}
788788
789+
// If it's a struct, we also have to check the fields' types
790+
match it.node {
791+
ast::item_struct(struct_def, _) => {
792+
for struct_def.fields.each |struct_field| {
793+
check_type(cx, struct_field.node.id, it.id,
794+
struct_field.span,
795+
ty::node_id_to_type(cx, struct_field.node.id));
796+
}
797+
}
798+
_ => ()
799+
}
800+
789801
let visit = item_stopping_visitor(
790802
visit::mk_simple_visitor(@visit::SimpleVisitor {
791803
visit_expr: |e: @ast::expr| {

0 commit comments

Comments
 (0)