Skip to content

Commit ce0907e

Browse files
committed
Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
1 parent af3889f commit ce0907e

Some content is hidden

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

72 files changed

+489
-457
lines changed

src/libcollections/string.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ mod tests {
872872

873873
use {Mutable, MutableSeq};
874874
use str;
875-
use str::{Str, StrSlice, Owned, Slice};
875+
use str::{Str, StrSlice, Owned};
876876
use super::String;
877877
use vec::Vec;
878878

@@ -898,10 +898,10 @@ mod tests {
898898
#[test]
899899
fn test_from_utf8_lossy() {
900900
let xs = b"hello";
901-
assert_eq!(String::from_utf8_lossy(xs), Slice("hello"));
901+
assert_eq!(String::from_utf8_lossy(xs), str::Slice("hello"));
902902

903903
let xs = "ศไทย中华Việt Nam".as_bytes();
904-
assert_eq!(String::from_utf8_lossy(xs), Slice("ศไทย中华Việt Nam"));
904+
assert_eq!(String::from_utf8_lossy(xs), str::Slice("ศไทย中华Việt Nam"));
905905

906906
let xs = b"Hello\xC2 There\xFF Goodbye";
907907
assert_eq!(String::from_utf8_lossy(xs),

src/libfmt_macros/lib.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use std::char;
2525
use std::str;
26+
use std::string;
2627

2728
/// A piece is a portion of the format string which represents the next part
2829
/// to emit. These are emitted as a stream by the `Parser` class.
@@ -32,7 +33,7 @@ pub enum Piece<'a> {
3233
String(&'a str),
3334
/// This describes that formatting should process the next argument (as
3435
/// specified inside) for emission.
35-
Argument(Argument<'a>),
36+
NextArgument(Argument<'a>),
3637
}
3738

3839
/// Representation of an argument specification.
@@ -129,7 +130,7 @@ pub struct Parser<'a> {
129130
input: &'a str,
130131
cur: str::CharOffsets<'a>,
131132
/// Error messages accumulated during parsing
132-
pub errors: Vec<String>,
133+
pub errors: Vec<string::String>,
133134
}
134135

135136
impl<'a> Iterator<Piece<'a>> for Parser<'a> {
@@ -140,7 +141,7 @@ impl<'a> Iterator<Piece<'a>> for Parser<'a> {
140141
if self.consume('{') {
141142
Some(String(self.string(pos + 1)))
142143
} else {
143-
let ret = Some(Argument(self.argument()));
144+
let ret = Some(NextArgument(self.argument()));
144145
self.must_consume('}');
145146
ret
146147
}
@@ -469,28 +470,28 @@ mod tests {
469470

470471
#[test]
471472
fn format_nothing() {
472-
same("{}", [Argument(Argument {
473+
same("{}", [NextArgument(Argument {
473474
position: ArgumentNext,
474475
format: fmtdflt(),
475476
})]);
476477
}
477478
#[test]
478479
fn format_position() {
479-
same("{3}", [Argument(Argument {
480+
same("{3}", [NextArgument(Argument {
480481
position: ArgumentIs(3),
481482
format: fmtdflt(),
482483
})]);
483484
}
484485
#[test]
485486
fn format_position_nothing_else() {
486-
same("{3:}", [Argument(Argument {
487+
same("{3:}", [NextArgument(Argument {
487488
position: ArgumentIs(3),
488489
format: fmtdflt(),
489490
})]);
490491
}
491492
#[test]
492493
fn format_type() {
493-
same("{3:a}", [Argument(Argument {
494+
same("{3:a}", [NextArgument(Argument {
494495
position: ArgumentIs(3),
495496
format: FormatSpec {
496497
fill: None,
@@ -504,7 +505,7 @@ mod tests {
504505
}
505506
#[test]
506507
fn format_align_fill() {
507-
same("{3:>}", [Argument(Argument {
508+
same("{3:>}", [NextArgument(Argument {
508509
position: ArgumentIs(3),
509510
format: FormatSpec {
510511
fill: None,
@@ -515,7 +516,7 @@ mod tests {
515516
ty: "",
516517
},
517518
})]);
518-
same("{3:0<}", [Argument(Argument {
519+
same("{3:0<}", [NextArgument(Argument {
519520
position: ArgumentIs(3),
520521
format: FormatSpec {
521522
fill: Some('0'),
@@ -526,7 +527,7 @@ mod tests {
526527
ty: "",
527528
},
528529
})]);
529-
same("{3:*<abcd}", [Argument(Argument {
530+
same("{3:*<abcd}", [NextArgument(Argument {
530531
position: ArgumentIs(3),
531532
format: FormatSpec {
532533
fill: Some('*'),
@@ -540,7 +541,7 @@ mod tests {
540541
}
541542
#[test]
542543
fn format_counts() {
543-
same("{:10s}", [Argument(Argument {
544+
same("{:10s}", [NextArgument(Argument {
544545
position: ArgumentNext,
545546
format: FormatSpec {
546547
fill: None,
@@ -551,7 +552,7 @@ mod tests {
551552
ty: "s",
552553
},
553554
})]);
554-
same("{:10$.10s}", [Argument(Argument {
555+
same("{:10$.10s}", [NextArgument(Argument {
555556
position: ArgumentNext,
556557
format: FormatSpec {
557558
fill: None,
@@ -562,7 +563,7 @@ mod tests {
562563
ty: "s",
563564
},
564565
})]);
565-
same("{:.*s}", [Argument(Argument {
566+
same("{:.*s}", [NextArgument(Argument {
566567
position: ArgumentNext,
567568
format: FormatSpec {
568569
fill: None,
@@ -573,7 +574,7 @@ mod tests {
573574
ty: "s",
574575
},
575576
})]);
576-
same("{:.10$s}", [Argument(Argument {
577+
same("{:.10$s}", [NextArgument(Argument {
577578
position: ArgumentNext,
578579
format: FormatSpec {
579580
fill: None,
@@ -584,7 +585,7 @@ mod tests {
584585
ty: "s",
585586
},
586587
})]);
587-
same("{:a$.b$s}", [Argument(Argument {
588+
same("{:a$.b$s}", [NextArgument(Argument {
588589
position: ArgumentNext,
589590
format: FormatSpec {
590591
fill: None,
@@ -598,7 +599,7 @@ mod tests {
598599
}
599600
#[test]
600601
fn format_flags() {
601-
same("{:-}", [Argument(Argument {
602+
same("{:-}", [NextArgument(Argument {
602603
position: ArgumentNext,
603604
format: FormatSpec {
604605
fill: None,
@@ -609,7 +610,7 @@ mod tests {
609610
ty: "",
610611
},
611612
})]);
612-
same("{:+#}", [Argument(Argument {
613+
same("{:+#}", [NextArgument(Argument {
613614
position: ArgumentNext,
614615
format: FormatSpec {
615616
fill: None,
@@ -623,7 +624,7 @@ mod tests {
623624
}
624625
#[test]
625626
fn format_mixture() {
626-
same("abcd {3:a} efg", [String("abcd "), Argument(Argument {
627+
same("abcd {3:a} efg", [String("abcd "), NextArgument(Argument {
627628
position: ArgumentIs(3),
628629
format: FormatSpec {
629630
fill: None,

src/libnative/io/net.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn ntohs(u: u16) -> u16 {
3737
}
3838

3939
enum InAddr {
40-
InAddr(libc::in_addr),
40+
In4Addr(libc::in_addr),
4141
In6Addr(libc::in6_addr),
4242
}
4343

@@ -48,7 +48,7 @@ fn ip_to_inaddr(ip: rtio::IpAddr) -> InAddr {
4848
(b as u32 << 16) |
4949
(c as u32 << 8) |
5050
(d as u32 << 0);
51-
InAddr(libc::in_addr {
51+
In4Addr(libc::in_addr {
5252
s_addr: Int::from_be(ip)
5353
})
5454
}
@@ -74,7 +74,7 @@ fn addr_to_sockaddr(addr: rtio::SocketAddr,
7474
-> libc::socklen_t {
7575
unsafe {
7676
let len = match ip_to_inaddr(addr.ip) {
77-
InAddr(inaddr) => {
77+
In4Addr(inaddr) => {
7878
let storage = storage as *mut _ as *mut libc::sockaddr_in;
7979
(*storage).sin_family = libc::AF_INET as libc::sa_family_t;
8080
(*storage).sin_port = htons(addr.port);
@@ -723,7 +723,7 @@ impl UdpSocket {
723723
pub fn set_membership(&mut self, addr: rtio::IpAddr,
724724
opt: libc::c_int) -> IoResult<()> {
725725
match ip_to_inaddr(addr) {
726-
InAddr(addr) => {
726+
In4Addr(addr) => {
727727
let mreq = libc::ip_mreq {
728728
imr_multiaddr: addr,
729729
// interface == INADDR_ANY

0 commit comments

Comments
 (0)