diff --git a/.gitignore b/.gitignore index c7e83518db3f8..ac7c20db8cd6b 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,10 @@ src/.DS_Store /doc/latex /doc/std /doc/extra +/doc/green +/doc/native +/doc/rustc +/doc/syntax /nd/ /llvm/ version.md diff --git a/.gitmodules b/.gitmodules index 76bdab1e64210..43169be195068 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "src/llvm"] path = src/llvm - url = https://github.com/alexcrichton/llvm.git + url = https://github.com/luqmana/llvm.git branch = master [submodule "src/libuv"] path = src/libuv diff --git a/doc/rust.md b/doc/rust.md index 48a1ea6f6539d..7d32959c4d2f4 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -610,12 +610,12 @@ the behavior of the compiler. ~~~~ // Package ID -#[ pkgid = "projx#2.5" ]; +#[ crate_id = "projx#2.5" ]; // Additional metadata attributes #[ desc = "Project X" ]; #[ license = "BSD" ]; -#[ author = "Jane Doe" ]; +#[ comment = "This is a comment on Project X." ]; // Specify the output type #[ crate_type = "lib" ]; @@ -776,9 +776,9 @@ as the `ident` provided in the `extern_mod_decl`. The external crate is resolved to a specific `soname` at compile time, and a runtime linkage requirement to that `soname` is passed to the linker for loading at runtime. The `soname` is resolved at compile time by scanning the -compiler's library path and matching the optional `pkgid` provided as a string literal -against the `pkgid` attributes that were declared on the external crate when -it was compiled. If no `pkgid` is provided, a default `name` attribute is +compiler's library path and matching the optional `crateid` provided as a string literal +against the `crateid` attributes that were declared on the external crate when +it was compiled. If no `crateid` is provided, a default `name` attribute is assumed, equal to the `ident` given in the `extern_mod_decl`. Four examples of `extern mod` declarations: @@ -1729,7 +1729,7 @@ names are effectively reserved. Some significant attributes include: * The `cfg` attribute, for conditional-compilation by build-configuration. * The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)). * The `link` attribute, for describing linkage metadata for a extern blocks. -* The `pkgid` attribute, for describing the package ID of a crate. +* The `crate_id` attribute, for describing the package ID of a crate. * The `test` attribute, for marking functions as unit tests. * The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks (see [Lint check attributes](#lint-check-attributes)). @@ -3792,7 +3792,7 @@ specified then log level 4 is assumed. Debug messages can be omitted by passing `--cfg ndebug` to `rustc`. As an example, to see all the logs generated by the compiler, you would set -`RUST_LOG` to `rustc`, which is the crate name (as specified in its `pkgid` +`RUST_LOG` to `rustc`, which is the crate name (as specified in its `crate_id` [attribute](#attributes)). To narrow down the logs to just crate resolution, you would set it to `rustc::metadata::creader`. To see just error logging use `rustc=0`. diff --git a/doc/rustdoc.md b/doc/rustdoc.md index 39fc03bca0d1e..ea87077b1196b 100644 --- a/doc/rustdoc.md +++ b/doc/rustdoc.md @@ -13,7 +13,7 @@ comments": ~~~ // the "link" crate attribute is currently required for rustdoc, but normally // isn't needed. -#[pkgid = "universe"]; +#[crate_id = "universe"]; #[crate_type="lib"]; //! Tools for dealing with universes (this is a doc comment, and is shown on @@ -132,9 +132,10 @@ specifiers that can be used to dictate how a code block is tested: ~~~ Rustdoc also supplies some extra sugar for helping with some tedious -documentation examples. If a line is prefixed with a `#` character, then the -line will not show up in the HTML documentation, but it will be used when -testing the code block. +documentation examples. If a line is prefixed with `# `, then the line +will not show up in the HTML documentation, but it will be used when +testing the code block (NB. the space after the `#` is required, so +that one can still write things like `#[deriving(Eq)]`). ~~~ ```rust diff --git a/doc/rustpkg.md b/doc/rustpkg.md index ff413ec1f1b57..f36cbe7153cfe 100644 --- a/doc/rustpkg.md +++ b/doc/rustpkg.md @@ -90,7 +90,7 @@ then both `bar` and `bar/extras/baz` are valid package identifiers in the workspace `foo`. Because rustpkg uses generic source file names as the main inputs, you will -need to specify the package identifier in them using the `pkgid` attribute +need to specify the package identifier in them using the `crate_id` attribute on the crate. ## Source files diff --git a/mk/docs.mk b/mk/docs.mk index 1e6cd063b85d0..add5f8c07ed8a 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -13,6 +13,7 @@ ###################################################################### DOCS := +CDOCS := DOCS_L10N := BASE_DOC_OPTS := --from=markdown --standalone --toc --number-sections @@ -232,8 +233,21 @@ doc/$(1)/index.html: $$(RUSTDOC) $$(TLIB2_T_$(3)_H_$(3))/$(CFG_STDLIB_$(3)) DOCS += doc/$(1)/index.html endef +define compiledoc +doc/$(1)/index.html: $$(RUSTDOC) $$(TLIB2_T_$(3)_H_$(3))/$(CFG_STDLIB_$(3)) + @$$(call E, rustdoc: $$@) + $(Q)$(RUSTDOC) --cfg stage2 $(2) + +CDOCS += doc/$(1)/index.html +endef + $(eval $(call libdoc,std,$(STDLIB_CRATE),$(CFG_BUILD))) $(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD))) +$(eval $(call libdoc,native,$(LIBNATIVE_CRATE),$(CFG_BUILD))) +$(eval $(call libdoc,green,$(LIBGREEN_CRATE),$(CFG_BUILD))) + +$(eval $(call compiledoc,rustc,$(COMPILER_CRATE),$(CFG_BUILD))) +$(eval $(call compiledoc,syntax,$(LIBSYNTAX_CRATE),$(CFG_BUILD))) ifdef CFG_DISABLE_DOCS @@ -256,6 +270,7 @@ doc/version_info.html: version_info.html.template $(MKFILE_DEPS) \ GENERATED += doc/version.md doc/version_info.html docs: $(DOCS) +compiler-docs: $(CDOCS) docs-l10n: $(DOCS_L10N) diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index aaba80aa44640..e87187abbcbf4 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -45,7 +45,7 @@ def scrub(b): """ // AUTO-GENERATED FILE: DO NOT EDIT #[crate_id=\"run_pass_stage2#0.1\"]; -#[pkgid=\"run_pass_stage2#0.1\"]; +#[crate_id=\"run_pass_stage2#0.1\"]; #[feature(globs, macro_rules, struct_variant, managed_boxes)]; #[allow(warnings)]; """ diff --git a/src/libextra/btree.rs b/src/libextra/btree.rs index 0f9eba2e9dcd4..bbb62bc06098e 100644 --- a/src/libextra/btree.rs +++ b/src/libextra/btree.rs @@ -14,8 +14,10 @@ //! Starting implementation of a btree for rust. //! Structure inspired by github user davidhalperin's gist. + +#[allow(attribute_usage)]; +#[feature(globs)]; #[allow(dead_code)]; -use std::util::replace; ///A B-tree contains a root node (which contains a vector of elements), ///a length (the height of the tree), and lower and upper bounds on the @@ -33,7 +35,7 @@ pub struct BTree { //especially during insertions and deletions. //Using the swap or replace methods is one option for replacing dependence on Clone, or //changing the way in which the BTree is stored could also potentially work. -impl BTree { +impl BTree { ///Returns new BTree with root node (leaf) and user-supplied lower bound pub fn new(k: K, v: V, lb: uint) -> BTree { @@ -58,27 +60,41 @@ impl BTree { } } - ///Implements the Clone trait for the BTree. - ///Uses a helper function/constructor to produce a new BTree. - pub fn clone(&self) -> BTree { - return BTree::new_with_node_len(self.root.clone(), self.len, self.lower_bound); + ///Stub for add method in progress. + pub fn add(self, k: K, v: V) -> BTree { + //replace(&self.root,self.root.add(k, v)); + return BTree::new(k, v, 2); } +} +impl BTree { ///Returns the value of a given key, which may not exist in the tree. ///Calls the root node's get method. pub fn get(self, k: K) -> Option { return self.root.get(k); } +} - ///Checks to see if the key already exists in the tree, and if it is not, - ///the key-value pair is added to the tree by calling add on the root node. - pub fn add(self, k: K, v: V) -> bool { - let is_get = &self.clone().get(k.clone()); - if is_get.is_some(){ return false; } - else { - replace(&mut self.root.clone(),self.root.add(k.clone(), v)); - return true; - } +impl Clone for BTree { + ///Implements the Clone trait for the BTree. + ///Uses a helper function/constructor to produce a new BTree. + fn clone(&self) -> BTree { + BTree::new_with_node_len(self.root.clone(), self.len, self.lower_bound) + } +} + +impl TotalEq for BTree { + + ///Testing equality on BTrees by comparing the root. + fn equals(&self, other: &BTree) -> bool { + self.root.cmp(&other.root) == Equal + } +} + +impl TotalOrd for BTree { + ///Returns an ordering based on the root nodes of each BTree. + fn cmp(&self, other: &BTree) -> Ordering { + self.root.cmp(&other.root) } } @@ -96,6 +112,7 @@ impl ToStr for BTree { //Branches contain BranchElts, which contain a left child (another node) and a key-value //pair. Branches also contain the rightmost child of the elements in the array. //Leaves contain LeafElts, which do not have children. +//#[deriving(Eq, TotalEq)] enum Node { LeafNode(Leaf), BranchNode(Branch) @@ -103,10 +120,10 @@ enum Node { //Node functions/methods -impl Node { +impl Node { ///Differentiates between leaf and branch nodes. - fn is_leaf(&self) -> bool{ + fn is_leaf(&self) -> bool { match self{ &LeafNode(..) => true, &BranchNode(..) => false @@ -118,12 +135,20 @@ impl Node { LeafNode(Leaf::new(vec)) } + ///Creates a new branch node given a vector of an elements and a pointer to a rightmost child. fn new_branch(vec: ~[BranchElt], right: ~Node) -> Node { BranchNode(Branch::new(vec, right)) } + ///A placeholder/stub for add + ///Currently returns a leaf node with a single value (the added one) + fn add(self, k: K, v: V) -> Node { + return Node::new_leaf(~[LeafElt::new(k, v)]); + } +} +impl Node { ///Returns the corresponding value to the provided key. ///get() is called in different ways on a branch or a leaf. fn get(&self, k: K) -> Option { @@ -132,84 +157,71 @@ impl Node { BranchNode(ref branch) => return branch.get(k) } } - - ///A placeholder for add - ///Currently returns a leaf node with a single value (the added one) - fn add(self, k: K, v: V) -> Node { - return Node::new_leaf(~[LeafElt::new(k, v)]); - } } -//Again, this might not be necessary in the future. impl Clone for Node { - ///Returns a new node based on whether or not it is a branch or a leaf. fn clone(&self) -> Node { match *self { LeafNode(ref leaf) => { - return Node::new_leaf(leaf.elts.clone()); + Node::new_leaf(leaf.elts.clone()) } BranchNode(ref branch) => { - return Node::new_branch(branch.elts.clone(), - branch.rightmost_child.clone()); + Node::new_branch(branch.elts.clone(), + branch.rightmost_child.clone()) } } } } -//The following impl is unfinished. Old iterations of code are left in for -//future reference when implementing this trait (commented-out). -impl TotalOrd for Node { - - ///Placeholder for an implementation of TotalOrd for Nodes. - #[allow(unused_variable)] - fn cmp(&self, other: &Node) -> Ordering { - //Requires a match statement--defer these procs to branch and leaf. - /* if self.elts[0].less_than(other.elts[0]) { return Less} - if self.elts[0].greater_than(other.elts[0]) {return Greater} - else {return Equal} - */ - return Equal; - } -} - -//The following impl is unfinished. Old iterations of code are left in for -//future reference when implementing this trait (commented-out). -impl TotalEq for Node { - - ///Placeholder for an implementation of TotalEq for Nodes. +impl TotalEq for Node { + ///Returns whether two nodes are equal #[allow(unused_variable)] - fn equals(&self, other: &Node) -> bool { - /* put in a match and defer this stuff to branch and leaf + fn equals(&self, other: &Node) -> bool{ + match *self{ + BranchNode(ref branch) => { + match *other{ + BranchNode(ref branch2) => branch.cmp(branch2) == Equal, + LeafNode(ref leaf) => false + } + } - let mut shorter = 0; - if self.elts.len() <= other.elts.len(){ - shorter = self.elts.len(); - } - else{ - shorter = other.elts.len(); - } - let mut i = 0; - while i < shorter{ - if !self.elts[i].has_key(other.elts[i].key){ - return false; - } - i +=1; + LeafNode(ref leaf) => { + match *other{ + LeafNode(ref leaf2) => leaf.cmp(leaf2) == Equal, + BranchNode(ref branch) => false + } + } + } } - return true; - */ - return true; + +impl TotalOrd for Node { + ///Implementation of TotalOrd for Nodes. + fn cmp(&self, other: &Node) -> Ordering { + match *self { + LeafNode(ref leaf) => { + match *other { + LeafNode(ref leaf2) => leaf.cmp(leaf2), + BranchNode(_) => Less + } + } + BranchNode(ref branch) => { + match *other { + BranchNode(ref branch2) => branch.cmp(branch2), + LeafNode(_) => Greater + } + } + } } } - impl ToStr for Node { ///Returns a string representation of a Node. ///The Branch's to_str() is not implemented yet. fn to_str(&self) -> ~str { match *self { LeafNode(ref leaf) => leaf.to_str(), - BranchNode(..) => ~"" + BranchNode(ref branch) => branch.to_str() } } } @@ -217,18 +229,20 @@ impl ToStr for Node { //A leaf is a vector with elements that contain no children. A leaf also //does not contain a rightmost child. +//#[deriving(Eq, TotalEq)] struct Leaf { elts: ~[LeafElt] } //Vector of values with children, plus a rightmost child (greater than all) +//#[deriving(Eq, TotalEq)] struct Branch { elts: ~[BranchElt], rightmost_child: ~Node } -impl Leaf { +impl Leaf { ///Creates a new Leaf from a vector of LeafElts. fn new(vec: ~[LeafElt]) -> Leaf { @@ -237,6 +251,17 @@ impl Leaf { } } + + + ///Placeholder for add method in progress. + ///Currently returns a new Leaf containing a single LeafElt. + fn add(&self, k: K, v: V) -> Node { + return Node::new_leaf(~[LeafElt::new(k, v)]); + } + +} + +impl Leaf { ///Returns the corresponding value to the supplied key. fn get(&self, k: K) -> Option { for s in self.elts.iter() { @@ -248,30 +273,57 @@ impl Leaf { } return None; } +} - ///Placeholder for add method in progress. - ///Currently returns a new Leaf containing a single LeafElt. - fn add(&self, k: K, v: V) -> Node { - return Node::new_leaf(~[LeafElt::new(k, v)]); +impl Clone for Leaf { + + ///Returns a new Leaf with the same elts. + fn clone(&self) -> Leaf { + Leaf::new(self.elts.clone()) } +} +impl TotalEq for Leaf { + + ///Implementation of equals function for leaves that compares LeafElts. + fn equals(&self, other: &Leaf) -> bool { + if self.elts.len() == other.elts.len() && self.elts.len() != 0 { + let mut i = 0; + while i < self.elts.len() { + if !self.elts[i].equals(&other.elts[i]) { + return false; + } + i = i + 1; + } + return true; + } + false + } +} + +impl TotalOrd for Leaf { + ///Returns an ordering based on the first element of each Leaf. + fn cmp(&self, other: &Leaf) -> Ordering { + if self.elts.len() > other.elts.len() { + return Greater; + } + if self.elts.len() < other.elts.len() { + return Less; + } + self.elts[0].cmp(&other.elts[0]) + } } -impl ToStr for Leaf { +impl ToStr for Leaf { ///Returns a string representation of a Leaf. fn to_str(&self) -> ~str { - let mut ret = ~""; - for s in self.elts.iter() { - ret = ret + " // " + s.to_str(); - } - ret + self.elts.iter().map(|s| s.to_str()).to_owned_vec().connect(" // ") } - } -impl Branch { +impl Branch { ///Creates a new Branch from a vector of BranchElts and a rightmost child (a node). fn new(vec: ~[BranchElt], right: ~Node) -> Branch { @@ -281,6 +333,13 @@ impl Branch { } } + ///Placeholder for add method in progress + fn add(&self, k: K, v: V) -> Node { + return Node::new_leaf(~[LeafElt::new(k, v)]); + } +} + +impl Branch { ///Returns the corresponding value to the supplied key. ///If the key is not there, find the child that might hold it. fn get(&self, k: K) -> Option { @@ -292,30 +351,100 @@ impl Branch { _ => {} } } - return self.rightmost_child.get(k); + self.rightmost_child.get(k) } +} +impl Clone for Branch { + ///Returns a new branch using the clone methods of the Branch's internal variables. + fn clone(&self) -> Branch { + Branch::new(self.elts.clone(), self.rightmost_child.clone()) + } +} - ///Placeholder for add method in progress - fn add(&self, k: K, v: V) -> Node { - return Node::new_leaf(~[LeafElt::new(k, v)]); +impl TotalEq for Branch { + ///Equals function for Branches--compares all the elements in each branch + fn equals(&self, other: &Branch) -> bool { + if self.elts.len() == other.elts.len() && self.elts.len() != 0 { + let mut i = 0; + while i < self.elts.len() { + if !self.elts[i].equals(&other.elts[i]) { + return false; + } + i = i + 1; + } + if self.rightmost_child.equals(&other.rightmost_child) { + return true; + } + } + false + } +} + +impl TotalOrd for Branch { + ///Compares the first elements of two branches to determine an ordering + fn cmp(&self, other: &Branch) -> Ordering { + if self.elts.len() > other.elts.len() { + return Greater; + } + if self.elts.len() < other.elts.len() { + return Less; + } + self.elts[0].cmp(&other.elts[0]) + } +} + +impl ToStr for Branch { + ///Returns a string representation of a Branch. + fn to_str(&self) -> ~str { + let mut ret = self.elts.iter().map(|s| s.to_str()).to_owned_vec().connect(" // "); + ret.push_str(" // "); + ret.push_str(self.rightmost_child.to_str()); + ret + } +} + +impl TotalEq for Branch{ + + ///Equals function for Branches--compares first elt (Placeholder) + fn equals(&self, other: &Branch) -> bool { + if self.elts[0].equals(&other.elts[0]){ + return true; + } + return false; + } +} + +impl ToStr for Branch { + + ///Returns a string representation of a Branch. + fn to_str(&self) -> ~str { + let mut ret = ~""; + for s in self.elts.iter() { + ret = ret + " // " + s.to_str(); + } + ret = ret + " // " + self.rightmost_child.to_str(); + ret } + } //A LeafElt containts no left child, but a key-value pair. +//#[deriving(Eq)] struct LeafElt { key: K, value: V } //A BranchElt has a left child in addition to a key-value pair. +//#[deriving(Eq, TotalEq)] struct BranchElt { left: Node, key: K, value: V } -impl LeafElt { +impl LeafElt { ///Creates a new LeafElt from a supplied key-value pair. fn new(k: K, v: V) -> LeafElt { @@ -356,28 +485,37 @@ impl LeafElt { } } -//This may be eliminated in the future to perserve efficiency by adjusting the way -//the BTree as a whole is stored in memory. impl Clone for LeafElt { ///Returns a new LeafElt by cloning the key and value. fn clone(&self) -> LeafElt { - return LeafElt::new(self.key.clone(), self.value.clone()); + LeafElt::new(self.key.clone(), self.value.clone()) } } -impl ToStr for LeafElt { +impl TotalEq for LeafElt { + ///TotalEq for LeafElts + fn equals(&self, other: &LeafElt) -> bool { + self.key.equals(&other.key) && self.value.equals(&other.value) + } +} +impl TotalOrd for LeafElt { + ///Returns an ordering based on the keys of the LeafElts. + fn cmp(&self, other: &LeafElt) -> Ordering { + self.key.cmp(&other.key) + } +} + +impl ToStr for LeafElt { ///Returns a string representation of a LeafElt. fn to_str(&self) -> ~str { - return "Key: " + self.key.to_str() + ", value: " - + self.value.to_str() + "; "; + format!("Key: {}, value: {};", + self.key.to_str(), self.value.to_str()) } - } -impl BranchElt { - +impl BranchElt { ///Creates a new BranchElt from a supplied key, value, and left child. fn new(k: K, v: V, n: Node) -> BranchElt { BranchElt { @@ -387,6 +525,7 @@ impl BranchElt { } } + ///Placeholder for add method in progress. ///Overall implementation will determine the actual return value of this method. fn add(&self, k: K, v: V) -> LeafElt { @@ -395,58 +534,119 @@ impl BranchElt { } impl Clone for BranchElt { - ///Returns a new BranchElt by cloning the key, value, and left child. fn clone(&self) -> BranchElt { - return BranchElt::new(self.key.clone(), - self.value.clone(), - self.left.clone()); + BranchElt::new(self.key.clone(), + self.value.clone(), + self.left.clone()) } } -#[cfg(test)] -mod test_btree{ +impl TotalEq for BranchElt{ + ///TotalEq for BranchElts + fn equals(&self, other: &BranchElt) -> bool { + self.key.equals(&other.key)&&self.value.equals(&other.value) + } +} - use super::{BTree, LeafElt}; +impl TotalOrd for BranchElt { + ///Fulfills TotalOrd for BranchElts + fn cmp(&self, other: &BranchElt) -> Ordering { + self.key.cmp(&other.key) + } +} - ///Tests the functionality of the add methods (which are unfinished). - #[test] +impl ToStr for BranchElt { + + ///Returns string containing key, value, and child (which should recur to a leaf) + ///Consider changing in future to be more readable. + fn to_str(&self) -> ~str { + format!("Key: {}, value: {}, child: {};", + self.key.to_str(), self.value.to_str(), self.left.to_str()) + } +} + + +#[cfg(test)] +mod test_btree { + use super::{BTree, LeafElt}; + //Tests the functionality of the add methods (which are unfinished). + /*#[test] fn add_test(){ let b = BTree::new(1, ~"abc", 2); let is_add = b.add(2, ~"xyz"); assert!(is_add); - } + }*/ - ///Tests the functionality of the get method. + //Tests the functionality of the get method. #[test] - fn get_test(){ + fn get_test() { let b = BTree::new(1, ~"abc", 2); let val = b.get(1); assert_eq!(val, Some(~"abc")); } - ///Tests the LeafElt's less_than() method. + //Tests the LeafElt's less_than() method. #[test] - fn leaf_lt(){ + fn leaf_lt() { let l1 = LeafElt::new(1, ~"abc"); let l2 = LeafElt::new(2, ~"xyz"); assert!(l1.less_than(l2)); } - ///Tests the LeafElt's greater_than() method. + //Tests the LeafElt's greater_than() method. #[test] - fn leaf_gt(){ + fn leaf_gt() { let l1 = LeafElt::new(1, ~"abc"); let l2 = LeafElt::new(2, ~"xyz"); assert!(l2.greater_than(l1)); } - ///Tests the LeafElt's has_key() method. + //Tests the LeafElt's has_key() method. #[test] - fn leaf_hk(){ + fn leaf_hk() { let l1 = LeafElt::new(1, ~"abc"); assert!(l1.has_key(1)); } + + //Tests the BTree's clone() method. + #[test] + fn btree_clone_test() { + let b = BTree::new(1, ~"abc", 2); + let b2 = b.clone(); + assert!(b.root.equals(&b2.root)) + } + + //Tests the BTree's cmp() method when one node is "less than" another. + #[test] + fn btree_cmp_test_less() { + let b = BTree::new(1, ~"abc", 2); + let b2 = BTree::new(2, ~"bcd", 2); + assert!(&b.cmp(&b2) == &Less) + } + + //Tests the BTree's cmp() method when two nodes are equal. + #[test] + fn btree_cmp_test_eq() { + let b = BTree::new(1, ~"abc", 2); + let b2 = BTree::new(1, ~"bcd", 2); + assert!(&b.cmp(&b2) == &Equal) + } + + //Tests the BTree's cmp() method when one node is "greater than" another. + #[test] + fn btree_cmp_test_greater() { + let b = BTree::new(1, ~"abc", 2); + let b2 = BTree::new(2, ~"bcd", 2); + assert!(&b2.cmp(&b) == &Greater) + } + + //Tests the BTree's to_str() method. + #[test] + fn btree_tostr_test() { + let b = BTree::new(1, ~"abc", 2); + assert_eq!(b.to_str(), ~"Key: 1, value: abc;") + } } diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index b63c3d92da3ee..984cc88a4c956 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -1433,7 +1433,7 @@ mod test { drop(handle); let mut handle = pool.spawn_sched(); - handle.send(TaskFromFriend(pool.task(TaskOpts::new(), proc() { + handle.send(PinnedTask(pool.task(TaskOpts::new(), proc() { // Wait until the other task has its lock start_po.recv(); diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index e761a14a3acec..786c05de20465 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -41,7 +41,7 @@ use syntax::ast; use syntax::ast_map::{path, path_mod, path_name, path_pretty_name}; use syntax::attr; use syntax::attr::AttrMetaMethods; -use syntax::pkgid::PkgId; +use syntax::crateid::CrateId; #[deriving(Clone, Eq)] pub enum output_type { @@ -444,13 +444,13 @@ pub mod write { * * So here is what we do: * - * - Consider the package id; every crate has one (specified with pkgid + * - Consider the package id; every crate has one (specified with crate_id * attribute). If a package id isn't provided explicitly, we infer a * versionless one from the output name. The version will end up being 0.0 * in this case. CNAME and CVERS are taken from this package id. For * example, github.com/mozilla/CNAME#CVERS. * - * - Define CMH as SHA256(pkgid). + * - Define CMH as SHA256(crateid). * * - Define CMH8 as the first 8 characters of CMH. * @@ -469,13 +469,13 @@ pub fn build_link_meta(sess: Session, symbol_hasher: &mut Sha256) -> LinkMeta { // This calculates CMH as defined above - fn crate_hash(symbol_hasher: &mut Sha256, pkgid: &PkgId) -> @str { + fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> @str { symbol_hasher.reset(); - symbol_hasher.input_str(pkgid.to_str()); + symbol_hasher.input_str(crateid.to_str()); truncated_hash_result(symbol_hasher).to_managed() } - let pkgid = match attr::find_pkgid(attrs) { + let crateid = match attr::find_crateid(attrs) { None => { let stem = session::expect( sess, @@ -487,10 +487,10 @@ pub fn build_link_meta(sess: Session, Some(s) => s, }; - let hash = crate_hash(symbol_hasher, &pkgid); + let hash = crate_hash(symbol_hasher, &crateid); LinkMeta { - pkgid: pkgid, + crateid: crateid, crate_hash: hash, } } @@ -509,7 +509,7 @@ pub fn symbol_hash(tcx: ty::ctxt, // to be independent of one another in the crate. symbol_hasher.reset(); - symbol_hasher.input_str(link_meta.pkgid.name); + symbol_hasher.input_str(link_meta.crateid.name); symbol_hasher.input_str("-"); symbol_hasher.input_str(link_meta.crate_hash); symbol_hasher.input_str("-"); @@ -669,7 +669,7 @@ pub fn mangle_exported_name(ccx: &CrateContext, let hash = get_symbol_hash(ccx, t); return exported_name(ccx.sess, path, hash, - ccx.link_meta.pkgid.version_or_default()); + ccx.link_meta.crateid.version_or_default()); } pub fn mangle_internal_name_by_type_only(ccx: &CrateContext, @@ -710,9 +710,9 @@ pub fn mangle_internal_name_by_path(ccx: &CrateContext, path: path) -> ~str { pub fn output_lib_filename(lm: &LinkMeta) -> ~str { format!("{}-{}-{}", - lm.pkgid.name, + lm.crateid.name, lm.crate_hash.slice_chars(0, 8), - lm.pkgid.version_or_default()) + lm.crateid.version_or_default()) } pub fn get_cc_prog(sess: Session) -> ~str { diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 2b9acb1db9d54..dba811d822feb 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -1030,12 +1030,12 @@ pub fn build_output_filenames(input: &input, str_input(_) => @"rust_out" }; - // If a pkgid is present, we use it as the link name - let pkgid = attr::find_pkgid(attrs); - match pkgid { + // If a crateid is present, we use it as the link name + let crateid = attr::find_crateid(attrs); + match crateid { None => {} - Some(pkgid) => { - stem = pkgid.name.to_managed() + Some(crateid) => { + stem = crateid.name.to_managed() } } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 6193e5e8fa1f6..7b2697b1d28e9 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -384,7 +384,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item { } fn is_extra(crate: &ast::Crate) -> bool { - match attr::find_pkgid(crate.attrs) { + match attr::find_crateid(crate.attrs) { Some(ref s) if "extra" == s.name => true, _ => false } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index a9f67e3108998..828e65b764870 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -292,18 +292,18 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { let t_outputs = d::build_output_filenames(&input, &odir, &ofile, attrs, sess); if crate_id || crate_name { - let pkgid = match attr::find_pkgid(attrs) { - Some(pkgid) => pkgid, + let crateid = match attr::find_crateid(attrs) { + Some(crateid) => crateid, None => { sess.fatal("No crate_id and --crate-id or \ --crate-name requested") } }; if crate_id { - println(pkgid.to_str()); + println(crateid.to_str()); } if crate_name { - println(pkgid.name); + println(crateid.name); } } diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index bd6794b1d9ff7..8b3d5062e1519 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::cast; -use syntax::pkgid::PkgId; +use syntax::crateid::CrateId; // EBML enum definitions and utils shared by the encoder and decoder @@ -206,6 +206,6 @@ pub static tag_native_libraries_kind: uint = 0x106; #[deriving(Clone)] pub struct LinkMeta { - pkgid: PkgId, + crateid: CrateId, crate_hash: @str, } diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index de5ae08cf5756..8fa1e5563947f 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -25,7 +25,7 @@ use syntax::codemap::{Span, dummy_sp}; use syntax::diagnostic::span_handler; use syntax::parse::token; use syntax::parse::token::ident_interner; -use syntax::pkgid::PkgId; +use syntax::crateid::CrateId; use syntax::visit; // Traverses an AST, reading all the information about use'd crates and extern @@ -73,7 +73,7 @@ struct cache_entry { cnum: ast::CrateNum, span: Span, hash: @str, - pkgid: PkgId, + crateid: CrateId, } fn dump_crates(crate_cache: &[cache_entry]) { @@ -89,10 +89,10 @@ fn warn_if_multiple_versions(e: &mut Env, diag: @mut span_handler, crate_cache: &[cache_entry]) { if crate_cache.len() != 0u { - let name = crate_cache[crate_cache.len() - 1].pkgid.name.clone(); + let name = crate_cache[crate_cache.len() - 1].crateid.name.clone(); let (matches, non_matches) = crate_cache.partitioned(|entry| - name == entry.pkgid.name); + name == entry.crateid.name); assert!(!matches.is_empty()); @@ -101,7 +101,7 @@ fn warn_if_multiple_versions(e: &mut Env, format!("using multiple versions of crate `{}`", name)); for match_ in matches.iter() { diag.span_note(match_.span, "used here"); - loader::note_pkgid_attr(diag, &match_.pkgid); + loader::note_crateid_attr(diag, &match_.crateid); } } @@ -138,15 +138,15 @@ fn visit_view_item(e: &mut Env, i: &ast::view_item) { ident, path_opt); let (name, version) = match path_opt { Some((path_str, _)) => { - let pkgid: Option = from_str(path_str); - match pkgid { + let crateid: Option = from_str(path_str); + match crateid { None => (@"", @""), - Some(pkgid) => { - let version = match pkgid.version { + Some(crateid) => { + let version = match crateid.version { None => @"", Some(ref ver) => ver.to_managed(), }; - (pkgid.name.to_managed(), version) + (crateid.name.to_managed(), version) } } } @@ -245,12 +245,12 @@ fn visit_item(e: &Env, i: @ast::item) { fn existing_match(e: &Env, name: @str, version: @str, hash: &str) -> Option { let crate_cache = e.crate_cache.borrow(); for c in crate_cache.get().iter() { - let pkgid_version = match c.pkgid.version { + let crateid_version = match c.crateid.version { None => @"0.0", Some(ref ver) => ver.to_managed(), }; - if (name.is_empty() || c.pkgid.name.to_managed() == name) && - (version.is_empty() || pkgid_version == version) && + if (name.is_empty() || c.crateid.name.to_managed() == name) && + (version.is_empty() || crateid_version == version) && (hash.is_empty() || c.hash.as_slice() == hash) { return Some(c.cnum); } @@ -282,7 +282,7 @@ fn resolve_crate(e: &mut Env, } = load_ctxt.load_library_crate(); let attrs = decoder::get_crate_attributes(metadata.as_slice()); - let pkgid = attr::find_pkgid(attrs).unwrap(); + let crateid = attr::find_crateid(attrs).unwrap(); let hash = decoder::get_crate_hash(metadata.as_slice()); // Claim this crate number and cache it @@ -293,7 +293,7 @@ fn resolve_crate(e: &mut Env, cnum: cnum, span: span, hash: hash, - pkgid: pkgid, + crateid: crateid, }); } e.next_crate_num += 1; diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index a0b339cc91d74..b4c19c771dc0a 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1173,9 +1173,9 @@ pub fn get_crate_hash(data: &[u8]) -> @str { pub fn get_crate_vers(data: &[u8]) -> @str { let attrs = decoder::get_crate_attributes(data); - match attr::find_pkgid(attrs) { + match attr::find_crateid(attrs) { None => @"0.0", - Some(pkgid) => pkgid.version_or_default().to_managed(), + Some(crateid) => crateid.version_or_default().to_managed(), } } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 7bd87f5dff816..73b0ac46cbda9 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1559,19 +1559,19 @@ fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[Attribute]) { ebml_w.end_tag(); } -// So there's a special crate attribute called 'pkgid' which defines the +// So there's a special crate attribute called 'crate_id' which defines the // metadata that Rust cares about for linking crates. If the user didn't // provide it we will throw it in anyway with a default value. fn synthesize_crate_attrs(ecx: &EncodeContext, crate: &Crate) -> ~[Attribute] { - fn synthesize_pkgid_attr(ecx: &EncodeContext) -> Attribute { - assert!(!ecx.link_meta.pkgid.name.is_empty()); + fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute { + assert!(!ecx.link_meta.crateid.name.is_empty()); attr::mk_attr( attr::mk_name_value_item_str( @"crate_id", - ecx.link_meta.pkgid.to_str().to_managed())) + ecx.link_meta.crateid.to_str().to_managed())) } let mut attrs = ~[]; @@ -1580,7 +1580,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext, attrs.push(*attr); } } - attrs.push(synthesize_pkgid_attr(ecx)); + attrs.push(synthesize_crateid_attr(ecx)); attrs } diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index e954fc06c9435..481a43d1cedd2 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -21,7 +21,7 @@ use metadata::filesearch; use syntax::codemap::Span; use syntax::diagnostic::span_handler; use syntax::parse::token::ident_interner; -use syntax::pkgid::PkgId; +use syntax::crateid::CrateId; use syntax::attr; use syntax::attr::AttrMetaMethods; @@ -112,7 +112,7 @@ impl Context { Some(cvec) => if crate_matches(cvec.as_slice(), self.name, self.version, self.hash) { - debug!("found {} with matching pkgid", + debug!("found {} with matching crate_id", path.display()); let (rlib, dylib) = if file.ends_with(".rlib") { (Some(path.clone()), None) @@ -126,7 +126,7 @@ impl Context { }); FileMatches } else { - debug!("skipping {}, pkgid doesn't match", + debug!("skipping {}, crate_id doesn't match", path.display()); FileDoesntMatch }, @@ -165,10 +165,10 @@ impl Context { } let data = lib.metadata.as_slice(); let attrs = decoder::get_crate_attributes(data); - match attr::find_pkgid(attrs) { + match attr::find_crateid(attrs) { None => {} - Some(pkgid) => { - note_pkgid_attr(self.sess.diagnostic(), &pkgid); + Some(crateid) => { + note_crateid_attr(self.sess.diagnostic(), &crateid); } } } @@ -231,9 +231,9 @@ impl Context { } } -pub fn note_pkgid_attr(diag: @mut span_handler, - pkgid: &PkgId) { - diag.handler().note(format!("pkgid: {}", pkgid.to_str())); +pub fn note_crateid_attr(diag: @mut span_handler, + crateid: &CrateId) { + diag.handler().note(format!("crate_id: {}", crateid.to_str())); } fn crate_matches(crate_data: &[u8], @@ -241,15 +241,15 @@ fn crate_matches(crate_data: &[u8], version: @str, hash: @str) -> bool { let attrs = decoder::get_crate_attributes(crate_data); - match attr::find_pkgid(attrs) { + match attr::find_crateid(attrs) { None => false, - Some(pkgid) => { + Some(crateid) => { if !hash.is_empty() { let chash = decoder::get_crate_hash(crate_data); if chash != hash { return false; } } - name == pkgid.name.to_managed() && - (version.is_empty() || version == pkgid.version_or_default().to_managed()) + name == crateid.name.to_managed() && + (version.is_empty() || version == crateid.version_or_default().to_managed()) } } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0b2ee710e9913..ce953ab3ab70f 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -3048,8 +3048,8 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta, let sym_name = if is_top { ~"_rust_crate_map_toplevel" } else { - symname(sess, "_rust_crate_map_" + mapmeta.pkgid.name, mapmeta.crate_hash, - mapmeta.pkgid.version_or_default()) + symname(sess, "_rust_crate_map_" + mapmeta.crateid.name, mapmeta.crate_hash, + mapmeta.crateid.version_or_default()) }; let slicetype = Type::struct_([int_type, int_type], false); @@ -3168,8 +3168,8 @@ pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] { flate::deflate_bytes(metadata); let llmeta = C_bytes(compressed); let llconst = C_struct([llmeta], false); - let name = format!("rust_metadata_{}_{}_{}", cx.link_meta.pkgid.name, - cx.link_meta.pkgid.version_or_default(), cx.link_meta.crate_hash); + let name = format!("rust_metadata_{}_{}_{}", cx.link_meta.crateid.name, + cx.link_meta.crateid.version_or_default(), cx.link_meta.crate_hash); let llglobal = name.with_c_str(|buf| { unsafe { llvm::LLVMAddGlobal(cx.metadata_llmod, val_ty(llconst).to_ref(), buf) @@ -3205,7 +3205,7 @@ pub fn trans_crate(sess: session::Session, // crashes if the module identifer is same as other symbols // such as a function name in the module. // 1. http://llvm.org/bugs/show_bug.cgi?id=11479 - let llmod_id = link_meta.pkgid.name.clone() + ".rc"; + let llmod_id = link_meta.crateid.name.clone() + ".rc"; let ccx = @CrateContext::new(sess, llmod_id, diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d81eaf8fab875..3e9aae4730e34 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -2827,7 +2827,7 @@ fn namespace_for_item(cx: &CrateContext, if def_id.crate == ast::LOCAL_CRATE { // prepend crate name if not already present - let crate_namespace_ident = token::str_to_ident(cx.link_meta.pkgid.name); + let crate_namespace_ident = token::str_to_ident(cx.link_meta.crateid.name); item_path.insert(0, ast_map::path_mod(crate_namespace_ident)); } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index bf7a0d6039bdc..9fcd0f458b3b5 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1855,7 +1855,7 @@ pub fn trans_log_level(bcx: @Block) -> DatumBlock { Some(&src) => { ccx.sess.cstore.get_crate_data(src.crate).name } - None => ccx.link_meta.pkgid.name.to_managed(), + None => ccx.link_meta.crateid.name.to_managed(), }; }; let mut modpath = ~[path_mod(ccx.sess.ident_of(srccrate))]; diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 7d80cea23c160..ab36079585fc4 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -73,7 +73,7 @@ pub struct Crate { impl Clean for visit_ast::RustdocVisitor { fn clean(&self) -> Crate { - use syntax::attr::find_pkgid; + use syntax::attr::find_crateid; let cx = local_data::get(super::ctxtkey, |x| *x.unwrap()); let mut externs = HashMap::new(); @@ -82,7 +82,7 @@ impl Clean for visit_ast::RustdocVisitor { }); Crate { - name: match find_pkgid(self.attrs) { + name: match find_crateid(self.attrs) { Some(n) => n.name, None => fail!("rustdoc requires a `crate_id` crate attribute"), }, @@ -1123,6 +1123,8 @@ fn lit_to_str(lit: &ast::lit) -> ~str { fn name_from_pat(p: &ast::Pat) -> ~str { use syntax::ast::*; + debug!("Trying to get a name from pattern: {:?}", p); + match p.node { PatWild => ~"_", PatWildMulti => ~"..", @@ -1134,9 +1136,12 @@ fn name_from_pat(p: &ast::Pat) -> ~str { PatBox(p) => name_from_pat(p), PatUniq(p) => name_from_pat(p), PatRegion(p) => name_from_pat(p), - PatLit(..) => fail!("tried to get argument name from pat_lit, \ - which is not allowed in function arguments"), - PatRange(..) => fail!("tried to get argument name from pat_range, \ + PatLit(..) => { + warn!("tried to get argument name from PatLit, \ + which is silly in function arguments"); + ~"()" + }, + PatRange(..) => fail!("tried to get argument name from PatRange, \ which is not allowed in function arguments"), PatVec(..) => fail!("tried to get argument name from pat_vec, \ which is not allowed in function arguments") diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 6fd83af3b2e76..5da087eedbd58 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -94,15 +94,26 @@ extern { } +/// Returns Some(code) if `s` is a line that should be stripped from +/// documentation but used in example code. `code` is the portion of +/// `s` that should be used in tests. (None for lines that should be +/// left as-is.) +fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> { + let trimmed = s.trim(); + if trimmed.starts_with("# ") { + Some(trimmed.slice_from(2)) + } else { + None + } +} + pub fn render(w: &mut io::Writer, s: &str) { extern fn block(ob: *buf, text: *buf, lang: *buf, opaque: *libc::c_void) { unsafe { let my_opaque: &my_opaque = cast::transmute(opaque); vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { let text = str::from_utf8(text); - let mut lines = text.lines().filter(|l| { - !l.trim().starts_with("#") - }); + let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none()); let text = lines.to_owned_vec().connect("\n"); let buf = buf { @@ -169,7 +180,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| { let tests: &mut ::test::Collector = intrinsics::transmute(opaque); let text = str::from_utf8(text); - let mut lines = text.lines().map(|l| l.trim_chars(&'#')); + let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l)); let text = lines.to_owned_vec().connect("\n"); tests.add_test(text, ignore, shouldfail); }) diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 7450abf34158b..e5ec3661b611c 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -173,6 +173,7 @@ impl Collector { let libs = self.libs.borrow(); let libs = (*libs.get()).clone(); let cratename = self.cratename.to_owned(); + debug!("Creating test {}: {}", name, test); self.tests.push(test::TestDescAndFn { desc: test::TestDesc { name: test::DynTestName(name), diff --git a/src/librustpkg/api.rs b/src/librustpkg/api.rs index 8e4216562c0a5..0730a6fc3a210 100644 --- a/src/librustpkg/api.rs +++ b/src/librustpkg/api.rs @@ -10,7 +10,7 @@ use context::*; use crate::*; -use package_id::*; +use crate_id::*; use package_source::*; use path_util::{platform_library_name, target_build_dir}; use target::*; @@ -92,7 +92,7 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str, build_in_destination: false, destination_workspace: root.clone(), start_dir: root.join_many(["src", name.as_slice()]), - id: PkgId{ version: version, ..PkgId::new(name)}, + id: CrateId{ version: version, ..CrateId::new(name)}, // n.b. This assumes the package only has one crate libs: ~[mk_crate(lib)], mains: ~[], @@ -115,7 +115,7 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str, build_in_destination: false, destination_workspace: root.clone(), start_dir: root.join_many(["src", name.as_slice()]), - id: PkgId{ version: version, ..PkgId::new(name)}, + id: CrateId{ version: version, ..CrateId::new(name)}, libs: ~[], // n.b. This assumes the package only has one crate mains: ~[mk_crate(main)], @@ -132,8 +132,8 @@ pub fn install_pkg(cx: &BuildContext, version: Version, // For now, these inputs are assumed to be inputs to each of the crates more_inputs: ~[(~str, Path)]) { // pairs of Kind and Path - let pkgid = PkgId{ version: version, ..PkgId::new(name)}; - cx.install(PkgSrc::new(workspace.clone(), workspace, false, pkgid), + let crateid = CrateId{ version: version, ..CrateId::new(name)}; + cx.install(PkgSrc::new(workspace.clone(), workspace, false, crateid), &WhatToBuild{ build_type: Inferred, inputs_to_discover: more_inputs, sources: Everything }); @@ -157,10 +157,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec, let out_name = workspace_build_dir.join_many([package_name.to_str(), platform_library_name(output)]); // make paths absolute - let pkgid = PkgId::new(package_name); + let crateid = CrateId::new(package_name); let absolute_paths = paths.map(|s| { let whatever = workspace.join_many([~"src", - pkgid.to_str(), + crateid.to_str(), s.to_owned()]); whatever.as_str().unwrap().to_owned() }); @@ -190,8 +190,8 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path { use bad_pkg_id = conditions::bad_pkg_id::cond; // (this assumes no particular version is requested) - let pkgid = PkgId::new(package_name); - let workspaces = pkg_parent_workspaces(context, &pkgid); + let crateid = CrateId::new(package_name); + let workspaces = pkg_parent_workspaces(context, &crateid); if workspaces.is_empty() { bad_pkg_id.raise((Path::new(package_name), package_name.to_owned())); } diff --git a/src/librustpkg/conditions.rs b/src/librustpkg/conditions.rs index 023bba15f97a1..6c38d63a51801 100644 --- a/src/librustpkg/conditions.rs +++ b/src/librustpkg/conditions.rs @@ -10,7 +10,7 @@ // Useful conditions -pub use package_id::PkgId; +pub use crate_id::CrateId; pub use std::io::FileStat; pub use std::io::process::ProcessExit; pub use std::path::Path; @@ -20,15 +20,15 @@ condition! { } condition! { - pub nonexistent_package: (PkgId, ~str) -> Path; + pub nonexistent_package: (CrateId, ~str) -> Path; } condition! { - pub missing_pkg_files: (PkgId) -> (); + pub missing_pkg_files: (CrateId) -> (); } condition! { - pub bad_pkg_id: (Path, ~str) -> PkgId; + pub bad_pkg_id: (Path, ~str) -> CrateId; } condition! { diff --git a/src/librustpkg/package_id.rs b/src/librustpkg/crate_id.rs similarity index 93% rename from src/librustpkg/package_id.rs rename to src/librustpkg/crate_id.rs index 04ac30e373287..7ff8417f23c78 100644 --- a/src/librustpkg/package_id.rs +++ b/src/librustpkg/crate_id.rs @@ -17,7 +17,7 @@ use std::hash; /// 'github.com/graydon/test'; path must be a relative /// path with >=1 component. #[deriving(Clone)] -pub struct PkgId { +pub struct CrateId { /// This is a path, on the local filesystem, referring to where the /// files for this package live. For example: /// github.com/mozilla/quux-whatever (it's assumed that if we're @@ -35,14 +35,14 @@ pub struct PkgId { version: Version } -impl Eq for PkgId { - fn eq(&self, other: &PkgId) -> bool { +impl Eq for CrateId { + fn eq(&self, other: &CrateId) -> bool { self.path == other.path && self.version == other.version } } -impl PkgId { - pub fn new(s: &str) -> PkgId { +impl CrateId { + pub fn new(s: &str) -> CrateId { use conditions::bad_pkg_id::cond; let mut given_version = None; @@ -60,10 +60,10 @@ impl PkgId { let path = Path::new(s); if !path.is_relative() { - return cond.raise((path, ~"absolute pkgid")); + return cond.raise((path, ~"absolute crate_id")); } if path.filename().is_none() { - return cond.raise((path, ~"0-length pkgid")); + return cond.raise((path, ~"0-length crate_id")); } let short_name = path.filestem_str().expect(format!("Strange path! {}", s)); @@ -78,7 +78,7 @@ impl PkgId { } }; - PkgId { + CrateId { path: path.clone(), short_name: short_name.to_owned(), version: version @@ -142,7 +142,7 @@ impl Iterator<(Path, Path)> for Prefixes { } } -impl ToStr for PkgId { +impl ToStr for CrateId { fn to_str(&self) -> ~str { // should probably use the filestem and not the whole path format!("{}-{}", self.path.as_str().unwrap(), self.version.to_str()) diff --git a/src/librustpkg/installed_packages.rs b/src/librustpkg/installed_packages.rs index 48c25a5368209..67ba5d2b8e83f 100644 --- a/src/librustpkg/installed_packages.rs +++ b/src/librustpkg/installed_packages.rs @@ -16,7 +16,7 @@ use std::os; use std::io; use std::io::fs; -pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool { +pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool { let workspaces = rust_path(); for p in workspaces.iter() { let binfiles = { @@ -28,7 +28,7 @@ pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool { match exec.filestem_str() { None => (), Some(exec_path) => { - if !f(&PkgId::new(exec_path)) { + if !f(&CrateId::new(exec_path)) { return false; } } @@ -50,7 +50,7 @@ pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool { let rel_path = rel_p.join(basename); rel_path.display().with_str(|s| { debug!("Rel name: {}", s); - f(&PkgId::new(s)); + f(&CrateId::new(s)); }); } None => () @@ -78,7 +78,7 @@ pub fn has_library(p: &Path) -> Option<~str> { None } -pub fn package_is_installed(p: &PkgId) -> bool { +pub fn package_is_installed(p: &CrateId) -> bool { let mut is_installed = false; list_installed_packages(|installed| { if installed == p { diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs index 6bb6add407a41..2b54a6d6f1c15 100644 --- a/src/librustpkg/lib.rs +++ b/src/librustpkg/lib.rs @@ -45,7 +45,7 @@ use workspace::determine_destination; use context::{Context, BuildContext, RustcFlags, Trans, Link, Nothing, Pretty, Analysis, Assemble, LLVMAssemble, LLVMCompileBitcode}; -use package_id::PkgId; +use crate_id::CrateId; use package_source::PkgSrc; use target::{WhatToBuild, Everything, is_lib, is_main, is_test, is_bench}; use target::{Main, Tests, MaybeCustom, Inferred, JustOne}; @@ -59,7 +59,7 @@ mod crate; pub mod exit_codes; mod installed_packages; mod messages; -pub mod package_id; +pub mod crate_id; pub mod package_source; mod path_util; mod source_control; @@ -78,7 +78,7 @@ pub mod usage; /// an explicit package script. struct PkgScript<'a> { /// Uniquely identifies this package - id: &'a PkgId, + id: &'a CrateId, /// File path for the package script input: Path, /// The session to use *only* for compiling the custom @@ -99,7 +99,7 @@ impl<'a> PkgScript<'a> { fn parse<'a>(sysroot: Path, script: Path, workspace: &Path, - id: &'a PkgId) -> PkgScript<'a> { + id: &'a CrateId) -> PkgScript<'a> { // Get the executable name that was invoked let binary = os::args()[0].to_managed(); // Build the rustc session data structures to pass @@ -208,10 +208,10 @@ pub trait CtxMethods { fn run(&self, cmd: &str, args: ~[~str]); fn do_cmd(&self, _cmd: &str, _pkgname: &str); /// Returns a pair of the selected package ID, and the destination workspace - fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)>; + fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(CrateId, Path)>; /// Returns the destination workspace fn build(&self, pkg_src: &mut PkgSrc, what: &WhatToBuild); - fn clean(&self, workspace: &Path, id: &PkgId); + fn clean(&self, workspace: &Path, id: &CrateId); fn info(&self); /// Returns a pair. First component is a list of installed paths, /// second is a list of declared and discovered inputs @@ -221,24 +221,24 @@ pub trait CtxMethods { build_workspace: &Path, build_inputs: &[Path], target_workspace: &Path, - id: &PkgId) -> ~[~str]; + id: &CrateId) -> ~[~str]; fn prefer(&self, _id: &str, _vers: Option<~str>); - fn test(&self, id: &PkgId, workspace: &Path); + fn test(&self, id: &CrateId, workspace: &Path); fn uninstall(&self, _id: &str, _vers: Option<~str>); fn unprefer(&self, _id: &str, _vers: Option<~str>); fn init(&self); } impl CtxMethods for BuildContext { - fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)> { + fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(CrateId, Path)> { let cwd = os::getcwd(); if args.len() < 1 { match cwd_to_workspace() { None if dir_has_crate_file(&cwd) => { // FIXME (#9639): This needs to handle non-utf8 paths - let pkgid = PkgId::new(cwd.filename_str().unwrap()); - let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, pkgid); + let crateid = CrateId::new(cwd.filename_str().unwrap()); + let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, crateid); self.build(&mut pkg_src, what); match pkg_src { PkgSrc { destination_workspace: ws, @@ -248,8 +248,8 @@ impl CtxMethods for BuildContext { } } None => { usage::build(); None } - Some((ws, pkgid)) => { - let mut pkg_src = PkgSrc::new(ws.clone(), ws, false, pkgid); + Some((ws, crateid)) => { + let mut pkg_src = PkgSrc::new(ws.clone(), ws, false, crateid); self.build(&mut pkg_src, what); match pkg_src { PkgSrc { destination_workspace: ws, @@ -262,23 +262,23 @@ impl CtxMethods for BuildContext { } else { // The package id is presumed to be the first command-line // argument - let pkgid = PkgId::new(args[0].clone()); + let crateid = CrateId::new(args[0].clone()); let mut dest_ws = default_workspace(); - each_pkg_parent_workspace(&self.context, &pkgid, |workspace| { + each_pkg_parent_workspace(&self.context, &crateid, |workspace| { debug!("found pkg {} in workspace {}, trying to build", - pkgid.to_str(), workspace.display()); + crateid.to_str(), workspace.display()); dest_ws = determine_destination(os::getcwd(), self.context.use_rust_path_hack, workspace); let mut pkg_src = PkgSrc::new(workspace.clone(), dest_ws.clone(), - false, pkgid.clone()); + false, crateid.clone()); self.build(&mut pkg_src, what); true }); // n.b. If this builds multiple packages, it only returns the workspace for // the last one. The whole building-multiple-packages-with-the-same-ID is weird // anyway and there are no tests for it, so maybe take it out - Some((pkgid, dest_ws)) + Some((crateid, dest_ws)) } } fn run(&self, cmd: &str, args: ~[~str]) { @@ -293,15 +293,15 @@ impl CtxMethods for BuildContext { None => { usage::clean(); return } // tjc: Maybe clean should clean all the packages in the // current workspace, though? - Some((ws, pkgid)) => self.clean(&ws, &pkgid) + Some((ws, crateid)) => self.clean(&ws, &crateid) } } else { // The package id is presumed to be the first command-line // argument - let pkgid = PkgId::new(args[0].clone()); - self.clean(&cwd, &pkgid); // tjc: should use workspace, not cwd + let crateid = CrateId::new(args[0].clone()); + self.clean(&cwd, &crateid); // tjc: should use workspace, not cwd } } "do" => { @@ -320,15 +320,15 @@ impl CtxMethods for BuildContext { None if dir_has_crate_file(&cwd) => { // FIXME (#9639): This needs to handle non-utf8 paths - let inferred_pkgid = - PkgId::new(cwd.filename_str().unwrap()); + let inferred_crateid = + CrateId::new(cwd.filename_str().unwrap()); self.install(PkgSrc::new(cwd, default_workspace(), - true, inferred_pkgid), + true, inferred_crateid), &WhatToBuild::new(MaybeCustom, Everything)); } None => { usage::install(); return; } - Some((ws, pkgid)) => { - let pkg_src = PkgSrc::new(ws.clone(), ws.clone(), false, pkgid); + Some((ws, crateid)) => { + let pkg_src = PkgSrc::new(ws.clone(), ws.clone(), false, crateid); self.install(pkg_src, &WhatToBuild::new(MaybeCustom, Everything)); } @@ -337,13 +337,13 @@ impl CtxMethods for BuildContext { else { // The package id is presumed to be the first command-line // argument - let pkgid = PkgId::new(args[0]); - let workspaces = pkg_parent_workspaces(&self.context, &pkgid); + let crateid = CrateId::new(args[0]); + let workspaces = pkg_parent_workspaces(&self.context, &crateid); debug!("package ID = {}, found it in {:?} workspaces", - pkgid.to_str(), workspaces.len()); + crateid.to_str(), workspaces.len()); if workspaces.is_empty() { let d = default_workspace(); - let src = PkgSrc::new(d.clone(), d, false, pkgid.clone()); + let src = PkgSrc::new(d.clone(), d, false, crateid.clone()); self.install(src, &WhatToBuild::new(MaybeCustom, Everything)); } else { @@ -354,7 +354,7 @@ impl CtxMethods for BuildContext { let src = PkgSrc::new(workspace.clone(), dest, self.context.use_rust_path_hack, - pkgid.clone()); + crateid.clone()); self.install(src, &WhatToBuild::new(MaybeCustom, Everything)); }; } @@ -400,8 +400,8 @@ impl CtxMethods for BuildContext { return usage::uninstall(); } - let pkgid = PkgId::new(args[0]); - if !installed_packages::package_is_installed(&pkgid) { + let crateid = CrateId::new(args[0]); + if !installed_packages::package_is_installed(&crateid) { warn(format!("Package {} doesn't seem to be installed! \ Doing nothing.", args[0])); return; @@ -409,10 +409,10 @@ impl CtxMethods for BuildContext { else { let rp = rust_path(); assert!(!rp.is_empty()); - each_pkg_parent_workspace(&self.context, &pkgid, |workspace| { - path_util::uninstall_package_from(workspace, &pkgid); + each_pkg_parent_workspace(&self.context, &crateid, |workspace| { + path_util::uninstall_package_from(workspace, &crateid); note(format!("Uninstalled package {} (was installed in {})", - pkgid.to_str(), workspace.display())); + crateid.to_str(), workspace.display())); true }); } @@ -437,34 +437,34 @@ impl CtxMethods for BuildContext { use conditions::git_checkout_failed::cond; let workspace = pkg_src.source_workspace.clone(); - let pkgid = pkg_src.id.clone(); + let crateid = pkg_src.id.clone(); debug!("build: workspace = {} (in Rust path? {:?} is git dir? {:?} \ - pkgid = {} pkgsrc start_dir = {}", workspace.display(), - in_rust_path(&workspace), is_git_dir(&workspace.join(&pkgid.path)), - pkgid.to_str(), pkg_src.start_dir.display()); + crateid = {} pkgsrc start_dir = {}", workspace.display(), + in_rust_path(&workspace), is_git_dir(&workspace.join(&crateid.path)), + crateid.to_str(), pkg_src.start_dir.display()); debug!("build: what to build = {:?}", what_to_build); // If workspace isn't in the RUST_PATH, and it's a git repo, // then clone it into the first entry in RUST_PATH, and repeat - if !in_rust_path(&workspace) && is_git_dir(&workspace.join(&pkgid.path)) { + if !in_rust_path(&workspace) && is_git_dir(&workspace.join(&crateid.path)) { let mut out_dir = default_workspace().join("src"); - out_dir.push(&pkgid.path); - let git_result = source_control::safe_git_clone(&workspace.join(&pkgid.path), - &pkgid.version, + out_dir.push(&crateid.path); + let git_result = source_control::safe_git_clone(&workspace.join(&crateid.path), + &crateid.version, &out_dir); match git_result { CheckedOutSources => make_read_only(&out_dir), // FIXME (#9639): This needs to handle non-utf8 paths - _ => cond.raise((pkgid.path.as_str().unwrap().to_owned(), out_dir.clone())) + _ => cond.raise((crateid.path.as_str().unwrap().to_owned(), out_dir.clone())) }; let default_ws = default_workspace(); debug!("Calling build recursively with {:?} and {:?}", default_ws.display(), - pkgid.to_str()); + crateid.to_str()); return self.build(&mut PkgSrc::new(default_ws.clone(), default_ws, false, - pkgid.clone()), what_to_build); + crateid.clone()), what_to_build); } // Is there custom build logic? If so, use it @@ -482,7 +482,7 @@ impl CtxMethods for BuildContext { let subsysroot = sysroot.clone(); let psp = package_script_path.clone(); let ws = workspace.clone(); - let pid = pkgid.clone(); + let pid = crateid.clone(); prep.exec(proc(exec) { let mut pscript = PkgScript::parse(subsysroot.clone(), psp.clone(), @@ -550,7 +550,7 @@ impl CtxMethods for BuildContext { } } - fn clean(&self, workspace: &Path, id: &PkgId) { + fn clean(&self, workspace: &Path, id: &CrateId) { // Could also support a custom build hook in the pkg // script for cleaning files rustpkg doesn't know about. // Do something reasonable for now @@ -616,7 +616,7 @@ impl CtxMethods for BuildContext { build_workspace: &Path, build_inputs: &[Path], target_workspace: &Path, - id: &PkgId) -> ~[~str] { + id: &CrateId) -> ~[~str] { debug!("install_no_build: assuming {} comes from {} with target {}", id.to_str(), build_workspace.display(), target_workspace.display()); @@ -705,8 +705,8 @@ impl CtxMethods for BuildContext { fail!("prefer not yet implemented"); } - fn test(&self, pkgid: &PkgId, workspace: &Path) { - match built_test_in_workspace(pkgid, workspace) { + fn test(&self, crateid: &CrateId, workspace: &Path) { + match built_test_in_workspace(crateid, workspace) { Some(test_exec) => { debug!("test: test_exec = {}", test_exec.display()); // FIXME (#9639): This needs to handle non-utf8 paths @@ -723,7 +723,7 @@ impl CtxMethods for BuildContext { None => { error(format!("Internal error: test executable for package ID {} in workspace {} \ wasn't built! Please report this as a bug.", - pkgid.to_str(), workspace.display())); + crateid.to_str(), workspace.display())); } } } diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs index 4865003cb5e9f..651d64aa9d32f 100644 --- a/src/librustpkg/package_source.rs +++ b/src/librustpkg/package_source.rs @@ -11,7 +11,7 @@ extern mod extra; use target::*; -use package_id::PkgId; +use crate_id::CrateId; use std::io; use std::io::fs; use std::os; @@ -49,7 +49,7 @@ pub struct PkgSrc { // Directory to start looking in for packages -- normally // this is workspace/src/id but it may be just workspace start_dir: Path, - id: PkgId, + id: CrateId, libs: ~[Crate], mains: ~[Crate], tests: ~[Crate], @@ -77,7 +77,7 @@ impl PkgSrc { pub fn new(mut source_workspace: Path, destination_workspace: Path, use_rust_path_hack: bool, - id: PkgId) -> PkgSrc { + id: CrateId) -> PkgSrc { use conditions::nonexistent_package::cond; debug!("Checking package source for package ID {}, \ @@ -133,14 +133,14 @@ impl PkgSrc { // See if any of the prefixes of this package ID form a valid package ID // That is, is this a package ID that points into the middle of a workspace? for (prefix, suffix) in id.prefixes() { - let package_id = PkgId::new(prefix.as_str().unwrap()); - let path = build_dir.join(&package_id.path); + let crate_id = CrateId::new(prefix.as_str().unwrap()); + let path = build_dir.join(&crate_id.path); debug!("in loop: checking if {} is a directory", path.display()); if path.is_dir() { let ps = PkgSrc::new(source_workspace, destination_workspace, use_rust_path_hack, - package_id); + crate_id); match ps { PkgSrc { source_workspace: source, @@ -264,36 +264,36 @@ impl PkgSrc { /// if this was successful, None otherwise. Similarly, if the package id /// refers to a git repo on the local version, also check it out. /// (right now we only support git) - pub fn fetch_git(local: &Path, pkgid: &PkgId) -> Option { + pub fn fetch_git(local: &Path, crateid: &CrateId) -> Option { use conditions::git_checkout_failed::cond; let cwd = os::getcwd(); debug!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}", - pkgid.to_str(), pkgid.path.display(), + crateid.to_str(), crateid.path.display(), cwd.display(), - pkgid.path.exists()); + crateid.path.exists()); - match safe_git_clone(&pkgid.path, &pkgid.version, local) { + match safe_git_clone(&crateid.path, &crateid.version, local) { CheckedOutSources => { make_read_only(local); Some(local.clone()) } DirToUse(clone_target) => { - if pkgid.path.components().nth(1).is_none() { + if crateid.path.components().nth(1).is_none() { // If a non-URL, don't bother trying to fetch return None; } // FIXME (#9639): This needs to handle non-utf8 paths - let url = format!("https://{}", pkgid.path.as_str().unwrap()); + let url = format!("https://{}", crateid.path.as_str().unwrap()); debug!("Fetching package: git clone {} {} [version={}]", - url, clone_target.display(), pkgid.version.to_str()); + url, clone_target.display(), crateid.version.to_str()); let mut failed = false; cond.trap(|_| { failed = true; - }).inside(|| git_clone_url(url, &clone_target, &pkgid.version)); + }).inside(|| git_clone_url(url, &clone_target, &crateid.version)); if failed { return None; diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index 0d927fc36aece..1b8a988ab2c5a 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -12,7 +12,7 @@ #[allow(dead_code)]; -pub use package_id::PkgId; +pub use crate_id::CrateId; pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install}; pub use version::{Version, NoVersion, split_version_general, try_parsing_version}; pub use rustc::metadata::filesearch::rust_path; @@ -59,12 +59,12 @@ pub fn make_dir_rwx_recursive(p: &Path) -> bool { // now. Should fix that. /// True if there's a directory in with -/// pkgid's short name -pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool { - workspace_contains_package_id_(pkgid, workspace, |p| p.join("src")).is_some() +/// crateid's short name +pub fn workspace_contains_crate_id(crateid: &CrateId, workspace: &Path) -> bool { + workspace_contains_crate_id_(crateid, workspace, |p| p.join("src")).is_some() } -pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path, +pub fn workspace_contains_crate_id_(crateid: &CrateId, workspace: &Path, // Returns the directory it was actually found in workspace_to_src_dir: |&Path| -> Path) -> Option { if !workspace.is_dir() { @@ -77,14 +77,14 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path, let mut found = None; for p in fs::walk_dir(&src_dir) { if p.is_dir() { - if p == src_dir.join(&pkgid.path) || { + if p == src_dir.join(&crateid.path) || { let pf = p.filename_str(); pf.iter().any(|&g| { match split_version_general(g, '-') { None => false, Some((ref might_match, ref vers)) => { - *might_match == pkgid.short_name - && (pkgid.version == *vers || pkgid.version == NoVersion) + *might_match == crateid.short_name + && (crateid.version == *vers || crateid.version == NoVersion) } } }) @@ -96,9 +96,9 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path, } if found.is_some() { - debug!("Found {} in {}", pkgid.to_str(), workspace.display()); + debug!("Found {} in {}", crateid.to_str(), workspace.display()); } else { - debug!("Didn't find {} in {}", pkgid.to_str(), workspace.display()); + debug!("Didn't find {} in {}", crateid.to_str(), workspace.display()); } found } @@ -126,11 +126,11 @@ fn target_bin_dir(workspace: &Path) -> Path { workspace.join("bin") } -/// Figure out what the executable name for in 's build +/// Figure out what the executable name for in 's build /// directory is, and if the file exists, return it. -pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option { +pub fn built_executable_in_workspace(crateid: &CrateId, workspace: &Path) -> Option { let mut result = target_build_dir(workspace); - result = mk_output_path(Main, Build, pkgid, result); + result = mk_output_path(Main, Build, crateid, result); debug!("built_executable_in_workspace: checking whether {} exists", result.display()); if result.exists() { @@ -142,22 +142,22 @@ pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option< } } -/// Figure out what the test name for in 's build +/// Figure out what the test name for in 's build /// directory is, and if the file exists, return it. -pub fn built_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option { - output_in_workspace(pkgid, workspace, Test) +pub fn built_test_in_workspace(crateid: &CrateId, workspace: &Path) -> Option { + output_in_workspace(crateid, workspace, Test) } -/// Figure out what the test name for in 's build +/// Figure out what the test name for in 's build /// directory is, and if the file exists, return it. -pub fn built_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option { - output_in_workspace(pkgid, workspace, Bench) +pub fn built_bench_in_workspace(crateid: &CrateId, workspace: &Path) -> Option { + output_in_workspace(crateid, workspace, Bench) } -fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Option { +fn output_in_workspace(crateid: &CrateId, workspace: &Path, what: OutputType) -> Option { let mut result = target_build_dir(workspace); // should use a target-specific subdirectory - result = mk_output_path(what, Build, pkgid, result); + result = mk_output_path(what, Build, crateid, result); debug!("output_in_workspace: checking whether {} exists", result.display()); if result.exists() { @@ -169,10 +169,11 @@ fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Opt } } -/// Figure out what the library name for in 's build +/// Figure out what the library name for in 's build /// directory is, and if the file exists, return it. -pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option { - library_in_workspace(&pkgid.path, pkgid.short_name, Build, workspace, "build", &pkgid.version) +pub fn built_library_in_workspace(crateid: &CrateId, workspace: &Path) -> Option { + library_in_workspace(&crateid.path, crateid.short_name, Build, workspace, "build", + &crateid.version) } /// Does the actual searching stuff @@ -292,45 +293,45 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti abs_path } -/// Returns the executable that would be installed for +/// Returns the executable that would be installed for /// in /// As a side effect, creates the bin-dir if it doesn't exist -pub fn target_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path { - target_file_in_workspace(pkgid, workspace, Main, Install) +pub fn target_executable_in_workspace(crateid: &CrateId, workspace: &Path) -> Path { + target_file_in_workspace(crateid, workspace, Main, Install) } -/// Returns the executable that would be installed for +/// Returns the executable that would be installed for /// in /// As a side effect, creates the lib-dir if it doesn't exist -pub fn target_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path { +pub fn target_library_in_workspace(crateid: &CrateId, workspace: &Path) -> Path { use conditions::bad_path::cond; if !workspace.is_dir() { cond.raise(((*workspace).clone(), format!("Workspace supplied to target_library_in_workspace \ is not a directory! {}", workspace.display()))); } - target_file_in_workspace(pkgid, workspace, Lib, Install) + target_file_in_workspace(crateid, workspace, Lib, Install) } -/// Returns the test executable that would be installed for +/// Returns the test executable that would be installed for /// in /// note that we *don't* install test executables, so this is just for unit testing -pub fn target_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path { - target_file_in_workspace(pkgid, workspace, Test, Install) +pub fn target_test_in_workspace(crateid: &CrateId, workspace: &Path) -> Path { + target_file_in_workspace(crateid, workspace, Test, Install) } -/// Returns the bench executable that would be installed for +/// Returns the bench executable that would be installed for /// in /// note that we *don't* install bench executables, so this is just for unit testing -pub fn target_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path { - target_file_in_workspace(pkgid, workspace, Bench, Install) +pub fn target_bench_in_workspace(crateid: &CrateId, workspace: &Path) -> Path { + target_file_in_workspace(crateid, workspace, Bench, Install) } -/// Returns the path that pkgid `pkgid` would have if placed `where` +/// Returns the path that crateid `crateid` would have if placed `where` /// in `workspace` -fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path, +fn target_file_in_workspace(crateid: &CrateId, workspace: &Path, what: OutputType, where: Target) -> Path { use conditions::bad_path::cond; @@ -340,25 +341,25 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path, // Artifacts in the build directory live in a package-ID-specific subdirectory, // but installed ones don't. let result = match (where, what) { - (Build, _) => target_build_dir(workspace).join(&pkgid.path), + (Build, _) => target_build_dir(workspace).join(&crateid.path), (Install, Lib) => target_lib_dir(workspace), (Install, _) => target_bin_dir(workspace) }; if io::result(|| fs::mkdir_recursive(&result, io::UserRWX)).is_err() { cond.raise((result.clone(), format!("target_file_in_workspace couldn't \ - create the {} dir (pkgid={}, workspace={}, what={:?}, where={:?}", - subdir, pkgid.to_str(), workspace.display(), what, where))); + create the {} dir (crateid={}, workspace={}, what={:?}, where={:?}", + subdir, crateid.to_str(), workspace.display(), what, where))); } - mk_output_path(what, where, pkgid, result) + mk_output_path(what, where, crateid, result) } -/// Return the directory for 's build artifacts in . +/// Return the directory for 's build artifacts in . /// Creates it if it doesn't exist. -pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path { +pub fn build_pkg_id_in_workspace(crateid: &CrateId, workspace: &Path) -> Path { let mut result = target_build_dir(workspace); - result.push(&pkgid.path); + result.push(&crateid.path); debug!("Creating build dir {} for package id {}", result.display(), - pkgid.to_str()); + crateid.to_str()); fs::mkdir_recursive(&result, io::UserRWX); return result; } @@ -366,7 +367,7 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path { /// Return the output file for a given directory name, /// given whether we're building a library and whether we're building tests pub fn mk_output_path(what: OutputType, where: Target, - pkg_id: &PkgId, workspace: Path) -> Path { + pkg_id: &CrateId, workspace: Path) -> Path { let short_name_with_version = format!("{}-{}", pkg_id.short_name, pkg_id.version.to_str()); // Not local_path.dir_path()! For package foo/bar/blat/, we want @@ -399,22 +400,22 @@ pub fn mk_output_path(what: OutputType, where: Target, output_path } -/// Removes files for the package `pkgid`, assuming it's installed in workspace `workspace` -pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) { +/// Removes files for the package `crateid`, assuming it's installed in workspace `workspace` +pub fn uninstall_package_from(workspace: &Path, crateid: &CrateId) { let mut did_something = false; - let installed_bin = target_executable_in_workspace(pkgid, workspace); + let installed_bin = target_executable_in_workspace(crateid, workspace); if installed_bin.exists() { fs::unlink(&installed_bin); did_something = true; } - let installed_lib = target_library_in_workspace(pkgid, workspace); + let installed_lib = target_library_in_workspace(crateid, workspace); if installed_lib.exists() { fs::unlink(&installed_lib); did_something = true; } if !did_something { warn(format!("Warning: there don't seem to be any files for {} installed in {}", - pkgid.to_str(), workspace.display())); + crateid.to_str(), workspace.display())); } } @@ -429,7 +430,7 @@ fn dir_has_file(dir: &Path, file: &str) -> bool { dir.join(file).exists() } -pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option { +pub fn find_dir_using_rust_path_hack(p: &CrateId) -> Option { let rp = rust_path(); for dir in rp.iter() { // Require that the parent directory match the package ID diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 21f18eda1409d..7f6342dba5c79 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.rs @@ -24,7 +24,7 @@ use extra::treemap::TreeMap; use extra::getopts::groups::getopts; use std::run::ProcessOutput; use installed_packages::list_installed_packages; -use package_id::{PkgId}; +use crate_id::{CrateId}; use version::{ExactRevision, NoVersion, Version, Tagged}; use path_util::{target_executable_in_workspace, target_test_in_workspace, target_bench_in_workspace, make_dir_rwx, @@ -59,25 +59,25 @@ fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext { } } -fn fake_pkg() -> PkgId { +fn fake_pkg() -> CrateId { let sn = ~"bogus"; - PkgId { + CrateId { path: Path::new(sn.as_slice()), short_name: sn, version: NoVersion } } -fn git_repo_pkg() -> PkgId { - PkgId { +fn git_repo_pkg() -> CrateId { + CrateId { path: Path::new("mockgithub.com/catamorphism/test-pkg"), short_name: ~"test-pkg", version: NoVersion } } -fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId { - PkgId { +fn git_repo_pkg_with_tag(a_tag: ~str) -> CrateId { + CrateId { path: Path::new("mockgithub.com/catamorphism/test-pkg"), short_name: ~"test-pkg", version: Tagged(a_tag) @@ -302,15 +302,16 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s } } -fn create_local_package(pkgid: &PkgId) -> TempDir { - let (workspace, parent_dir) = mk_temp_workspace(&pkgid.path, &pkgid.version); - debug!("Created empty package dir for {}, returning {}", pkgid.to_str(), parent_dir.display()); +fn create_local_package(crateid: &CrateId) -> TempDir { + let (workspace, parent_dir) = mk_temp_workspace(&crateid.path, &crateid.version); + debug!("Created empty package dir for {}, returning {}", crateid.to_str(), + parent_dir.display()); workspace } -fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path { +fn create_local_package_in(crateid: &CrateId, pkgdir: &Path) -> Path { - let package_dir = pkgdir.join_many([~"src", pkgid.to_str()]); + let package_dir = pkgdir.join_many([~"src", crateid.to_str()]); // Create main, lib, test, and bench files fs::mkdir_recursive(&package_dir, io::UserRWX); @@ -329,29 +330,29 @@ fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path { package_dir } -fn create_local_package_with_test(pkgid: &PkgId) -> TempDir { - debug!("Dry run -- would create package {:?} with test", pkgid); - create_local_package(pkgid) // Already has tests??? +fn create_local_package_with_test(crateid: &CrateId) -> TempDir { + debug!("Dry run -- would create package {:?} with test", crateid); + create_local_package(crateid) // Already has tests??? } -fn create_local_package_with_dep(pkgid: &PkgId, subord_pkgid: &PkgId) -> TempDir { - let package_dir = create_local_package(pkgid); - create_local_package_in(subord_pkgid, package_dir.path()); - // Write a main.rs file into pkgid that references subord_pkgid - writeFile(&package_dir.path().join_many([~"src", pkgid.to_str(), ~"main.rs"]), +fn create_local_package_with_dep(crateid: &CrateId, subord_crateid: &CrateId) -> TempDir { + let package_dir = create_local_package(crateid); + create_local_package_in(subord_crateid, package_dir.path()); + // Write a main.rs file into crateid that references subord_crateid + writeFile(&package_dir.path().join_many([~"src", crateid.to_str(), ~"main.rs"]), format!("extern mod {};\nfn main() \\{\\}", - subord_pkgid.short_name)); - // Write a lib.rs file into subord_pkgid that has something in it - writeFile(&package_dir.path().join_many([~"src", subord_pkgid.to_str(), ~"lib.rs"]), + subord_crateid.short_name)); + // Write a lib.rs file into subord_crateid that has something in it + writeFile(&package_dir.path().join_many([~"src", subord_crateid.to_str(), ~"lib.rs"]), "pub fn f() {}"); package_dir } -fn create_local_package_with_custom_build_hook(pkgid: &PkgId, +fn create_local_package_with_custom_build_hook(crateid: &CrateId, custom_build_hook: &str) -> TempDir { debug!("Dry run -- would create package {} with custom build hook {}", - pkgid.to_str(), custom_build_hook); - create_local_package(pkgid) + crateid.to_str(), custom_build_hook); + create_local_package(crateid) // actually write the pkg.rs with the custom build hook } @@ -376,18 +377,18 @@ fn assert_executable_exists(repo: &Path, short_name: &str) { fn executable_exists(repo: &Path, short_name: &str) -> bool { debug!("executable_exists: repo = {}, short_name = {}", repo.display(), short_name); - let exec = target_executable_in_workspace(&PkgId::new(short_name), repo); + let exec = target_executable_in_workspace(&CrateId::new(short_name), repo); exec.exists() && is_rwx(&exec) } fn test_executable_exists(repo: &Path, short_name: &str) -> bool { debug!("test_executable_exists: repo = {}, short_name = {}", repo.display(), short_name); - let exec = built_test_in_workspace(&PkgId::new(short_name), repo); + let exec = built_test_in_workspace(&CrateId::new(short_name), repo); exec.map_default(false, |exec| exec.exists() && is_rwx(&exec)) } -fn remove_executable_file(p: &PkgId, workspace: &Path) { - let exec = target_executable_in_workspace(&PkgId::new(p.short_name), workspace); +fn remove_executable_file(p: &CrateId, workspace: &Path) { + let exec = target_executable_in_workspace(&CrateId::new(p.short_name), workspace); if exec.exists() { fs::unlink(&exec); } @@ -400,15 +401,15 @@ fn assert_built_executable_exists(repo: &Path, short_name: &str) { fn built_executable_exists(repo: &Path, short_name: &str) -> bool { debug!("assert_built_executable_exists: repo = {}, short_name = {}", repo.display(), short_name); - let exec = built_executable_in_workspace(&PkgId::new(short_name), repo); + let exec = built_executable_in_workspace(&CrateId::new(short_name), repo); exec.is_some() && { let execname = exec.get_ref(); execname.exists() && is_rwx(execname) } } -fn remove_built_executable_file(p: &PkgId, workspace: &Path) { - let exec = built_executable_in_workspace(&PkgId::new(p.short_name), workspace); +fn remove_built_executable_file(p: &CrateId, workspace: &Path) { + let exec = built_executable_in_workspace(&CrateId::new(p.short_name), workspace); match exec { Some(r) => fs::unlink(&r), None => () @@ -443,7 +444,7 @@ fn assert_built_library_exists(repo: &Path, short_name: &str) { fn built_library_exists(repo: &Path, short_name: &str) -> bool { debug!("assert_built_library_exists: repo = {}, short_name = {}", repo.display(), short_name); - let lib = built_library_in_workspace(&PkgId::new(short_name), repo); + let lib = built_library_in_workspace(&CrateId::new(short_name), repo); lib.is_some() && { let libname = lib.get_ref(); libname.exists() && is_rwx(libname) @@ -493,9 +494,9 @@ fn output_file_name(workspace: &Path, short_name: ~str) -> Path { } #[cfg(target_os = "linux")] -fn touch_source_file(workspace: &Path, pkgid: &PkgId) { +fn touch_source_file(workspace: &Path, crateid: &CrateId) { use conditions::bad_path::cond; - let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]); + let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]); let contents = fs::readdir(&pkg_src_dir); for p in contents.iter() { if p.extension_str() == Some("rs") { @@ -513,9 +514,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) { } #[cfg(not(target_os = "linux"))] -fn touch_source_file(workspace: &Path, pkgid: &PkgId) { +fn touch_source_file(workspace: &Path, crateid: &CrateId) { use conditions::bad_path::cond; - let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]); + let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]); let contents = fs::readdir(&pkg_src_dir); for p in contents.iter() { if p.extension_str() == Some("rs") { @@ -532,9 +533,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) { } /// Add a comment at the end -fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) { +fn frob_source_file(workspace: &Path, crateid: &CrateId, filename: &str) { use conditions::bad_path::cond; - let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]); + let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]); let mut maybe_p = None; let maybe_file = pkg_src_dir.join(filename); debug!("Trying to frob {} -- {}", pkg_src_dir.display(), filename); @@ -618,7 +619,7 @@ fn test_install_valid() { #[ignore] fn test_install_invalid() { let sysroot = test_sysroot(); - let pkgid = fake_pkg(); + let crateid = fake_pkg(); let temp_workspace = TempDir::new("test").expect("couldn't create temp dir"); let temp_workspace = temp_workspace.path().clone(); let ctxt = fake_ctxt(sysroot, &temp_workspace); @@ -628,7 +629,7 @@ fn test_install_invalid() { let pkg_src = PkgSrc::new(temp_workspace.clone(), temp_workspace.clone(), false, - pkgid.clone()); + crateid.clone()); ctxt.install(pkg_src, &WhatToBuild::new(MaybeCustom, Everything)); }; assert!(result.unwrap_err() @@ -637,7 +638,7 @@ fn test_install_invalid() { #[test] fn test_install_valid_external() { - let temp_pkg_id = PkgId::new("foo"); + let temp_pkg_id = CrateId::new("foo"); let (tempdir, _) = mk_temp_workspace(&temp_pkg_id.path, &temp_pkg_id.version); let temp_workspace = tempdir.path(); @@ -724,7 +725,7 @@ fn test_install_git() { } #[test] -fn test_package_ids_must_be_relative_path_like() { +fn test_crate_ids_must_be_relative_path_like() { use conditions::bad_pkg_id::cond; /* @@ -738,30 +739,30 @@ fn test_package_ids_must_be_relative_path_like() { */ - let whatever = PkgId::new("foo"); + let whatever = CrateId::new("foo"); assert_eq!(~"foo-0.0", whatever.to_str()); assert!("github.com/catamorphism/test-pkg-0.0" == - PkgId::new("github.com/catamorphism/test-pkg").to_str()); + CrateId::new("github.com/catamorphism/test-pkg").to_str()); cond.trap(|(p, e)| { assert!(p.filename().is_none()) - assert!("0-length pkgid" == e); + assert!("0-length crate_id" == e); whatever.clone() }).inside(|| { - let x = PkgId::new(""); + let x = CrateId::new(""); assert_eq!(~"foo-0.0", x.to_str()); }); cond.trap(|(p, e)| { let abs = os::make_absolute(&Path::new("foo/bar/quux")); assert_eq!(p, abs); - assert!("absolute pkgid" == e); + assert!("absolute crate_id" == e); whatever.clone() }).inside(|| { let zp = os::make_absolute(&Path::new("foo/bar/quux")); // FIXME (#9639): This needs to handle non-utf8 paths - let z = PkgId::new(zp.as_str().unwrap()); + let z = CrateId::new(zp.as_str().unwrap()); assert_eq!(~"foo-0.0", z.to_str()); }) } @@ -785,7 +786,7 @@ fn test_package_version() { add_git_tag(&repo_subdir, ~"0.4"); // It won't pick up the 0.4 version because the dir isn't in the RUST_PATH, but... - let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version"); + let temp_pkg_id = CrateId::new("mockgithub.com/catamorphism/test_pkg_version"); // This should look at the prefix, clone into a workspace, then build. command_line_test([~"install", ~"mockgithub.com/catamorphism/test_pkg_version"], repo); @@ -837,7 +838,7 @@ fn test_package_request_version() { } None => false }); - let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version#0.3"); + let temp_pkg_id = CrateId::new("mockgithub.com/catamorphism/test_pkg_version#0.3"); assert!(target_executable_in_workspace(&temp_pkg_id, &repo.join(".rust")) == repo.join_many([".rust", "bin", "test_pkg_version"])); @@ -880,7 +881,7 @@ fn rustpkg_library_target() { #[test] fn rustpkg_local_pkg() { - let dir = create_local_package(&PkgId::new("foo")); + let dir = create_local_package(&CrateId::new("foo")); command_line_test([~"install", ~"foo"], dir.path()); assert_executable_exists(dir.path(), "foo"); } @@ -888,7 +889,7 @@ fn rustpkg_local_pkg() { #[test] #[ignore(reason="busted")] fn package_script_with_default_build() { - let dir = create_local_package(&PkgId::new("fancy-lib")); + let dir = create_local_package(&CrateId::new("fancy-lib")); let dir = dir.path(); debug!("dir = {}", dir.display()); let mut source = test_sysroot().dir_path(); @@ -945,7 +946,7 @@ fn rustpkg_clean_no_arg() { command_line_test([~"build"], &package_dir); assert_built_executable_exists(&tmp, "foo"); command_line_test([~"clean"], &package_dir); - let res = built_executable_in_workspace(&PkgId::new("foo"), &tmp); + let res = built_executable_in_workspace(&CrateId::new("foo"), &tmp); assert!(!res.as_ref().map_default(false, |m| m.exists())); } @@ -1003,11 +1004,11 @@ fn rust_path_parse() { fn test_list() { let dir = TempDir::new("test_list").expect("test_list failed"); let dir = dir.path(); - let foo = PkgId::new("foo"); + let foo = CrateId::new("foo"); create_local_package_in(&foo, dir); - let bar = PkgId::new("bar"); + let bar = CrateId::new("bar"); create_local_package_in(&bar, dir); - let quux = PkgId::new("quux"); + let quux = CrateId::new("quux"); create_local_package_in(&quux, dir); // list doesn't output very much right now... @@ -1033,9 +1034,9 @@ fn test_list() { fn install_remove() { let dir = TempDir::new("install_remove").expect("install_remove"); let dir = dir.path(); - let foo = PkgId::new("foo"); - let bar = PkgId::new("bar"); - let quux = PkgId::new("quux"); + let foo = CrateId::new("foo"); + let bar = CrateId::new("bar"); + let quux = CrateId::new("quux"); create_local_package_in(&foo, dir); create_local_package_in(&bar, dir); create_local_package_in(&quux, dir); @@ -1062,13 +1063,13 @@ fn install_check_duplicates() { // check invariant that there are no dups in the pkg database let dir = TempDir::new("install_remove").expect("install_remove"); let dir = dir.path(); - let foo = PkgId::new("foo"); + let foo = CrateId::new("foo"); create_local_package_in(&foo, dir); command_line_test([~"install", ~"foo"], dir); command_line_test([~"install", ~"foo"], dir); let mut contents = ~[]; - let check_dups = |p: &PkgId| { + let check_dups = |p: &CrateId| { if contents.contains(p) { fail!("package {} appears in `list` output more than once", p.path.display()); } @@ -1082,7 +1083,7 @@ fn install_check_duplicates() { #[test] fn no_rebuilding() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); command_line_test([~"build", ~"foo"], workspace); @@ -1103,7 +1104,7 @@ fn no_rebuilding() { #[test] #[ignore] fn no_recopying() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); command_line_test([~"install", ~"foo"], workspace); @@ -1122,8 +1123,8 @@ fn no_recopying() { #[test] fn no_rebuilding_dep() { - let p_id = PkgId::new("foo"); - let dep_id = PkgId::new("bar"); + let p_id = CrateId::new("foo"); + let dep_id = CrateId::new("bar"); let workspace = create_local_package_with_dep(&p_id, &dep_id); let workspace = workspace.path(); command_line_test([~"build", ~"foo"], workspace); @@ -1141,8 +1142,8 @@ fn no_rebuilding_dep() { #[test] fn do_rebuild_dep_dates_change() { - let p_id = PkgId::new("foo"); - let dep_id = PkgId::new("bar"); + let p_id = CrateId::new("foo"); + let dep_id = CrateId::new("bar"); let workspace = create_local_package_with_dep(&p_id, &dep_id); let workspace = workspace.path(); command_line_test([~"build", ~"foo"], workspace); @@ -1161,8 +1162,8 @@ fn do_rebuild_dep_dates_change() { #[test] fn do_rebuild_dep_only_contents_change() { - let p_id = PkgId::new("foo"); - let dep_id = PkgId::new("bar"); + let p_id = CrateId::new("foo"); + let dep_id = CrateId::new("bar"); let workspace = create_local_package_with_dep(&p_id, &dep_id); let workspace = workspace.path(); command_line_test([~"build", ~"foo"], workspace); @@ -1182,8 +1183,8 @@ fn do_rebuild_dep_only_contents_change() { #[test] fn test_versions() { - let workspace = create_local_package(&PkgId::new("foo#0.1")); - let _other_workspace = create_local_package(&PkgId::new("foo#0.2")); + let workspace = create_local_package(&CrateId::new("foo#0.1")); + let _other_workspace = create_local_package(&CrateId::new("foo#0.2")); command_line_test([~"install", ~"foo#0.1"], workspace.path()); let output = command_line_test_output([~"list"]); // make sure output includes versions @@ -1193,7 +1194,7 @@ fn test_versions() { #[test] #[ignore(reason = "do not yet implemented")] fn test_build_hooks() { - let workspace = create_local_package_with_custom_build_hook(&PkgId::new("foo"), + let workspace = create_local_package_with_custom_build_hook(&CrateId::new("foo"), "frob"); command_line_test([~"do", ~"foo", ~"frob"], workspace.path()); } @@ -1203,14 +1204,14 @@ fn test_build_hooks() { #[ignore(reason = "info not yet implemented")] fn test_info() { let expected_info = ~"package foo"; // fill in - let workspace = create_local_package(&PkgId::new("foo")); + let workspace = create_local_package(&CrateId::new("foo")); let output = command_line_test([~"info", ~"foo"], workspace.path()); assert_eq!(str::from_utf8_owned(output.output), expected_info); } #[test] fn test_uninstall() { - let workspace = create_local_package(&PkgId::new("foo")); + let workspace = create_local_package(&CrateId::new("foo")); command_line_test([~"uninstall", ~"foo"], workspace.path()); let output = command_line_test([~"list"], workspace.path()); assert!(!str::from_utf8(output.output).contains("foo")); @@ -1346,7 +1347,7 @@ fn test_extern_mod_simpler() { #[test] fn test_import_rustpkg() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]), @@ -1359,7 +1360,7 @@ fn test_import_rustpkg() { #[test] fn test_macro_pkg_script() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]), @@ -1386,7 +1387,7 @@ fn multiple_workspaces() { // FIXME (#9639): This needs to handle non-utf8 paths let env = Some(~[(~"RUST_PATH", format!("{}:{}", a_loc.as_str().unwrap(), b_loc.as_str().unwrap()))]); - let c_loc = create_local_package_with_dep(&PkgId::new("bar"), &PkgId::new("foo")); + let c_loc = create_local_package_with_dep(&CrateId::new("bar"), &CrateId::new("foo")); command_line_test_with_env([~"install", ~"bar"], c_loc.path(), env); } @@ -1399,7 +1400,7 @@ fn rust_path_hack_test(hack_flag: bool) { make sure built files for foo are in B make sure nothing gets built into A or A/../build[lib,bin] */ - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace"); @@ -1524,8 +1525,8 @@ fn rust_path_hack_build_no_arg() { #[test] fn rust_path_hack_build_with_dependency() { - let foo_id = PkgId::new("foo"); - let dep_id = PkgId::new("dep"); + let foo_id = CrateId::new("foo"); + let dep_id = CrateId::new("dep"); // Tests that when --rust-path-hack is in effect, dependencies get built // into the destination workspace and not the source directory let work_dir = create_local_package(&foo_id); @@ -1573,7 +1574,7 @@ fn rust_path_install_target() { #[test] fn sysroot_flag() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); // no-op sysroot setting; I'm not sure how else to test this @@ -1589,7 +1590,7 @@ fn sysroot_flag() { #[test] fn compile_flag_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1606,7 +1607,7 @@ fn compile_flag_build() { #[test] fn compile_flag_fail() { // --no-link shouldn't be accepted for install - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1622,7 +1623,7 @@ fn compile_flag_fail() { #[test] fn notrans_flag_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let flags_to_test = [~"--no-trans", ~"--parse-only", @@ -1647,7 +1648,7 @@ fn notrans_flag_build() { #[test] fn notrans_flag_fail() { // --no-trans shouldn't be accepted for install - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let flags_to_test = [~"--no-trans", ~"--parse-only", @@ -1668,7 +1669,7 @@ fn notrans_flag_fail() { #[test] fn dash_S() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1685,7 +1686,7 @@ fn dash_S() { #[test] fn dash_S_fail() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1702,7 +1703,7 @@ fn dash_S_fail() { #[test] fn test_cfg_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); // If the cfg flag gets messed up, this won't compile @@ -1721,7 +1722,7 @@ fn test_cfg_build() { #[test] fn test_cfg_fail() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); writeFile(&workspace.join_many(["src", "foo-0.0", "main.rs"]), @@ -1740,7 +1741,7 @@ fn test_cfg_fail() { #[test] fn test_emit_llvm_S_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1758,7 +1759,7 @@ fn test_emit_llvm_S_build() { #[test] fn test_emit_llvm_S_fail() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1778,7 +1779,7 @@ fn test_emit_llvm_S_fail() { #[test] fn test_emit_llvm_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1797,7 +1798,7 @@ fn test_emit_llvm_build() { #[test] fn test_emit_llvm_fail() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1818,7 +1819,7 @@ fn test_emit_llvm_fail() { #[test] fn test_linker_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let matches = getopts([], optgroups()); @@ -1863,7 +1864,7 @@ fn test_build_install_flags_fail() { #[test] fn test_optimized_build() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1877,7 +1878,7 @@ fn test_optimized_build() { } #[test] -fn pkgid_pointing_to_subdir() { +fn crateid_pointing_to_subdir() { // The actual repo is mockgithub.com/mozilla/some_repo // rustpkg should recognize that and treat the part after some_repo/ as a subdir let workspace = TempDir::new("parent_repo").expect("Couldn't create temp dir"); @@ -1913,9 +1914,9 @@ fn pkgid_pointing_to_subdir() { #[test] fn test_recursive_deps() { - let a_id = PkgId::new("a"); - let b_id = PkgId::new("b"); - let c_id = PkgId::new("c"); + let a_id = CrateId::new("a"); + let b_id = CrateId::new("b"); + let c_id = CrateId::new("c"); let b_workspace = create_local_package_with_dep(&b_id, &c_id); let b_workspace = b_workspace.path(); writeFile(&b_workspace.join_many(["src", "c-0.0", "lib.rs"]), @@ -1939,7 +1940,7 @@ fn test_recursive_deps() { #[test] fn test_install_to_rust_path() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let second_workspace = create_local_package(&p_id); let second_workspace = second_workspace.path(); let first_workspace = mk_empty_workspace(&Path::new("p"), &NoVersion, "dest"); @@ -1963,7 +1964,7 @@ fn test_install_to_rust_path() { #[test] fn test_target_specific_build_dir() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1979,7 +1980,7 @@ fn test_target_specific_build_dir() { #[test] fn test_target_specific_install_dir() { - let p_id = PkgId::new("foo"); + let p_id = CrateId::new("foo"); let workspace = create_local_package(&p_id); let workspace = workspace.path(); let test_sys = test_sysroot(); @@ -1998,7 +1999,7 @@ fn test_target_specific_install_dir() { #[test] #[ignore(reason = "See #7240")] fn test_dependencies_terminate() { - let b_id = PkgId::new("b"); + let b_id = CrateId::new("b"); let workspace = create_local_package(&b_id); let workspace = workspace.path(); let b_dir = workspace.join_many(["src", "b-0.0"]); @@ -2011,7 +2012,7 @@ fn test_dependencies_terminate() { #[test] fn install_after_build() { - let b_id = PkgId::new("b"); + let b_id = CrateId::new("b"); let workspace = create_local_package(&b_id); let workspace = workspace.path(); command_line_test([~"build", ~"b"], workspace); @@ -2022,7 +2023,7 @@ fn install_after_build() { #[test] fn reinstall() { - let b = PkgId::new("b"); + let b = CrateId::new("b"); let workspace = create_local_package(&b); let workspace = workspace.path(); // 1. Install, then remove executable file, then install again, @@ -2061,8 +2062,8 @@ fn correct_package_name_with_rust_path_hack() { */ // Set RUST_PATH to something containing only the sources for foo - let foo_id = PkgId::new("foo"); - let bar_id = PkgId::new("bar"); + let foo_id = CrateId::new("foo"); + let bar_id = CrateId::new("bar"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace"); @@ -2091,7 +2092,7 @@ fn correct_package_name_with_rust_path_hack() { #[test] fn test_rustpkg_test_creates_exec() { - let foo_id = PkgId::new("foo"); + let foo_id = CrateId::new("foo"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]), @@ -2102,7 +2103,7 @@ fn test_rustpkg_test_creates_exec() { #[test] fn test_rustpkg_test_output() { - let workspace = create_local_package_with_test(&PkgId::new("foo")); + let workspace = create_local_package_with_test(&CrateId::new("foo")); let output = command_line_test([~"test", ~"foo"], workspace.path()); let output_str = str::from_utf8(output.output); // The first two assertions are separate because test output may @@ -2114,7 +2115,7 @@ fn test_rustpkg_test_output() { #[test] fn test_rustpkg_test_failure_exit_status() { - let foo_id = PkgId::new("foo"); + let foo_id = CrateId::new("foo"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]), @@ -2128,7 +2129,7 @@ fn test_rustpkg_test_failure_exit_status() { #[test] fn test_rustpkg_test_cfg() { - let foo_id = PkgId::new("foo"); + let foo_id = CrateId::new("foo"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]), @@ -2141,7 +2142,7 @@ fn test_rustpkg_test_cfg() { #[test] fn test_rebuild_when_needed() { - let foo_id = PkgId::new("foo"); + let foo_id = CrateId::new("foo"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]); @@ -2162,7 +2163,7 @@ fn test_rebuild_when_needed() { #[test] #[ignore] // FIXME (#10257): This doesn't work as is since a read only file can't execute fn test_no_rebuilding() { - let foo_id = PkgId::new("foo"); + let foo_id = CrateId::new("foo"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]); @@ -2196,7 +2197,7 @@ fn test_installed_read_only() { writeFile(&repo_subdir.join("lib.rs"), "pub fn f() { let _x = (); }"); add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files - // update pkgid to what will be auto-detected + // update crateid to what will be auto-detected temp_pkg_id.version = ExactRevision(~"0.1"); // FIXME (#9639): This needs to handle non-utf8 paths @@ -2281,7 +2282,7 @@ fn test_installed_local_changes() { #[test] fn test_7402() { - let dir = create_local_package(&PkgId::new("foo")); + let dir = create_local_package(&CrateId::new("foo")); let dest_workspace = TempDir::new("more_rust").expect("test_7402"); let dest_workspace = dest_workspace.path(); // FIXME (#9639): This needs to handle non-utf8 paths @@ -2295,7 +2296,7 @@ fn test_7402() { #[test] fn test_compile_error() { - let foo_id = PkgId::new("foo"); + let foo_id = CrateId::new("foo"); let foo_workspace = create_local_package(&foo_id); let foo_workspace = foo_workspace.path(); let main_crate = foo_workspace.join_many(["src", "foo-0.0", "main.rs"]); @@ -2329,7 +2330,7 @@ fn test_c_dependency_ok() { // registers a hook to build it if it's not fresh // After running `build`, test that the C library built - let dir = create_local_package(&PkgId::new("cdep")); + let dir = create_local_package(&CrateId::new("cdep")); let dir = dir.path(); writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]), "#[link_args = \"-lfoo\"]\nextern { fn f(); } \ @@ -2352,7 +2353,7 @@ fn test_c_dependency_ok() { #[test] #[ignore(reason="busted")] fn test_c_dependency_no_rebuilding() { - let dir = create_local_package(&PkgId::new("cdep")); + let dir = create_local_package(&CrateId::new("cdep")); let dir = dir.path(); writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]), "#[link_args = \"-lfoo\"]\nextern { fn f(); } \ @@ -2386,7 +2387,7 @@ fn test_c_dependency_no_rebuilding() { #[test] #[ignore(reason="busted")] fn test_c_dependency_yes_rebuilding() { - let dir = create_local_package(&PkgId::new("cdep")); + let dir = create_local_package(&CrateId::new("cdep")); let dir = dir.path(); writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]), "#[link_args = \"-lfoo\"]\nextern { fn f(); } \ @@ -2407,7 +2408,7 @@ fn test_c_dependency_yes_rebuilding() { assert!(c_library_path.exists()); // Now, make the Rust library read-only so rebuilding will fail - match built_library_in_workspace(&PkgId::new("cdep"), dir) { + match built_library_in_workspace(&CrateId::new("cdep"), dir) { Some(ref pth) => assert!(chmod_read_only(pth)), None => assert_built_library_exists(dir, "cdep") } @@ -2425,7 +2426,7 @@ fn test_c_dependency_yes_rebuilding() { fn correct_error_dependency() { // Supposing a package we're trying to install via a dependency doesn't // exist, we should throw a condition, and not ICE - let workspace_dir = create_local_package(&PkgId::new("badpkg")); + let workspace_dir = create_local_package(&CrateId::new("badpkg")); let dir = workspace_dir.path(); let main_rs = dir.join_many(["src", "badpkg-0.0", "main.rs"]); diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 17b46b883b37f..4ec752aeb391a 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -29,7 +29,7 @@ use syntax::util::small_vector::SmallVector; use rustc::back::link::output_type_exe; use rustc::back::link; use context::{in_target, StopBefore, Link, Assemble, BuildContext}; -use package_id::PkgId; +use crate_id::CrateId; use package_source::PkgSrc; use workspace::pkg_parent_workspaces; use path_util::{system_library, target_build_dir}; @@ -52,7 +52,7 @@ static COMMANDS: &'static [&'static str] = pub type ExitCode = int; // For now pub struct Pkg { - id: PkgId, + id: CrateId, bins: ~[~str], libs: ~[~str], } @@ -170,7 +170,7 @@ pub fn ready_crate(sess: session::Session, pub fn compile_input(context: &BuildContext, exec: &mut workcache::Exec, - pkg_id: &PkgId, + pkg_id: &CrateId, in_file: &Path, workspace: &Path, deps: &mut DepMap, @@ -303,17 +303,17 @@ pub fn compile_input(context: &BuildContext, addl_lib_search_paths.get().insert(p); }); - // Inject the pkgid attribute so we get the right package name and version + // Inject the crate_id attribute so we get the right package name and version if !attr::contains_name(crate.attrs, "crate_id") { // FIXME (#9639): This needs to handle non-utf8 paths - let pkgid_attr = + let crateid_attr = attr::mk_name_value_item_str(@"crate_id", format!("{}\\#{}", pkg_id.path.as_str().unwrap(), pkg_id.version.to_str()).to_managed()); - debug!("pkgid attr: {:?}", pkgid_attr); - crate.attrs.push(attr::mk_attr(pkgid_attr)); + debug!("crateid attr: {:?}", crateid_attr); + crate.attrs.push(attr::mk_attr(crateid_attr)); } debug!("calling compile_crate_from_input, workspace = {}, @@ -428,7 +428,7 @@ pub fn exe_suffix() -> ~str { ~"" } // Called by build_crates pub fn compile_crate(ctxt: &BuildContext, exec: &mut workcache::Exec, - pkg_id: &PkgId, + pkg_id: &CrateId, crate: &Path, workspace: &Path, deps: &mut DepMap, @@ -446,7 +446,7 @@ pub fn compile_crate(ctxt: &BuildContext, struct ViewItemVisitor<'a> { context: &'a BuildContext, - parent: &'a PkgId, + parent: &'a CrateId, parent_crate: &'a Path, sess: session::Session, exec: &'a mut workcache::Exec, @@ -491,7 +491,7 @@ impl<'a> Visitor<()> for ViewItemVisitor<'a> { debug!("Trying to install library {}, rebuilding it", lib_name.to_str()); // Try to install it - let pkg_id = PkgId::new(lib_name); + let pkg_id = CrateId::new(lib_name); // Find all the workspaces in the RUST_PATH that contain this package. let workspaces = pkg_parent_workspaces(&self.context.context, &pkg_id); @@ -607,7 +607,7 @@ impl<'a> Visitor<()> for ViewItemVisitor<'a> { /// try to install their targets, failing if any target /// can't be found. pub fn find_and_install_dependencies(context: &BuildContext, - parent: &PkgId, + parent: &CrateId, parent_crate: &Path, sess: session::Session, exec: &mut workcache::Exec, diff --git a/src/librustpkg/workspace.rs b/src/librustpkg/workspace.rs index 95fc667727240..d6e617d2d5071 100644 --- a/src/librustpkg/workspace.rs +++ b/src/librustpkg/workspace.rs @@ -13,23 +13,23 @@ use std::os; use std::path::Path; use context::Context; -use path_util::{workspace_contains_package_id, find_dir_using_rust_path_hack, default_workspace}; +use path_util::{workspace_contains_crate_id, find_dir_using_rust_path_hack, default_workspace}; use path_util::rust_path; use util::option_to_vec; -use package_id::PkgId; +use crate_id::CrateId; pub fn each_pkg_parent_workspace(cx: &Context, - pkgid: &PkgId, + crateid: &CrateId, action: |&Path| -> bool) -> bool { // Using the RUST_PATH, find workspaces that contain // this package ID - let workspaces = pkg_parent_workspaces(cx, pkgid); + let workspaces = pkg_parent_workspaces(cx, crateid); if workspaces.is_empty() { // tjc: make this a condition fail!("Package {} not found in any of \ the following workspaces: {}", - pkgid.path.display(), + crateid.path.display(), rust_path().map(|p| p.display().to_str()).to_str()); } for ws in workspaces.iter() { @@ -42,12 +42,12 @@ pub fn each_pkg_parent_workspace(cx: &Context, /// Given a package ID, return a vector of all of the workspaces in /// the RUST_PATH that contain it -pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] { +pub fn pkg_parent_workspaces(cx: &Context, crateid: &CrateId) -> ~[Path] { let rs: ~[Path] = rust_path().move_iter() - .filter(|ws| workspace_contains_package_id(pkgid, ws)) + .filter(|ws| workspace_contains_crate_id(crateid, ws)) .collect(); if cx.use_rust_path_hack { - rs + option_to_vec(find_dir_using_rust_path_hack(pkgid)) + rs + option_to_vec(find_dir_using_rust_path_hack(crateid)) } else { rs @@ -56,7 +56,7 @@ pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] { /// Construct a workspace and package-ID name based on the current directory. /// This gets used when rustpkg gets invoked without a package-ID argument. -pub fn cwd_to_workspace() -> Option<(Path, PkgId)> { +pub fn cwd_to_workspace() -> Option<(Path, CrateId)> { let cwd = os::getcwd(); for path in rust_path().move_iter() { let srcpath = path.join("src"); @@ -64,7 +64,7 @@ pub fn cwd_to_workspace() -> Option<(Path, PkgId)> { let rel = cwd.path_relative_from(&srcpath); let rel_s = rel.as_ref().and_then(|p|p.as_str()); if rel_s.is_some() { - return Some((path, PkgId::new(rel_s.unwrap()))); + return Some((path, CrateId::new(rel_s.unwrap()))); } } } diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 45a91d01b7a9c..814cf3287717b 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +//! Traits for dynamic typing of any type (through runtime reflection) +//! //! This module implements the `Any` trait, which enables dynamic typing //! of any type, through runtime reflection. //! diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 4cdcbbdb9e8e1..97f0a6a9d8af8 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations on ASCII strings and characters. +//! Operations on ASCII strings and characters use to_str::{ToStr,IntoStr}; use str; diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 7b1d29b664b6d..fd8b88417e0eb 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Managed vectors +//! Operations on managed vectors (`@[T]` type) use clone::Clone; use container::Container; diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index 29c304f9ac539..923aacf352bc0 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! The `bool` module contains useful code to help work with boolean values. +//! Operations on boolean values (`bool` type) //! //! A quick summary: //! diff --git a/src/libstd/char.rs b/src/libstd/char.rs index 93667bb6225ff..4e9c72de61887 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Utilities for manipulating the char type +//! Unicode characters manipulation (`char` type) use cast::transmute; use option::{None, Option, Some}; diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 6bff438bbc605..b383c9edf36d3 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! The Clone trait for types that cannot be "implicitly copied" +/*! The `Clone` trait for types that cannot be 'implicitly copied' In Rust, some simple types are "implicitly copyable" and when you assign them or pass them as arguments, the receiver will get a copy, diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs index 21db234122b2e..b21b255dbfc7c 100644 --- a/src/libstd/comm/mod.rs +++ b/src/libstd/comm/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Rust Communication Primitives +//! Communication primitives for concurrent tasks (`Chan` and `Port` types) //! //! Rust makes it very difficult to share data among tasks to prevent race //! conditions and to improve parallelism, but there is often a need for @@ -599,7 +599,7 @@ impl Chan { // the TLS overhead can be a bit much. n => { assert!(n >= 0); - if n > 0 && n % RESCHED_FREQ == 0 { + if can_resched && n > 0 && n % RESCHED_FREQ == 0 { let task: ~Task = Local::take(); task.maybe_yield(); } @@ -1019,7 +1019,6 @@ mod test { }) #[test] - #[ignore(cfg(windows))] // FIXME(#11003) fn send_from_outside_runtime() { let (p, c) = Chan::::new(); let (p1, c1) = Chan::new(); @@ -1044,7 +1043,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#11003) fn recv_from_outside_runtime() { let (p, c) = Chan::::new(); let (dp, dc) = Chan::new(); @@ -1061,7 +1059,6 @@ mod test { } #[test] - #[ignore(cfg(windows))] // FIXME(#11003) fn no_runtime() { let (p1, c1) = Chan::::new(); let (p2, c2) = Chan::::new(); diff --git a/src/libstd/container.rs b/src/libstd/container.rs index c91a53f966388..326b9fa3d3321 100644 --- a/src/libstd/container.rs +++ b/src/libstd/container.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Container traits +//! Traits for generic containers (including `Map` and `Set`) use option::Option; diff --git a/src/libstd/default.rs b/src/libstd/default.rs index 120cf3fa8013b..aaba23c683bca 100644 --- a/src/libstd/default.rs +++ b/src/libstd/default.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! The Default trait +//! The `Default` trait for types which may have meaningful default values /// A trait that types which have a useful default value should implement. pub trait Default { diff --git a/src/libstd/either.rs b/src/libstd/either.rs index 96f4e524852d1..d07006aa6de75 100644 --- a/src/libstd/either.rs +++ b/src/libstd/either.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! A type that represents one of two alternatives +//! Representing values with two possibilities (`Either` type) #[allow(missing_doc)]; diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 3bbf8031fff93..cd9c0f5d2b77c 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -10,7 +10,7 @@ /*! -The Formatting Module +Utilities for formatting and printing strings This module contains the runtime support for the `format!` syntax extension. This macro is implemented in the compiler to emit calls to this module in order diff --git a/src/libstd/from_str.rs b/src/libstd/from_str.rs index e5bf9f6bb2a41..289a5f11c4f61 100644 --- a/src/libstd/from_str.rs +++ b/src/libstd/from_str.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! The trait for types that can be created from strings +//! The `FromStr` trait for types that can be created from strings use option::Option; diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 03956560db939..6ef327ab617d1 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! An unordered map and set type implemented as hash tables +//! Unordered containers, implemented as hash-tables (`HashSet` and `HashMap` types) //! //! The tables use a keyed hash with new random keys generated for each container, so the ordering //! of a set of keys in a hash table is randomized. diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs index b116f92f3d0c9..462a0f1b0c8a4 100644 --- a/src/libstd/kinds.rs +++ b/src/libstd/kinds.rs @@ -9,7 +9,7 @@ // except according to those terms. /*! -The kind traits +Primitive traits representing basic 'kinds' of types Rust types can be classified in various useful ways according to intrinsic properties of the type. These classifications, often called diff --git a/src/libstd/logging.rs b/src/libstd/logging.rs index fb83cfdd6ea8a..d1b812ae36567 100644 --- a/src/libstd/logging.rs +++ b/src/libstd/logging.rs @@ -10,7 +10,7 @@ /*! -Logging +Utilities for program-wide and customizable logging This module is used by the compiler when emitting output for the logging family of macros. The methods of this module shouldn't necessarily be used directly, diff --git a/src/libstd/num/cmath.rs b/src/libstd/num/cmath.rs index 5212b6fc15ec4..a91dee7fa501c 100644 --- a/src/libstd/num/cmath.rs +++ b/src/libstd/num/cmath.rs @@ -12,6 +12,8 @@ #[allow(non_uppercase_statics)]; #[allow(dead_code)]; +//! Bindings for the C math library (for basic mathematic functions) + // function names are almost identical to C's libmath, a few have been // renamed, grep for "rename:" diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 2cb7d527618e6..43b0235c5f45a 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `f32` +//! Operations and constants for 32-bits floats (`f32` type) #[allow(missing_doc)]; use prelude::*; diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 1f01c26ad76f3..c2d19d4121542 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `f64` +//! Operations and constants for 64-bits floats (`f64` type) #[allow(missing_doc)]; diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index fcf1f24d0e455..5f431dfdf0427 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `i16` +//! Operations and constants for signed 16-bits integers (`i16` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 385e1c91ca503..8bb03344923de 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `i32` +//! Operations and constants for signed 32-bits integers (`i32` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index f6b369b1312a5..891043ad5f82d 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `i64` +//! Operations and constants for signed 64-bits integers (`i64` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index 9de90ca4657d1..fd123ec57cc74 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `i8` +//! Operations and constants for signed 8-bits integers (`i8` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index 517bd45e45bd1..123555e4a63d8 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `int` +//! Operations and constants for architecture-sized signed integers (`int` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 0f81a5faac811..8dbec0f63c601 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Numeric traits and functions for generic mathematics. +//! Numeric traits and functions for generic mathematics //! //! These are implemented for the primitive numeric types in `std::{u8, u16, //! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`. diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs index ed8ec3b6c54b9..7e4145fc723db 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `u16` +//! Operations and constants for unsigned 16-bits integers (`u16` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 2977549803384..34c2a892d56b7 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `u32` +//! Operations and constants for unsigned 32-bits integers (`u32` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index dc43801eb3958..c307b038627f9 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `u64` +//! Operations and constants for unsigned 64-bits integer (`u64` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index 12ad4efdbd5d1..06bda72c5fe6d 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `u8` +//! Operations and constants for unsigned 8-bits integers (`u8` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index 549490050c590..a752cd938ba0d 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations and constants for `uint` +//! Operations and constants for architecture-sized unsigned integers (`uint` type) #[allow(non_uppercase_statics)]; diff --git a/src/libstd/ops.rs b/src/libstd/ops.rs index 5bce884448a21..fbefce71e88a6 100644 --- a/src/libstd/ops.rs +++ b/src/libstd/ops.rs @@ -13,8 +13,10 @@ /*! * - * Traits for the built-in operators. Implementing these traits allows you to get - * an effect similar to overloading operators. + * Traits representing built-in operators, useful for overloading + * + * Implementing these traits allows you to get an effect similar to + * overloading operators. * * The values for the right hand side of an operator are automatically * borrowed, so `a + b` is sugar for `a.add(&b)`. diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 5467a894cff3b..35db800b3cc2a 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Operations on the ubiquitous `Option` type. +//! Optionally nullable values (`Option` type) //! //! Type `Option` represents an optional value. //! diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index f59264254ad97..3c81ff661bcbf 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -10,6 +10,8 @@ /*! +The standard module imported by default into all Rust modules + Many programming languages have a 'prelude': a particular subset of the libraries that come with the language. Every program imports the prelude by default. diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 917b14e4b4f6e..336bbe637b474 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -9,7 +9,7 @@ // except according to those terms. /*! -Random number generation. +Utilities for random number generation The key functions are `random()` and `Rng::gen()`. These are polymorphic and so can be used to generate any type that implements `Rand`. Type inference diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index f2beea992c67a..9158e8cdb899c 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! Task-local reference counted boxes +/*! Task-local reference-counted boxes (`Rc` type) The `Rc` type provides shared ownership of an immutable value. Destruction is deterministic, and will occur as soon as the last owner is gone. It is marked as non-sendable because it avoids the diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 2dbba3096982f..4e8db15a92ebd 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! A type representing either success or failure +//! Signaling success or failure states (`Result` type) use clone::Clone; use cmp::Eq; diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 0dd6c883d5b47..9bd804f7babe8 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! The Rust Runtime, including the task scheduler and I/O +/*! Runtime services, including the task scheduler and I/O dispatcher The `rt` module provides the private runtime infrastructure necessary to support core language features like the exchange and local heap, diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 33be746e604d9..337cb744080eb 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Process spawning. +//! Utilities for spawning and managing processes #[allow(missing_doc)]; diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs index b0bc4c3f46793..f10818b052df1 100644 --- a/src/libstd/send_str.rs +++ b/src/libstd/send_str.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! `SendStr` definition and trait implementations +//! The `SendStr` trait for optionally static strings use clone::{Clone, DeepClone}; use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv}; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 2f5ef932a18e6..8e6d8523f779b 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -10,7 +10,7 @@ /*! -String manipulation +Unicode string manipulation (`str` type) # Basic Usage diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 2f0f9bf64af4c..bc45b9e3c4a6a 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -9,7 +9,7 @@ // except according to those terms. /*! - * Task management. + * Utilities for managing and scheduling tasks * * An executing Rust program consists of a tree of tasks, each with their own * stack, and sole ownership of their allocated heap data. Tasks communicate diff --git a/src/libstd/to_bytes.rs b/src/libstd/to_bytes.rs index 815320be94e6a..9de812ed3856a 100644 --- a/src/libstd/to_bytes.rs +++ b/src/libstd/to_bytes.rs @@ -10,7 +10,7 @@ /*! -The `ToBytes` and `IterBytes` traits +The `ToBytes` and `IterBytes` traits for converting to raw bytes */ diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 09dd091d0e716..4f3f253d5e24d 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! An ordered map and set for integer keys implemented as a radix trie +//! Ordered containers with integer keys, implemented as radix tries (`TrieSet` and `TrieMap` types) use prelude::*; use uint; diff --git a/src/libstd/unstable/mutex.rs b/src/libstd/unstable/mutex.rs index 5b2fac8e74e2e..7ab8a83d04ba8 100644 --- a/src/libstd/unstable/mutex.rs +++ b/src/libstd/unstable/mutex.rs @@ -286,7 +286,7 @@ mod imp { pub unsafe fn wait(cond: *c_void, m: *c_void) { unlock(m); - WaitForSingleObject(cond as HANDLE, 0); + WaitForSingleObject(cond as HANDLE, libc::INFINITE); lock(m); } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 85dac814add57..d12d61ed46c88 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Miscellaneous helpers for common patterns. +//! Miscellaneous helpers for common patterns use cast; use ptr; diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index aa349ed81860a..450cf1a4ef25c 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -10,7 +10,7 @@ /*! -Vector manipulation +Utilities for vector manipulation The `vec` module contains useful code to help work with vector values. Vectors are Rust's list type. Vectors contain zero or more values of @@ -2069,6 +2069,10 @@ fn merge_sort(v: &mut [T], compare: |&T, &T| -> Ordering) { /// Extension methods for vectors such that their elements are /// mutable. pub trait MutableVector<'a, T> { + /// Work with `self` as a mut slice. + /// Primarily intended for getting a &mut [T] from a [T, ..N]. + fn as_mut_slice(self) -> &'a mut [T]; + /// Return a slice that points into another slice. fn mut_slice(self, start: uint, end: uint) -> &'a mut [T]; @@ -2302,6 +2306,8 @@ pub trait MutableVector<'a, T> { impl<'a,T> MutableVector<'a, T> for &'a mut [T] { #[inline] + fn as_mut_slice(self) -> &'a mut [T] { self } + fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { assert!(start <= end); assert!(end <= self.len()); diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 8dff321ca0e6a..f2526c29b9a80 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -16,7 +16,7 @@ use codemap::{Span, Spanned, spanned, dummy_spanned}; use codemap::BytePos; use diagnostic::span_handler; use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; -use pkgid::PkgId; +use crateid::CrateId; use std::hashmap::HashSet; @@ -234,10 +234,10 @@ pub fn find_linkage_metas(attrs: &[Attribute]) -> ~[@MetaItem] { result } -pub fn find_pkgid(attrs: &[Attribute]) -> Option { +pub fn find_crateid(attrs: &[Attribute]) -> Option { match first_attr_value_str_by_name(attrs, "crate_id") { None => None, - Some(id) => from_str::(id), + Some(id) => from_str::(id), } } diff --git a/src/libsyntax/pkgid.rs b/src/libsyntax/crateid.rs similarity index 57% rename from src/libsyntax/pkgid.rs rename to src/libsyntax/crateid.rs index 3c10e5199c926..0bb1eec512bf7 100644 --- a/src/libsyntax/pkgid.rs +++ b/src/libsyntax/crateid.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/// PkgIds identify crates and include the crate name and optionall a path and -/// version. In the full form, they look like relative URLs. Example: +/// CrateIds identify crates and include the crate name and optionally a path +/// and version. In the full form, they look like relative URLs. Example: /// `github.com/mozilla/rust#std:1.0` would be a package ID with a path of /// `gitub.com/mozilla/rust` and a crate name of `std` with a version of /// `1.0`. If no crate name is given after the hash, the name is inferred to /// be the last component of the path. If no version is given, it is inferred /// to be `0.0`. #[deriving(Clone, Eq)] -pub struct PkgId { +pub struct CrateId { /// A path which represents the codes origin. By convention this is the /// URL, without `http://` or `https://` prefix, to the crate's repository path: ~str, @@ -26,7 +26,7 @@ pub struct PkgId { version: Option<~str>, } -impl ToStr for PkgId { +impl ToStr for CrateId { fn to_str(&self) -> ~str { let version = match self.version { None => "0.0", @@ -40,8 +40,8 @@ impl ToStr for PkgId { } } -impl FromStr for PkgId { - fn from_str(s: &str) -> Option { +impl FromStr for CrateId { + fn from_str(s: &str) -> Option { let pieces: ~[&str] = s.splitn('#', 1).collect(); let path = pieces[0].to_owned(); @@ -78,7 +78,7 @@ impl FromStr for PkgId { (name, version) }; - Some(PkgId { + Some(CrateId { path: path, name: name, version: version, @@ -86,7 +86,7 @@ impl FromStr for PkgId { } } -impl PkgId { +impl CrateId { pub fn version_or_default<'a>(&'a self) -> &'a str { match self.version { None => "0.0", @@ -97,90 +97,90 @@ impl PkgId { #[test] fn bare_name() { - let pkgid: PkgId = from_str("foo").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"foo"); - assert_eq!(pkgid.version, None); - assert_eq!(pkgid.path, ~"foo"); + let crateid: CrateId = from_str("foo").expect("valid crateid"); + assert_eq!(crateid.name, ~"foo"); + assert_eq!(crateid.version, None); + assert_eq!(crateid.path, ~"foo"); } #[test] fn bare_name_single_char() { - let pkgid: PkgId = from_str("f").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"f"); - assert_eq!(pkgid.version, None); - assert_eq!(pkgid.path, ~"f"); + let crateid: CrateId = from_str("f").expect("valid crateid"); + assert_eq!(crateid.name, ~"f"); + assert_eq!(crateid.version, None); + assert_eq!(crateid.path, ~"f"); } #[test] -fn empty_pkgid() { - let pkgid: Option = from_str(""); - assert!(pkgid.is_none()); +fn empty_crateid() { + let crateid: Option = from_str(""); + assert!(crateid.is_none()); } #[test] fn simple_path() { - let pkgid: PkgId = from_str("example.com/foo/bar").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"bar"); - assert_eq!(pkgid.version, None); - assert_eq!(pkgid.path, ~"example.com/foo/bar"); + let crateid: CrateId = from_str("example.com/foo/bar").expect("valid crateid"); + assert_eq!(crateid.name, ~"bar"); + assert_eq!(crateid.version, None); + assert_eq!(crateid.path, ~"example.com/foo/bar"); } #[test] fn simple_version() { - let pkgid: PkgId = from_str("foo#1.0").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"foo"); - assert_eq!(pkgid.version, Some(~"1.0")); - assert_eq!(pkgid.path, ~"foo"); + let crateid: CrateId = from_str("foo#1.0").expect("valid crateid"); + assert_eq!(crateid.name, ~"foo"); + assert_eq!(crateid.version, Some(~"1.0")); + assert_eq!(crateid.path, ~"foo"); } #[test] fn absolute_path() { - let pkgid: Option = from_str("/foo/bar"); - assert!(pkgid.is_none()); + let crateid: Option = from_str("/foo/bar"); + assert!(crateid.is_none()); } #[test] fn path_ends_with_slash() { - let pkgid: Option = from_str("foo/bar/"); - assert!(pkgid.is_none()); + let crateid: Option = from_str("foo/bar/"); + assert!(crateid.is_none()); } #[test] fn path_and_version() { - let pkgid: PkgId = from_str("example.com/foo/bar#1.0").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"bar"); - assert_eq!(pkgid.version, Some(~"1.0")); - assert_eq!(pkgid.path, ~"example.com/foo/bar"); + let crateid: CrateId = from_str("example.com/foo/bar#1.0").expect("valid crateid"); + assert_eq!(crateid.name, ~"bar"); + assert_eq!(crateid.version, Some(~"1.0")); + assert_eq!(crateid.path, ~"example.com/foo/bar"); } #[test] fn single_chars() { - let pkgid: PkgId = from_str("a/b#1").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"b"); - assert_eq!(pkgid.version, Some(~"1")); - assert_eq!(pkgid.path, ~"a/b"); + let crateid: CrateId = from_str("a/b#1").expect("valid crateid"); + assert_eq!(crateid.name, ~"b"); + assert_eq!(crateid.version, Some(~"1")); + assert_eq!(crateid.path, ~"a/b"); } #[test] fn missing_version() { - let pkgid: PkgId = from_str("foo#").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"foo"); - assert_eq!(pkgid.version, None); - assert_eq!(pkgid.path, ~"foo"); + let crateid: CrateId = from_str("foo#").expect("valid crateid"); + assert_eq!(crateid.name, ~"foo"); + assert_eq!(crateid.version, None); + assert_eq!(crateid.path, ~"foo"); } #[test] fn path_and_name() { - let pkgid: PkgId = from_str("foo/rust-bar#bar:1.0").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"bar"); - assert_eq!(pkgid.version, Some(~"1.0")); - assert_eq!(pkgid.path, ~"foo/rust-bar"); + let crateid: CrateId = from_str("foo/rust-bar#bar:1.0").expect("valid crateid"); + assert_eq!(crateid.name, ~"bar"); + assert_eq!(crateid.version, Some(~"1.0")); + assert_eq!(crateid.path, ~"foo/rust-bar"); } #[test] fn empty_name() { - let pkgid: PkgId = from_str("foo/bar#:1.0").expect("valid pkgid"); - assert_eq!(pkgid.name, ~"bar"); - assert_eq!(pkgid.version, Some(~"1.0")); - assert_eq!(pkgid.path, ~"foo/bar"); + let crateid: CrateId = from_str("foo/bar#:1.0").expect("valid crateid"); + assert_eq!(crateid.name, ~"bar"); + assert_eq!(crateid.version, Some(~"1.0")); + assert_eq!(crateid.path, ~"foo/bar"); } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index a8c5ba0153db9..9631849235e86 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -47,7 +47,7 @@ pub mod fold; pub mod parse; -pub mod pkgid; +pub mod crateid; pub mod print { pub mod pp; diff --git a/src/llvm b/src/llvm index eac6ff795c407..8841dcef357e0 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit eac6ff795c40778683e42b0c6ab6f6adaceb391d +Subproject commit 8841dcef357e051c34a46030db7c7b1a83f9b1d8 diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 4ac341a12e42a..cab9c187eae0d 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -81,9 +81,7 @@ LLVMRustCreateTargetMachine(const char *triple, TargetOptions Options; Options.NoFramePointerElim = true; Options.EnableSegmentedStacks = EnableSegmentedStacks; - Options.FloatABIType = - (Trip.getEnvironment() == Triple::GNUEABIHF) ? FloatABI::Hard : - FloatABI::Default; + Options.FloatABIType = FloatABI::Default; Options.UseSoftFloat = UseSoftFloat; if (UseSoftFloat) { Options.FloatABIType = FloatABI::Soft; diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger index 14dfc92097a2e..95b950973d18e 100644 --- a/src/rustllvm/llvm-auto-clean-trigger +++ b/src/rustllvm/llvm-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2013-12-18 +2013-12-29 diff --git a/src/snapshots.txt b/src/snapshots.txt index 2d6e42e005f00..bd21413e1e31c 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2013-12-27 a5fa1d9 + freebsd-x86_64 7ed0226bb924d40bebda19e7bb0a7663233a600c + linux-i386 10c113aa925f9985b5111ded570b7db4a50b8569 + linux-x86_64 64a2e929996833dc5d032ccdb9c288c4d4ec3d3c + macos-i386 c7d4c05a04aa7d3865a431b0a7243894c08d1619 + macos-x86_64 164731b12d766fc562ef8b6950cec99e475047b3 + winnt-i386 0037dfef804a72419945c8b3a7b8a4ff24017a13 + S 2013-12-25 cab6af5 freebsd-x86_64 bf06667e19a24ffad3a4111c704e9e919f08b076 linux-i386 1d3c54daa6192f823dab694e5ea42c636633df6b diff --git a/src/test/compile-fail/issue-7573.rs b/src/test/compile-fail/issue-7573.rs index 4ab0ac6386e4c..3b8eda8f78388 100644 --- a/src/test/compile-fail/issue-7573.rs +++ b/src/test/compile-fail/issue-7573.rs @@ -8,14 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct PkgId { +pub struct CrateId { local_path: ~str, junk: ~str } -impl PkgId { - fn new(s: &str) -> PkgId { - PkgId { +impl CrateId { + fn new(s: &str) -> CrateId { + CrateId { local_path: s.to_owned(), junk: ~"wutevs" } @@ -23,8 +23,8 @@ impl PkgId { } pub fn remove_package_from_database() { - let mut lines_to_use: ~[&PkgId] = ~[]; //~ ERROR cannot infer an appropriate lifetime - let push_id = |installed_id: &PkgId| { + let mut lines_to_use: ~[&CrateId] = ~[]; //~ ERROR cannot infer an appropriate lifetime + let push_id = |installed_id: &CrateId| { lines_to_use.push(installed_id); }; list_database(push_id); @@ -35,11 +35,11 @@ pub fn remove_package_from_database() { } -pub fn list_database(f: |&PkgId|) { +pub fn list_database(f: |&CrateId|) { let stuff = ["foo", "bar"]; for l in stuff.iter() { - f(&PkgId::new(*l)); + f(&CrateId::new(*l)); } } diff --git a/src/test/run-make/rustdoc-hidden-line/Makefile b/src/test/run-make/rustdoc-hidden-line/Makefile new file mode 100644 index 0000000000000..7e6f8fe105e92 --- /dev/null +++ b/src/test/run-make/rustdoc-hidden-line/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTDOC) --test foo.rs + $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs + cp verify.sh $(TMPDIR) + $(call RUN,verify.sh) $(TMPDIR) diff --git a/src/test/run-make/rustdoc-hidden-line/foo.rs b/src/test/run-make/rustdoc-hidden-line/foo.rs new file mode 100644 index 0000000000000..69c7683780b2f --- /dev/null +++ b/src/test/run-make/rustdoc-hidden-line/foo.rs @@ -0,0 +1,22 @@ +#[crate_id="foo#0.1"]; + +/// The '# ' lines should be removed from the output, but the #[deriving] should be +/// retained. +/// +/// ```rust +/// mod to_make_deriving_work { // FIXME #4913 +/// +/// # #[deriving(Eq)] // invisible +/// # struct Foo; // invisible +/// +/// #[deriving(Eq)] // Bar +/// struct Bar(Foo); +/// +/// fn test() { +/// let x = Bar(Foo); +/// assert!(x == x); // check that the derivings worked +/// } +/// +/// } +/// ``` +pub fn foo() {} diff --git a/src/test/run-make/rustdoc-hidden-line/verify.sh b/src/test/run-make/rustdoc-hidden-line/verify.sh new file mode 100755 index 0000000000000..c1d817c998d29 --- /dev/null +++ b/src/test/run-make/rustdoc-hidden-line/verify.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +file="$1/doc/foo/fn.foo.html" + +grep -v 'invisible' $file && +grep '#\[deriving(Eq)\] // Bar' $file + +exit $?