parent
0a852e0da0
commit
3a34c96086
@ -53,6 +53,7 @@ enum lint {
|
||||
deprecated_mode,
|
||||
deprecated_pattern,
|
||||
non_camel_case_types,
|
||||
structural_records,
|
||||
|
||||
managed_heap_memory,
|
||||
owned_heap_memory,
|
||||
@ -171,6 +172,11 @@ fn get_lint_dict() -> lint_dict {
|
||||
desc: ~"use of any (~ type or @ type) heap memory",
|
||||
default: allow}),
|
||||
|
||||
(~"structural_records",
|
||||
@{lint: structural_records,
|
||||
desc: ~"use of any structural records",
|
||||
default: allow}),
|
||||
|
||||
/* FIXME(#3266)--make liveness warnings lintable
|
||||
(~"unused_variable",
|
||||
@{lint: unused_variable,
|
||||
@ -380,6 +386,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
|
||||
check_item_path_statement(cx, i);
|
||||
check_item_non_camel_case_types(cx, i);
|
||||
check_item_heap(cx, i);
|
||||
check_item_structural_records(cx, i);
|
||||
}
|
||||
|
||||
// Take a visitor, and modify it so that it will not proceed past subitems.
|
||||
@ -413,6 +420,23 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
|
||||
visit::visit_item(it, (), visit);
|
||||
}
|
||||
|
||||
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
|
||||
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
|
||||
visit_expr: fn@(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) {
|
||||
|
||||
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
|
||||
|
4
src/test/run-pass/lint-structural-records.rs
Normal file
4
src/test/run-pass/lint-structural-records.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#[warn(structural_records)];
|
||||
fn main() {
|
||||
let _foo = {x:5};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user