Skip to content

Commit b21569f

Browse files
committed
---
yaml --- r: 95143 b: refs/heads/dist-snap c: 371a7ec h: refs/heads/master i: 95141: 05fc98d 95139: fdddbb4 95135: 9e567f9 v: v3
1 parent 461e88e commit b21569f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+710
-401
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: b7fe83d573d8073f7d663bee5c0b3e1493b9998d
9+
refs/heads/dist-snap: 371a7ec56959323fd8add557219c4cbcac89825f
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/etc/emacs/rust-mode-tests.el

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,35 @@ This is some more text. Fee fie fo fum. Humpty dumpty sat on a wall.
196196
*very very very long string
197197
*/"))
198198

199+
(ert-deftest fill-paragraph-single-line-style-with-code-before ()
200+
(test-fill-paragraph
201+
"fn foo() { }
202+
/// This is my comment. This is more of my comment. This is even more."
203+
"fn foo() { }
204+
/// This is my comment. This is
205+
/// more of my comment. This is
206+
/// even more." 14))
207+
208+
(ert-deftest fill-paragraph-single-line-style-with-code-after ()
209+
(test-fill-paragraph
210+
"/// This is my comment. This is more of my comment. This is even more.
211+
fn foo() { }"
212+
"/// This is my comment. This is
213+
/// more of my comment. This is
214+
/// even more.
215+
fn foo() { }" 1 73))
216+
217+
(ert-deftest fill-paragraph-single-line-style-code-before-and-after ()
218+
(test-fill-paragraph
219+
"fn foo() { }
220+
/// This is my comment. This is more of my comment. This is even more.
221+
fn bar() { }"
222+
"fn foo() { }
223+
/// This is my comment. This is
224+
/// more of my comment. This is
225+
/// even more.
226+
fn bar() { }" 14 67))
227+
199228
(defun test-auto-fill (initial position inserted expected)
200229
(rust-test-manip-code
201230
initial

branches/dist-snap/src/etc/emacs/rust-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@
300300
(let
301301
((fill-paragraph-function
302302
(if (not (eq fill-paragraph-function 'rust-fill-paragraph))
303-
fill-paragraph-function)))
303+
fill-paragraph-function))
304+
(fill-paragraph-handle-comment t))
304305
(apply 'fill-paragraph args)
305306
t))))))
306307

branches/dist-snap/src/libextra/base64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'self> FromBase64 for &'self str {
200200
'0'..'9' => buf |= val + 0x04,
201201
'+'|'-' => buf |= 0x3E,
202202
'/'|'_' => buf |= 0x3F,
203-
'\r'|'\n' => loop,
203+
'\r'|'\n' => continue,
204204
'=' => break,
205205
_ => return Err(format!("Invalid character '{}' at position {}",
206206
self.char_at(idx), idx))

branches/dist-snap/src/libextra/fileinput.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl io::Reader for FileInput {
303303
let b = r.read_byte();
304304

305305
if b < 0 {
306-
loop;
306+
continue;
307307
}
308308

309309
if b == '\n' as int {

branches/dist-snap/src/libextra/glob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl Pattern {
211211
let cs = parse_char_specifiers(chars.slice(i + 2, i + 3 + j));
212212
tokens.push(AnyExcept(cs));
213213
i += j + 4;
214-
loop;
214+
continue;
215215
}
216216
}
217217
}
@@ -222,7 +222,7 @@ impl Pattern {
222222
let cs = parse_char_specifiers(chars.slice(i + 1, i + 2 + j));
223223
tokens.push(AnyWithin(cs));
224224
i += j + 3;
225-
loop;
225+
continue;
226226
}
227227
}
228228
}

branches/dist-snap/src/libextra/hex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'self> FromHex for &'self str {
100100
'0'..'9' => buf |= byte - ('0' as u8),
101101
' '|'\r'|'\n'|'\t' => {
102102
buf >>= 4;
103-
loop
103+
continue
104104
}
105105
_ => return Err(format!("Invalid character '{}' at position {}",
106106
self.char_at(idx), idx))

branches/dist-snap/src/libextra/num/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl Integer for BigUint {
413413
}
414414
if d0.is_zero() {
415415
n = 2;
416-
loop;
416+
continue;
417417
}
418418
n = 1;
419419
// FIXME(#6102): Assignment operator for BigInt causes ICE

branches/dist-snap/src/libextra/priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<T:Ord> PriorityQueue<T> {
140140
let x = replace(&mut self.data[parent], init());
141141
move_val_init(&mut self.data[pos], x);
142142
pos = parent;
143-
loop
143+
continue
144144
}
145145
break
146146
}

branches/dist-snap/src/libextra/terminfo/parser/compiled.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
276276
for (i, v) in string_offsets.iter().enumerate() {
277277
let offset = *v;
278278
if offset == 0xFFFF { // non-entry
279-
loop;
279+
continue;
280280
}
281281

282282
let name = if snames[i] == "_" {
@@ -289,7 +289,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
289289
// undocumented: FFFE indicates cap@, which means the capability is not present
290290
// unsure if the handling for this is correct
291291
string_map.insert(name.to_owned(), ~[]);
292-
loop;
292+
continue;
293293
}
294294

295295

branches/dist-snap/src/libextra/time.rs

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,59 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
734734
}
735735

736736
fn do_strftime(format: &str, tm: &Tm) -> ~str {
737+
fn days_in_year(year: int) -> i32 {
738+
if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))) {
739+
366 /* Days in a leap year */
740+
} else {
741+
365 /* Days in a non-leap year */
742+
}
743+
}
744+
745+
fn iso_week_days(yday: i32, wday: i32) -> int {
746+
/* The number of days from the first day of the first ISO week of this
747+
* year to the year day YDAY with week day WDAY.
748+
* ISO weeks start on Monday. The first ISO week has the year's first
749+
* Thursday.
750+
* YDAY may be as small as yday_minimum.
751+
*/
752+
let yday: int = yday as int;
753+
let wday: int = wday as int;
754+
let iso_week_start_wday: int = 1; /* Monday */
755+
let iso_week1_wday: int = 4; /* Thursday */
756+
let yday_minimum: int = 366;
757+
/* Add enough to the first operand of % to make it nonnegative. */
758+
let big_enough_multiple_of_7: int = (yday_minimum / 7 + 2) * 7;
759+
760+
yday - (yday - wday + iso_week1_wday + big_enough_multiple_of_7) % 7
761+
+ iso_week1_wday - iso_week_start_wday
762+
}
763+
764+
fn iso_week(ch:char, tm: &Tm) -> ~str {
765+
let mut year: int = tm.tm_year as int + 1900;
766+
let mut days: int = iso_week_days (tm.tm_yday, tm.tm_wday);
767+
768+
if (days < 0) {
769+
/* This ISO week belongs to the previous year. */
770+
year -= 1;
771+
days = iso_week_days (tm.tm_yday + (days_in_year(year)), tm.tm_wday);
772+
} else {
773+
let d: int = iso_week_days (tm.tm_yday - (days_in_year(year)),
774+
tm.tm_wday);
775+
if (0 <= d) {
776+
/* This ISO week belongs to the next year. */
777+
year += 1;
778+
days = d;
779+
}
780+
}
781+
782+
match ch {
783+
'G' => format!("{}", year),
784+
'g' => format!("{:02d}", (year % 100 + 100) % 100),
785+
'V' => format!("{:02d}", days / 7 + 1),
786+
_ => ~""
787+
}
788+
}
789+
737790
fn parse_type(ch: char, tm: &Tm) -> ~str {
738791
//FIXME (#2350): Implement missing types.
739792
let die = || format!("strftime: can't understand this format {} ", ch);
@@ -812,8 +865,8 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
812865
parse_type('m', tm),
813866
parse_type('d', tm))
814867
}
815-
//'G' {}
816-
//'g' {}
868+
'G' => iso_week('G', tm),
869+
'g' => iso_week('g', tm),
817870
'H' => format!("{:02d}", tm.tm_hour),
818871
'I' => {
819872
let mut h = tm.tm_hour;
@@ -855,12 +908,12 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
855908
parse_type('S', tm))
856909
}
857910
't' => ~"\t",
858-
//'U' {}
911+
'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
859912
'u' => {
860913
let i = tm.tm_wday as int;
861914
(if i == 0 { 7 } else { i }).to_str()
862915
}
863-
//'V' {}
916+
'V' => iso_week('V', tm),
864917
'v' => {
865918
format!("{}-{}-{}",
866919
parse_type('e', tm),
@@ -1222,8 +1275,8 @@ mod tests {
12221275
assert_eq!(local.strftime("%e"), ~"13");
12231276
assert_eq!(local.strftime("%f"), ~"000054321");
12241277
assert_eq!(local.strftime("%F"), ~"2009-02-13");
1225-
// assert!(local.strftime("%G") == "2009");
1226-
// assert!(local.strftime("%g") == "09");
1278+
assert_eq!(local.strftime("%G"), ~"2009");
1279+
assert_eq!(local.strftime("%g"), ~"09");
12271280
assert_eq!(local.strftime("%H"), ~"15");
12281281
assert_eq!(local.strftime("%I"), ~"03");
12291282
assert_eq!(local.strftime("%j"), ~"044");
@@ -1240,9 +1293,9 @@ mod tests {
12401293
assert_eq!(local.strftime("%s"), ~"1234567890");
12411294
assert_eq!(local.strftime("%T"), ~"15:31:30");
12421295
assert_eq!(local.strftime("%t"), ~"\t");
1243-
// assert!(local.strftime("%U") == "06");
1296+
assert_eq!(local.strftime("%U"), ~"06");
12441297
assert_eq!(local.strftime("%u"), ~"5");
1245-
// assert!(local.strftime("%V") == "07");
1298+
assert_eq!(local.strftime("%V"), ~"07");
12461299
assert_eq!(local.strftime("%v"), ~"13-Feb-2009");
12471300
// assert!(local.strftime("%W") == "06");
12481301
assert_eq!(local.strftime("%w"), ~"5");

branches/dist-snap/src/libextra/url.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ pub fn query_to_str(query: &Query) -> ~str {
359359
pub fn get_scheme(rawurl: &str) -> Result<(~str, ~str), ~str> {
360360
for (i,c) in rawurl.iter().enumerate() {
361361
match c {
362-
'A' .. 'Z' | 'a' .. 'z' => loop,
362+
'A' .. 'Z' | 'a' .. 'z' => continue,
363363
'0' .. '9' | '+' | '-' | '.' => {
364364
if i == 0 {
365365
return Err(~"url: Scheme must begin with a letter.");
366366
}
367-
loop;
367+
continue;
368368
}
369369
':' => {
370370
if i == 0 {
@@ -420,7 +420,7 @@ fn get_authority(rawurl: &str) ->
420420
let mut end = len;
421421

422422
for (i,c) in rawurl.iter().enumerate() {
423-
if i < 2 { loop; } // ignore the leading //
423+
if i < 2 { continue; } // ignore the leading //
424424

425425
// deal with input class first
426426
match c {
@@ -558,7 +558,7 @@ fn get_path(rawurl: &str, authority: bool) ->
558558
'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '&' |'\'' | '(' | ')' | '.'
559559
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
560560
| '_' | '-' => {
561-
loop;
561+
continue;
562562
}
563563
'?' | '#' => {
564564
end = i;

branches/dist-snap/src/librust/rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub fn main() {
247247
os::set_exit_status(exit_code);
248248
return;
249249
}
250-
_ => loop
250+
_ => {}
251251
}
252252
}
253253
}

branches/dist-snap/src/librustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ pub fn link_args(sess: Session,
10041004
for cratepath in r.iter() {
10051005
if cratepath.filetype() == Some(".rlib") {
10061006
args.push(cratepath.to_str());
1007-
loop;
1007+
continue;
10081008
}
10091009
let dir = cratepath.dirname();
10101010
if dir != ~"" { args.push(~"-L" + dir); }

branches/dist-snap/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/dist-snap/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ impl<'self> CheckLoanCtxt<'self> {
263263
debug2!("illegal_if={:?}", illegal_if);
264264

265265
for restr in loan1.restrictions.iter() {
266-
if !restr.set.intersects(illegal_if) { loop; }
267-
if restr.loan_path != loan2.loan_path { loop; }
266+
if !restr.set.intersects(illegal_if) { continue; }
267+
if restr.loan_path != loan2.loan_path { continue; }
268268

269269
match (new_loan.mutbl, old_loan.mutbl) {
270270
(MutableMutability, MutableMutability) => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
133133
_ => false
134134
}
135135
};
136+
136137
do walk_pat(*pat) |p| {
137138
if pat_matches_nan(p) {
138139
cx.tcx.sess.span_warn(p.span, "unmatchable NaN in pattern, \

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

Lines changed: 30 additions & 1 deletion
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 all caps",
217+
default: warn
218+
}),
219+
212220
("managed_heap_memory",
213221
LintSpec {
214222
lint: managed_heap_memory,
@@ -613,7 +621,7 @@ pub fn each_lint(sess: session::Session,
613621
ast::MetaList(_, ref metas) => metas,
614622
_ => {
615623
sess.span_err(meta.span, "malformed lint attribute");
616-
loop;
624+
continue;
617625
}
618626
};
619627
for meta in metas.iter() {
@@ -1110,6 +1118,22 @@ fn check_item_non_uppercase_statics(cx: &Context, it: &ast::item) {
11101118
}
11111119
}
11121120

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+
11131137
struct UnusedUnsafeLintVisitor { stopping_on_items: bool }
11141138

11151139
impl SubitemStoppableVisitor for UnusedUnsafeLintVisitor {
@@ -1542,6 +1566,11 @@ struct LintCheckVisitor;
15421566

15431567
impl Visitor<@mut Context> for LintCheckVisitor {
15441568

1569+
fn visit_pat(&mut self, p:@ast::Pat, cx: @mut Context) {
1570+
check_pat_non_uppercase_statics(cx, p);
1571+
visit::walk_pat(self, p, cx);
1572+
}
1573+
15451574
fn visit_item(&mut self, it:@ast::item, cx: @mut Context) {
15461575

15471576
do cx.with_lint_attrs(it.attrs) {

branches/dist-snap/src/librustc/middle/privacy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl PrivacyVisitor {
225225
fn check_field(&mut self, span: Span, id: ast::DefId, ident: ast::Ident) {
226226
let fields = ty::lookup_struct_fields(self.tcx, id);
227227
for field in fields.iter() {
228-
if field.name != ident.name { loop; }
228+
if field.name != ident.name { continue; }
229229
if field.vis == private {
230230
self.tcx.sess.span_err(span, format!("field `{}` is private",
231231
token::ident_to_str(&ident)));

0 commit comments

Comments
 (0)