Skip to content

Commit 574ddae

Browse files
committed
---
yaml --- r: 82060 b: refs/heads/master c: 2461b31 h: refs/heads/master v: v3
1 parent e25bc88 commit 574ddae

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 88d34ff2498e3ca8020c79c63d4501f749831f2f
2+
refs/heads/master: 2461b3102607c1cb4469c94bbe95d67db6c5e54d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/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

trunk/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)