about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2022-05-16use GlobalId in eval_to_valtree query and introduce query for ↵b-naber-81/+236
valtree_to_const_val
2022-05-16Add a query for checking whether a function is an intrinsic.Oli Scherer-10/+4
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-3/+3
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-14Auto merge of #95826 - carbotaniuman:miri-permissive-provenance, r=RalfJungbors-35/+112
Initial work on Miri permissive-exposed-provenance Rustc portion of the changes for portions of a permissive ptr-to-int model for Miri. The main changes here are changing `ptr_get_alloc` and `get_alloc_id` to return an Option, and also making ptr-to-int casts have an expose side effect.
2022-05-13Add bound_type_ofJack Huey-5/+4
2022-05-13Rustc changes for permissive provenancecarbotaniuman-35/+112
2022-05-12fix clippy expect_fun_callklensy-1/+3
2022-05-12Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwcobors-17/+13
don't encode only locally used attrs Part of https://github.com/rust-lang/compiler-team/issues/505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
2022-05-12Auto merge of #96889 - Aaron1011:place-ref-remove, r=compiler-errorsbors-2/+3
Remove `PartialOrd`/`Ord` impl for `PlaceRef` This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
2022-05-11Apply CR suggestions; add real tracking issueScott McMurray-0/+2
2022-05-11Add a debug check for ordering, and check for isize overflow in CTFEScott McMurray-3/+10
2022-05-11Add `unsigned_offset_from` on pointersScott McMurray-5/+19
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`. Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`. As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives. That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change. This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE. It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11Remove `PartialOrd`/`Ord` impl for `PlaceRef`Aaron Hill-2/+3
This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
2022-05-11Auto merge of #96220 - RalfJung:scalar-no-padding, r=oli-obkbors-53/+53
tighten sanity checks around Scalar and ScalarPair While investigating https://github.com/rust-lang/rust/issues/96185 I noticed codegen has tighter sanity checks here than Miri does, so I added some more assertions. Strangely, some of them fail, so I also needed to add a HACK... that is probably worth looking into. This does not fix that issue, but it changes the ICE messages, making it quite clear that we have a scalar whose size is not the same as that of the surrounding layout. r? `@oli-obk`
2022-05-11Rollup merge of #95281 - pierwill:fix-85513, r=Dylan-DPCDylan DPC-3/+3
Fix inaccurate function name in `rustc_const_eval` docs Looks to me like this fixes #85513. I had trouble making a intra-docs link to `eval_place_to_op` work, though...
2022-05-11avoid computing Scalar size/align in debug buildsRalf Jung-3/+3
2022-05-10Introduce EarlyBinderJack Huey-6/+7
2022-05-10fmtRalf Jung-3/+1
2022-05-10update/remove some old commentsRalf Jung-5/+1
2022-05-10even tighter checks for layouts on immediate field projectionsRalf Jung-6/+11
2022-05-10disable one check for now until #96185 is fixedRalf Jung-4/+5
2022-05-10tighten sanity checks around Scalar and ScalarPairRalf Jung-44/+44
2022-05-10only_local: always check for misuselcnr-17/+13
2022-05-09Auto merge of #96815 - SparrowLii:promote_const, r=oli-obkbors-42/+52
optimize `promote_consts` by caching the results of `validate_local` From the FIXME in the impl of `promote_consts`. Early return the `validate_local` should save some compile time. `qualif_local` is similar to this, but requires futher changing because there are different types of qualif checks. If this PR is effective, I will do it as well.
2022-05-09use `Result<(),()>` instead of Validity enumSparrowLii-54/+35
2022-05-07optimize `promote_consts` by cache the validate checkSparrowLii-41/+70
2022-05-06Check that field projections have the correct typeJakob Degen-1/+55
2022-05-06Fix inaccurate function name in `rustc_const_eval` docspierwill-3/+3
2022-05-06Expand validator to be more precise on checked binary opsJakob Degen-3/+41
2022-05-05Rollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obkMatthias Krüger-49/+95
interpret/validity: debug-check ScalarPair layout information This would have caught https://github.com/rust-lang/rust/issues/96158. I ran the Miri test suite and it still passes. r? `@oli-obk`
2022-05-05give it a scary nameRalf Jung-10/+13
2022-05-04interpret: debug-check ScalarPair layout informationRalf Jung-43/+86
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-4/+4
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-30Auto merge of #96500 - SparrowLii:rpo, r=tmiaskobors-2/+2
Reduce duplication of RPO calculation of mir Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow. This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
2022-04-30Eliminate duplication of RPO calculation for mirSparrowLii-2/+2
add `postorder_cache` to mir Body add `ReversePostorderCache` struct correct struct name and comments
2022-04-28Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obkbors-146/+511
Implement Valtree to ConstValue conversion Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction. r? `@oli-obk` cc `@RalfJung`
2022-04-27combine all unsized types and add another recursive call to process nested ↵b-naber-96/+78
unsized types correctly
2022-04-26account for custom DSTs in valtree -> constvalue conversionb-naber-9/+123
2022-04-24include valtree creation and valtree -> constvalue conversion in debug ↵b-naber-31/+30
assertions check
2022-04-22Relax restrictions for copy operandsJakob Degen-1/+2
2022-04-21deduplicate a lot of codeb-naber-242/+121
2022-04-21implement (as of now still unused) query for valtree -> constvalue conversionb-naber-0/+4
2022-04-21implement valtree -> constvalue conversionb-naber-150/+537
2022-04-20Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obkDylan DPC-6/+23
Miri/interpreter debugging tweaks Some changes I made to make debugging Miri with trace logging less terrible. r? ``@oli-obk``
2022-04-19Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obkDylan DPC-46/+59
Miri provenance cleanup Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here. ``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type. r? ``@oli-obk``
2022-04-18remove an unnecessary use of loc_place.ptr.into_pointer_or_addrRalf Jung-1/+1
2022-04-18avoid an unnecessary call to Pointer::into_parts, and caution against ↵Ralf Jung-3/+2
into_pointer_or_addr
2022-04-18add method to get absolute address of a pointer (useful only for Miri)Ralf Jung-6/+4
2022-04-18avoid pairing up AllocId and PointerTag, which is redundantRalf Jung-23/+40