Skip to content

Commit a3ed110

Browse files
committed
---
yaml --- r: 120535 b: refs/heads/dist-snap c: 83eefa8 h: refs/heads/master i: 120533: ad8c73c 120531: ee66e32 120527: ac90058 v: v3
1 parent f0343e3 commit a3ed110

File tree

17 files changed

+169
-138
lines changed

17 files changed

+169
-138
lines changed

[refs]

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

branches/dist-snap/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ struct Foo { x: int, y: Box<int> }
944944
// `a` is the owner of the struct, and thus the owner of the struct's fields
945945
let a = Foo { x: 5, y: box 10 };
946946
}
947-
// when `a` goes out of scope, the destructor for the `~int` in the struct's
947+
// when `a` goes out of scope, the destructor for the `Box<int>` in the struct's
948948
// field is called
949949
950950
// `b` is mutable, and the mutability is inherited by the objects it owns

branches/dist-snap/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ pub struct RangeInclusive<A> {
20162016

20172017
/// Return an iterator over the range [start, stop]
20182018
#[inline]
2019-
pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One + ToPrimitive>(start: A, stop: A)
2019+
pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A)
20202020
-> RangeInclusive<A> {
20212021
RangeInclusive{range: range(start, stop), done: false}
20222022
}

branches/dist-snap/src/libflate/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ mod tests {
125125
for _ in range(0, 20) {
126126
let mut input = vec![];
127127
for _ in range(0, 2000) {
128-
input.push_all(r.choose(words.as_slice()).as_slice());
128+
input.push_all(r.choose(words.as_slice()).unwrap().as_slice());
129129
}
130130
debug!("de/inflate of {} bytes of random word-sequences",
131131
input.len());

branches/dist-snap/src/librand/lib.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -266,37 +266,39 @@ pub trait Rng {
266266
0123456789");
267267
let mut s = StrBuf::with_capacity(len);
268268
for _ in range(0, len) {
269-
s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char)
269+
s.push_char(*self.choose(GEN_ASCII_STR_CHARSET).unwrap() as char)
270270
}
271271
s
272272
}
273273

274-
/// Choose an item randomly, failing if `values` is empty.
275-
fn choose<T: Clone>(&mut self, values: &[T]) -> T {
276-
self.choose_option(values).expect("Rng.choose: `values` is empty").clone()
277-
}
278-
279-
/// Choose `Some(&item)` randomly, returning `None` if values is
280-
/// empty.
274+
/// Return a random element from `values`.
275+
///
276+
/// Return `None` if `values` is empty.
281277
///
282278
/// # Example
283279
///
284-
/// ```rust
280+
/// ```
285281
/// use rand::{task_rng, Rng};
286282
///
287283
/// let choices = [1, 2, 4, 8, 16, 32];
288284
/// let mut rng = task_rng();
289-
/// println!("{:?}", rng.choose_option(choices));
290-
/// println!("{:?}", rng.choose_option(choices.slice_to(0)));
285+
/// println!("{}", rng.choose(choices));
286+
/// assert_eq!(rng.choose(choices.slice_to(0)), None);
291287
/// ```
292-
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
288+
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
293289
if values.is_empty() {
294290
None
295291
} else {
296292
Some(&values[self.gen_range(0u, values.len())])
297293
}
298294
}
299295

296+
/// Deprecated name for `choose()`.
297+
#[deprecated = "replaced by .choose()"]
298+
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
299+
self.choose(values)
300+
}
301+
300302
/// Shuffle a mutable slice in place.
301303
///
302304
/// # Example
@@ -793,18 +795,10 @@ mod test {
793795
#[test]
794796
fn test_choose() {
795797
let mut r = task_rng();
796-
assert_eq!(r.choose([1, 1, 1]), 1);
797-
}
798+
assert_eq!(r.choose([1, 1, 1]).map(|&x|x), Some(1));
798799

799-
#[test]
800-
fn test_choose_option() {
801-
let mut r = task_rng();
802800
let v: &[int] = &[];
803-
assert!(r.choose_option(v).is_none());
804-
805-
let i = 1;
806-
let v = [1,1,1];
807-
assert_eq!(r.choose_option(v), Some(&i));
801+
assert_eq!(r.choose(v), None);
808802
}
809803

810804
#[test]

branches/dist-snap/src/librustc/driver/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct Options {
7070
pub gc: bool,
7171
pub optimize: OptLevel,
7272
pub debuginfo: DebugInfoLevel,
73-
pub lint_opts: Vec<(lint::Lint, lint::level)> ,
73+
pub lint_opts: Vec<(lint::Lint, lint::Level)> ,
7474
pub output_types: Vec<back::link::OutputType> ,
7575
// This was mutable for rustpkg, which updates search paths based on the
7676
// parsed code. It remains mutable in case its replacements wants to use
@@ -580,8 +580,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
580580
let no_trans = matches.opt_present("no-trans");
581581
let no_analysis = matches.opt_present("no-analysis");
582582

583-
let lint_levels = [lint::allow, lint::warn,
584-
lint::deny, lint::forbid];
583+
let lint_levels = [lint::Allow, lint::Warn,
584+
lint::Deny, lint::Forbid];
585585
let mut lint_opts = Vec::new();
586586
let lint_dict = lint::get_lint_dict();
587587
for level in lint_levels.iter() {

branches/dist-snap/src/librustc/driver/driver.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
226226
krate = time(time_passes, "prelude injection", krate, |krate|
227227
front::std_inject::maybe_inject_prelude(sess, krate));
228228

229-
let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
229+
let (krate, map) = time(time_passes, "assigning node ids and indexing ast", krate, |krate|
230230
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
231231

232232
if sess.opts.debugging_opts & config::AST_JSON != 0 {
@@ -653,11 +653,22 @@ pub fn pretty_print_input(sess: Session,
653653
PpmFlowGraph(nodeid) => {
654654
let ast_map = ast_map.expect("--pretty flowgraph missing ast_map");
655655
let node = ast_map.find(nodeid).unwrap_or_else(|| {
656-
fail!("--pretty flowgraph=id couldn't find id: {}", id)
656+
sess.fatal(format_strbuf!("--pretty flowgraph couldn't find id: {}",
657+
nodeid).as_slice())
657658
});
658659
let block = match node {
659660
syntax::ast_map::NodeBlock(block) => block,
660-
_ => fail!("--pretty=flowgraph needs block, got {:?}", node)
661+
_ => {
662+
let message = format_strbuf!("--pretty=flowgraph needs block, got {:?}",
663+
node);
664+
665+
// point to what was found, if there's an
666+
// accessible span.
667+
match ast_map.opt_span(nodeid) {
668+
Some(sp) => sess.span_fatal(sp, message.as_slice()),
669+
None => sess.fatal(message.as_slice())
670+
}
671+
}
661672
};
662673
let analysis = phase_3_run_analysis_passes(sess, &krate, ast_map);
663674
print_flowgraph(analysis, block, out)
@@ -846,4 +857,3 @@ pub fn build_output_filenames(input: &Input,
846857
}
847858
}
848859
}
849-

branches/dist-snap/src/librustc/driver/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,12 @@ pub fn parse_pretty(sess: &Session, name: &str) -> PpMode {
302302
(None, "typed") => PpmTyped,
303303
(None, "expanded,identified") => PpmExpandedIdentified,
304304
(None, "identified") => PpmIdentified,
305-
(Some(s), "flowgraph") => {
306-
match from_str(s) {
305+
(arg, "flowgraph") => {
306+
match arg.and_then(from_str) {
307307
Some(id) => PpmFlowGraph(id),
308-
None => sess.fatal(format!("`pretty flowgraph=<nodeid>` needs \
309-
an integer <nodeid>; got {}", s))
308+
None => sess.fatal(format_strbuf!("`pretty flowgraph=<nodeid>` needs \
309+
an integer <nodeid>; got {}",
310+
arg.unwrap_or("nothing")).as_slice())
310311
}
311312
}
312313
_ => {

branches/dist-snap/src/librustc/front/std_inject.rs

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use syntax::parse::token::InternedString;
2222
use syntax::parse::token;
2323
use syntax::util::small_vector::SmallVector;
2424

25+
use std::mem;
26+
2527
pub static VERSION: &'static str = "0.11.0-pre";
2628

2729
pub fn maybe_inject_crates_ref(sess: &Session, krate: ast::Crate)
@@ -70,13 +72,13 @@ pub fn with_version(krate: &str) -> Option<(InternedString, ast::StrStyle)> {
7072
}
7173

7274
impl<'a> fold::Folder for StandardLibraryInjector<'a> {
73-
fn fold_crate(&mut self, krate: ast::Crate) -> ast::Crate {
75+
fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
7476
let mut vis = vec!(ast::ViewItem {
7577
node: ast::ViewItemExternCrate(token::str_to_ident("std"),
7678
with_version("std"),
7779
ast::DUMMY_NODE_ID),
7880
attrs: vec!(
79-
attr::mk_attr(attr::mk_list_item(
81+
attr::mk_attr_outer(attr::mk_list_item(
8082
InternedString::new("phase"),
8183
vec!(
8284
attr::mk_word_item(InternedString::new("syntax")),
@@ -101,16 +103,20 @@ impl<'a> fold::Folder for StandardLibraryInjector<'a> {
101103
}
102104

103105
// `extern crate` must be precede `use` items
104-
vis.push_all_move(krate.module.view_items.clone());
105-
let new_module = ast::Mod {
106-
view_items: vis,
107-
..krate.module.clone()
108-
};
106+
mem::swap(&mut vis, &mut krate.module.view_items);
107+
krate.module.view_items.push_all_move(vis);
109108

110-
ast::Crate {
111-
module: new_module,
112-
..krate
113-
}
109+
// don't add #![no_std] here, that will block the prelude injection later.
110+
// Add it during the prelude injection instead.
111+
112+
// Add #![feature(phase)] here, because we use #[phase] on extern crate std.
113+
let feat_phase_attr = attr::mk_attr_inner(attr::mk_list_item(
114+
InternedString::new("feature"),
115+
vec![attr::mk_word_item(InternedString::new("phase"))],
116+
));
117+
krate.attrs.push(feat_phase_attr);
118+
119+
krate
114120
}
115121
}
116122

@@ -127,29 +133,29 @@ struct PreludeInjector<'a> {
127133

128134

129135
impl<'a> fold::Folder for PreludeInjector<'a> {
130-
fn fold_crate(&mut self, krate: ast::Crate) -> ast::Crate {
136+
fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
137+
// Add #![no_std] here, so we don't re-inject when compiling pretty-printed source.
138+
// This must happen here and not in StandardLibraryInjector because this
139+
// fold happens second.
140+
141+
let no_std_attr = attr::mk_attr_inner(attr::mk_word_item(InternedString::new("no_std")));
142+
krate.attrs.push(no_std_attr);
143+
131144
if !no_prelude(krate.attrs.as_slice()) {
132145
// only add `use std::prelude::*;` if there wasn't a
133146
// `#![no_implicit_prelude]` at the crate level.
134147

135-
let mut attrs = krate.attrs.clone();
136-
137148
// fold_mod() will insert glob path.
138-
let globs_attr = attr::mk_attr(attr::mk_list_item(
149+
let globs_attr = attr::mk_attr_inner(attr::mk_list_item(
139150
InternedString::new("feature"),
140151
vec!(
141152
attr::mk_word_item(InternedString::new("globs")),
142153
)));
143-
attrs.push(globs_attr);
154+
krate.attrs.push(globs_attr);
144155

145-
ast::Crate {
146-
module: self.fold_mod(&krate.module),
147-
attrs: attrs,
148-
..krate
149-
}
150-
} else {
151-
krate
156+
krate.module = self.fold_mod(&krate.module);
152157
}
158+
krate
153159
}
154160

155161
fn fold_item(&mut self, item: @ast::Item) -> SmallVector<@ast::Item> {

branches/dist-snap/src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
341341
// This attribute tells resolve to let us call unexported functions
342342
let resolve_unexported_str = InternedString::new("!resolve_unexported");
343343
let resolve_unexported_attr =
344-
attr::mk_attr(attr::mk_word_item(resolve_unexported_str));
344+
attr::mk_attr_inner(attr::mk_word_item(resolve_unexported_str));
345345

346346
let item = ast::Item {
347347
ident: token::str_to_ident("__test"),

branches/dist-snap/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext,
14361436
fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute {
14371437
assert!(!ecx.link_meta.crateid.name.is_empty());
14381438

1439-
attr::mk_attr(
1439+
attr::mk_attr_inner(
14401440
attr::mk_name_value_item_str(
14411441
InternedString::new("crate_id"),
14421442
token::intern_and_get_ident(ecx.link_meta.crateid.to_str())))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// closely. The idea is that all reachable symbols are live, codes called
1313
// from live codes are live, and everything else is dead.
1414

15-
use middle::lint::{allow, contains_lint, DeadCode};
15+
use middle::lint::{Allow, contains_lint, DeadCode};
1616
use middle::privacy;
1717
use middle::ty;
1818
use middle::typeck;
@@ -195,7 +195,7 @@ impl<'a> Visitor<()> for MarkSymbolVisitor<'a> {
195195
}
196196

197197
fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
198-
contains_lint(attrs, allow, DEAD_CODE_LINT_STR)
198+
contains_lint(attrs, Allow, DEAD_CODE_LINT_STR)
199199
|| attr::contains_name(attrs.as_slice(), "lang")
200200
}
201201

0 commit comments

Comments
 (0)