Skip to content

Commit 5d84939

Browse files
committed
---
yaml --- r: 32415 b: refs/heads/dist-snap c: 3a34c96 h: refs/heads/master i: 32413: 8637012 32411: 3f59ddb 32407: 9452b89 32399: 6f8fa7d 32383: ebe5b0e v: v3
1 parent 5ad8de3 commit 5d84939

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 0a852e0da0503b3abcc2dd0b0858f64e3f4dc6b0
10+
refs/heads/dist-snap: 3a34c96086e88466e350100af874f07b387a7620
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/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)