As a Rust newbie, I found the book's explanation for why the `filter` closure gets a reference very confusing, and tried to figure out why `filter` is somehow less consumptive than `map` -- but it isn't; that's controlled by `iter`/`into_iter`. I flailed around for a while until @habnabit explained it to me, and in retrospect it is quite obvious :-)
Reference implied that use declarations may appear *only* at the top of blocks and modules, but it is not the case, and the following is valid:
```Rust
fn foo() {
let x = 92;
use baz::bar;
}
```
r? @steveklabnik
In MIR we previously tried to match `let x in { exprs; let y in { exprs; }}` with our data
structures which is rather unwieldy, espeicially because it requires some sort of recursion or
stack to process, while, a flat list of statements is enough – lets only relinquish their lifetime
at the end of the block (i.e. end of the list).
Also fixes#31853.
Hopefully the author caught all the cases. For the mir_dynamic_drops_3 test case the ratio of
memsets to other instructions is 12%. On the other hand we actually do not double drop for at least
the test cases provided anymore in MIR.
This commit adds support for *truly* unstable options in the compiler, as well
as adding warnings for the start of the deprecation path of
unstable-but-not-really options. Specifically, the following behavior is now in
place for handling unstable options:
* As before, an unconditional error is emitted if an unstable option is passed
and the `-Z unstable-options` flag is not present. Note that passing another
`-Z` flag does not require passing `-Z unstable-options` as well.
* New flags added to the compiler will be in the `Unstable` category as opposed
to the `UnstableButNotReally` category which means they will unconditionally
emit an error when used on stable.
* All current flags are in a category where they will emit warnings when used
that the option will soon be a hard error.
Also as before, it is intended that `-Z` is akin to `#![feature]` in a crate
where it is required to unlock unstable functionality. A nightly compiler which
is used without any `-Z` flags should only be exercising stable behavior.
Similar to #31825 where the read/write limits were capped for files, this
implements similar limits when reading/writing networking types. On Unix this
shouldn't affect anything because the write size is already a `usize`, but on
Windows this will cap the read/write amounts to `i32::max_value`.
cc #31841
I am not entirely sure I have got everything right, but if it compiles it is ok probably...
I tested it with msvc x86_64 and gnu.
Somehow a lot of `EXCEPTION-*` constants are dead code when running test, no idea why.
I have put `#![cfg_attr(test, allow(dead_code))]` at the top for this.
The MinGW-based Python implementations would automatically do this, but if we
want to use Python from the official downloads our usage of `/` instead of `\`
can wreak havoc. In a few select locations just use `os.path.normpath` do do the
conversions properly for us.
The MinGW-based Python implementations would automatically do this, but if we
want to use Python from the official downloads our usage of `/` instead of `\`
can wreak havoc. In a few select locations just use `os.path.normpath` do do the
conversions properly for us.
I'm a bit iffy on the return type, but `Result` would also be a bit weird... The two error cases are `Unterminated` and `InteriorNul(usize)`.
I considered `from_chars(&[c_char])` but this meshes better with `as_bytes_with_nul()` and Rust code in general.
Should there also be a corresponding unsafe `from_bytes_unchecked` variant?
`ReadFile` and `WriteFile` take a DWORD (u32) for the length argument
which was erroneously cast from a usize causing truncation. This meant
methods like `write_all` and `read_exact` would unexpectedly fail if
given a buffer 4 GiB or larger.
We can instead just ask for `u32::MAX` bytes if the given buffer is too
big.