Skip to content

Commit c34d0c2

Browse files
committed
---
yaml --- r: 151157 b: refs/heads/try2 c: 4e55bc7 h: refs/heads/master i: 151155: 7bc310c v: v3
1 parent 840461a commit c34d0c2

File tree

25 files changed

+298
-240
lines changed

25 files changed

+298
-240
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: 405861ed0a87ca67e34882d8c444c4cb2f34ab7c
8+
refs/heads/try2: 4e55bc7ac353b6968995f6464ac27d0aba6cf7e0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/complement-lang-faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Some examples that demonstrate different aspects of the language:
2222

2323
[sprocketnes]: https://github.com/pcwalton/sprocketnes
2424
[hash]: https://github.com/mozilla/rust/blob/master/src/libstd/hash.rs
25-
[HashMap]: https://github.com/mozilla/rust/blob/master/src/libstd/hashmap.rs
26-
[json]: https://github.com/mozilla/rust/blob/master/src/libextra/json.rs
25+
[HashMap]: https://github.com/mozilla/rust/blob/master/src/libcollections/hashmap.rs
26+
[json]: https://github.com/mozilla/rust/blob/master/src/libserialize/json.rs
2727

2828
You may also be interested in browsing [GitHub's Rust][github-rust] page.
2929

branches/try2/src/doc/tutorial.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,11 +1793,6 @@ spawn(proc() {
17931793
});
17941794
~~~~
17951795
1796-
> *Note:* If you want to see the output of `debug!` statements, you will need to turn on
1797-
> `debug!` logging. To enable `debug!` logging, set the RUST_LOG environment
1798-
> variable to the name of your crate, which, for a file named `foo.rs`, will be
1799-
> `foo` (e.g., with bash, `export RUST_LOG=foo`).
1800-
18011796
## Closure compatibility
18021797
18031798
Rust closures have a convenient subtyping property: you can pass any kind of

branches/try2/src/libnum/bigint.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ impl Sub<BigUint, BigUint> for BigUint {
230230
lo
231231
}).collect();
232232

233-
assert_eq!(borrow, 0); // <=> assert!((self >= other));
233+
assert!(borrow == 0,
234+
"Cannot subtract other from self because other is larger than self.");
234235
return BigUint::new(diff);
235236
}
236237
}
@@ -1755,6 +1756,13 @@ mod biguint_tests {
17551756
}
17561757
}
17571758

1759+
#[test]
1760+
#[should_fail]
1761+
fn test_sub_fail_on_underflow() {
1762+
let (a, b) : (BigUint, BigUint) = (Zero::zero(), One::one());
1763+
a - b;
1764+
}
1765+
17581766
static mul_triples: &'static [(&'static [BigDigit],
17591767
&'static [BigDigit],
17601768
&'static [BigDigit])] = &[

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,14 @@ impl<'a> Visitor<()> for Context<'a> {
130130

131131
fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) {
132132
match i.node {
133-
ast::ViewItemUse(ref paths) => {
134-
for path in paths.iter() {
135-
match path.node {
136-
ast::ViewPathGlob(..) => {
137-
self.gate_feature("globs", path.span,
138-
"glob import statements are \
139-
experimental and possibly buggy");
140-
}
141-
_ => {}
133+
ast::ViewItemUse(ref path) => {
134+
match path.node {
135+
ast::ViewPathGlob(..) => {
136+
self.gate_feature("globs", path.span,
137+
"glob import statements are \
138+
experimental and possibly buggy");
142139
}
140+
_ => {}
143141
}
144142
}
145143
ast::ViewItemExternCrate(..) => {

branches/try2/src/librustc/front/std_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
166166

167167
let vp = @codemap::dummy_spanned(ast::ViewPathGlob(prelude_path, ast::DUMMY_NODE_ID));
168168
let vi2 = ast::ViewItem {
169-
node: ast::ViewItemUse(vec!(vp)),
169+
node: ast::ViewItemUse(vp),
170170
attrs: Vec::new(),
171171
vis: ast::Inherited,
172172
span: DUMMY_SP,

branches/try2/src/librustc/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
299299
let id_test = token::str_to_ident("test");
300300
let (vi, vis) = if cx.is_test_crate {
301301
(ast::ViewItemUse(
302-
vec!(@nospan(ast::ViewPathSimple(id_test,
303-
path_node(vec!(id_test)),
304-
ast::DUMMY_NODE_ID)))),
302+
@nospan(ast::ViewPathSimple(id_test,
303+
path_node(vec!(id_test)),
304+
ast::DUMMY_NODE_ID))),
305305
ast::Public)
306306
} else {
307307
(ast::ViewItemExternCrate(id_test,

branches/try2/src/librustc/middle/privacy.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -872,26 +872,24 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
872872
fn visit_view_item(&mut self, a: &ast::ViewItem, _: ()) {
873873
match a.node {
874874
ast::ViewItemExternCrate(..) => {}
875-
ast::ViewItemUse(ref uses) => {
876-
for vpath in uses.iter() {
877-
match vpath.node {
878-
ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {}
879-
ast::ViewPathList(_, ref list, _) => {
880-
for pid in list.iter() {
881-
debug!("privacy - list {}", pid.node.id);
882-
let seg = ast::PathSegment {
883-
identifier: pid.node.name,
884-
lifetimes: Vec::new(),
885-
types: OwnedSlice::empty(),
886-
};
887-
let segs = vec!(seg);
888-
let path = ast::Path {
889-
global: false,
890-
span: pid.span,
891-
segments: segs,
892-
};
893-
self.check_path(pid.span, pid.node.id, &path);
894-
}
875+
ast::ViewItemUse(ref vpath) => {
876+
match vpath.node {
877+
ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {}
878+
ast::ViewPathList(_, ref list, _) => {
879+
for pid in list.iter() {
880+
debug!("privacy - list {}", pid.node.id);
881+
let seg = ast::PathSegment {
882+
identifier: pid.node.name,
883+
lifetimes: Vec::new(),
884+
types: OwnedSlice::empty(),
885+
};
886+
let segs = vec!(seg);
887+
let path = ast::Path {
888+
global: false,
889+
span: pid.span,
890+
segments: segs,
891+
};
892+
self.check_path(pid.span, pid.node.id, &path);
895893
}
896894
}
897895
}

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 71 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,72 +1417,70 @@ impl<'a> Resolver<'a> {
14171417
fn build_reduced_graph_for_view_item(&mut self, view_item: &ViewItem,
14181418
parent: ReducedGraphParent) {
14191419
match view_item.node {
1420-
ViewItemUse(ref view_paths) => {
1421-
for view_path in view_paths.iter() {
1422-
// Extract and intern the module part of the path. For
1423-
// globs and lists, the path is found directly in the AST;
1424-
// for simple paths we have to munge the path a little.
1425-
1426-
let mut module_path = Vec::new();
1427-
match view_path.node {
1428-
ViewPathSimple(_, ref full_path, _) => {
1429-
let path_len = full_path.segments.len();
1430-
assert!(path_len != 0);
1431-
1432-
for (i, segment) in full_path.segments
1433-
.iter()
1434-
.enumerate() {
1435-
if i != path_len - 1 {
1436-
module_path.push(segment.identifier)
1437-
}
1438-
}
1439-
}
1440-
1441-
ViewPathGlob(ref module_ident_path, _) |
1442-
ViewPathList(ref module_ident_path, _, _) => {
1443-
for segment in module_ident_path.segments.iter() {
1420+
ViewItemUse(ref view_path) => {
1421+
// Extract and intern the module part of the path. For
1422+
// globs and lists, the path is found directly in the AST;
1423+
// for simple paths we have to munge the path a little.
1424+
1425+
let mut module_path = Vec::new();
1426+
match view_path.node {
1427+
ViewPathSimple(_, ref full_path, _) => {
1428+
let path_len = full_path.segments.len();
1429+
assert!(path_len != 0);
1430+
1431+
for (i, segment) in full_path.segments
1432+
.iter()
1433+
.enumerate() {
1434+
if i != path_len - 1 {
14441435
module_path.push(segment.identifier)
14451436
}
14461437
}
14471438
}
14481439

1449-
// Build up the import directives.
1450-
let module_ = parent.module();
1451-
let is_public = view_item.vis == ast::Public;
1452-
match view_path.node {
1453-
ViewPathSimple(binding, ref full_path, id) => {
1454-
let source_ident =
1455-
full_path.segments.last().unwrap().identifier;
1456-
let subclass = SingleImport(binding,
1457-
source_ident);
1458-
self.build_import_directive(&*module_,
1459-
module_path,
1460-
subclass,
1461-
view_path.span,
1462-
id,
1463-
is_public);
1440+
ViewPathGlob(ref module_ident_path, _) |
1441+
ViewPathList(ref module_ident_path, _, _) => {
1442+
for segment in module_ident_path.segments.iter() {
1443+
module_path.push(segment.identifier)
14641444
}
1465-
ViewPathList(_, ref source_idents, _) => {
1466-
for source_ident in source_idents.iter() {
1467-
let name = source_ident.node.name;
1468-
self.build_import_directive(
1469-
&*module_,
1470-
module_path.clone(),
1471-
SingleImport(name, name),
1472-
source_ident.span,
1473-
source_ident.node.id,
1474-
is_public);
1475-
}
1476-
}
1477-
ViewPathGlob(_, id) => {
1478-
self.build_import_directive(&*module_,
1479-
module_path,
1480-
GlobImport,
1481-
view_path.span,
1482-
id,
1483-
is_public);
1445+
}
1446+
}
1447+
1448+
// Build up the import directives.
1449+
let module_ = parent.module();
1450+
let is_public = view_item.vis == ast::Public;
1451+
match view_path.node {
1452+
ViewPathSimple(binding, ref full_path, id) => {
1453+
let source_ident =
1454+
full_path.segments.last().unwrap().identifier;
1455+
let subclass = SingleImport(binding,
1456+
source_ident);
1457+
self.build_import_directive(&*module_,
1458+
module_path,
1459+
subclass,
1460+
view_path.span,
1461+
id,
1462+
is_public);
1463+
}
1464+
ViewPathList(_, ref source_idents, _) => {
1465+
for source_ident in source_idents.iter() {
1466+
let name = source_ident.node.name;
1467+
self.build_import_directive(
1468+
&*module_,
1469+
module_path.clone(),
1470+
SingleImport(name, name),
1471+
source_ident.span,
1472+
source_ident.node.id,
1473+
is_public);
14841474
}
14851475
}
1476+
ViewPathGlob(_, id) => {
1477+
self.build_import_directive(&*module_,
1478+
module_path,
1479+
GlobImport,
1480+
view_path.span,
1481+
id,
1482+
is_public);
1483+
}
14861484
}
14871485
}
14881486

@@ -5226,23 +5224,21 @@ impl<'a> Resolver<'a> {
52265224

52275225
match vi.node {
52285226
ViewItemExternCrate(..) => {} // ignore
5229-
ViewItemUse(ref path) => {
5230-
for p in path.iter() {
5231-
match p.node {
5232-
ViewPathSimple(_, _, id) => self.finalize_import(id, p.span),
5233-
ViewPathList(_, ref list, _) => {
5234-
for i in list.iter() {
5235-
self.finalize_import(i.node.id, i.span);
5236-
}
5237-
},
5238-
ViewPathGlob(_, id) => {
5239-
if !self.used_imports.contains(&(id, TypeNS)) &&
5240-
!self.used_imports.contains(&(id, ValueNS)) {
5241-
self.session.add_lint(UnusedImports, id, p.span,
5242-
"unused import".to_owned());
5243-
}
5244-
},
5245-
}
5227+
ViewItemUse(ref p) => {
5228+
match p.node {
5229+
ViewPathSimple(_, _, id) => self.finalize_import(id, p.span),
5230+
ViewPathList(_, ref list, _) => {
5231+
for i in list.iter() {
5232+
self.finalize_import(i.node.id, i.span);
5233+
}
5234+
},
5235+
ViewPathGlob(_, id) => {
5236+
if !self.used_imports.contains(&(id, TypeNS)) &&
5237+
!self.used_imports.contains(&(id, ValueNS)) {
5238+
self.session.add_lint(UnusedImports, id, p.span,
5239+
"unused import".to_owned());
5240+
}
5241+
},
52465242
}
52475243
}
52485244
}

branches/try2/src/librustdoc/clean.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ use core;
3232
use doctree;
3333
use visit_ast;
3434

35+
/// A stable identifier to the particular version of JSON output.
36+
/// Increment this when the `Crate` and related structures change.
37+
pub static SCHEMA_VERSION: &'static str = "0.8.2";
38+
3539
pub trait Clean<T> {
3640
fn clean(&self) -> T;
3741
}
@@ -1085,7 +1089,7 @@ impl Clean<Item> for ast::ViewItem {
10851089
#[deriving(Clone, Encodable, Decodable)]
10861090
pub enum ViewItemInner {
10871091
ExternCrate(~str, Option<~str>, ast::NodeId),
1088-
Import(Vec<ViewPath>)
1092+
Import(ViewPath)
10891093
}
10901094

10911095
impl Clean<ViewItemInner> for ast::ViewItem_ {
@@ -1099,7 +1103,7 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
10991103
ExternCrate(i.clean(), string, *id)
11001104
}
11011105
&ast::ViewItemUse(ref vp) => {
1102-
Import(vp.clean().move_iter().collect())
1106+
Import(vp.clean())
11031107
}
11041108
}
11051109
}

branches/try2/src/librustdoc/html/render.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,12 +1167,10 @@ fn item_module(w: &mut Writer, cx: &Context,
11671167
try!(write!(w, ";</code></td></tr>"));
11681168
}
11691169

1170-
clean::Import(ref imports) => {
1171-
for import in imports.iter() {
1172-
try!(write!(w, "<tr><td><code>{}{}</code></td></tr>",
1173-
VisSpace(myitem.visibility),
1174-
*import));
1175-
}
1170+
clean::Import(ref import) => {
1171+
try!(write!(w, "<tr><td><code>{}{}</code></td></tr>",
1172+
VisSpace(myitem.visibility),
1173+
*import));
11761174
}
11771175
}
11781176

branches/try2/src/librustdoc/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ use std::io::{File, MemWriter};
3434
use std::str;
3535
use serialize::{json, Decodable, Encodable};
3636

37+
// reexported from `clean` so it can be easily updated with the mod itself
38+
pub use clean::SCHEMA_VERSION;
39+
3740
pub mod clean;
3841
pub mod core;
3942
pub mod doctree;
@@ -55,8 +58,6 @@ pub mod visit_ast;
5558
pub mod test;
5659
mod flock;
5760

58-
pub static SCHEMA_VERSION: &'static str = "0.8.1";
59-
6061
type Pass = (&'static str, // name
6162
fn(clean::Crate) -> plugins::PluginResult, // fn
6263
&'static str); // description

branches/try2/src/librustdoc/visit_ast.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,12 @@ impl<'a> RustdocVisitor<'a> {
133133
return om.view_items.push(item.clone());
134134
}
135135
let item = match item.node {
136-
ast::ViewItemUse(ref paths) => {
137-
// rustc no longer supports "use foo, bar;"
138-
assert_eq!(paths.len(), 1);
139-
match self.visit_view_path(*paths.get(0), om) {
136+
ast::ViewItemUse(ref vpath) => {
137+
match self.visit_view_path(*vpath, om) {
140138
None => return,
141139
Some(path) => {
142140
ast::ViewItem {
143-
node: ast::ViewItemUse(vec!(path)),
141+
node: ast::ViewItemUse(path),
144142
.. item.clone()
145143
}
146144
}

0 commit comments

Comments
 (0)