Skip to content

Commit 9989b76

Browse files
committed
---
yaml --- r: 149692 b: refs/heads/try2 c: c602c81 h: refs/heads/master v: v3
1 parent 1bc75be commit 9989b76

File tree

13 files changed

+87
-68
lines changed

13 files changed

+87
-68
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b5ad3022da9d4cea11ce3ddbce953edcc6e0eae9
8+
refs/heads/try2: c602c814ff7220b9afb228270a53f8dcf16c910a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,11 @@ syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[
163163
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
164164
syn match rustCharacter /'\([^'\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial,rustSpecialError
165165

166-
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
167-
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
168-
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell
169-
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell
170-
syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent
171-
syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent
166+
syn cluster rustComment contains=rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
167+
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
168+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
169+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
170+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
172171
" FIXME: this is a really ugly and not fully correct implementation. Most
173172
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
174173
" a comment, but in practice at present it leaves comments open two levels

branches/try2/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,26 +1145,12 @@ fn list_crate_deps(data: &[u8], out: &mut io::Writer) -> io::IoResult<()> {
11451145
Ok(())
11461146
}
11471147

1148-
pub fn maybe_get_crate_hash(data: &[u8]) -> Option<Svh> {
1149-
let cratedoc = reader::Doc(data);
1150-
reader::maybe_get_doc(cratedoc, tag_crate_hash).map(|doc| {
1151-
Svh::new(doc.as_str_slice())
1152-
})
1153-
}
1154-
11551148
pub fn get_crate_hash(data: &[u8]) -> Svh {
11561149
let cratedoc = reader::Doc(data);
11571150
let hashdoc = reader::get_doc(cratedoc, tag_crate_hash);
11581151
Svh::new(hashdoc.as_str_slice())
11591152
}
11601153

1161-
pub fn maybe_get_crate_id(data: &[u8]) -> Option<CrateId> {
1162-
let cratedoc = reader::Doc(data);
1163-
reader::maybe_get_doc(cratedoc, tag_crate_crateid).map(|doc| {
1164-
from_str(doc.as_str_slice()).unwrap()
1165-
})
1166-
}
1167-
11681154
pub fn get_crate_id(data: &[u8]) -> CrateId {
11691155
let cratedoc = reader::Doc(data);
11701156
let hashdoc = reader::get_doc(cratedoc, tag_crate_crateid);

branches/try2/src/librustc/metadata/loader.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,12 @@ impl<'a> Context<'a> {
318318
}
319319

320320
fn crate_matches(&mut self, crate_data: &[u8]) -> bool {
321-
match decoder::maybe_get_crate_id(crate_data) {
322-
Some(ref id) if self.crate_id.matches(id) => {}
323-
_ => return false
324-
}
325-
let hash = match decoder::maybe_get_crate_hash(crate_data) {
326-
Some(hash) => hash, None => return false
327-
};
321+
let other_id = decoder::get_crate_id(crate_data);
322+
if !self.crate_id.matches(&other_id) { return false }
328323
match self.hash {
329324
None => true,
330-
Some(myhash) => {
331-
if *myhash != hash {
325+
Some(hash) => {
326+
if *hash != decoder::get_crate_hash(crate_data) {
332327
self.rejected_via_hash = true;
333328
false
334329
} else {

branches/try2/src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ impl<'a> DynamicFailureHandler<'a> {
11881188

11891189
let fcx = self.bcx.fcx;
11901190
let fail_cx = fcx.new_block(false, "case_fallthrough", None);
1191-
controlflow::trans_fail(fail_cx, self.sp, self.msg.clone());
1191+
controlflow::trans_fail(fail_cx, Some(self.sp), self.msg.clone());
11921192
self.finished.set(Some(fail_cx.llbb));
11931193
fail_cx.llbb
11941194
}

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ pub fn fail_if_zero<'a>(
864864
}
865865
};
866866
with_cond(cx, is_zero, |bcx| {
867-
controlflow::trans_fail(bcx, span, InternedString::new(text))
867+
controlflow::trans_fail(bcx, Some(span), InternedString::new(text))
868868
})
869869
}
870870

branches/try2/src/librustc/middle/trans/controlflow.rs

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use middle::trans::debuginfo;
1818
use middle::trans::cleanup;
1919
use middle::trans::cleanup::CleanupMethods;
2020
use middle::trans::expr;
21+
use middle::ty;
22+
use util::ppaux;
2123
use util::ppaux::Repr;
2224

2325
use middle::trans::type_::Type;
@@ -325,23 +327,67 @@ pub fn trans_ret<'a>(bcx: &'a Block<'a>,
325327
return bcx;
326328
}
327329

330+
pub fn trans_fail_expr<'a>(
331+
bcx: &'a Block<'a>,
332+
sp_opt: Option<Span>,
333+
fail_expr: Option<@ast::Expr>)
334+
-> &'a Block<'a> {
335+
let _icx = push_ctxt("trans_fail_expr");
336+
let mut bcx = bcx;
337+
match fail_expr {
338+
Some(arg_expr) => {
339+
let ccx = bcx.ccx();
340+
let tcx = ccx.tcx;
341+
let arg_datum =
342+
unpack_datum!(bcx, expr::trans_to_lvalue(bcx, arg_expr, "fail"));
343+
344+
if ty::type_is_str(arg_datum.ty) {
345+
let (lldata, _) = arg_datum.get_vec_base_and_len(bcx);
346+
return trans_fail_value(bcx, sp_opt, lldata);
347+
} else if bcx.unreachable.get() || ty::type_is_bot(arg_datum.ty) {
348+
return bcx;
349+
} else {
350+
bcx.sess().span_bug(
351+
arg_expr.span, ~"fail called with unsupported type " +
352+
ppaux::ty_to_str(tcx, arg_datum.ty));
353+
}
354+
}
355+
_ => trans_fail(bcx, sp_opt, InternedString::new("explicit failure"))
356+
}
357+
}
358+
328359
pub fn trans_fail<'a>(
329360
bcx: &'a Block<'a>,
330-
sp: Span,
361+
sp_opt: Option<Span>,
331362
fail_str: InternedString)
332363
-> &'a Block<'a> {
364+
let _icx = push_ctxt("trans_fail");
333365
let V_fail_str = C_cstr(bcx.ccx(), fail_str);
366+
return trans_fail_value(bcx, sp_opt, V_fail_str);
367+
}
368+
369+
fn trans_fail_value<'a>(
370+
bcx: &'a Block<'a>,
371+
sp_opt: Option<Span>,
372+
V_fail_str: ValueRef)
373+
-> &'a Block<'a> {
334374
let _icx = push_ctxt("trans_fail_value");
335375
let ccx = bcx.ccx();
336-
let sess = bcx.sess();
337-
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
338-
let V_filename = C_cstr(bcx.ccx(),
339-
token::intern_and_get_ident(loc.file.name));
340-
let V_line = loc.line as int;
376+
let (V_filename, V_line) = match sp_opt {
377+
Some(sp) => {
378+
let sess = bcx.sess();
379+
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
380+
(C_cstr(bcx.ccx(), token::intern_and_get_ident(loc.file.name)),
381+
loc.line as int)
382+
}
383+
None => {
384+
(C_cstr(bcx.ccx(), InternedString::new("<runtime>")), 0)
385+
}
386+
};
341387
let V_str = PointerCast(bcx, V_fail_str, Type::i8p());
342388
let V_filename = PointerCast(bcx, V_filename, Type::i8p());
343389
let args = ~[V_str, V_filename, C_int(ccx, V_line)];
344-
let did = langcall(bcx, Some(sp), "", FailFnLangItem);
390+
let did = langcall(bcx, sp_opt, "", FailFnLangItem);
345391
let bcx = callee::trans_lang_call(bcx, did, args, Some(expr::Ignore)).bcx;
346392
Unreachable(bcx);
347393
return bcx;

branches/try2/src/librustdoc/html/highlight.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use html::escape::Escape;
2626
use t = syntax::parse::token;
2727

2828
/// Highlights some source code, returning the HTML output.
29-
pub fn highlight(src: &str) -> ~str {
29+
pub fn highlight(src: &str, class: Option<&str>) -> ~str {
3030
let sess = parse::new_parse_sess();
3131
let handler = diagnostic::default_handler();
3232
let span_handler = diagnostic::mk_span_handler(handler, sess.cm);
@@ -35,6 +35,7 @@ pub fn highlight(src: &str) -> ~str {
3535
let mut out = io::MemWriter::new();
3636
doit(sess,
3737
lexer::new_string_reader(span_handler, fm),
38+
class,
3839
&mut out).unwrap();
3940
str::from_utf8_lossy(out.unwrap()).into_owned()
4041
}
@@ -46,14 +47,15 @@ pub fn highlight(src: &str) -> ~str {
4647
/// it's used. All source code emission is done as slices from the source map,
4748
/// not from the tokens themselves, in order to stay true to the original
4849
/// source.
49-
fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader,
50+
fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>,
5051
out: &mut Writer) -> io::IoResult<()> {
5152
use syntax::parse::lexer::Reader;
5253
53-
try!(write!(out, "<pre class='rust'>\n"));
54+
try!(write!(out, "<pre class='rust {}'>\n", class.unwrap_or("")));
5455
let mut last = BytePos(0);
5556
let mut is_attribute = false;
5657
let mut is_macro = false;
58+
let mut is_macro_nonterminal = false;
5759
loop {
5860
let next = lexer.next_token();
5961
let test = if next.tok == t::EOF {lexer.pos.get()} else {next.sp.lo};
@@ -101,8 +103,15 @@ fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader,
101103
// miscellaneous, no highlighting
102104
t::DOT | t::DOTDOT | t::DOTDOTDOT | t::COMMA | t::SEMI |
103105
t::COLON | t::MOD_SEP | t::LARROW | t::DARROW | t::LPAREN |
104-
t::RPAREN | t::LBRACKET | t::LBRACE | t::RBRACE |
105-
t::DOLLAR => "",
106+
t::RPAREN | t::LBRACKET | t::LBRACE | t::RBRACE => "",
107+
t::DOLLAR => {
108+
if t::is_ident(&lexer.peek().tok) {
109+
is_macro_nonterminal = true;
110+
"macro-nonterminal"
111+
} else {
112+
""
113+
}
114+
}
106115

107116
// This is the start of an attribute. We're going to want to
108117
// continue highlighting it as an attribute until the ending ']' is
@@ -143,7 +152,10 @@ fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader,
143152

144153
_ if t::is_any_keyword(&next.tok) => "kw",
145154
_ => {
146-
if lexer.peek().tok == t::NOT {
155+
if is_macro_nonterminal {
156+
is_macro_nonterminal = false;
157+
"macro-nonterminal"
158+
} else if lexer.peek().tok == t::NOT {
147159
is_macro = true;
148160
"macro"
149161
} else {
@@ -171,4 +183,3 @@ fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader,
171183

172184
write!(out, "</pre>\n")
173185
}
174-

branches/try2/src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn render(w: &mut io::Writer, s: &str) -> fmt::Result {
146146
};
147147

148148
if !rendered {
149-
let output = highlight::highlight(text).to_c_str();
149+
let output = highlight::highlight(text, None).to_c_str();
150150
output.with_ref(|r| {
151151
bufputs(ob, r)
152152
})

branches/try2/src/librustdoc/html/render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,13 +1630,13 @@ impl<'a> fmt::Show for Source<'a> {
16301630
try!(write!(fmt.buf, "<span id='{0:u}'>{0:1$u}</span>\n", i, cols));
16311631
}
16321632
try!(write!(fmt.buf, "</pre>"));
1633-
try!(write!(fmt.buf, "{}", highlight::highlight(s.as_slice())));
1633+
try!(write!(fmt.buf, "{}", highlight::highlight(s.as_slice(), None)));
16341634
Ok(())
16351635
}
16361636
}
16371637

16381638
fn item_macro(w: &mut Writer, it: &clean::Item,
16391639
t: &clean::Macro) -> fmt::Result {
1640-
try!(write!(w, "<pre class='macro'>{}</pre>", t.source));
1640+
try!(w.write_str(highlight::highlight(t.source, Some("macro"))));
16411641
document(w, it)
16421642
}

branches/try2/src/librustdoc/html/static/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ pre.rust .op { color: #cc782f; }
315315
pre.rust .comment { color: #533add; }
316316
pre.rust .doccomment { color: #d343d0; }
317317
pre.rust .macro { color: #d343d0; }
318+
pre.rust .macro-nonterminal { color: #d343d0; }
318319
pre.rust .string { color: #c13928; }
319320
pre.rust .lifetime { color: #d343d0; }
320321
pre.rust .attribute { color: #d343d0 !important; }

branches/try2/src/test/run-make/invalid-library/Makefile

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

branches/try2/src/test/run-make/invalid-library/foo.rs

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

0 commit comments

Comments
 (0)