Skip to content

Commit 4273b01

Browse files
committed
---
yaml --- r: 106560 b: refs/heads/try c: 910012a h: refs/heads/master v: v3
1 parent acd2a0e commit 4273b01

File tree

9 files changed

+65
-15
lines changed

9 files changed

+65
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
5-
refs/heads/try: 355932407ba324d33cd9353a69203f7f76c059a6
5+
refs/heads/try: 910012aabae3dfd4b7190f46e88cde75804b5cb0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,12 +1145,26 @@ 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+
11481155
pub fn get_crate_hash(data: &[u8]) -> Svh {
11491156
let cratedoc = reader::Doc(data);
11501157
let hashdoc = reader::get_doc(cratedoc, tag_crate_hash);
11511158
Svh::new(hashdoc.as_str_slice())
11521159
}
11531160

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+
11541168
pub fn get_crate_id(data: &[u8]) -> CrateId {
11551169
let cratedoc = reader::Doc(data);
11561170
let hashdoc = reader::get_doc(cratedoc, tag_crate_crateid);

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

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

320320
fn crate_matches(&mut self, crate_data: &[u8]) -> bool {
321-
let other_id = decoder::get_crate_id(crate_data);
322-
if !self.crate_id.matches(&other_id) { return false }
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+
};
323328
match self.hash {
324329
None => true,
325-
Some(hash) => {
326-
if *hash != decoder::get_crate_hash(crate_data) {
330+
Some(myhash) => {
331+
if *myhash != hash {
327332
self.rejected_via_hash = true;
328333
false
329334
} else {

branches/try/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/try/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/try/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/try/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; }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-include ../tools.mk
2+
3+
all:
4+
touch $(TMPDIR)/rust.metadata.bin
5+
ar crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/rust.metadata.bin
6+
$(RUSTC) foo.rs 2>&1 | grep "can't find crate for"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate foo;
12+
13+
fn main() {}

0 commit comments

Comments
 (0)