]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #65749 - Centril:insurance-policy, r=RalfJung
authorYuki Okushi <huyuumi.dev@gmail.com>
Fri, 25 Oct 2019 17:45:57 +0000 (02:45 +0900)
committerGitHub <noreply@github.com>
Fri, 25 Oct 2019 17:45:57 +0000 (02:45 +0900)
Insurance policy in case `iter.size_hint()` lies.

Follow up to https://github.com/rust-lang/rust/pull/64949/files#r334235076.
(If the perf impact is bad we can use `debug_assert!` instead.)

The good news is that the UI tests pass locally so `iter.size_hint()` seems to be honest *thus far*.
On the other hand, with the status quo we do not have an insurance policy should that change in some case. This is problematic because a) this could possibly make some program be accepted which shouldn't, b) the compiler itself could have memory unsafety if the correctness of the iterator is assumed in `unsafe { ... }` code (even though the blame lies with the `unsafe { ... }` block in question.)

r? @RalfJung
cc @nnethercote


Trivial merge