Skip to content

Commit 0b3927b

Browse files
committed
---
yaml --- r: 83621 b: refs/heads/try c: 2461b31 h: refs/heads/master i: 83619: 83b233d v: v3
1 parent 30c0cc0 commit 0b3927b

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
5-
refs/heads/try: 88d34ff2498e3ca8020c79c63d4501f749831f2f
5+
refs/heads/try: 2461b3102607c1cb4469c94bbe95d67db6c5e54d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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/try/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)