]> git.lizzy.rs Git - rust.git/commit
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)
commit7068c2d4e9af54c1e1a2fae2a7d17786c49fea7d
treed09174d556f7ae8ea90168673d9e28269b90f48d
parenta808ba374f7fdf6fea3f0bde9ce09f98f0db7d2d
parentdfcfca28ad1321aff82503ebfffd40cf6476a7a2
Rollup merge of #65749 - Centril:insurance-policy, r=RalfJung

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