Skip to content

Commit da69495

Browse files
committed
---
yaml --- r: 96140 b: refs/heads/dist-snap c: 727b70d h: refs/heads/master v: v3
1 parent 9647bf8 commit da69495

File tree

23 files changed

+387
-225
lines changed

23 files changed

+387
-225
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: b60b4114959a0f0bfa4c1099c5c1af9a35edeb45
9+
refs/heads/dist-snap: 727b70d6ae1c1daf36afa6addd8805b87cf31563
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ 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' ;
257258
dec_digit : '0' | nonzero_dec ;
258259
nonzero_dec: '1' | '2' | '3' | '4'
259260
| '5' | '6' | '7' | '8' | '9' ;
@@ -318,8 +319,9 @@ r##"foo #"# bar"##; // foo #"# bar
318319
~~~~ {.ebnf .gram}
319320
320321
num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ?
321-
| '0' [ [ dec_digit | '_' ] + num_suffix ?
322+
| '0' [ [ dec_digit | '_' ] * num_suffix ?
322323
| 'b' [ '1' | '0' | '_' ] + int_suffix ?
324+
| 'o' [ oct_digit | '_' ] + int_suffix ?
323325
| 'x' [ hex_digit | '_' ] + int_suffix ? ] ;
324326
325327
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/libextra/url.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ fn query_from_str(rawquery: &str) -> Query {
364364
return query;
365365
}
366366

367+
/**
368+
* Converts an instance of a URI `Query` type to a string.
369+
*
370+
* # Example
371+
*
372+
* ```rust
373+
* let query = ~[(~"title", ~"The Village"), (~"north", ~"52.91"), (~"west", ~"4.10")];
374+
* println(query_to_str(&query)); // title=The%20Village&north=52.91&west=4.10
375+
* ```
376+
*/
367377
pub fn query_to_str(query: &Query) -> ~str {
368378
let mut strvec = ~[];
369379
for kv in query.iter() {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
117117
ExprUnary(_, UnDeref, _) => { }
118118
ExprUnary(_, UnBox(_), _) | ExprUnary(_, UnUniq, _) => {
119119
sess.span_err(e.span,
120-
"disallowed operator in constant expression");
120+
"cannot do allocations in constant expressions");
121121
return;
122122
}
123123
ExprLit(@codemap::Spanned {node: lit_str(*), _}) => { }
@@ -191,7 +191,13 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
191191
e.span,
192192
"borrowed pointers in constants may only refer to \
193193
immutable values");
194-
}
194+
},
195+
ExprVstore(_, ExprVstoreUniq) |
196+
ExprVstore(_, ExprVstoreBox) |
197+
ExprVstore(_, ExprVstoreMutBox) => {
198+
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
199+
},
200+
195201
_ => {
196202
sess.span_err(e.span,
197203
"constant contains unimplemented expression type");

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -883,20 +883,23 @@ 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-
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);
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");
900903
}
901904
}
902905
_ => ()

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,13 @@ 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(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()));
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()));
871873
return;
872874
}
873875

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ 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]) {
8489
let cx = default_context(sysroot, root.clone());
8590
let pkg_src = PkgSrc {
8691
source_workspace: root.clone(),
@@ -94,11 +99,16 @@ pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
9499
tests: ~[],
95100
benchs: ~[]
96101
};
97-
pkg_src.build(&cx, ~[], []);
102+
pkg_src.build(&cx, cfgs, []);
98103
}
99104

100105
pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
101106
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]) {
102112
let cx = default_context(sysroot, root.clone());
103113
let pkg_src = PkgSrc {
104114
source_workspace: root.clone(),
@@ -113,7 +123,7 @@ pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
113123
benchs: ~[]
114124
};
115125

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

119129
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: 26 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ use prelude::*;
5555

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

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

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] {
97+
impl<R: Reader> Buffer for BufferedReader<R> {
98+
fn fill<'a>(&'a mut self) -> &'a [u8] {
13599
if self.pos == self.cap {
136100
match self.inner.read(self.buf) {
137101
Some(cap) => {
@@ -143,12 +107,17 @@ impl<R: Reader> BufferedReader<R> {
143107
}
144108
return self.buf.slice(self.pos, self.cap);
145109
}
110+
111+
fn consume(&mut self, amt: uint) {
112+
self.pos += amt;
113+
assert!(self.pos <= self.cap);
114+
}
146115
}
147116

148117
impl<R: Reader> Reader for BufferedReader<R> {
149118
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
150119
let nread = {
151-
let available = self.fill_buffer();
120+
let available = self.fill();
152121
if available.len() == 0 {
153122
return None;
154123
}
@@ -166,17 +135,9 @@ impl<R: Reader> Reader for BufferedReader<R> {
166135
}
167136

168137
impl<R: Reader> Decorator<R> for BufferedReader<R> {
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-
}
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 }
180141
}
181142

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

281242
impl<W: Reader> Reader for InternalBufferedWriter<W> {
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-
}
243+
fn read(&mut self, buf: &mut [u8]) -> Option<uint> { self.inner.read(buf) }
244+
fn eof(&mut self) -> bool { self.inner.eof() }
289245
}
290246

291247
/// Wraps a Stream and buffers input and output to and from it
@@ -311,35 +267,24 @@ impl<S: Stream> BufferedStream<S> {
311267
}
312268
}
313269

314-
impl<S: Stream> Reader for BufferedStream<S> {
315-
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
316-
self.inner.read(buf)
317-
}
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+
}
318274

319-
fn eof(&mut self) -> bool {
320-
self.inner.eof()
321-
}
275+
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() }
322278
}
323279

324280
impl<S: Stream> Writer for BufferedStream<S> {
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-
}
281+
fn write(&mut self, buf: &[u8]) { self.inner.inner.write(buf) }
282+
fn flush(&mut self) { self.inner.inner.flush() }
332283
}
333284

334285
impl<S: Stream> Decorator<S> for BufferedStream<S> {
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-
286+
fn inner(self) -> S { self.inner.inner.inner() }
287+
fn inner_ref<'a>(&'a self) -> &'a S { self.inner.inner.inner_ref() }
343288
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut S {
344289
self.inner.inner.inner_mut_ref()
345290
}

0 commit comments

Comments
 (0)