| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new ones
|
|
|
|
|
|
Ensure that evaluating or validating a constant never reads from a static
r? @RalfJung
as per https://github.com/rust-lang/rust/pull/66302#issuecomment-554663387
This does not yet address the fact that evaluation of a constant can read from a static (under unleash-miri)
|
|
|
|
Fix ICE in mir interpretation
Indices from the end start at 1 so you can immediately subtract them from the length to get the index instead of having to do an additional `-1`. Kinda documented in https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/enum.ProjectionElem.html#variant.ConstantIndex
|
|
Co-Authored-By: Ralf Jung <post@ralfj.de>
|
|
|
|
|
|
Co-Authored-By: Ralf Jung <post@ralfj.de>
|
|
|
|
|
|
Add `ImmTy::try_from_(u)int` methods
r? @RalfJung
|
|
Add simpler entry points to const eval for common usages.
I found the `tcx.const_eval` API to be complex/awkward to work with, because of the inherent complexity from all of the different situations it is called from. Though it mainly used in one of the following ways:
- Evaluates the value of a constant without any substitutions, e.g. evaluating a static, discriminant, etc.
- Evaluates the value of a resolved instance of a constant. this happens when evaluating unevaluated constants or normalising trait constants.
- Evaluates a promoted constant.
This PR adds three new functions `const_eval_mono`, `const_eval_resolve`, and `const_eval_promoted` to `TyCtxt`, which each cater to one of the three ways `tcx.const_eval`
is normally used.
|
|
|
|
|
|
|
|
Test slice patterns more
Adds tests for const evaluation and some more borrow checking tests.
Fixes some bugs in const eval for subslice patterns.
closes #66934
r? @oli-obk
cc @Centril
|
|
|
|
2. mir::Mutability -> ast::Mutability.
|
|
This operator creates a raw pointer to a Place directly, without first
creating a reference. See RFC #2582 for motivation.
The Rvalue is currently unused.
|
|
|
|
Reduce allocs for validation errors
This probably doesn't really matter, but I just felt like I had to do this...
r? @oli-obk
|
|
|
|
|
|
|
|
Remove uniform array move MIR passes
This PR fixes a number of bugs caused by limitations of this pass
* Projections from constant indexes weren't being canonicalized
* Constant indexes from the start weren't being canonicalized (they could have different min_lengths)
* It didn't apply to non-moves
This PR makes the following changes to support removing this pass:
* ConstantIndex of arrays are now generated in a canonical form (from the start, min_length is the actual length).
* Subslices are now split when generating move paths and when checking subslices have been moved.
Additionally
* The parent move path of a projection from an array element is now calculated correctly
closes #66502
|
|
* `min_length` is now exact for const index elements.
* const index elements are always from the start.
* make array `Subslice` `PlaceElems` count both `from` and `to` from the
start.
|
|
|
|
Cleanup BodyCache
After this PR:
- `BodyCache` is renamed to `BodyAndCache`
- `ReadOnlyBodyCache` is renamed to `ReadOnlyBodyAndCache`
- `ReadOnlyBodyAndCache::body` fn is removed and all calls to it are replaced by a deref (possible due to fix of its `Deref` imp in #65947)
cc @eddyb @oli-obk
|
|
Implement #[track_caller] attribute. (RFC 2091 4/N)
Implements the `#[track_caller]` attribute in both const and codegen contexts.
The const implementation walks up the stack to find the nearest untracked callsite.
The codegen implementation adds an implicit argument to tracked function calls, and populates it with either a call to the previously-landed intrinsic or if the caller has `#[track_caller]` with a copy of the location passed to the current function.
Also includes a little cleanup and a few comments in the other caller location areas.
[Depends on: 65664](https://github.com/rust-lang/rust/pull/65664)
[RFC 2091 text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md)
[Tracking issue](https://github.com/rust-lang/rust/issues/47809)
[Tracking doc](https://paper.dropbox.com/doc/track_rfc_2091_impl-notes--Anf1NwnIb0xcRv31YLIadyj0Ag-rwCdRc2fi2yvRZ7syGZ9q#:uid=863513134494965680023183&h2=TODO-actually-pass-location-to)
|
|
Miri core engine: use throw_ub instead of throw_panic
See https://github.com/rust-lang/rust/issues/66902 for context: panicking is not really an "interpreter error", but just part of a normal Rust execution. This is a first step towards removing the `InterpError::Panic` variant: the core Miri engine does not use it any more.
ConstProp and ConstEval still use it, though. This will be addressed in future PRs.
From what I can tell, all the error messages this removes are actually duplicates.
r? @oli-obk @wesleywiser
|
|
|
|
|
|
|
|
|
|
Index impl, remove body fn
rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence
rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
|
|
Only memoize const fn calls during const eval
Miri and other engines may want to execute the function in order to detect UB inside of them.
r? @RalfJung
|
|
Co-Authored-By: Ralf Jung <post@ralfj.de>
|
|
Organize intrinsics promotion checks
cc @vertexclique
supersedes #61835
r? @RalfJung
|
|
[const-prop] Fix ICE calculating enum discriminant
Fixes #66787
Different approach than #66857
r? @oli-obk
cc @RalfJung @eddyb
|
|
Fixes #66787
|
|
Show the sign for signed ops on `exact_div`
r? @RalfJung Cc https://github.com/rust-lang/miri/pull/961/files#r341842128
I'm fairly unhappy with the duplication and the general effort required for this.
Maybe it would be better to add a `display` impl for `ImmTy`?
|