auto merge of #6223 : alexcrichton/rust/issue-6183, r=pcwalton
Closes #6183. The first commit changes the compiler's method of treating a `for` loop, and all the remaining commits are just dealing with the fallout. The biggest fallout was the `IterBytes` trait, although it's really a whole lot nicer now because all of the `iter_bytes_XX` methods are just and-ed together. Sadly there was a huge amount of stuff that's `cfg(stage0)` gated, but whoever lands the next snapshot is going to have a lot of fun deleting all this code!
This commit is contained in:
@@ -97,11 +97,18 @@ impl<D:Decoder> Decodable<D> for ident {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ident {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
self.repr.iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ident {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
self.repr.iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
// Functions may or may not have names.
|
||||
pub type fn_ident = Option<ident>;
|
||||
@@ -284,6 +291,7 @@ pub enum binding_mode {
|
||||
bind_infer
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for binding_mode {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
match *self {
|
||||
@@ -297,6 +305,18 @@ impl to_bytes::IterBytes for binding_mode {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for binding_mode {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
match *self {
|
||||
bind_by_copy => 0u8.iter_bytes(lsb0, f),
|
||||
|
||||
bind_by_ref(ref m) => to_bytes::iter_bytes_2(&1u8, m, lsb0, f),
|
||||
|
||||
bind_infer => 2u8.iter_bytes(lsb0, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -330,11 +350,18 @@ pub enum pat_ {
|
||||
#[deriving(Eq)]
|
||||
pub enum mutability { m_mutbl, m_imm, m_const, }
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for mutability {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for mutability {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -345,11 +372,18 @@ pub enum Sigil {
|
||||
ManagedSigil
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Sigil {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Sigil {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToStr for Sigil {
|
||||
fn to_str(&self) -> ~str {
|
||||
@@ -744,11 +778,18 @@ impl ToStr for int_ty {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for int_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for int_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -761,11 +802,18 @@ impl ToStr for uint_ty {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for uint_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for uint_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -778,11 +826,18 @@ impl ToStr for float_ty {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for float_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for float_ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
// NB Eq method appears below.
|
||||
#[auto_encode]
|
||||
@@ -823,11 +878,18 @@ impl ToStr for Onceness {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Onceness {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as uint).iter_bytes(lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Onceness {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as uint).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -874,11 +936,18 @@ pub enum ty_ {
|
||||
ty_infer,
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for Ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for Ty {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -941,11 +1010,18 @@ impl ToStr for purity {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for purity {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for purity {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
@@ -956,11 +1032,18 @@ pub enum ret_style {
|
||||
return_val, // everything else
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl to_bytes::IterBytes for ret_style {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
impl to_bytes::IterBytes for ret_style {
|
||||
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
|
||||
(*self as u8).iter_bytes(lsb0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
|
||||
Reference in New Issue
Block a user