Skip to content

Commit a70e797

Browse files
committed
---
yaml --- r: 47095 b: refs/heads/try c: 6351515 h: refs/heads/master i: 47093: 624898a 47091: 8cbc596 47087: 192e3c0 v: v3
1 parent 75fe52a commit a70e797

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1156
-582
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: c77c5c4674c92b342132a56bd1b59f86af3d5a63
5+
refs/heads/try: 6351515d98d4d79500eac021bd573fbbd586bb24
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/os.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,17 @@ pub fn path_exists(p: &Path) -> bool {
565565
*
566566
* If the given path is relative, return it prepended with the current working
567567
* directory. If the given path is already an absolute path, return it
568-
* as is. This is a shortcut for calling os::getcwd().unsafe_join(p)
568+
* as is.
569569
*/
570570
// NB: this is here rather than in path because it is a form of environment
571571
// querying; what it does depends on the process working directory, not just
572572
// the input paths.
573573
pub fn make_absolute(p: &Path) -> Path {
574-
getcwd().unsafe_join(p)
574+
if p.is_absolute {
575+
copy *p
576+
} else {
577+
getcwd().push_many(p.components)
578+
}
575579
}
576580

577581

branches/try/src/libcore/path.rs

Lines changed: 5 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ pub trait GenericPath {
6464
pure fn push_many((&[~str])) -> Self;
6565
pure fn pop() -> Self;
6666

67-
pure fn unsafe_join((&Self)) -> Self;
68-
pure fn is_restricted() -> bool;
69-
7067
pure fn normalize() -> Self;
7168
}
7269

@@ -488,19 +485,6 @@ impl GenericPath for PosixPath {
488485
self.push_many(other.components)
489486
}
490487

491-
pure fn unsafe_join(other: &PosixPath) -> PosixPath {
492-
if other.is_absolute {
493-
PosixPath { is_absolute: true,
494-
components: copy other.components }
495-
} else {
496-
self.push_rel(other)
497-
}
498-
}
499-
500-
pure fn is_restricted() -> bool {
501-
false
502-
}
503-
504488
pure fn push_many(cs: &[~str]) -> PosixPath {
505489
let mut v = copy self.components;
506490
for cs.each |e| {
@@ -701,61 +685,6 @@ impl GenericPath for WindowsPath {
701685
self.push_many(other.components)
702686
}
703687

704-
pure fn unsafe_join(other: &WindowsPath) -> WindowsPath {
705-
/* rhs not absolute is simple push */
706-
if !other.is_absolute {
707-
return self.push_many(other.components);
708-
}
709-
710-
/* if rhs has a host set, then the whole thing wins */
711-
match other.host {
712-
Some(copy host) => {
713-
return WindowsPath {
714-
host: Some(host),
715-
device: copy other.device,
716-
is_absolute: true,
717-
components: copy other.components
718-
};
719-
}
720-
_ => {}
721-
}
722-
723-
/* if rhs has a device set, then a part wins */
724-
match other.device {
725-
Some(copy device) => {
726-
return WindowsPath {
727-
host: None,
728-
device: Some(device),
729-
is_absolute: true,
730-
components: copy other.components
731-
};
732-
}
733-
_ => {}
734-
}
735-
736-
/* fallback: host and device of lhs win, but the
737-
whole path of the right */
738-
WindowsPath {
739-
host: copy self.host,
740-
device: copy self.device,
741-
is_absolute: self.is_absolute || other.is_absolute,
742-
components: copy other.components
743-
}
744-
}
745-
746-
pure fn is_restricted() -> bool {
747-
match self.filestem() {
748-
Some(stem) => {
749-
match stem.to_lower() {
750-
~"con" | ~"aux" | ~"com1" | ~"com2" | ~"com3" | ~"com4" |
751-
~"lpt1" | ~"lpt2" | ~"lpt3" | ~"prn" | ~"nul" => true,
752-
_ => false
753-
}
754-
},
755-
None => false
756-
}
757-
}
758-
759688
pure fn push_many(cs: &[~str]) -> WindowsPath {
760689
let mut v = copy self.components;
761690
for cs.each |e| {
@@ -796,10 +725,7 @@ impl GenericPath for WindowsPath {
796725
pure fn normalize() -> WindowsPath {
797726
return WindowsPath {
798727
host: copy self.host,
799-
device: match self.device {
800-
None => None,
801-
Some(ref device) => Some(device.to_upper())
802-
},
728+
device: copy self.device,
803729
is_absolute: self.is_absolute,
804730
components: normalize(self.components)
805731
}
@@ -838,13 +764,13 @@ pub mod windows {
838764
839765
pub pure fn extract_unc_prefix(s: &str) -> Option<(~str,~str)> {
840766
if (s.len() > 1 &&
841-
(s[0] == '\\' as u8 || s[0] == '/' as u8) &&
842-
s[0] == s[1]) {
767+
s[0] == '\\' as u8 &&
768+
s[1] == '\\' as u8) {
843769
let mut i = 2;
844770
while i < s.len() {
845-
if is_sep(s[i]) {
771+
if s[i] == '\\' as u8 {
846772
let pre = s.slice(2, i);
847-
let mut rest = s.slice(i, s.len());
773+
let rest = s.slice(i, s.len());
848774
return Some((pre, rest));
849775
}
850776
i += 1;
@@ -990,21 +916,13 @@ mod tests {
990916
#[test]
991917
fn test_extract_unc_prefixes() {
992918
assert windows::extract_unc_prefix("\\\\").is_none();
993-
assert windows::extract_unc_prefix("//").is_none();
994919
assert windows::extract_unc_prefix("\\\\hi").is_none();
995-
assert windows::extract_unc_prefix("//hi").is_none();
996920
assert windows::extract_unc_prefix("\\\\hi\\") ==
997921
Some((~"hi", ~"\\"));
998-
assert windows::extract_unc_prefix("//hi\\") ==
999-
Some((~"hi", ~"\\"));
1000922
assert windows::extract_unc_prefix("\\\\hi\\there") ==
1001923
Some((~"hi", ~"\\there"));
1002-
assert windows::extract_unc_prefix("//hi/there") ==
1003-
Some((~"hi", ~"/there"));
1004924
assert windows::extract_unc_prefix("\\\\hi\\there\\friends.txt") ==
1005925
Some((~"hi", ~"\\there\\friends.txt"));
1006-
assert windows::extract_unc_prefix("//hi\\there\\friends.txt") ==
1007-
Some((~"hi", ~"\\there\\friends.txt"));
1008926
}
1009927

1010928
#[test]
@@ -1063,61 +981,5 @@ mod tests {
1063981
.push_many([~"lib", ~"thingy.dll"])
1064982
.with_filename("librustc.dll")),
1065983
"c:\\program files (x86)\\rust\\lib\\librustc.dll");
1066-
1067-
t(&(WindowsPath("\\\\computer\\share")
1068-
.unsafe_join(&WindowsPath("\\a"))),
1069-
"\\\\computer\\a");
1070-
1071-
t(&(WindowsPath("//computer/share")
1072-
.unsafe_join(&WindowsPath("\\a"))),
1073-
"\\\\computer\\a");
1074-
1075-
t(&(WindowsPath("//computer/share")
1076-
.unsafe_join(&WindowsPath("\\\\computer\\share"))),
1077-
"\\\\computer\\share");
1078-
1079-
t(&(WindowsPath("C:/whatever")
1080-
.unsafe_join(&WindowsPath("//computer/share/a/b"))),
1081-
"\\\\computer\\share\\a\\b");
1082-
1083-
t(&(WindowsPath("C:")
1084-
.unsafe_join(&WindowsPath("D:/foo"))),
1085-
"D:\\foo");
1086-
1087-
t(&(WindowsPath("C:")
1088-
.unsafe_join(&WindowsPath("B"))),
1089-
"C:B");
1090-
1091-
t(&(WindowsPath("C:")
1092-
.unsafe_join(&WindowsPath("/foo"))),
1093-
"C:\\foo");
1094-
1095-
t(&(WindowsPath("C:\\")
1096-
.unsafe_join(&WindowsPath("\\bar"))),
1097-
"C:\\bar");
1098-
1099-
t(&(WindowsPath("")
1100-
.unsafe_join(&WindowsPath(""))),
1101-
"");
1102-
1103-
t(&(WindowsPath("")
1104-
.unsafe_join(&WindowsPath("a"))),
1105-
"a");
1106-
1107-
t(&(WindowsPath("")
1108-
.unsafe_join(&WindowsPath("C:\\a"))),
1109-
"C:\\a");
1110-
1111-
t(&(WindowsPath("c:\\foo")
1112-
.normalize()),
1113-
"C:\\foo");
1114-
}
1115-
1116-
#[test]
1117-
fn test_windows_path_restrictions() {
1118-
assert WindowsPath("hi").is_restricted() == false;
1119-
assert WindowsPath("C:\\NUL").is_restricted() == true;
1120-
assert WindowsPath("C:\\COM1.TXT").is_restricted() == true;
1121-
assert WindowsPath("c:\\prn.exe").is_restricted() == true;
1122984
}
1123985
}

branches/try/src/libcore/vec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,7 @@ pub trait OwnedVector<T> {
18651865
fn consume(self, f: fn(uint, v: T));
18661866
fn filter(self, f: fn(t: &T) -> bool) -> ~[T];
18671867
fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]);
1868+
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
18681869
}
18691870

18701871
impl<T> OwnedVector<T> for ~[T] {
@@ -1936,6 +1937,11 @@ impl<T> OwnedVector<T> for ~[T] {
19361937
fn partition(self, f: fn(&T) -> bool) -> (~[T], ~[T]) {
19371938
partition(self, f)
19381939
}
1940+
1941+
#[inline]
1942+
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
1943+
grow_fn(self, n, op);
1944+
}
19391945
}
19401946

19411947
impl<T> Mutable for ~[T] {
@@ -1946,7 +1952,6 @@ impl<T> Mutable for ~[T] {
19461952
pub trait OwnedCopyableVector<T: Copy> {
19471953
fn push_all(&mut self, rhs: &[const T]);
19481954
fn grow(&mut self, n: uint, initval: &T);
1949-
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>);
19501955
fn grow_set(&mut self, index: uint, initval: &T, val: T);
19511956
}
19521957

@@ -1961,11 +1966,6 @@ impl<T: Copy> OwnedCopyableVector<T> for ~[T] {
19611966
grow(self, n, initval);
19621967
}
19631968

1964-
#[inline]
1965-
fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
1966-
grow_fn(self, n, op);
1967-
}
1968-
19691969
#[inline]
19701970
fn grow_set(&mut self, index: uint, initval: &T, val: T) {
19711971
grow_set(self, index, initval, val);

branches/try/src/librustc/front/core_inject.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ fn inject_libcore_ref(sess: Session,
4545
fold_crate: |crate, span, fld| {
4646
let n1 = sess.next_node_id();
4747
let vi1 = @ast::view_item {
48-
node: ast::view_item_use(sess.ident_of(~"core"), ~[], n1),
48+
node: ast::view_item_extern_mod(
49+
sess.ident_of(~"core"), ~[], n1),
4950
attrs: ~[
5051
spanned(ast::attribute_ {
5152
style: ast::attr_inner,
@@ -86,7 +87,7 @@ fn inject_libcore_ref(sess: Session,
8687
};
8788

8889
let vp = @spanned(ast::view_path_glob(prelude_path, n2));
89-
let vi2 = @ast::view_item { node: ast::view_item_import(~[vp]),
90+
let vi2 = @ast::view_item { node: ast::view_item_use(~[vp]),
9091
attrs: ~[],
9192
vis: ast::private,
9293
span: dummy_sp() };

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ fn mk_std(cx: &TestCtxt) -> @ast::view_item {
266266
let mi = nospan(mi);
267267
let id_std = cx.sess.ident_of(~"std");
268268
let vi = if is_std(cx) {
269-
ast::view_item_import(
269+
ast::view_item_use(
270270
~[@nospan(ast::view_path_simple(id_std,
271271
path_node(~[id_std]),
272272
ast::type_value_ns,
273273
cx.sess.next_node_id()))])
274274
} else {
275-
ast::view_item_use(id_std, ~[@mi],
275+
ast::view_item_extern_mod(id_std, ~[@mi],
276276
cx.sess.next_node_id())
277277
};
278278
let vi = ast::view_item {

branches/try/src/librustc/metadata/creader.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ fn visit_crate(e: @mut Env, c: ast::crate) {
142142

143143
fn visit_view_item(e: @mut Env, i: @ast::view_item) {
144144
match /*bad*/copy i.node {
145-
ast::view_item_use(ident, meta_items, id) => {
146-
debug!("resolving use stmt. ident: %?, meta: %?", ident, meta_items);
145+
ast::view_item_extern_mod(ident, meta_items, id) => {
146+
debug!("resolving extern mod stmt. ident: %?, meta: %?",
147+
ident, meta_items);
147148
let cnum = resolve_crate(e, ident, meta_items, ~"", i.span);
148-
cstore::add_use_stmt_cnum(e.cstore, id, cnum);
149+
cstore::add_extern_mod_stmt_cnum(e.cstore, id, cnum);
149150
}
150151
_ => ()
151152
}

branches/try/src/librustc/metadata/cstore.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ pub type crate_metadata = @{name: ~str,
4040

4141
pub struct CStore {
4242
priv metas: oldmap::HashMap<ast::crate_num, crate_metadata>,
43-
priv use_crate_map: use_crate_map,
43+
priv extern_mod_crate_map: extern_mod_crate_map,
4444
priv used_crate_files: ~[Path],
4545
priv used_libraries: ~[~str],
4646
priv used_link_args: ~[~str],
4747
intr: @ident_interner
4848
}
4949

50-
// Map from node_id's of local use statements to crate numbers
51-
type use_crate_map = oldmap::HashMap<ast::node_id, ast::crate_num>;
50+
// Map from node_id's of local extern mod statements to crate numbers
51+
type extern_mod_crate_map = oldmap::HashMap<ast::node_id, ast::crate_num>;
5252

5353
pub fn mk_cstore(intr: @ident_interner) -> CStore {
5454
let meta_cache = oldmap::HashMap();
5555
let crate_map = oldmap::HashMap();
5656
return CStore {
5757
metas: meta_cache,
58-
use_crate_map: crate_map,
58+
extern_mod_crate_map: crate_map,
5959
used_crate_files: ~[],
6060
used_libraries: ~[],
6161
used_link_args: ~[],
@@ -127,18 +127,18 @@ pub fn get_used_link_args(cstore: @mut CStore) -> ~[~str] {
127127
return /*bad*/copy cstore.used_link_args;
128128
}
129129

130-
pub fn add_use_stmt_cnum(cstore: @mut CStore,
131-
use_id: ast::node_id,
132-
cnum: ast::crate_num) {
133-
let use_crate_map = cstore.use_crate_map;
134-
use_crate_map.insert(use_id, cnum);
130+
pub fn add_extern_mod_stmt_cnum(cstore: @mut CStore,
131+
emod_id: ast::node_id,
132+
cnum: ast::crate_num) {
133+
let extern_mod_crate_map = cstore.extern_mod_crate_map;
134+
extern_mod_crate_map.insert(emod_id, cnum);
135135
}
136136

137-
pub fn find_use_stmt_cnum(cstore: @mut CStore,
138-
use_id: ast::node_id)
137+
pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore,
138+
emod_id: ast::node_id)
139139
-> Option<ast::crate_num> {
140-
let use_crate_map = cstore.use_crate_map;
141-
use_crate_map.find(&use_id)
140+
let extern_mod_crate_map = cstore.extern_mod_crate_map;
141+
extern_mod_crate_map.find(&emod_id)
142142
}
143143

144144
// returns hashes of crates directly used by this crate. Hashes are
@@ -147,8 +147,8 @@ pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] {
147147
type crate_hash = {name: ~str, hash: ~str};
148148
let mut result = ~[];
149149

150-
let use_crate_map = cstore.use_crate_map;
151-
for use_crate_map.each_value |&cnum| {
150+
let extern_mod_crate_map = cstore.extern_mod_crate_map;
151+
for extern_mod_crate_map.each_value |&cnum| {
152152
let cdata = cstore::get_crate_data(cstore, cnum);
153153
let hash = decoder::get_crate_hash(cdata.data);
154154
debug!("Add hash[%s]: %s", cdata.name, hash);

0 commit comments

Comments
 (0)