diff options
| author | bors <bors@rust-lang.org> | 2021-07-29 00:31:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-29 00:31:07 +0000 |
| commit | 85237886df31ba237acd3b7912336704026813f5 (patch) | |
| tree | f4c3ce4df24039cb23abab32ee843c26224d2be8 /compiler/rustc_interface/src/interface.rs | |
| parent | 4533be947b011c9bde4871ae93e6553b24cc5ec6 (diff) | |
| parent | 6d9c0a16d9398b2eb24582f60f47affc119eb0af (diff) | |
| download | rust-85237886df31ba237acd3b7912336704026813f5.tar.gz rust-85237886df31ba237acd3b7912336704026813f5.zip | |
Auto merge of #85874 - steffahn:fix_unsound_zip_optimization, r=yaahc
Remove unsound TrustedRandomAccess implementations Removes the implementations that depend on the user-definable trait `Copy`. Fixes #85873 in the most straightforward way. <hr> _Edit:_ This PR now contains additional trait infrastructure to avoid performance regressions around in-place collect, see the discussion in this thread starting from the codegen test failure at https://github.com/rust-lang/rust/pull/85874#issuecomment-872327577. With this PR, `TrustedRandomAccess` gains additional documentation that specifically allows for and specifies the safety conditions around subtype coercions – those coercions can happen in safe Rust code with the `Zip` API’s usage of `TrustedRandomAccess`. This PR introduces a new supertrait of `TrustedRandomAccess`(currently named `TrustedRandomAccessNoCoerce`) that _doesn’t allow_ such coercions, which means it can be still be useful for optimizing cases such as in-place collect where no iterator is handed out to a user (who could do coercions) after a `get_unchecked` call; the benefit of the supertrait is that it doesn’t come with the additional safety conditions around supertraits either, so it can be implemented for more types than `TrustedRandomAccess`. The `TrustedRandomAccess` implementations for `vec::IntoIter`, `vec_deque::IntoIter`, and `array::IntoIter` are removed as they don’t conform with the newly documented safety conditions, this way unsoundness is removed. But this PR in turn (re-)adds a `TrustedRandomAccessNoCoerce` implementation for `vec::IntoIter` to avoid performance regressions from stable in a case of in-place collecting of `Vec`s [the above-mentioned codegen test failure]. Re-introducing the (currently nightly+beta-only) impls for `VecDeque`’s and `[T; N]`’s iterators is technically possible, but goes beyond the scope of this PR (i.e. it can happen in a future PR).
Diffstat (limited to 'compiler/rustc_interface/src/interface.rs')
0 files changed, 0 insertions, 0 deletions
