Skip to content

Commit 7c8193e

Browse files
committed
---
yaml --- r: 96123 b: refs/heads/dist-snap c: c8e6a38 h: refs/heads/master i: 96121: 3e60e07 96119: 56bcd0d v: v3
1 parent 56f10f9 commit 7c8193e

File tree

15 files changed

+137
-219
lines changed

15 files changed

+137
-219
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 5208332a1a0cc2d07d52c117a6abe7e2c8c1f36e
9+
refs/heads/dist-snap: c8e6a38693d73e06e59c69fbd40c3924836a10e9
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/rust.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ common_escape : '\x5c'
254254
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
255255
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
256256
| dec_digit ;
257-
oct_digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' ;
258257
dec_digit : '0' | nonzero_dec ;
259258
nonzero_dec: '1' | '2' | '3' | '4'
260259
| '5' | '6' | '7' | '8' | '9' ;
@@ -319,9 +318,8 @@ r##"foo #"# bar"##; // foo #"# bar
319318
~~~~ {.ebnf .gram}
320319
321320
num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?
322-
| '0' [ [ dec_digit | '_' ] * num_suffix ?
321+
| '0' [ [ dec_digit | '_' ] + num_suffix ?
323322
| 'b' [ '1' | '0' | '_' ] + int_suffix ?
324-
| 'o' [ oct_digit | '_' ] + int_suffix ?
325323
| 'x' [ hex_digit | '_' ] + int_suffix ? ] ;
326324
327325
num_suffix : int_suffix | float_suffix ;

branches/dist-snap/src/libextra/num/bigint.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ impl ToStrRadix for BigUint {
660660
let divider = FromPrimitive::from_uint(base).unwrap();
661661
let mut result = ~[];
662662
let mut m = n;
663-
while m > divider {
663+
while m >= divider {
664664
let (d, m0) = m.div_mod_floor(&divider);
665665
result.push(m0.to_uint().unwrap() as BigDigit);
666666
m = d;
@@ -2520,6 +2520,11 @@ mod bigint_tests {
25202520
check("-10", Some(-10));
25212521
check("Z", None);
25222522
check("_", None);
2523+
2524+
// issue 10522, this hit an edge case that caused it to
2525+
// attempt to allocate a vector of size (-1u) == huge.
2526+
let x: BigInt = from_str("1" + "0".repeat(36)).unwrap();
2527+
let _y = x.to_str();
25232528
}
25242529

25252530
#[test]

branches/dist-snap/src/librustc/middle/lint.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -883,23 +883,20 @@ fn check_unused_unsafe(cx: &Context, e: &ast::Expr) {
883883

884884
fn check_unused_mut_pat(cx: &Context, p: @ast::Pat) {
885885
match p.node {
886-
ast::PatIdent(ast::BindByValue(ast::MutMutable),
887-
ref path, _) if pat_util::pat_is_binding(cx.tcx.def_map, p)=> {
888-
// `let mut _a = 1;` doesn't need a warning.
889-
let initial_underscore = match path.segments {
890-
[ast::PathSegment { identifier: id, _ }] => {
891-
cx.tcx.sess.str_of(id).starts_with("_")
892-
}
893-
_ => {
894-
cx.tcx.sess.span_bug(p.span,
895-
"mutable binding that doesn't \
896-
consist of exactly one segment");
897-
}
898-
};
899-
900-
if !initial_underscore && !cx.tcx.used_mut_nodes.contains(&p.id) {
901-
cx.span_lint(unused_mut, p.span,
902-
"variable does not need to be mutable");
886+
ast::PatIdent(ast::BindByValue(ast::MutMutable), _, _) => {
887+
let mut used = false;
888+
let mut bindings = 0;
889+
do pat_util::pat_bindings(cx.tcx.def_map, p) |_, id, _, _| {
890+
used = used || cx.tcx.used_mut_nodes.contains(&id);
891+
bindings += 1;
892+
}
893+
if !used {
894+
let msg = if bindings == 1 {
895+
"variable does not need to be mutable"
896+
} else {
897+
"variables do not need to be mutable"
898+
};
899+
cx.span_lint(unused_mut, p.span, msg);
903900
}
904901
}
905902
_ => ()

branches/dist-snap/src/librustc/middle/typeck/check/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -863,13 +863,11 @@ pub fn compare_impl_method(tcx: ty::ctxt,
863863
if impl_m.fty.sig.inputs.len() != trait_m.fty.sig.inputs.len() {
864864
tcx.sess.span_err(
865865
impl_m_span,
866-
format!("method `{}` has {} parameter{} \
867-
but the declaration in trait `{}` has {}",
868-
tcx.sess.str_of(trait_m.ident),
869-
impl_m.fty.sig.inputs.len(),
870-
if impl_m.fty.sig.inputs.len() == 1 { "" } else { "s" },
871-
ty::item_path_str(tcx, trait_m.def_id),
872-
trait_m.fty.sig.inputs.len()));
866+
format!("method `{}` has {} parameter(s) \
867+
but the trait has {} parameter(s)",
868+
tcx.sess.str_of(trait_m.ident),
869+
impl_m.fty.sig.inputs.len(),
870+
trait_m.fty.sig.inputs.len()));
873871
return;
874872
}
875873

branches/dist-snap/src/librustpkg/api.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
8181

8282
pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
8383
lib: Path) {
84-
build_lib_with_cfgs(sysroot, root, name, version, lib, ~[])
85-
}
86-
87-
pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
88-
version: Version, lib: Path, cfgs: ~[~str]) {
8984
let cx = default_context(sysroot, root.clone());
9085
let pkg_src = PkgSrc {
9186
source_workspace: root.clone(),
@@ -99,16 +94,11 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
9994
tests: ~[],
10095
benchs: ~[]
10196
};
102-
pkg_src.build(&cx, cfgs, []);
97+
pkg_src.build(&cx, ~[], []);
10398
}
10499

105100
pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
106101
main: Path) {
107-
build_exe_with_cfgs(sysroot, root, name, version, main, ~[])
108-
}
109-
110-
pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
111-
version: Version, main: Path, cfgs: ~[~str]) {
112102
let cx = default_context(sysroot, root.clone());
113103
let pkg_src = PkgSrc {
114104
source_workspace: root.clone(),
@@ -123,7 +113,7 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
123113
benchs: ~[]
124114
};
125115

126-
pkg_src.build(&cx, cfgs, []);
116+
pkg_src.build(&cx, ~[], []);
127117
}
128118

129119
pub fn install_pkg(cx: &BuildContext,

branches/dist-snap/src/libstd/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ mod tests {
207207

208208
#[test]
209209
fn type_id_hash() {
210-
let (a, b) = (TypeId::of::<uint>(), TypeId::of::<uint>());
210+
let (a, b) = (TypeId::of::<uint>(), TypeId::of::<uint>::());
211211

212212
assert_eq!(a.hash(), b.hash());
213213
}

branches/dist-snap/src/libstd/io/buffered.rs

Lines changed: 81 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ use prelude::*;
5555

5656
use num;
5757
use vec;
58-
use super::{Stream, Decorator};
58+
use str;
59+
use super::{Reader, Writer, Stream, Decorator};
5960

6061
// libuv recommends 64k buffers to maximize throughput
6162
// https://groups.google.com/forum/#!topic/libuv/oQO1HJAIDdA
@@ -92,10 +93,45 @@ impl<R: Reader> BufferedReader<R> {
9293
pub fn new(inner: R) -> BufferedReader<R> {
9394
BufferedReader::with_capacity(DEFAULT_CAPACITY, inner)
9495
}
95-
}
9696

97-
impl<R: Reader> Buffer for BufferedReader<R> {
98-
fn fill<'a>(&'a mut self) -> &'a [u8] {
97+
/// Reads the next line of input, interpreted as a sequence of utf-8
98+
/// encoded unicode codepoints. If a newline is encountered, then the
99+
/// newline is contained in the returned string.
100+
pub fn read_line(&mut self) -> Option<~str> {
101+
self.read_until('\n' as u8).map(str::from_utf8_owned)
102+
}
103+
104+
/// Reads a sequence of bytes leading up to a specified delimeter. Once the
105+
/// specified byte is encountered, reading ceases and the bytes up to and
106+
/// including the delimiter are returned.
107+
pub fn read_until(&mut self, byte: u8) -> Option<~[u8]> {
108+
let mut res = ~[];
109+
let mut used;
110+
loop {
111+
{
112+
let available = self.fill_buffer();
113+
match available.iter().position(|&b| b == byte) {
114+
Some(i) => {
115+
res.push_all(available.slice_to(i + 1));
116+
used = i + 1;
117+
break
118+
}
119+
None => {
120+
res.push_all(available);
121+
used = available.len();
122+
}
123+
}
124+
}
125+
if used == 0 {
126+
break
127+
}
128+
self.pos += used;
129+
}
130+
self.pos += used;
131+
return if res.len() == 0 {None} else {Some(res)};
132+
}
133+
134+
fn fill_buffer<'a>(&'a mut self) -> &'a [u8] {
99135
if self.pos == self.cap {
100136
match self.inner.read(self.buf) {
101137
Some(cap) => {
@@ -107,17 +143,12 @@ impl<R: Reader> Buffer for BufferedReader<R> {
107143
}
108144
return self.buf.slice(self.pos, self.cap);
109145
}
110-
111-
fn consume(&mut self, amt: uint) {
112-
self.pos += amt;
113-
assert!(self.pos <= self.cap);
114-
}
115146
}
116147

117148
impl<R: Reader> Reader for BufferedReader<R> {
118149
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
119150
let nread = {
120-
let available = self.fill();
151+
let available = self.fill_buffer();
121152
if available.len() == 0 {
122153
return None;
123154
}
@@ -135,9 +166,17 @@ impl<R: Reader> Reader for BufferedReader<R> {
135166
}
136167

137168
impl<R: Reader> Decorator<R> for BufferedReader<R> {
138-
fn inner(self) -> R { self.inner }
139-
fn inner_ref<'a>(&'a self) -> &'a R { &self.inner }
140-
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut R { &mut self.inner }
169+
fn inner(self) -> R {
170+
self.inner
171+
}
172+
173+
fn inner_ref<'a>(&'a self) -> &'a R {
174+
&self.inner
175+
}
176+
177+
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut R {
178+
&mut self.inner
179+
}
141180
}
142181

143182
/// Wraps a Writer and buffers output to it
@@ -240,8 +279,13 @@ impl<W: Writer> Decorator<W> for LineBufferedWriter<W> {
240279
struct InternalBufferedWriter<W>(BufferedWriter<W>);
241280

242281
impl<W: Reader> Reader for InternalBufferedWriter<W> {
243-
fn read(&mut self, buf: &mut [u8]) -> Option<uint> { self.inner.read(buf) }
244-
fn eof(&mut self) -> bool { self.inner.eof() }
282+
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
283+
self.inner.read(buf)
284+
}
285+
286+
fn eof(&mut self) -> bool {
287+
self.inner.eof()
288+
}
245289
}
246290

247291
/// Wraps a Stream and buffers input and output to and from it
@@ -267,24 +311,35 @@ impl<S: Stream> BufferedStream<S> {
267311
}
268312
}
269313

270-
impl<S: Stream> Buffer for BufferedStream<S> {
271-
fn fill<'a>(&'a mut self) -> &'a [u8] { self.inner.fill() }
272-
fn consume(&mut self, amt: uint) { self.inner.consume(amt) }
273-
}
274-
275314
impl<S: Stream> Reader for BufferedStream<S> {
276-
fn read(&mut self, buf: &mut [u8]) -> Option<uint> { self.inner.read(buf) }
277-
fn eof(&mut self) -> bool { self.inner.eof() }
315+
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
316+
self.inner.read(buf)
317+
}
318+
319+
fn eof(&mut self) -> bool {
320+
self.inner.eof()
321+
}
278322
}
279323

280324
impl<S: Stream> Writer for BufferedStream<S> {
281-
fn write(&mut self, buf: &[u8]) { self.inner.inner.write(buf) }
282-
fn flush(&mut self) { self.inner.inner.flush() }
325+
fn write(&mut self, buf: &[u8]) {
326+
self.inner.inner.write(buf)
327+
}
328+
329+
fn flush(&mut self) {
330+
self.inner.inner.flush()
331+
}
283332
}
284333

285334
impl<S: Stream> Decorator<S> for BufferedStream<S> {
286-
fn inner(self) -> S { self.inner.inner.inner() }
287-
fn inner_ref<'a>(&'a self) -> &'a S { self.inner.inner.inner_ref() }
335+
fn inner(self) -> S {
336+
self.inner.inner.inner()
337+
}
338+
339+
fn inner_ref<'a>(&'a self) -> &'a S {
340+
self.inner.inner.inner_ref()
341+
}
342+
288343
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut S {
289344
self.inner.inner.inner_mut_ref()
290345
}

branches/dist-snap/src/libstd/io/mem.rs

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,29 @@ impl Reader for MemReader {
123123

124124
impl Seek for MemReader {
125125
fn tell(&self) -> u64 { self.pos as u64 }
126-
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
127-
}
128126

129-
impl Buffer for MemReader {
130-
fn fill<'a>(&'a mut self) -> &'a [u8] { self.buf.slice_from(self.pos) }
131-
fn consume(&mut self, amt: uint) { self.pos += amt; }
127+
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
132128
}
133129

134130
impl Decorator<~[u8]> for MemReader {
135-
fn inner(self) -> ~[u8] { self.buf }
136-
fn inner_ref<'a>(&'a self) -> &'a ~[u8] { &self.buf }
137-
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut ~[u8] { &mut self.buf }
131+
132+
fn inner(self) -> ~[u8] {
133+
match self {
134+
MemReader { buf: buf, _ } => buf
135+
}
136+
}
137+
138+
fn inner_ref<'a>(&'a self) -> &'a ~[u8] {
139+
match *self {
140+
MemReader { buf: ref buf, _ } => buf
141+
}
142+
}
143+
144+
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut ~[u8] {
145+
match *self {
146+
MemReader { buf: ref mut buf, _ } => buf
147+
}
148+
}
138149
}
139150

140151

@@ -233,11 +244,6 @@ impl<'self> Seek for BufReader<'self> {
233244
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
234245
}
235246

236-
impl<'self> Buffer for BufReader<'self> {
237-
fn fill<'a>(&'a mut self) -> &'a [u8] { self.buf.slice_from(self.pos) }
238-
fn consume(&mut self, amt: uint) { self.pos += amt; }
239-
}
240-
241247
///Calls a function with a MemWriter and returns
242248
///the writer's stored vector.
243249
pub fn with_mem_writer(writeFn:&fn(&mut MemWriter)) -> ~[u8] {
@@ -388,20 +394,4 @@ mod test {
388394
let buf = with_mem_writer(|wr| wr.write([1,2,3,4,5,6,7]));
389395
assert_eq!(buf, ~[1,2,3,4,5,6,7]);
390396
}
391-
392-
#[test]
393-
fn test_read_char() {
394-
let mut r = BufReader::new(bytes!("Việt"));
395-
assert_eq!(r.read_char(), Some('V'));
396-
assert_eq!(r.read_char(), Some('i'));
397-
assert_eq!(r.read_char(), Some('ệ'));
398-
assert_eq!(r.read_char(), Some('t'));
399-
assert_eq!(r.read_char(), None);
400-
}
401-
402-
#[test]
403-
fn test_read_bad_char() {
404-
let mut r = BufReader::new(bytes!(0x80));
405-
assert_eq!(r.read_char(), None);
406-
}
407397
}

0 commit comments

Comments
 (0)