mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 22:18:23 +03:00
rustc: In lint, forbid structural records unless legacy_records is on
This commit is contained in:
+18
-16
@@ -213,7 +213,7 @@ fn get_lint_dict() -> lint_dict {
|
||||
(~"structural_records",
|
||||
@{lint: structural_records,
|
||||
desc: "use of any structural records",
|
||||
default: allow}),
|
||||
default: deny}),
|
||||
|
||||
(~"legacy modes",
|
||||
@{lint: legacy_modes,
|
||||
@@ -663,21 +663,23 @@ fn maybe_warn(cx: ty::ctxt,
|
||||
}
|
||||
|
||||
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
|
||||
let visit = item_stopping_visitor(
|
||||
visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
visit_expr: |e: @ast::expr| {
|
||||
match e.node {
|
||||
ast::expr_rec(*) =>
|
||||
cx.sess.span_lint(
|
||||
structural_records, e.id, it.id,
|
||||
e.span,
|
||||
~"structural records are deprecated"),
|
||||
_ => ()
|
||||
}
|
||||
},
|
||||
.. *visit::default_simple_visitor()
|
||||
}));
|
||||
visit::visit_item(it, (), visit);
|
||||
if !cx.legacy_records {
|
||||
let visit = item_stopping_visitor(
|
||||
visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
visit_expr: |e: @ast::expr| {
|
||||
match e.node {
|
||||
ast::expr_rec(*) =>
|
||||
cx.sess.span_lint(
|
||||
structural_records, e.id, it.id,
|
||||
e.span,
|
||||
~"structural records are deprecated"),
|
||||
_ => ()
|
||||
}
|
||||
},
|
||||
.. *visit::default_simple_visitor()
|
||||
}));
|
||||
visit::visit_item(it, (), visit);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
||||
|
||||
Reference in New Issue
Block a user