| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Fix ui constant tests for big-endian platforms
A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files.
Fix this by a combination of two types of changes:
- Where possible (i.e. where the particular value of a constant does not affect the purpose of the test), choose constant values that have the same encoding on big- and little-endian platforms.
- Where this is not possible, provide a normalize-stderr-test rule that transforms the printed big-endian encoding of such constants into the corresponding little-endian form.
Fixes part of https://github.com/rust-lang/rust/issues/105383.
|
|
Perform SimplifyLocals before ConstProp.
MIR before `ConstProp` may have a lot of dead writes, this makes `ConstProp` do unnecessary work.
r? `@ghost`
|
|
fix rustdoc ui test
|
|
A number of tests under ui/const-ptr and ui/consts are currently
failing on big-endian platforms as the binary encoding of some
constants is hard-coded in the stderr test files. Fix this by
providing a normalize-stderr-test rule that strips out the
raw bytes hex dump, so the comparison can be done in an
endianness-independent manner. Note that in most cases, this
means the tests are now also independent of word size, so the
32bit and 64bit cases can be re-unified.
To keep tests that verify the details of those raw bytes dumps,
a new test case raw-bytes.rs performs the tests where the hex
dumps were stripped out a second time, but only on little-
endian platforms.
In addition, src/test/ui/const-ptr/forbidden_slices.rs exposes
an endian-specific difference in this diagnostic output:
constructing invalid value at .<deref>[0]: encountered 0x11,
but expected a boolean
depending on which byte of D0 is not a boolean value (0 or 1).
Fixed this by choosing a value of D0 that differs from 0 or 1
in all bytes.
Fixes part of https://github.com/rust-lang/rust/issues/105383.
|
|
|
|
Stop promoting all the things
fixes #91009
r? `@RalfJung`
|
|
Ensure param-env is const before calling `eval_to_valtree`
Other queries call `ParamEnv::with_const` *inside* of the query itself (e.g. `const_eval_global_id_for_typeck`), so this could alternatively be moved into the provider of `eval_to_valtree` instead. I don't have a particularly strong opinion, though *theoretically* caching is better if we make the query keys more constrained.
I'm not exactly sure how this is an effect of the `-Zmir-opt-level=3` flag. Maybe something about the inliner causes us to inline an unevaluated const into a body where it can be evaluated, but where it has not yet been normalized.
This seems likely, since we're inlining `from_fn_1::<{ N / 2 }, _>` in `from_fn_2`, which means that we will need to evaluate that constant during the const prop pass after inlining.
Fixes #104396
|
|
Rename `assert_uninit_valid` intrinsic
It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that.
This is actually not fully correct though, as it does still panic for all uninit with `-Zstrict-init-checks`. I'm not sure what the best way is to deal with that not causing confusion. I guess we could just remove the flag? I don't think having it makes a lot of sense anymore with the direction that we have chose to go. It could be relevant again if #100423 lands so removing it may be a bit over eager.
r? `@RalfJung`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
It's not about "uninit" anymore but about "filling with 0x01 bytes" so
the name should at least try to reflect that.
|
|
available
|
|
|
|
|
|
|
|
|
|
|
|
labels are reordered within the file in which they are reported, which can mess up the stack trace
|
|
|
|
|
|
When *any* of the suggested impls is an exact match, *only* show the
exact matches. This is particularly relevant for integer types.
fix fmt
|
|
Add `type_ascribe!` macro as placeholder syntax for type ascription
This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription.
I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether.
Part of #101728
|
|
Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bump the const eval step limit
fixes https://github.com/rust-lang/rust/issues/103814
https://github.com/rust-lang/rust/pull/103877 has too much of an impact to beta backport. So let's just increase the limit, avoiding the immediate breakage.
r? ``@pnkfelix``
|
|
|
|
|
|
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
|
|
Use it in all UI tests that are about the semantics and not the syntax
of type ascription.
|
|
|
|
|
|
Add new MIR constant propagation based on dataflow analysis
The current constant propagation in `rustc_mir_transform/src/const_prop.rs` fails to handle many cases that would be expected from a constant propagation optimization. For example:
```rust
let x = if true { 0 } else { 0 };
```
This pull request adds a new constant propagation MIR optimization pass based on the existing dataflow analysis framework. Since most of the analysis is not unique to constant propagation, a generic framework has been extracted. It works on top of the existing framework and could be reused for other optimzations.
Closes #80038. Closes #81605.
## Todo
### Essential
- [x] [Writes to inactive enum variants](https://github.com/rust-lang/rust/pull/101168#pullrequestreview-1089493974). Resolved by rejecting the registration of places with downcast projections for now. Could be improved by flooding other variants if mutable access to a variant is observed.
- [X] Handle [`StatementKind::CopyNonOverlapping`](https://github.com/rust-lang/rust/pull/101168#discussion_r957774914). Resolved by flooding the destination.
- [x] Handle `UnsafeCell` / `!Freeze` correctly.
- [X] Overflow propagation of `CheckedBinaryOp`: Decided to not propagate if overflow flag is `true` (`false` will still be propagated)
- [x] More documentation in general.
- [x] Arguments for correctness, documentation of necessary assumptions.
- [x] Better performance, or alternatively, require `-Zmir-opt-level=3` for now.
### Extra
- [x] Add explicit unreachability, i.e. upgrading the lattice from $\mathbb{P} \to \mathbb{V}$ to $\set{\bot} \cup (\mathbb{P} \to \mathbb{V})$.
- [x] Use storage statements to improve precision.
- [ ] Consider opening issue for duplicate diagnostics: https://github.com/rust-lang/rust/pull/101168#issuecomment-1276609950
- [ ] Flood moved-from places with $\bot$ (requires some changes for places with tracked projections).
- [ ] Add downcast projections back in.
- [ ] [Algebraic simplifications](https://github.com/rust-lang/rust/pull/101168#discussion_r957967878) (possibly with a shared API; done by old const prop).
- [ ] Propagation through slices / arrays.
- [ ] Find other optimizations that are done by old `const_prop.rs`, but not by this one.
|
|
|
|
|
|
|
|
|
|
Add context to compiler error message
Changed `creates a temporary which is freed while still in use` to `creates a temporary value which is freed while still in use`.
|
|
Const Compare for Tuples
Makes the impls for Tuples of ~const `PartialEq` types also `PartialEq`, impls for Tuples of ~const `PartialOrd` types also `PartialOrd`, for Tuples of ~const `Ord` types also `Ord`.
behind the `#![feature(const_cmp)]` gate.
~~Do not merge before #104113 is merged because I want to use this feature to clean up the new test that I added there.~~
r? ``@fee1-dead``
|
|
|
|
Use `nominal_obligations_without_const` in wf for FnDef
Fixes #104155.
|