Skip to content

Commit 2796e1e

Browse files
committed
---
yaml --- r: 47092 b: refs/heads/try c: aa284de h: refs/heads/master v: v3
1 parent 8cbc596 commit 2796e1e

File tree

12 files changed

+74
-165
lines changed

12 files changed

+74
-165
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: b07eab5faab16a975df89eae8ea5d7276bc44507
5+
refs/heads/try: aa284de1fc246b55fb53783ded3e9786e04b03d0
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 & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +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-
6967
pure fn normalize() -> Self;
7068
}
7169

@@ -487,15 +485,6 @@ impl GenericPath for PosixPath {
487485
self.push_many(other.components)
488486
}
489487

490-
pure fn unsafe_join(other: &PosixPath) -> PosixPath {
491-
if other.is_absolute {
492-
PosixPath { is_absolute: true,
493-
components: copy other.components }
494-
} else {
495-
self.push_rel(other)
496-
}
497-
}
498-
499488
pure fn push_many(cs: &[~str]) -> PosixPath {
500489
let mut v = copy self.components;
501490
for cs.each |e| {
@@ -696,48 +685,6 @@ impl GenericPath for WindowsPath {
696685
self.push_many(other.components)
697686
}
698687

699-
pure fn unsafe_join(other: &WindowsPath) -> WindowsPath {
700-
/* rhs not absolute is simple push */
701-
if !other.is_absolute {
702-
return self.push_many(other.components);
703-
}
704-
705-
/* if rhs has a host set, then the whole thing wins */
706-
match other.host {
707-
Some(copy host) => {
708-
return WindowsPath {
709-
host: Some(host),
710-
device: copy other.device,
711-
is_absolute: true,
712-
components: copy other.components
713-
};
714-
}
715-
_ => {}
716-
}
717-
718-
/* if rhs has a device set, then a part wins */
719-
match other.device {
720-
Some(copy device) => {
721-
return WindowsPath {
722-
host: None,
723-
device: Some(device),
724-
is_absolute: true,
725-
components: copy other.components
726-
};
727-
}
728-
_ => {}
729-
}
730-
731-
/* fallback: host and device of lhs win, but the
732-
whole path of the right */
733-
WindowsPath {
734-
host: copy self.host,
735-
device: copy self.device,
736-
is_absolute: self.is_absolute || other.is_absolute,
737-
components: copy other.components
738-
}
739-
}
740-
741688
pure fn push_many(cs: &[~str]) -> WindowsPath {
742689
let mut v = copy self.components;
743690
for cs.each |e| {
@@ -778,10 +725,7 @@ impl GenericPath for WindowsPath {
778725
pure fn normalize() -> WindowsPath {
779726
return WindowsPath {
780727
host: copy self.host,
781-
device: match self.device {
782-
None => None,
783-
Some(ref device) => Some(device.to_upper())
784-
},
728+
device: copy self.device,
785729
is_absolute: self.is_absolute,
786730
components: normalize(self.components)
787731
}
@@ -820,13 +764,13 @@ pub mod windows {
820764
821765
pub pure fn extract_unc_prefix(s: &str) -> Option<(~str,~str)> {
822766
if (s.len() > 1 &&
823-
(s[0] == '\\' as u8 || s[0] == '/' as u8) &&
824-
s[0] == s[1]) {
767+
s[0] == '\\' as u8 &&
768+
s[1] == '\\' as u8) {
825769
let mut i = 2;
826770
while i < s.len() {
827-
if is_sep(s[i]) {
771+
if s[i] == '\\' as u8 {
828772
let pre = s.slice(2, i);
829-
let mut rest = s.slice(i, s.len());
773+
let rest = s.slice(i, s.len());
830774
return Some((pre, rest));
831775
}
832776
i += 1;
@@ -972,21 +916,13 @@ mod tests {
972916
#[test]
973917
fn test_extract_unc_prefixes() {
974918
assert windows::extract_unc_prefix("\\\\").is_none();
975-
assert windows::extract_unc_prefix("//").is_none();
976919
assert windows::extract_unc_prefix("\\\\hi").is_none();
977-
assert windows::extract_unc_prefix("//hi").is_none();
978920
assert windows::extract_unc_prefix("\\\\hi\\") ==
979921
Some((~"hi", ~"\\"));
980-
assert windows::extract_unc_prefix("//hi\\") ==
981-
Some((~"hi", ~"\\"));
982922
assert windows::extract_unc_prefix("\\\\hi\\there") ==
983923
Some((~"hi", ~"\\there"));
984-
assert windows::extract_unc_prefix("//hi/there") ==
985-
Some((~"hi", ~"/there"));
986924
assert windows::extract_unc_prefix("\\\\hi\\there\\friends.txt") ==
987925
Some((~"hi", ~"\\there\\friends.txt"));
988-
assert windows::extract_unc_prefix("//hi\\there\\friends.txt") ==
989-
Some((~"hi", ~"\\there\\friends.txt"));
990926
}
991927

992928
#[test]
@@ -1045,53 +981,5 @@ mod tests {
1045981
.push_many([~"lib", ~"thingy.dll"])
1046982
.with_filename("librustc.dll")),
1047983
"c:\\program files (x86)\\rust\\lib\\librustc.dll");
1048-
1049-
t(&(WindowsPath("\\\\computer\\share")
1050-
.unsafe_join(&WindowsPath("\\a"))),
1051-
"\\\\computer\\a");
1052-
1053-
t(&(WindowsPath("//computer/share")
1054-
.unsafe_join(&WindowsPath("\\a"))),
1055-
"\\\\computer\\a");
1056-
1057-
t(&(WindowsPath("//computer/share")
1058-
.unsafe_join(&WindowsPath("\\\\computer\\share"))),
1059-
"\\\\computer\\share");
1060-
1061-
t(&(WindowsPath("C:/whatever")
1062-
.unsafe_join(&WindowsPath("//computer/share/a/b"))),
1063-
"\\\\computer\\share\\a\\b");
1064-
1065-
t(&(WindowsPath("C:")
1066-
.unsafe_join(&WindowsPath("D:/foo"))),
1067-
"D:\\foo");
1068-
1069-
t(&(WindowsPath("C:")
1070-
.unsafe_join(&WindowsPath("B"))),
1071-
"C:B");
1072-
1073-
t(&(WindowsPath("C:")
1074-
.unsafe_join(&WindowsPath("/foo"))),
1075-
"C:\\foo");
1076-
1077-
t(&(WindowsPath("C:\\")
1078-
.unsafe_join(&WindowsPath("\\bar"))),
1079-
"C:\\bar");
1080-
1081-
t(&(WindowsPath("")
1082-
.unsafe_join(&WindowsPath(""))),
1083-
"");
1084-
1085-
t(&(WindowsPath("")
1086-
.unsafe_join(&WindowsPath("a"))),
1087-
"a");
1088-
1089-
t(&(WindowsPath("")
1090-
.unsafe_join(&WindowsPath("C:\\a"))),
1091-
"C:\\a");
1092-
1093-
t(&(WindowsPath("c:\\foo")
1094-
.normalize()),
1095-
"C:\\foo");
1096984
}
1097985
}

branches/try/src/libcore/to_str.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ impl ToStr for @str {
4343
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
4444
}
4545

46+
// FIXME #4898: impl for one-tuples
47+
4648
impl<A: ToStr, B: ToStr> ToStr for (A, B) {
4749
#[inline(always)]
4850
pure fn to_str(&self) -> ~str {

branches/try/src/libcore/tuple.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
111111
}
112112
}
113113

114+
// FIXME #4898: impl for one-tuples
115+
114116
#[cfg(notest)]
115117
impl<A: Eq, B: Eq> Eq for (A, B) {
116118
#[inline(always)]

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub fn read_crates(diag: span_handler,
5555
visit_view_item: |a| visit_view_item(e, a),
5656
visit_item: |a| visit_item(e, a),
5757
.. *visit::default_simple_visitor()});
58-
visit_crate(e, crate);
5958
visit::visit_crate(crate, (), v);
6059
dump_crates(e.crate_cache);
6160
warn_if_multiple_versions(e, diag, e.crate_cache);
@@ -126,20 +125,6 @@ struct Env {
126125
intr: @ident_interner
127126
}
128127

129-
fn visit_crate(e: @mut Env, c: ast::crate) {
130-
let cstore = e.cstore;
131-
let link_args = attr::find_attrs_by_name(c.node.attrs, "link_args");
132-
133-
for link_args.each |a| {
134-
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
135-
Some(ref linkarg) => {
136-
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
137-
}
138-
None => {/* fallthrough */ }
139-
}
140-
}
141-
}
142-
143128
fn visit_view_item(e: @mut Env, i: @ast::view_item) {
144129
match /*bad*/copy i.node {
145130
ast::view_item_use(ident, meta_items, id) => {
@@ -196,7 +181,7 @@ fn visit_item(e: @mut Env, i: @ast::item) {
196181
for link_args.each |a| {
197182
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
198183
Some(ref linkarg) => {
199-
cstore::add_used_link_args(cstore, *linkarg);
184+
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
200185
}
201186
None => {/* fallthrough */ }
202187
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub fn get_used_libraries(cstore: @mut CStore) -> ~[~str] {
119119
return /*bad*/copy cstore.used_libraries;
120120
}
121121

122-
pub fn add_used_link_args(cstore: @mut CStore, args: &str) {
122+
pub fn add_used_link_args(cstore: @mut CStore, args: ~str) {
123123
cstore.used_link_args.push_all(str::split_char(args, ' '));
124124
}
125125

branches/try/src/librustc/middle/trans/type_of.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,20 +328,11 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
328328
pub fn enum_body_types(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
329329
-> ~[TypeRef] {
330330
let univar = ty::enum_is_univariant(cx.tcx, did);
331+
let size = machine::static_size_of_enum(cx, t);
331332
if !univar {
332-
let size = machine::static_size_of_enum(cx, t);
333333
~[T_enum_discrim(cx), T_array(T_i8(), size)]
334-
}
335-
else {
336-
// Use the actual fields, so we get the alignment right.
337-
match ty::get(t).sty {
338-
ty::ty_enum(_, ref substs) => {
339-
do ty::enum_variants(cx.tcx, did)[0].args.map |&field_ty| {
340-
sizing_type_of(cx, ty::subst(cx.tcx, substs, field_ty))
341-
}
342-
}
343-
_ => cx.sess.bug(~"enum is not an enum")
344-
}
334+
} else {
335+
~[T_array(T_i8(), size)]
345336
}
346337
}
347338

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,21 @@ pub impl Parser {
576576
self.bump();
577577
ty_nil
578578
} else {
579+
// (t) is a parenthesized ty
580+
// (t,) is the type of a tuple with only one field,
581+
// of type t
579582
let mut ts = ~[self.parse_ty(false)];
583+
let mut one_tuple = false;
580584
while self.token == token::COMMA {
581585
self.bump();
582-
ts.push(self.parse_ty(false));
586+
if self.token != token::RPAREN {
587+
ts.push(self.parse_ty(false));
588+
}
589+
else {
590+
one_tuple = true;
591+
}
583592
}
584-
let t = if vec::len(ts) == 1u { ts[0].node }
593+
let t = if ts.len() == 1 && !one_tuple { ts[0].node }
585594
else { ty_tup(ts) };
586595
self.expect(token::RPAREN);
587596
t
@@ -1061,6 +1070,9 @@ pub impl Parser {
10611070

10621071
if self.token == token::LPAREN {
10631072
self.bump();
1073+
// (e) is parenthesized e
1074+
// (e,) is a tuple with only one field, e
1075+
let mut one_tuple = false;
10641076
if self.token == token::RPAREN {
10651077
hi = self.span.hi;
10661078
self.bump();
@@ -1069,12 +1081,18 @@ pub impl Parser {
10691081
}
10701082
let mut es = ~[self.parse_expr()];
10711083
while self.token == token::COMMA {
1072-
self.bump(); es.push(self.parse_expr());
1084+
self.bump();
1085+
if self.token != token::RPAREN {
1086+
es.push(self.parse_expr());
1087+
}
1088+
else {
1089+
one_tuple = true;
1090+
}
10731091
}
10741092
hi = self.span.hi;
10751093
self.expect(token::RPAREN);
10761094

1077-
return if es.len() == 1 {
1095+
return if es.len() == 1 && !one_tuple {
10781096
self.mk_expr(lo, self.span.hi, expr_paren(es[0]))
10791097
}
10801098
else {
@@ -2158,11 +2176,13 @@ pub impl Parser {
21582176
pat = pat_lit(expr);
21592177
} else {
21602178
let mut fields = ~[self.parse_pat(refutable)];
2161-
while self.token == token::COMMA {
2162-
self.bump();
2163-
fields.push(self.parse_pat(refutable));
2179+
if self.look_ahead(1) != token::RPAREN {
2180+
while self.token == token::COMMA {
2181+
self.bump();
2182+
fields.push(self.parse_pat(refutable));
2183+
}
21642184
}
2165-
if vec::len(fields) == 1u { self.expect(token::COMMA); }
2185+
if fields.len() == 1 { self.expect(token::COMMA); }
21662186
hi = self.span.hi;
21672187
self.expect(token::RPAREN);
21682188
pat = pat_tup(fields);

0 commit comments

Comments
 (0)