Skip to content

Commit dbf135d

Browse files
committed
---
yaml --- r: 63098 b: refs/heads/snap-stage3 c: b870477 h: refs/heads/master v: v3
1 parent 240b6ab commit dbf135d

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 93b2ddfc88f581a1155236c9ac79983f72b0ff46
4+
refs/heads/snap-stage3: b87047789723ac140f471c56cebf3faa27e0c06f
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,15 +1439,10 @@ call_closure_with_ten(closure);
14391439
~~~~
14401440

14411441
Closures begin with the argument list between vertical bars and are followed by
1442-
a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, is
1443-
considered a single expression: it evaluates to the result of the last
1444-
expression it contains if that expression is not followed by a semicolon,
1445-
otherwise the block evaluates to `()`.
1446-
1447-
The types of the arguments are generally omitted, as is the return type,
1448-
because the compiler can almost always infer them. In the rare case where the
1449-
compiler needs assistance, though, the arguments and return types may be
1450-
annotated.
1442+
a single expression. The types of the arguments are generally omitted,
1443+
as is the return type, because the compiler can almost always infer
1444+
them. In the rare case where the compiler needs assistance, though, the
1445+
arguments and return types may be annotated.
14511446

14521447
~~~~
14531448
let square = |x: int| -> uint { x * x as uint };

branches/snap-stage3/src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub fn gather_comments_and_literals(span_diagnostic:
347347
}
348348

349349

350-
let bstart = rdr.pos;
350+
let bstart = rdr.last_pos;
351351
rdr.next_token();
352352
//discard, and look ahead; we're working with internal state
353353
let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();

branches/snap-stage3/src/libsyntax/parse/lexer.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,20 @@ fn string_advance_token(r: @mut StringReader) {
161161
}
162162
}
163163

164-
fn byte_offset(rdr: &StringReader) -> BytePos {
165-
(rdr.pos - rdr.filemap.start_pos)
164+
fn byte_offset(rdr: &StringReader, pos: BytePos) -> BytePos {
165+
(pos - rdr.filemap.start_pos)
166166
}
167167

168168
pub fn get_str_from(rdr: @mut StringReader, start: BytePos) -> ~str {
169-
// I'm pretty skeptical about this subtraction. What if there's a
170-
// multi-byte character before the mark?
171-
return str::slice(*rdr.src, start.to_uint() - 1u,
172-
byte_offset(rdr).to_uint() - 1u).to_owned();
169+
return str::slice(*rdr.src, start.to_uint(),
170+
byte_offset(rdr, rdr.last_pos).to_uint()).to_owned();
173171
}
174172

175173
// EFFECT: advance the StringReader by one character. If a newline is
176174
// discovered, add it to the FileMap's list of line start offsets.
177175
pub fn bump(rdr: &mut StringReader) {
178176
rdr.last_pos = rdr.pos;
179-
let current_byte_offset = byte_offset(rdr).to_uint();;
177+
let current_byte_offset = byte_offset(rdr, rdr.pos).to_uint();
180178
if current_byte_offset < (*rdr.src).len() {
181179
assert!(rdr.curr != -1 as char);
182180
let last_char = rdr.curr;
@@ -202,7 +200,7 @@ pub fn is_eof(rdr: @mut StringReader) -> bool {
202200
rdr.curr == -1 as char
203201
}
204202
pub fn nextch(rdr: @mut StringReader) -> char {
205-
let offset = byte_offset(rdr).to_uint();
203+
let offset = byte_offset(rdr, rdr.pos).to_uint();
206204
if offset < (*rdr.src).len() {
207205
return str::char_at(*rdr.src, offset);
208206
} else { return -1 as char; }
@@ -540,19 +538,19 @@ fn ident_continue(c: char) -> bool {
540538
// EFFECT: advances the input past that token
541539
// EFFECT: updates the interner
542540
fn next_token_inner(rdr: @mut StringReader) -> token::Token {
543-
let mut accum_str = ~"";
544541
let mut c = rdr.curr;
545542
if ident_start(c) {
546-
while ident_continue(c) {
547-
str::push_char(&mut accum_str, c);
543+
let start = byte_offset(rdr, rdr.last_pos);
544+
while ident_continue(rdr.curr) {
548545
bump(rdr);
549-
c = rdr.curr;
550546
}
551-
if accum_str == ~"_" { return token::UNDERSCORE; }
552-
let is_mod_name = c == ':' && nextch(rdr) == ':';
547+
let string = get_str_from(rdr, start);
548+
549+
if "_" == string { return token::UNDERSCORE; }
550+
let is_mod_name = rdr.curr == ':' && nextch(rdr) == ':';
553551

554552
// FIXME: perform NFKC normalization here. (Issue #2253)
555-
return token::IDENT(str_to_ident(accum_str), is_mod_name);
553+
return token::IDENT(str_to_ident(string), is_mod_name);
556554
}
557555
if is_dec_digit(c) {
558556
return scan_number(c, rdr);
@@ -692,7 +690,8 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token {
692690
return token::LIT_INT(c2 as i64, ast::ty_char);
693691
}
694692
'"' => {
695-
let n = byte_offset(rdr);
693+
let mut accum_str = ~"";
694+
let n = byte_offset(rdr, rdr.last_pos);
696695
bump(rdr);
697696
while rdr.curr != '"' {
698697
if is_eof(rdr) {

0 commit comments

Comments
 (0)