Skip to content

Commit 6cbccc9

Browse files
committed
rustc: In lint, forbid structural records unless legacy_records is on
1 parent db6af50 commit 6cbccc9

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/librustc/middle/lint.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn get_lint_dict() -> lint_dict {
213213
(~"structural_records",
214214
@{lint: structural_records,
215215
desc: "use of any structural records",
216-
default: allow}),
216+
default: deny}),
217217

218218
(~"legacy modes",
219219
@{lint: legacy_modes,
@@ -663,21 +663,23 @@ fn check_item_deprecated_self(cx: ty::ctxt, item: @ast::item) {
663663
}
664664
665665
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
666-
let visit = item_stopping_visitor(
667-
visit::mk_simple_visitor(@visit::SimpleVisitor {
668-
visit_expr: |e: @ast::expr| {
669-
match e.node {
670-
ast::expr_rec(*) =>
671-
cx.sess.span_lint(
672-
structural_records, e.id, it.id,
673-
e.span,
674-
~"structural records are deprecated"),
675-
_ => ()
676-
}
677-
},
678-
.. *visit::default_simple_visitor()
679-
}));
680-
visit::visit_item(it, (), visit);
666+
if !cx.legacy_records {
667+
let visit = item_stopping_visitor(
668+
visit::mk_simple_visitor(@visit::SimpleVisitor {
669+
visit_expr: |e: @ast::expr| {
670+
match e.node {
671+
ast::expr_rec(*) =>
672+
cx.sess.span_lint(
673+
structural_records, e.id, it.id,
674+
e.span,
675+
~"structural records are deprecated"),
676+
_ => ()
677+
}
678+
},
679+
.. *visit::default_simple_visitor()
680+
}));
681+
visit::visit_item(it, (), visit);
682+
}
681683
}
682684

683685
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {

0 commit comments

Comments
 (0)