Skip to content

Commit c29ee26

Browse files
committed
---
yaml --- r: 146518 b: refs/heads/try2 c: 8379890 h: refs/heads/master v: v3
1 parent 1a79a53 commit c29ee26

File tree

18 files changed

+231
-21
lines changed

18 files changed

+231
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f6e8d49a1a3cd67933c7efebfe7a0c55470049f3
8+
refs/heads/try2: 8379890c05b20e97fcc73c1865b8b3787caecc9f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/getopts.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,14 @@ impl Name {
185185
}
186186

187187
impl Matches {
188-
/// FIXME: #9311 This used to be private, but rustpkg somehow managed to depend on it.
189-
/// No idea what this does.
190-
pub fn opt_vals(&self, nm: &str) -> ~[Optval] {
188+
fn opt_vals(&self, nm: &str) -> ~[Optval] {
191189
match find_opt(self.opts, Name::from_str(nm)) {
192190
Some(id) => self.vals[id].clone(),
193191
None => fail!("No option '{}' defined", nm)
194192
}
195193
}
196194

197-
/// FIXME: #9311 This used to be private, but rustpkg somehow managed to depend on it.
198-
/// No idea what this does.
199-
pub fn opt_val(&self, nm: &str) -> Option<Optval> {
195+
fn opt_val(&self, nm: &str) -> Option<Optval> {
200196
let vals = self.opt_vals(nm);
201197
if (vals.is_empty()) {
202198
None

branches/try2/src/libextra/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Rust extras are part of the standard Rust distribution.
2121
*/
2222

2323
#[link(name = "extra",
24+
package_id = "extra",
2425
vers = "0.9-pre",
2526
uuid = "122bed0b-c19b-4b82-b0b7-7ae8aead7297",
2627
url = "https://github.com/mozilla/rust/tree/master/src/libextra")];

branches/try2/src/librustc/back/link.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,18 @@ pub fn build_link_meta(sess: Session,
634634
}
635635
}
636636

637+
fn crate_meta_pkgid(sess: Session, name: @str, opt_pkg_id: Option<@str>)
638+
-> @str {
639+
match opt_pkg_id {
640+
Some(v) if !v.is_empty() => v,
641+
_ => {
642+
let pkg_id = name.clone();
643+
warn_missing(sess, "package_id", pkg_id);
644+
pkg_id
645+
}
646+
}
647+
}
648+
637649
let ProvidedMetas {
638650
name: opt_name,
639651
vers: opt_vers,
@@ -642,15 +654,16 @@ pub fn build_link_meta(sess: Session,
642654
} = provided_link_metas(sess, c);
643655
let name = crate_meta_name(sess, output, opt_name);
644656
let vers = crate_meta_vers(sess, opt_vers);
657+
let pkg_id = crate_meta_pkgid(sess, name, opt_pkg_id);
645658
let dep_hashes = cstore::get_dep_hashes(sess.cstore);
646659
let extras_hash =
647660
crate_meta_extras_hash(symbol_hasher, cmh_items,
648-
dep_hashes, opt_pkg_id);
661+
dep_hashes, Some(pkg_id));
649662

650663
LinkMeta {
651664
name: name,
652665
vers: vers,
653-
package_id: opt_pkg_id,
666+
package_id: Some(pkg_id),
654667
extras_hash: extras_hash
655668
}
656669
}

branches/try2/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#[link(name = "rustc",
12+
package_id = "rustc",
1213
vers = "0.9-pre",
1314
uuid = "0ce89b41-2f92-459e-bbc1-8f5fe32f16cf",
1415
url = "https://github.com/mozilla/rust/tree/master/src/rustc")];

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,8 +1501,8 @@ fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[Attribute]) {
15011501

15021502
// So there's a special crate attribute called 'link' which defines the
15031503
// metadata that Rust cares about for linking crates. This attribute requires
1504-
// 'name' and 'vers' items, so if the user didn't provide them we will throw
1505-
// them in anyway with default values.
1504+
// 'name', 'vers' and 'package_id' items, so if the user didn't provide them we
1505+
// will throw them in anyway with default values.
15061506
fn synthesize_crate_attrs(ecx: &EncodeContext,
15071507
crate: &Crate) -> ~[Attribute] {
15081508

@@ -1519,9 +1519,20 @@ fn synthesize_crate_attrs(ecx: &EncodeContext,
15191519
attr::mk_name_value_item_str(@"vers",
15201520
ecx.link_meta.vers);
15211521

1522-
let mut meta_items = ~[name_item, vers_item];
1522+
let pkgid_item = match ecx.link_meta.package_id {
1523+
Some(pkg_id) => attr::mk_name_value_item_str(@"package_id",
1524+
pkg_id),
1525+
// uses package_id equal to name;
1526+
// this should never happen here but package_id is an Option
1527+
// FIXME (#10370): change package_id in LinkMeta to @str instead of Option<@str>
1528+
_ => attr::mk_name_value_item_str(@"package_id",
1529+
ecx.link_meta.name)
1530+
};
1531+
1532+
let mut meta_items = ~[name_item, vers_item, pkgid_item];
15231533

1524-
for &mi in items.iter().filter(|mi| "name" != mi.name() && "vers" != mi.name()) {
1534+
for &mi in items.iter().filter(|mi| "name" != mi.name() && "vers" != mi.name() &&
1535+
"package_id" != mi.name()) {
15251536
meta_items.push(mi);
15261537
}
15271538
let link_item = attr::mk_list_item(@"link", meta_items);

branches/try2/src/librustdoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#[link(name = "rustdoc",
12+
package_id = "rustdoc",
1213
vers = "0.9-pre",
1314
uuid = "8c6e4598-1596-4aa5-a24c-b811914bbbc6",
1415
url = "https://github.com/mozilla/rust/tree/master/src/librustdoc")];

branches/try2/src/librustpkg/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// rustpkg - a package manager and build system for Rust
1212

1313
#[link(name = "rustpkg",
14+
package_id = "rustpkg",
1415
vers = "0.9-pre",
1516
uuid = "25de5e6e-279e-4a20-845c-4cabae92daaf",
1617
url = "https://github.com/mozilla/rust/tree/master/src/librustpkg")];
@@ -762,7 +763,7 @@ pub fn main_args(args: &[~str]) -> int {
762763
matches.opt_present("help");
763764
let no_link = matches.opt_present("no-link");
764765
let no_trans = matches.opt_present("no-trans");
765-
let supplied_sysroot = matches.opt_val("sysroot");
766+
let supplied_sysroot = matches.opt_str("sysroot");
766767
let generate_asm = matches.opt_present("S") ||
767768
matches.opt_present("assembly");
768769
let parse_only = matches.opt_present("parse-only");
@@ -894,7 +895,7 @@ pub fn main_args(args: &[~str]) -> int {
894895
let mut remaining_args: ~[~str] = remaining_args.map(|s| (*s).clone()).collect();
895896
remaining_args.shift();
896897
let sroot = match supplied_sysroot {
897-
Some(getopts::Val(s)) => Path::new(s),
898+
Some(s) => Path::new(s),
898899
_ => filesearch::get_or_default_sysroot()
899900
};
900901

branches/try2/src/librustpkg/tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,24 @@ fn no_rebuilding() {
10961096
}
10971097
}
10981098
1099+
#[test]
1100+
fn no_recopying() {
1101+
let p_id = PkgId::new("foo");
1102+
let workspace = create_local_package(&p_id);
1103+
let workspace = workspace.path();
1104+
command_line_test([~"install", ~"foo"], workspace);
1105+
let foo_lib = installed_library_in_workspace(&p_id.path, workspace);
1106+
assert!(foo_lib.is_some());
1107+
// Now make `foo` read-only so that subsequent attempts to copy to it will fail
1108+
assert!(chmod_read_only(&foo_lib.unwrap()));
1109+
1110+
match command_line_test_partial([~"install", ~"foo"], workspace) {
1111+
Success(*) => (), // ok
1112+
Fail(65) => fail!("no_recopying failed: it tried to re-copy foo"),
1113+
Fail(_) => fail!("no_copying failed for some other reason")
1114+
}
1115+
}
1116+
10991117
#[test]
11001118
fn no_rebuilding_dep() {
11011119
let p_id = PkgId::new("foo");

branches/try2/src/librustuv/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ via `close` and `delete` methods.
3535
*/
3636

3737
#[link(name = "rustuv",
38+
package_id = "rustuv",
3839
vers = "0.9-pre",
3940
uuid = "f3719011-0459-9b86-b11c-29265c0d0864",
4041
url = "https://github.com/mozilla/rust/tree/master/src/librustuv")];

branches/try2/src/libstd/any.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use cast::transmute;
1515
use cmp::Eq;
1616
use option::{Option, Some, None};
17+
use to_bytes::{IterBytes, Cb};
1718
use to_str::ToStr;
1819
use unstable::intrinsics;
1920
use util::Void;
@@ -42,6 +43,12 @@ impl Eq for TypeId {
4243
}
4344
}
4445

46+
impl IterBytes for TypeId {
47+
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
48+
self.t.iter_bytes(lsb0, f)
49+
}
50+
}
51+
4552
///////////////////////////////////////////////////////////////////////////////
4653
// Any trait
4754
///////////////////////////////////////////////////////////////////////////////
@@ -175,6 +182,7 @@ mod tests {
175182
use super::*;
176183
use super::AnyRefExt;
177184
use option::{Some, None};
185+
use hash::Hash;
178186

179187
#[deriving(Eq)]
180188
struct Test;
@@ -197,6 +205,13 @@ mod tests {
197205
assert_eq!(c, f);
198206
}
199207

208+
#[test]
209+
fn type_id_hash() {
210+
let (a, b) = (TypeId::of::<uint>(), TypeId::of::<uint>::());
211+
212+
assert_eq!(a.hash(), b.hash());
213+
}
214+
200215
#[test]
201216
fn any_as_void_ptr() {
202217
let (a, b, c) = (~5u as ~Any, ~TEST as ~Any, ~Test as ~Any);

branches/try2/src/libstd/clone.rs

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,27 @@ pub trait Clone {
2929
/// are copied to maintain uniqueness, while the contents of
3030
/// managed pointers are not copied.
3131
fn clone(&self) -> Self;
32+
33+
/// Perform copy-assignment from `source`.
34+
///
35+
/// `a.clone_from(&b)` is equivalent to `a = b.clone()` in functionality,
36+
/// but can be overriden to reuse the resources of `a` to avoid unnecessary
37+
/// allocations.
38+
#[inline(always)]
39+
fn clone_from(&mut self, source: &Self) {
40+
*self = source.clone()
41+
}
3242
}
3343

3444
impl<T: Clone> Clone for ~T {
35-
/// Return a deep copy of the owned box.
45+
/// Return a copy of the owned box.
3646
#[inline]
3747
fn clone(&self) -> ~T { ~(**self).clone() }
48+
49+
/// Perform copy-assignment from `source` by reusing the existing allocation.
50+
fn clone_from(&mut self, source: &~T) {
51+
**self = (**source).clone()
52+
}
3853
}
3954

4055
impl<T> Clone for @T {
@@ -118,16 +133,31 @@ extern_fn_clone!(A, B, C, D, E, F, G, H)
118133

119134
/// A trait distinct from `Clone` which represents "deep copies" of things like
120135
/// managed boxes which would otherwise not be copied.
121-
pub trait DeepClone {
136+
pub trait DeepClone: Clone {
122137
/// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
123138
/// *are* copied.
124139
fn deep_clone(&self) -> Self;
140+
141+
/// Perform deep copy-assignment from `source`.
142+
///
143+
/// `a.deep_clone_from(&b)` is equivalent to `a = b.deep_clone()` in
144+
/// functionality, but can be overriden to reuse the resources of `a` to
145+
/// avoid unnecessary allocations.
146+
#[inline(always)]
147+
fn deep_clone_from(&mut self, source: &Self) {
148+
*self = source.deep_clone()
149+
}
125150
}
126151

127152
impl<T: DeepClone> DeepClone for ~T {
128153
/// Return a deep copy of the owned box.
129154
#[inline]
130155
fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
156+
157+
/// Perform deep copy-assignment from `source` by reusing the existing allocation.
158+
fn deep_clone_from(&mut self, source: &~T) {
159+
**self = (**source).deep_clone()
160+
}
131161
}
132162

133163
// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
@@ -234,6 +264,22 @@ fn test_borrowed_clone() {
234264
assert_eq!(*z, 5);
235265
}
236266

267+
#[test]
268+
fn test_clone_from() {
269+
let a = ~5;
270+
let mut b = ~10;
271+
b.clone_from(&a);
272+
assert_eq!(*b, 5);
273+
}
274+
275+
#[test]
276+
fn test_deep_clone_from() {
277+
let a = ~5;
278+
let mut b = ~10;
279+
b.deep_clone_from(&a);
280+
assert_eq!(*b, 5);
281+
}
282+
237283
#[test]
238284
fn test_extern_fn_clone() {
239285
trait Empty {}

branches/try2/src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
//! use std::prelude::*;
4545
4646
#[link(name = "std",
47+
package_id = "std",
4748
vers = "0.9-pre",
4849
uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
4950
url = "https://github.com/mozilla/rust/tree/master/src/libstd")];

0 commit comments

Comments
 (0)