Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace old iterator for with do { .. } expressions in std and extra #8159

Closed
wants to merge 8 commits into from
Closed

Conversation

bluss
Copy link
Member

@bluss bluss commented Jul 31, 2013

Where the code still uses old style internal iterators together with for, replace the iterations with do expressions. This helps get the old fors out of the way for future for syntax changes.

Do this except for (of course) where we use .advance(), and not where we use any ::range( .. ) function.

@huonw
Copy link
Member

huonw commented Aug 1, 2013

Needs a rebase.

blake2-ppc added 8 commits August 1, 2013 16:54
Convert some internally used functions to use a external iterators.

Change all uses of remaining internal iterators to use `do` expr
.intersection(), .union() etc methods in trait std::container::Set use
internal iters. Remove these methods from the trait.

I reported issue #8154 for the reinstatement of iterator-based set algebra
methods to the Set trait.

For bitv and treemap, that lack Iterator implementations of set
operations, preserve them as methods directly on the types themselves.

For HashSet, these methods are replaced by the present .union_iter()
etc.
Change all users of old-style for with internal iterators to using
`do`-loops.

The code in stackwalk.rs does not actually implement the
looping protocol (no break on return false).

The code in gc.rs does not use loop breaks, nor does any code using it.

We remove the capacity to break from the loops in std::gc and implement
the walks using `do { .. }` expressions.

No behavior change.
Change the former repetition::

    for 5.times { }

to::

    do 5.times { }

.times() cannot be broken with `break` or `return` anymore; for those
cases, use a numerical range loop instead.
@bluss
Copy link
Member Author

bluss commented Aug 1, 2013

rebased

@thestinger
Copy link
Contributor

Landing as part of #8190.

@thestinger thestinger closed this Aug 1, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 28, 2023
…Jarcho

Do not lint `assertions_on_constants` for `const _: () = assert!(expr)`

Fixes rust-lang#8159

```rust
pub fn f() {
    // warning
    assert!(true);
    assert!(usize::BITS >= 32);

    // ok
    const _: () = assert!(usize::BITS >= 32);
}
```

changelog: Fix `const _: () = assert!(expr)` false positive on `assertions_on_constants` lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants