]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #15809 : pcwalton/rust/dedesugar-for, r=pnkfelix
authorbors <bors@rust-lang.org>
Fri, 25 Jul 2014 02:21:14 +0000 (02:21 +0000)
committerbors <bors@rust-lang.org>
Fri, 25 Jul 2014 02:21:14 +0000 (02:21 +0000)
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]

1  2 
src/librustc/middle/typeck/check/_match.rs