Skip to content

Commit 4c743fe

Browse files
committed
---
yaml --- r: 96142 b: refs/heads/dist-snap c: 8eda5d8 h: refs/heads/master v: v3
1 parent 39b4cc2 commit 4c743fe

28 files changed

+678
-240
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: dab8fec4af85c94b65d7036129f89a7e7bf6cbac
9+
refs/heads/dist-snap: 8eda5d831591e608b7de2910469a73d1dc02da42
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/librustpkg/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Context data structure used by rustpkg
1212

1313
use extra::workcache;
14-
use rustc::driver::session::{OptLevel, No};
14+
use rustc::driver::session;
1515

1616
use std::hashmap::HashSet;
1717

@@ -88,7 +88,7 @@ pub struct RustcFlags {
8888
// Extra arguments to pass to rustc with the --link-args flag
8989
link_args: Option<~str>,
9090
// Optimization level. 0 = default. -O = 2.
91-
optimization_level: OptLevel,
91+
optimization_level: session::OptLevel,
9292
// True if the user passed in --save-temps
9393
save_temps: bool,
9494
// Target (defaults to rustc's default target)
@@ -224,7 +224,7 @@ impl RustcFlags {
224224
linker: None,
225225
link_args: None,
226226
compile_upto: Nothing,
227-
optimization_level: No,
227+
optimization_level: session::Default,
228228
save_temps: false,
229229
target: None,
230230
target_cpu: None,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use workcache_support::{digest_only_date, digest_file_with_date, crate_tag};
2828
use extra::workcache;
2929
use extra::treemap::TreeMap;
3030

31+
use rustc::driver::session;
32+
3133
// An enumeration of the unpacked source of a package workspace.
3234
// This contains a list of files found in the source workspace.
3335
#[deriving(Clone)]
@@ -425,6 +427,7 @@ impl PkgSrc {
425427
}
426428
debug!("Compiling crate {}; its output will be in {}",
427429
subpath.display(), sub_dir.display());
430+
let opt: session::OptLevel = subcx.context.rustc_flags.optimization_level;
428431
let result = compile_crate(&subcx,
429432
exec,
430433
&id,
@@ -433,7 +436,7 @@ impl PkgSrc {
433436
&mut (sub_deps.clone()),
434437
sub_flags,
435438
subcfgs,
436-
false,
439+
opt,
437440
what);
438441
// XXX: result is an Option<Path>. The following code did not take that
439442
// into account. I'm not sure if the workcache really likes seeing the

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub fn compile_input(context: &BuildContext,
175175
deps: &mut DepMap,
176176
flags: &[~str],
177177
cfgs: &[~str],
178-
opt: bool,
178+
opt: session::OptLevel,
179179
what: OutputType) -> Option<Path> {
180180
assert!(in_file.component_iter().nth(1).is_some());
181181
let input = driver::file_input(in_file.clone());
@@ -241,7 +241,7 @@ pub fn compile_input(context: &BuildContext,
241241

242242
let options = @session::options {
243243
crate_type: crate_type,
244-
optimize: if opt { session::Aggressive } else { session::No },
244+
optimize: opt,
245245
test: what == Test || what == Bench,
246246
maybe_sysroot: Some(sysroot_to_use),
247247
addl_lib_search_paths: @mut context.additional_library_paths(),
@@ -408,7 +408,7 @@ pub fn compile_crate(ctxt: &BuildContext,
408408
deps: &mut DepMap,
409409
flags: &[~str],
410410
cfgs: &[~str],
411-
opt: bool,
411+
opt: session::OptLevel,
412412
what: OutputType) -> Option<Path> {
413413
debug!("compile_crate: crate={}, workspace={}", crate.display(), workspace.display());
414414
debug!("compile_crate: short_name = {}, flags =...", pkg_id.to_str());

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/cast.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
2525
dest
2626
}
2727

28-
/**
29-
* Forces a copy of a value, even if that value is considered noncopyable.
30-
*/
31-
#[inline]
32-
pub unsafe fn unsafe_copy<T>(thing: &T) -> T {
33-
transmute_copy(thing)
34-
}
35-
3628
/**
3729
* Move a thing into the void
3830
*

0 commit comments

Comments
 (0)