about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2022-05-30validate derefer, run derefer inside generatorouz-a-1/+10
2022-05-30Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errorsbors-24/+16
Replace `#[default_method_body_is_const]` with `#[const_trait]` pulled out of #96077 related issues: #67792 and #92158 cc `@fee1-dead` This is groundwork to only allowing `impl const Trait` for traits that are marked with `#[const_trait]`. This is necessary to prevent adding a new default method from becoming a breaking change (as it could be a non-const fn).
2022-05-30Reduce the scope of a mutable variableOli Scherer-7/+2
2022-05-30Add a helper function for checking whether a default function in a trait can ↵Oli Scherer-11/+8
be treated as `const`
2022-05-30Remove `#[default..]` and add `#[const_trait]`Deadbeef-12/+12
2022-05-28Fix TyKind lint, make consts no longer fn, etcMichael Goulet-5/+5
2022-05-28Initial fixes on top of type interner commitMichael Goulet-4/+5
2022-05-28Move things to rustc_type_irWilco Kusee-3/+3
2022-05-27Auto merge of #96046 - oli-obk:const_typeck, r=cjgillotbors-8/+4
Move various checks to typeck so them failing causes the typeck result to get tainted Fixes #69487 fixes #79047 cc `@RalfJung` this gets rid of the `Transmute` invalid program error variant
2022-05-26clippy::complexity fixesMatthias Krüger-7/+3
clone_on_copy useless_format bind_instead_of_map filter_map_identity useless_conversion map_flatten unnecessary_unwrap
2022-05-25Miri call ABI check: ensure type size+align stay the sameRalf Jung-1/+8
2022-05-24Remove outdated commentOli Scherer-4/+0
2022-05-24Add the transmute and asm checks to typeck as deferred checksOli Scherer-4/+4
2022-05-24Add flag for stricter checks on uninit/zeroed5225225-3/+11
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-53/+66
2022-05-22Lifetime variance fixes for rustcMichael Goulet-4/+4
2022-05-22Auto merge of #97177 - oli-obk:const-stability, r=davidtwcobors-28/+31
Implement proper stability check for const impl Trait, fall back to unstable const when undeclared Continuation of #93960 `@jhpratt` it looks to me like the test was simply not testing for the failure you were looking for? Your checks actually do the right thing for const traits?
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-10/+9
2022-05-20Ensure we never consider the null pointer dereferencableRalf Jung-0/+4
2022-05-20Rollup merge of #97188 - carbotaniuman:remove-null-assert, r=RalfJungGuillaume Gomez-8/+1
Remove unneeded null pointer asserts in ptr2int casts This removes an assert that a pointer with address 0 has no provenance. This change is needed to support permissive provenance work in Miri, and seems justified by `ptr.with_addr(0)` working and a discussion on Zulip regarding LLVM semantics. r? `@RalfJung`
2022-05-20Rollup merge of #97185 - RalfJung:number-validity, r=oli-obkGuillaume Gomez-15/+33
interpret/validity: separately control checking numbers for being init and non-ptr This lets Miri control this in a more fine-grained way. r? `@oli-obk`
2022-05-19Remove unneeded assertscarbotaniuman-8/+1
2022-05-19fmtRalf Jung-2/+1
2022-05-19interpret/validity: separately control checking numbers for being init and ↵Ralf Jung-15/+34
non-ptr
2022-05-19Proper const stability check, default to unstableJacob Pratt-19/+35
Rather than deferring to const eval for checking if a trait is const, we now check up-front. This allows the error to be emitted earlier, notably at the same time as other stability checks. Also included in this commit is a change of the default const stability level to UNstable. Previously, an item that was `const` but did not explicitly state it was unstable was implicitly stable.
2022-05-19Add and use stability helper methodsJacob Pratt-2/+2
This avoids an ambiguity (when reading) where `.level.is_stable()` is not immediately clear whether it is general stability or const stability.
2022-05-19Fall back to being const-unstable when undeclaredJacob Pratt-19/+6
2022-05-18Auto merge of #97019 - b-naber:transition-to-valtrees-pt1, r=oli-obkbors-81/+236
Transition to valtrees pt1 Compartmentalising https://github.com/rust-lang/rust/pull/96591 as much as possible. r? `@oli-obk`
2022-05-18Rollup merge of #97116 - RalfJung:ref-validity, r=oli-obkYuki Okushi-6/+11
interpret/validity: reject references to uninhabited types According to https://doc.rust-lang.org/reference/behavior-considered-undefined.html, this is definitely UB. And we can check this without actually looking up anything in memory, we just need the reference value and its type, making this a great candidate for a validity invariant IMO and my favorite resolution of https://github.com/rust-lang/unsafe-code-guidelines/issues/77. With this PR, Miri with `-Zmiri-check-number-validity` implements all my preferred options for what the validity invariants of our types could be. :) CTFE has been doing recursive checking anyway, so this is backwards compatible but might change the error output. I will submit a PR with the new Miri tests soon. r? `@oli-obk`
2022-05-17interpret/validity: reject references to uninhabited typesRalf Jung-6/+11
2022-05-17Auto merge of #97111 - JohnTitor:rollup-x3vjf6u, r=JohnTitorbors-1/+4
Rollup of 7 pull requests Successful merges: - #96329 (Add a couple tests for #90887 fixes) - #97009 (Allow `unused_macro_rules` in path tests) - #97075 (Add regression test for #81804) - #97079 (Change `Successors` to `impl Iterator<Item = BasicBlock>`) - #97080 (remove the `RelateResultCompare` trait) - #97093 (Migrate `maybe_recover_from_bad_type_plus` diagnostic) - #97102 (Update function pointer call error message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-17Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwcobors-10/+4
Add a query for checking whether a function is an intrinsic. work towards #93145 This will reduce churn when we add more ways to declare intrinsics r? `@scottmcm`
2022-05-17Update function pointer call error messagembartlett21-1/+4
It now uses the type of context. (issue 97082)
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