| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
CTFE/Miri engine Pointer type overhaul
This fixes the long-standing problem that we are using `Scalar` as a type to represent pointers that might be integer values (since they point to a ZST). The main problem is that with int-to-ptr casts, there are multiple ways to represent the same pointer as a `Scalar` and it is unclear if "normalization" (i.e., the cast) already happened or not. This leads to ugly methods like `force_mplace_ptr` and `force_op_ptr`.
Another problem this solves is that in Miri, it would make a lot more sense to have the `Pointer::offset` field represent the full absolute address (instead of being relative to the `AllocId`). This means we can do ptr-to-int casts without access to any machine state, and it means that the overflow checks on pointer arithmetic are (finally!) accurate.
To solve this, the `Pointer` type is made entirely parametric over the provenance, so that we can use `Pointer<AllocId>` inside `Scalar` but use `Pointer<Option<AllocId>>` when accessing memory (where `None` represents the case that we could not figure out an `AllocId`; in that case the `offset` is an absolute address). Moreover, the `Provenance` trait determines if a pointer with a given provenance can be cast to an integer by simply dropping the provenance.
I hope this can be read commit-by-commit, but the first commit does the bulk of the work. It introduces some FIXMEs that are resolved later.
Fixes https://github.com/rust-lang/miri/issues/841
Miri PR: https://github.com/rust-lang/miri/pull/1851
r? `@oli-obk`
|
|
|
|
|
|
Scalar methods
|
|
infallible
This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
|
|
Cache expansion hash globally
... instead of computing it multiple times.
Split from #86676
r? `@petrochenkov`
|
|
|
|
Add #[default_method_body_is_const]
`@rustbot` label F-const_trait_impl
|
|
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
|
|
Fix type: `'satic` -> `'static`
Pointed out on discord: https://discord.com/channels/273534239310479360/490356824420122645/863434443170250793
~~The fact that this compiles is probably a bug.~~ Nope it's `#![feature(in_band_lifetimes)]` (Thanks to [floppy](https://discord.com/channels/273534239310479360/490356824420122645/863437381671059486)
~~[The docs](https://doc.rust-lang.org/stable/nightly-rustc/rustc_mir/transform/inline/struct.Inliner.html#method.check_codegen_attributes) seem to indicate rust thinks this function is generic over the lifetime `'satic`~~ This is because of `in_band_lifetimes`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Support allocation failures when interpreting MIR
This closes #79601 by handling the case where memory allocation fails during MIR interpretation, and translates that failure into an `InterpError`. The error message is "tried to allocate more memory than available to compiler" to make it clear that the memory shortage is happening at compile-time by the compiler itself, and that it is not a runtime issue.
Now that memory allocation can fail, it would be neat if Miri could simulate low-memory devices to make it easy to see how much memory a Rust program needs.
Note that this breaks Miri because it assumes that allocation can never fail.
|
|
Co-authored-by: Ralf Jung <post@ralfj.de>
|
|
|
|
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note that this breaks Miri.
Closes #79601
|
|
r=wesleywiser
Fix uninhabited enum branching pass
when the discriminant is taken with some projection.
|
|
Fix `unused_unsafe` around `await`
Enables `unused_unsafe` lint for `unsafe { future.await }`.
The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe.
Reverts some parts of #85421, but the issue predates that PR.
|
|
|
|
Add MIR pass to lower call to `core::slice::len` into `Len` operand
During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator.
It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how.
Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
|
|
|
|
Use `map_or` instead of open-coding it
`@rustbot` modify labels +C-cleanup +T-compiler
|
|
Remove some last remants of {push,pop}_unsafe!
These macros have already been removed, but there was still some code handling these macros. That code is now removed.
|
|
|
|
This function only ever returns `None`. Make that explicity by not returning a value at all.
|
|
Peephole optimize `x == false` and `x != true`
This adds peephole optimizations to make `x == false`, `false == x`, `x != true`, and `true != x` get optimized to `!x` in the `instcombine` MIR pass. That pass currently handles `x == true` -> `x` already.
|
|
|
|
Replace a `match` with an `if let`
Seems like a better fit here and saves one level of indentation.
`@rustbot` modify labels +C-cleanup +T-compiler
|
|
These macros have already been removed, but there was still some code
handling these macros. That code is now removed.
|
|
We've already checked that `proj_base == []` in the line above and renaming
`place_local` to `local` doesn't gain us anything.
|
|
Reland - Report coverage `0` of dead blocks
Fixes: #84018
With `-Z instrument-coverage`, coverage reporting of dead blocks
(for example, blocks dropped because a conditional branch is dropped,
based on const evaluation) is now supported.
Note, this PR relands an earlier, reverted PR that failed when compiling
generators. The prior issues with generators has been resolved and a new
test was added to prevent future regressions.
Check out the resulting changes to test coverage of dead blocks in the
test coverage reports in this PR.
r? `@tmandry`
fyi: `@wesleywiser`
|
|
Seems like a better fit here and saves one level of indentation.
|
|
Rollup of 13 pull requests
Successful merges:
- #83362 (Stabilize `vecdeque_binary_search`)
- #85706 (Turn off frame pointer elimination on all Apple platforms. )
- #85724 (Fix issue 85435 by restricting Fake Read precision)
- #85852 (Clarify meaning of MachineApplicable suggestions.)
- #85877 (Intra doc link-ify a reference to a function)
- #85880 (convert assertion on rvalue::threadlocalref to delay bug)
- #85896 (Add test for forward declared const param defaults)
- #85897 (Update I-unsound label for triagebot)
- #85900 (Use pattern matching instead of checking lengths explicitly)
- #85911 (Avoid a clone of output_filenames.)
- #85926 (Update cargo)
- #85934 (Add `Ty::is_union` predicate)
- #85935 (Validate type of locals used as indices)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Validate type of locals used as indices
|
|
Add `Ty::is_union` predicate
|