Skip to content

Commit 344ed47

Browse files
committed
---
yaml --- r: 81270 b: refs/heads/snap-stage3 c: 8d6f4c2 h: refs/heads/master v: v3
1 parent 3251639 commit 344ed47

40 files changed

+339
-225
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: bc6dd906a9075f694f562c753e165e1d108e6ec3
4+
refs/heads/snap-stage3: 8d6f4c207a5a9cf8721d4cd2c884390eb3d5e61f
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/tests.mk

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,6 @@ tidy:
261261
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
262262
$(Q)echo $(ALL_HS) \
263263
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
264-
$(Q)find $(S)src -type f -perm +111 \
265-
-not -name '*.rs' -and -not -name '*.py' \
266-
-and -not -name '*.sh' \
267-
| grep '^$(S)src/llvm' -v \
268-
| grep '^$(S)src/libuv' -v \
269-
| grep '^$(S)src/gyp' -v \
270-
| grep '^$(S)src/etc' -v \
271-
| grep '^$(S)src/rt/jemalloc' -v \
272-
| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
273264

274265
endif
275266

branches/snap-stage3/src/etc/check-binaries.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

branches/snap-stage3/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// LLVM wrappers are intended to be called from trans,
1212
// which already runs in a #[fixed_stack_segment]
1313
#[allow(cstack)];
14+
#[allow(non_uppercase_pattern_statics)];
1415

1516
use std::c_str::ToCStr;
1617
use std::hashmap::HashMap;

branches/snap-stage3/src/librustc/middle/check_match.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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;
1415
use middle::pat_util::*;
1516
use middle::ty::*;
1617
use middle::ty;
@@ -121,7 +122,7 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
121122
for pat in arm.pats.iter() {
122123

123124
// Check that we do not match against a static NaN (#6804)
124-
let pat_matches_nan: &fn(&Pat) -> bool = |p| {
125+
let pat_matches_nan: &fn(@Pat) -> bool = |p| {
125126
match cx.tcx.def_map.find(&p.id) {
126127
Some(&DefStatic(did, false)) => {
127128
let const_expr = lookup_const_by_id(cx.tcx, did).unwrap();
@@ -133,11 +134,30 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
133134
_ => false
134135
}
135136
};
137+
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 have an uppercase identifier";
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+
136155
do walk_pat(*pat) |p| {
137156
if pat_matches_nan(p) {
138157
cx.tcx.sess.span_warn(p.span, "unmatchable NaN in pattern, \
139158
use the is_nan method in a guard instead");
140159
}
160+
pat_matches_non_uppercase_static(p);
141161
true
142162
};
143163

@@ -893,7 +913,7 @@ pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
893913
}
894914
}
895915

896-
let check_move: &fn(&Pat, Option<@Pat>) = |p, sub| {
916+
let check_move: &fn(@Pat, Option<@Pat>) = |p, sub| {
897917
// check legality of moving out of the enum
898918

899919
// x @ Foo(*) is legal, but x @ Foo(y) isn't.

branches/snap-stage3/src/librustc/middle/dataflow.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
422422
}
423423

424424
fn walk_expr(&mut self,
425-
expr: &ast::Expr,
425+
expr: @ast::Expr,
426426
in_out: &mut [uint],
427427
loop_scopes: &mut ~[LoopScope]) {
428428
debug!("DataFlowContext::walk_expr(expr=%s, in_out=%s)",
@@ -744,7 +744,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
744744
}
745745

746746
fn pop_scopes(&mut self,
747-
from_expr: &ast::Expr,
747+
from_expr: @ast::Expr,
748748
to_scope: &mut LoopScope,
749749
in_out: &mut [uint]) {
750750
//! Whenever you have a `break` or a `loop` statement, flow
@@ -778,7 +778,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
778778
}
779779

780780
fn break_from_to(&mut self,
781-
from_expr: &ast::Expr,
781+
from_expr: @ast::Expr,
782782
to_scope: &mut LoopScope,
783783
in_out: &mut [uint]) {
784784
self.pop_scopes(from_expr, to_scope, in_out);
@@ -811,7 +811,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
811811
fn walk_call(&mut self,
812812
_callee_id: ast::NodeId,
813813
call_id: ast::NodeId,
814-
arg0: &ast::Expr,
814+
arg0: @ast::Expr,
815815
args: &[@ast::Expr],
816816
in_out: &mut [uint],
817817
loop_scopes: &mut ~[LoopScope]) {
@@ -865,7 +865,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
865865
}
866866

867867
fn find_scope<'a>(&self,
868-
expr: &ast::Expr,
868+
expr: @ast::Expr,
869869
label: Option<ast::Name>,
870870
loop_scopes: &'a mut ~[LoopScope]) -> &'a mut LoopScope {
871871
let index = match label {
@@ -899,7 +899,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
899899
&mut loop_scopes[index]
900900
}
901901

902-
fn is_method_call(&self, expr: &ast::Expr) -> bool {
902+
fn is_method_call(&self, expr: @ast::Expr) -> bool {
903903
self.dfcx.method_map.contains_key(&expr.id)
904904
}
905905

branches/snap-stage3/src/librustc/middle/lint.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub enum lint {
8383
unrecognized_lint,
8484
non_camel_case_types,
8585
non_uppercase_statics,
86+
non_uppercase_pattern_statics,
8687
type_limits,
8788
unused_unsafe,
8889

@@ -209,6 +210,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
209210
default: allow
210211
}),
211212

213+
("non_uppercase_pattern_statics",
214+
LintSpec {
215+
lint: non_uppercase_pattern_statics,
216+
desc: "static constants in match patterns should be uppercased",
217+
default: warn
218+
}),
219+
212220
("managed_heap_memory",
213221
LintSpec {
214222
lint: managed_heap_memory,

branches/snap-stage3/src/librustc/middle/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5363,7 +5363,7 @@ impl Resolver {
53635363
}
53645364

53655365
pub fn enforce_default_binding_mode(&mut self,
5366-
pat: &Pat,
5366+
pat: @Pat,
53675367
pat_binding_mode: BindingMode,
53685368
descr: &str) {
53695369
match pat_binding_mode {

branches/snap-stage3/src/librustc/middle/trans/_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ fn insert_lllocals(bcx: @mut Block,
13981398
}
13991399

14001400
fn compile_guard(bcx: @mut Block,
1401-
guard_expr: &ast::Expr,
1401+
guard_expr: @ast::Expr,
14021402
data: &ArmData,
14031403
m: &[Match],
14041404
vals: &[ValueRef],
@@ -1826,7 +1826,7 @@ fn compile_submatch_continue(mut bcx: @mut Block,
18261826

18271827
pub fn trans_match(bcx: @mut Block,
18281828
match_expr: &ast::Expr,
1829-
discr_expr: &ast::Expr,
1829+
discr_expr: @ast::Expr,
18301830
arms: &[ast::Arm],
18311831
dest: Dest) -> @mut Block {
18321832
let _icx = push_ctxt("match::trans_match");
@@ -1876,7 +1876,7 @@ fn create_bindings_map(bcx: @mut Block, pat: @ast::Pat) -> BindingsMap {
18761876
}
18771877

18781878
fn trans_match_inner(scope_cx: @mut Block,
1879-
discr_expr: &ast::Expr,
1879+
discr_expr: @ast::Expr,
18801880
arms: &[ast::Arm],
18811881
dest: Dest) -> @mut Block {
18821882
let _icx = push_ctxt("match::trans_match_inner");

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,10 +1407,7 @@ pub fn cleanup_and_leave(bcx: @mut Block,
14071407
}
14081408
match leave {
14091409
Some(target) => Br(bcx, target),
1410-
None => {
1411-
let ll_load = Load(bcx, bcx.fcx.personality.unwrap());
1412-
Resume(bcx, ll_load);
1413-
}
1410+
None => { Resume(bcx, Load(bcx, bcx.fcx.personality.unwrap())); }
14141411
}
14151412
}
14161413

@@ -2488,7 +2485,7 @@ pub fn item_path(ccx: &CrateContext, id: &ast::NodeId) -> path {
24882485
ty::item_path(ccx.tcx, ast_util::local_def(*id))
24892486
}
24902487

2491-
fn exported_name(ccx: &mut CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str {
2488+
fn exported_name(ccx: @mut CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str {
24922489
match attr::first_attr_value_str_by_name(attrs, "export_name") {
24932490
// Use provided name
24942491
Some(name) => name.to_owned(),
@@ -2982,7 +2979,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
29822979
return map;
29832980
}
29842981

2985-
pub fn fill_crate_map(ccx: &mut CrateContext, map: ValueRef) {
2982+
pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
29862983
let mut subcrates: ~[ValueRef] = ~[];
29872984
let mut i = 1;
29882985
let cstore = ccx.sess.cstore;
@@ -3033,7 +3030,7 @@ pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::encode_
30333030
}
30343031
}
30353032

3036-
pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) {
3033+
pub fn write_metadata(cx: &mut CrateContext, crate: &ast::Crate) {
30373034
if !*cx.sess.building_library { return; }
30383035

30393036
let encode_inlined_item: encoder::encode_inlined_item =

0 commit comments

Comments
 (0)