Skip to content

Commit faac3b6

Browse files
committed
---
yaml --- r: 149694 b: refs/heads/try2 c: df40aec h: refs/heads/master v: v3
1 parent 8692f40 commit faac3b6

File tree

11 files changed

+52
-66
lines changed

11 files changed

+52
-66
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: baf79083aedb8ae64efddbcf28b358841cfd1157
8+
refs/heads/try2: df40aeccdbfcfb0cc7851c6df24f28fbeccfe046
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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/librustdoc/html/highlight.rs

Lines changed: 7 additions & 18 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, class: Option<&str>) -> ~str {
29+
pub fn highlight(src: &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,7 +35,6 @@ pub fn highlight(src: &str, class: Option<&str>) -> ~str {
3535
let mut out = io::MemWriter::new();
3636
doit(sess,
3737
lexer::new_string_reader(span_handler, fm),
38-
class,
3938
&mut out).unwrap();
4039
str::from_utf8_lossy(out.unwrap()).into_owned()
4140
}
@@ -47,15 +46,14 @@ pub fn highlight(src: &str, class: Option<&str>) -> ~str {
4746
/// it's used. All source code emission is done as slices from the source map,
4847
/// not from the tokens themselves, in order to stay true to the original
4948
/// source.
50-
fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>,
49+
fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader,
5150
out: &mut Writer) -> io::IoResult<()> {
5251
use syntax::parse::lexer::Reader;
5352
54-
try!(write!(out, "<pre class='rust {}'>\n", class.unwrap_or("")));
53+
try!(write!(out, "<pre class='rust'>\n"));
5554
let mut last = BytePos(0);
5655
let mut is_attribute = false;
5756
let mut is_macro = false;
58-
let mut is_macro_nonterminal = false;
5957
loop {
6058
let next = lexer.next_token();
6159
let test = if next.tok == t::EOF {lexer.pos.get()} else {next.sp.lo};
@@ -103,15 +101,8 @@ fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>
103101
// miscellaneous, no highlighting
104102
t::DOT | t::DOTDOT | t::DOTDOTDOT | t::COMMA | t::SEMI |
105103
t::COLON | t::MOD_SEP | t::LARROW | t::DARROW | t::LPAREN |
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-
}
104+
t::RPAREN | t::LBRACKET | t::LBRACE | t::RBRACE |
105+
t::DOLLAR => "",
115106

116107
// This is the start of an attribute. We're going to want to
117108
// continue highlighting it as an attribute until the ending ']' is
@@ -152,10 +143,7 @@ fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>
152143

153144
_ if t::is_any_keyword(&next.tok) => "kw",
154145
_ => {
155-
if is_macro_nonterminal {
156-
is_macro_nonterminal = false;
157-
"macro-nonterminal"
158-
} else if lexer.peek().tok == t::NOT {
146+
if lexer.peek().tok == t::NOT {
159147
is_macro = true;
160148
"macro"
161149
} else {
@@ -183,3 +171,4 @@ fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>
183171

184172
write!(out, "</pre>\n")
185173
}
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, None).to_c_str();
149+
let output = highlight::highlight(text).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(), None)));
1633+
try!(write!(fmt.buf, "{}", highlight::highlight(s.as_slice())));
16341634
Ok(())
16351635
}
16361636
}
16371637

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ 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; }
319318
pre.rust .string { color: #c13928; }
320319
pre.rust .lifetime { color: #d343d0; }
321320
pre.rust .attribute { color: #d343d0 !important; }

branches/try2/src/libstd/hash/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ use option::{Option, Some, None};
7070
use rc::Rc;
7171
use str::{Str, StrSlice};
7272
use vec::{Vector, ImmutableVector};
73+
use vec_ng::Vec;
7374

7475
/// Reexport the `sip::hash` function as our default hasher.
7576
pub use hash = self::sip::hash;
@@ -207,6 +208,13 @@ impl<S: Writer, T: Hash<S>> Hash<S> for ~[T] {
207208
}
208209
}
209210

211+
impl<S: Writer, T: Hash<S>> Hash<S> for Vec<T> {
212+
#[inline]
213+
fn hash(&self, state: &mut S) {
214+
self.as_slice().hash(state);
215+
}
216+
}
217+
210218
impl<'a, S: Writer, T: Hash<S>> Hash<S> for &'a T {
211219
#[inline]
212220
fn hash(&self, state: &mut S) {

branches/try2/src/libstd/vec_ng.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use cast::{forget, transmute};
1515
use clone::Clone;
1616
use cmp::{Eq, Ordering, TotalEq, TotalOrd};
1717
use container::Container;
18+
use default::Default;
1819
use iter::{DoubleEndedIterator, FromIterator, Iterator};
1920
use libc::{free, c_void};
2021
use mem::{size_of, move_val_init};
@@ -26,7 +27,8 @@ use ptr::RawPtr;
2627
use ptr;
2728
use rt::global_heap::{malloc_raw, realloc_raw};
2829
use raw::Slice;
29-
use vec::{ImmutableVector, Items, MutItems, MutableVector, RevItems};
30+
use vec::{ImmutableEqVector, ImmutableVector, Items, MutItems, MutableVector};
31+
use vec::{RevItems};
3032

3133
pub struct Vec<T> {
3234
priv len: uint,
@@ -340,6 +342,18 @@ impl<T> Vec<T> {
340342
pub fn slice_from<'a>(&'a self, start: uint) -> &'a [T] {
341343
self.as_slice().slice_from(start)
342344
}
345+
346+
#[inline]
347+
pub fn init<'a>(&'a self) -> &'a [T] {
348+
self.slice(0, self.len() - 1)
349+
}
350+
}
351+
352+
impl<T:Eq> Vec<T> {
353+
/// Return true if a vector contains an element with the given value
354+
pub fn contains(&self, x: &T) -> bool {
355+
self.as_slice().contains(x)
356+
}
343357
}
344358

345359
#[inline]
@@ -348,6 +362,14 @@ pub fn append<T:Clone>(mut first: Vec<T>, second: &[T]) -> Vec<T> {
348362
first
349363
}
350364

365+
/// Appends one element to the vector provided. The vector itself is then
366+
/// returned for use again.
367+
#[inline]
368+
pub fn append_one<T>(mut lhs: Vec<T>, x: T) -> Vec<T> {
369+
lhs.push(x);
370+
lhs
371+
}
372+
351373
#[unsafe_destructor]
352374
impl<T> Drop for Vec<T> {
353375
fn drop(&mut self) {
@@ -360,6 +382,12 @@ impl<T> Drop for Vec<T> {
360382
}
361383
}
362384

385+
impl<T> Default for Vec<T> {
386+
fn default() -> Vec<T> {
387+
Vec::new()
388+
}
389+
}
390+
363391
pub struct MoveItems<T> {
364392
priv allocation: *mut c_void, // the block of memory allocated for the vector
365393
priv iter: Items<'static, T>

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)