diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-07-21 20:54:28 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-07-24 18:58:12 -0700 |
| commit | caa564bea3d5f5a24d0797c4769184c1ea0abaff (patch) | |
| tree | f0f1b5d284efe24018586e85fb5b442e8b578283 /src/libcore/fmt | |
| parent | 7f2e63ec3f6f03ac9273a9f166a4ce8deff48097 (diff) | |
librustc: Stop desugaring `for` expressions and translate them directly.
This makes edge cases in which the `Iterator` trait was not in scope
and/or `Option` or its variants were not in scope work properly.
This breaks code that looks like:
struct MyStruct { ... }
impl MyStruct {
fn next(&mut self) -> Option<int> { ... }
}
for x in MyStruct { ... } { ... }
Change ad-hoc `next` methods like the above to implementations of the
`Iterator` trait. For example:
impl Iterator<int> for MyStruct {
fn next(&mut self) -> Option<int> { ... }
}
Closes #15392.
[breaking-change]
Diffstat (limited to 'src/libcore/fmt')
| -rw-r--r-- | src/libcore/fmt/float.rs | 8 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index ef5b51fd00b..386fc28119a 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -13,15 +13,19 @@ use char; use collections::Collection; use fmt; -use iter::{Iterator, range, DoubleEndedIterator}; +use iter::{range, DoubleEndedIterator}; use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive}; use num::{Zero, One, cast}; -use option::{None, Some}; use result::Ok; use slice::{ImmutableVector, MutableVector}; use slice; use str::StrSlice; +#[cfg(stage0)] +use iter::Iterator; // NOTE(stage0): Remove after snapshot. +#[cfg(stage0)] +use option::{Some, None}; // NOTE(stage0): Remove after snapshot. + /// A flag that specifies whether to use exponential (scientific) notation. pub enum ExponentFormat { /// Do not use exponential notation. diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index d52791f6b0e..81e84c447e7 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -16,11 +16,15 @@ use collections::Collection; use fmt; -use iter::{Iterator, DoubleEndedIterator}; +use iter::DoubleEndedIterator; use num::{Int, cast, zero}; -use option::{Some, None}; use slice::{ImmutableVector, MutableVector}; +#[cfg(stage0)] +use iter::Iterator; // NOTE(stage0): Remove after snapshot. +#[cfg(stage0)] +use option::{Some, None}; // NOTE(stage0): Remove after snapshot. + /// A type that represents a specific radix trait GenericRadix { /// The number of digits. |
