diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-02 18:24:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-02 18:24:41 +0200 |
| commit | 7daf2e8946015f0ba1bf69f5be61964a3f29f04e (patch) | |
| tree | b29eef3d79d578d337065fa4f65eb84276cf7628 /src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs | |
| parent | 10b0fe9c5c9bc2d58b2ac2451114bf2a670bd0dc (diff) | |
| parent | 33aa5e855ed1deec5d086c7919b2a9572128b7ee (diff) | |
| download | rust-7daf2e8946015f0ba1bf69f5be61964a3f29f04e.tar.gz rust-7daf2e8946015f0ba1bf69f5be61964a3f29f04e.zip | |
Rollup merge of #64980 - ecstatic-morse:better-rustc-peek, r=oli-obk
Enable support for `IndirectlyMutableLocals` in `rustc_peek` This PR allows `rustc_peek` tests to be written for the `IndirectlyMutableLocals` analysis implemented in #64470. See any of the tests in [`test/ui/mir-dataflow`](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir-dataflow/inits-1.rs) for an example. Included in this PR is a major rewrite of the `rustc_peek` module. This was motivated by the differences between the `IndirectlyMutableLocals` analysis and the initialized places ones. To properly test `IndirectlyMutableLocals`, we must pass locals by-value to `rustc_peek`, since any local that is not `Freeze` will be marked as indirectly mutable as soon as a reference to it is taken. Unfortunately, `UnsafeCell` is not `Copy`, so we can only do one `rustc_peek` on each value with interior mutability inside a test. I'm not sure how to deal with this restriction; perhaps I need to special case borrows preceding a call to `rustc_peek` in the analysis itself? `rustc_peek` also assumed that the analysis was done on move paths and that its transfer function only needed to be applied at assignment statements. This PR removes both of those restrictions by adding a trait, `RustcPeekAt`, that controls how the peeked at `Place` maps to the current dataflow state and using a dataflow cursor to retrieve the state itself. Finally, this PR adds a test which demonstrates some unsoundness in the `IndirectlyMutableLocals` analysis by converting a reference to a `Freeze` field to a reference to a `!Freeze` field by offsetting a pointer (or in this case transmuting a pointer to a ZST field with the same address as a `!Freeze` field). This does not represent a hole in the language proper, since this analysis is only used to validate `const` bodies, in which the unsound code will only compile with `-Zunleash-the-miri-inside-of-you`. Nevertheless, this should get fixed. r? @oli-obk
Diffstat (limited to 'src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs')
0 files changed, 0 insertions, 0 deletions
