Skip to content

Commit 066fe15

Browse files
committed
---
yaml --- r: 145663 b: refs/heads/try2 c: 2461b31 h: refs/heads/master i: 145661: 5a3fd48 145659: 7a4c7d3 145655: cfd36e1 145647: 0917a9a 145631: b5f965b 145599: ee7cfaa 145535: 0f64fd6 145407: 6080f3a v: v3
1 parent 43d1d5d commit 066fe15

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 88d34ff2498e3ca8020c79c63d4501f749831f2f
8+
refs/heads/try2: 2461b3102607c1cb4469c94bbe95d67db6c5e54d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use middle::const_eval::{compare_const_vals, lookup_const_by_id};
1313
use middle::const_eval::{eval_const_expr, const_val, const_bool, const_float};
14-
use middle::lint::non_uppercase_pattern_statics;
1514
use middle::pat_util::*;
1615
use middle::ty::*;
1716
use middle::ty;
@@ -135,29 +134,11 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
135134
}
136135
};
137136

138-
// Lint for constants that look like binding identifiers (#7526)
139-
let pat_matches_non_uppercase_static: &fn(@Pat) = |p| {
140-
let msg = "static constant in pattern should be all caps";
141-
match (&p.node, cx.tcx.def_map.find(&p.id)) {
142-
(&PatIdent(_, ref path, _), Some(&DefStatic(_, false))) => {
143-
// last identifier alone is right choice for this lint.
144-
let ident = path.segments.last().identifier;
145-
let s = cx.tcx.sess.str_of(ident);
146-
if s.iter().any(|c| c.is_lowercase()) {
147-
cx.tcx.sess.add_lint(non_uppercase_pattern_statics,
148-
p.id, path.span, msg.to_owned());
149-
}
150-
}
151-
_ => {}
152-
}
153-
};
154-
155137
do walk_pat(*pat) |p| {
156138
if pat_matches_nan(p) {
157139
cx.tcx.sess.span_warn(p.span, "unmatchable NaN in pattern, \
158140
use the is_nan method in a guard instead");
159141
}
160-
pat_matches_non_uppercase_static(p);
161142
true
162143
};
163144

branches/try2/src/librustc/middle/lint.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,22 @@ fn check_item_non_uppercase_statics(cx: &Context, it: &ast::item) {
11181118
}
11191119
}
11201120

1121+
fn check_pat_non_uppercase_statics(cx: &Context, p: &ast::Pat) {
1122+
// Lint for constants that look like binding identifiers (#7526)
1123+
match (&p.node, cx.tcx.def_map.find(&p.id)) {
1124+
(&ast::PatIdent(_, ref path, _), Some(&ast::DefStatic(_, false))) => {
1125+
// last identifier alone is right choice for this lint.
1126+
let ident = path.segments.last().identifier;
1127+
let s = cx.tcx.sess.str_of(ident);
1128+
if s.iter().any(|c| c.is_lowercase()) {
1129+
cx.span_lint(non_uppercase_pattern_statics, path.span,
1130+
"static constant in pattern should be all caps");
1131+
}
1132+
}
1133+
_ => {}
1134+
}
1135+
}
1136+
11211137
struct UnusedUnsafeLintVisitor { stopping_on_items: bool }
11221138

11231139
impl SubitemStoppableVisitor for UnusedUnsafeLintVisitor {
@@ -1524,6 +1540,11 @@ struct LintCheckVisitor;
15241540

15251541
impl Visitor<@mut Context> for LintCheckVisitor {
15261542

1543+
fn visit_pat(&mut self, p:@ast::Pat, cx: @mut Context) {
1544+
check_pat_non_uppercase_statics(cx, p);
1545+
visit::walk_pat(self, p, cx);
1546+
}
1547+
15271548
fn visit_item(&mut self, it:@ast::item, cx: @mut Context) {
15281549

15291550
do cx.with_lint_attrs(it.attrs) {

0 commit comments

Comments
 (0)