Skip to content

Commit 663d6b1

Browse files
committed
---
yaml --- r: 23753 b: refs/heads/master c: 3a34c96 h: refs/heads/master i: 23751: 499cf9c v: v3
1 parent 8bee1e0 commit 663d6b1

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0a852e0da0503b3abcc2dd0b0858f64e3f4dc6b0
2+
refs/heads/master: 3a34c96086e88466e350100af874f07b387a7620
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/middle/lint.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum lint {
5353
deprecated_mode,
5454
deprecated_pattern,
5555
non_camel_case_types,
56+
structural_records,
5657

5758
managed_heap_memory,
5859
owned_heap_memory,
@@ -171,6 +172,11 @@ fn get_lint_dict() -> lint_dict {
171172
desc: ~"use of any (~ type or @ type) heap memory",
172173
default: allow}),
173174

175+
(~"structural_records",
176+
@{lint: structural_records,
177+
desc: ~"use of any structural records",
178+
default: allow}),
179+
174180
/* FIXME(#3266)--make liveness warnings lintable
175181
(~"unused_variable",
176182
@{lint: unused_variable,
@@ -380,6 +386,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
380386
check_item_path_statement(cx, i);
381387
check_item_non_camel_case_types(cx, i);
382388
check_item_heap(cx, i);
389+
check_item_structural_records(cx, i);
383390
}
384391

385392
// 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) {
413420
visit::visit_item(it, (), visit);
414421
}
415422

423+
fn check_item_structural_records(cx: ty::ctxt, it: @ast::item) {
424+
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
425+
visit_expr: fn@(e: @ast::expr) {
426+
match e.node {
427+
ast::expr_rec(*) =>
428+
cx.sess.span_lint(
429+
structural_records, e.id, it.id,
430+
e.span,
431+
~"structural records are deprecated"),
432+
_ => ()
433+
}
434+
},
435+
.. *visit::default_simple_visitor()
436+
}));
437+
visit::visit_item(it, (), visit);
438+
}
439+
416440
fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
417441

418442
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[warn(structural_records)];
2+
fn main() {
3+
let _foo = {x:5};
4+
}

0 commit comments

Comments
 (0)