Skip to content

Commit ad3eda1

Browse files
committed
auto merge of #15339 : cmr/rust/rewrite-lexer2, r=huonw
Mostly minor things that rebasing is becoming painful.
2 parents 5716abe + 69a0cdf commit ad3eda1

Some content is hidden

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

63 files changed

+2297
-2063
lines changed

src/libcore/str.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,9 @@ impl<'a> StrSlice<'a> for &'a str {
17641764

17651765
#[inline]
17661766
fn slice(&self, begin: uint, end: uint) -> &'a str {
1767-
assert!(self.is_char_boundary(begin) && self.is_char_boundary(end));
1767+
assert!(self.is_char_boundary(begin) && self.is_char_boundary(end),
1768+
"index {} and/or {} in `{}` do not lie on character boundary", begin,
1769+
end, *self);
17681770
unsafe { raw::slice_bytes(*self, begin, end) }
17691771
}
17701772

@@ -1775,7 +1777,8 @@ impl<'a> StrSlice<'a> for &'a str {
17751777

17761778
#[inline]
17771779
fn slice_to(&self, end: uint) -> &'a str {
1778-
assert!(self.is_char_boundary(end));
1780+
assert!(self.is_char_boundary(end), "index {} in `{}` does not lie on \
1781+
a character boundary", end, *self);
17791782
unsafe { raw::slice_bytes(*self, 0, end) }
17801783
}
17811784

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ impl UnusedMut {
11141114
match mode {
11151115
ast::BindByValue(ast::MutMutable) => {
11161116
if !token::get_ident(ident).get().starts_with("_") {
1117-
mutables.insert_or_update_with(ident.name as uint,
1117+
mutables.insert_or_update_with(ident.name.uint(),
11181118
vec!(id), |_, old| { old.push(id); });
11191119
}
11201120
}

src/librustc/metadata/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn item_name(intr: &IdentInterner, item: ebml::Doc) -> ast::Ident {
323323
let string = name.as_str_slice();
324324
match intr.find_equiv(&string) {
325325
None => token::str_to_ident(string),
326-
Some(val) => ast::Ident::new(val as ast::Name),
326+
Some(val) => ast::Ident::new(val),
327327
}
328328
}
329329

src/librustc/middle/astencode.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1523,14 +1523,15 @@ fn test_basic() {
15231523
fn foo() {}
15241524
));
15251525
}
1526-
1526+
/* NOTE: When there's a snapshot, update this (yay quasiquoter!)
15271527
#[test]
15281528
fn test_smalltalk() {
15291529
let cx = mk_ctxt();
15301530
roundtrip(quote_item!(cx,
15311531
fn foo() -> int { 3 + 4 } // first smalltalk program ever executed.
15321532
));
15331533
}
1534+
*/
15341535

15351536
#[test]
15361537
fn test_more() {

src/librustc/middle/trans/consts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use syntax::{ast, ast_util};
4242
pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
4343
-> ValueRef {
4444
let _icx = push_ctxt("trans_lit");
45+
debug!("const_lit: {}", lit);
4546
match lit.node {
4647
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
4748
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),

src/librustdoc/html/highlight.rs

+17-27
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::io;
1818

1919
use syntax::parse;
2020
use syntax::parse::lexer;
21-
use syntax::codemap::{BytePos, Span};
2221

2322
use html::escape::Escape;
2423

@@ -59,38 +58,30 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
5958
None => {}
6059
}
6160
try!(write!(out, "class='rust {}'>\n", class.unwrap_or("")));
62-
let mut last = BytePos(0);
6361
let mut is_attribute = false;
6462
let mut is_macro = false;
6563
let mut is_macro_nonterminal = false;
6664
loop {
6765
let next = lexer.next_token();
68-
let test = if next.tok == t::EOF {lexer.pos} else {next.sp.lo};
69-
70-
// The lexer consumes all whitespace and non-doc-comments when iterating
71-
// between tokens. If this token isn't directly adjacent to our last
72-
// token, then we need to emit the whitespace/comment.
73-
//
74-
// If the gap has any '/' characters then we consider the whole thing a
75-
// comment. This will classify some whitespace as a comment, but that
76-
// doesn't matter too much for syntax highlighting purposes.
77-
if test > last {
78-
let snip = sess.span_diagnostic.cm.span_to_snippet(Span {
79-
lo: last,
80-
hi: test,
81-
expn_info: None,
82-
}).unwrap();
83-
if snip.as_slice().contains("/") {
84-
try!(write!(out, "<span class='comment'>{}</span>",
85-
Escape(snip.as_slice())));
86-
} else {
87-
try!(write!(out, "{}", Escape(snip.as_slice())));
88-
}
89-
}
90-
last = next.sp.hi;
66+
67+
let snip = |sp| sess.span_diagnostic.cm.span_to_snippet(sp).unwrap();
68+
9169
if next.tok == t::EOF { break }
9270

9371
let klass = match next.tok {
72+
t::WS => {
73+
try!(write!(out, "{}", Escape(snip(next.sp).as_slice())));
74+
continue
75+
},
76+
t::COMMENT => {
77+
try!(write!(out, "<span class='comment'>{}</span>",
78+
Escape(snip(next.sp).as_slice())));
79+
continue
80+
},
81+
t::SHEBANG(s) => {
82+
try!(write!(out, "{}", Escape(s.as_str())));
83+
continue
84+
},
9485
// If this '&' token is directly adjacent to another token, assume
9586
// that it's the address-of operator instead of the and-operator.
9687
// This allows us to give all pointers their own class (`Box` and
@@ -144,8 +135,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
144135
t::LIT_CHAR(..) | t::LIT_STR(..) | t::LIT_STR_RAW(..) => "string",
145136

146137
// number literals
147-
t::LIT_INT(..) | t::LIT_UINT(..) | t::LIT_INT_UNSUFFIXED(..) |
148-
t::LIT_FLOAT(..) | t::LIT_FLOAT_UNSUFFIXED(..) => "number",
138+
t::LIT_INTEGER(..) | t::LIT_FLOAT(..) => "number",
149139

150140
// keywords are also included in the identifier set
151141
t::IDENT(ident, _is_mod_sep) => {

src/libsyntax/abi.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ pub struct AbiData {
6060
}
6161

6262
pub enum AbiArchitecture {
63-
RustArch, // Not a real ABI (e.g., intrinsic)
64-
AllArch, // An ABI that specifies cross-platform defaults (e.g., "C")
65-
Archs(u32) // Multiple architectures (bitset)
63+
/// Not a real ABI (e.g., intrinsic)
64+
RustArch,
65+
/// An ABI that specifies cross-platform defaults (e.g., "C")
66+
AllArch,
67+
/// Multiple architectures (bitset)
68+
Archs(u32)
6669
}
6770

6871
static AbiDatas: &'static [AbiData] = &[
@@ -84,21 +87,13 @@ static AbiDatas: &'static [AbiData] = &[
8487
AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch},
8588
];
8689

90+
/// Iterates through each of the defined ABIs.
8791
fn each_abi(op: |abi: Abi| -> bool) -> bool {
88-
/*!
89-
*
90-
* Iterates through each of the defined ABIs.
91-
*/
92-
9392
AbiDatas.iter().advance(|abi_data| op(abi_data.abi))
9493
}
9594

95+
/// Returns the ABI with the given name (if any).
9696
pub fn lookup(name: &str) -> Option<Abi> {
97-
/*!
98-
*
99-
* Returns the ABI with the given name (if any).
100-
*/
101-
10297
let mut res = None;
10398

10499
each_abi(|abi| {

0 commit comments

Comments
 (0)