about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-17/+8
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-07Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakisbors-8/+17
Lazy type-alias-impl-trait Previously opaque types were processed by 1. replacing all mentions of them with inference variables 2. memorizing these inference variables in a side-table 3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing. This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around. Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing * https://github.com/rust-lang/rfcs/pull/2515 much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities). r? `@nikomatsakis` fixes #93411 fixes #88236
2022-02-03Rollup merge of #92802 - compiler-errors:deduplicate-stack-trace, r=oli-obkYuki Okushi-1/+29
Deduplicate lines in long const-eval stack trace Lemme know if this is kinda overkill, lol. Fixes #92796
2022-02-02Rollup merge of #93546 - tmiasko:validate-switch-int, r=oli-obkMatthias Krüger-0/+18
Validate that values in switch int terminator are unique
2022-02-02Fixup changes that aren't neccessary anymoreOli Scherer-2/+2
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-8/+17
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-02-01Validate that values in switch int terminator are uniqueTomasz Miąsko-0/+18
2022-01-30Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-deadMatthias Krüger-3/+2
Add note suggesting that predicate may be satisfied, but is not `const` Not sure if we should be printing this in addition to, or perhaps _instead_ of the help message: ``` help: the trait `~const Add` is not implemented for `NonConstAdd` ``` Also added `ParamEnv::is_const` and `PolyTraitPredicate::is_const_if_const` and, in a separate commit, used those in other places instead of `== hir::Constness::Const`, etc. r? ````@fee1-dead````
2022-01-29Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obkMatthias Krüger-0/+27
Add `intrinsics::const_deallocate` Tracking issue: #79597 Related: #91884 This allows deallocation of a memory allocated by `intrinsics::const_allocate`. At the moment, this can be only used to reduce memory usage, but in the future this may be useful to detect memory leaks (If an allocated memory remains after evaluation, raise an error...?).
2022-01-26drive-by: use is_const and is_const_if_constMichael Goulet-3/+2
2022-01-26`const_deallocate`: Don't deallocate memory allocated in an another const. ↵woppopo-5/+15
Does nothing at runtime. `const_allocate`: Returns a null pointer at runtime.
2022-01-24Auto merge of #93028 - compiler-errors:const_drop_bounds, r=fee1-deadbors-21/+39
Check `const Drop` impls considering `~const` Bounds This PR adds logic to trait selection to account for `~const` bounds in custom `impl const Drop` for types, elaborates the `const Drop` check in `rustc_const_eval` to check those bounds, and steals some drop linting fixes from #92922, thanks `@DrMeepster.` r? `@fee1-dead` `@oli-obk` <sup>(edit: guess I can't request review from two people, lol)</sup> since each of you wrote and reviewed #88558, respectively. Since the logic here is more complicated than what existed, it's possible that this is a perf regression. But it works correctly with tests, and that makes me happy. Fixes #92881
2022-01-23Add `intrinsics::const_deallocate`woppopo-0/+17
2022-01-20update commentslcnr-1/+5
2022-01-19Foreign types are trivially dropMichael Goulet-1/+1
- Also rename a trivial_const_drop to match style of other functions in the util module. - Also add a test for `const Drop` that doesn't depend on a `~const` bound. - Also comment a bit why we remove the const bound during dropck impl check.
2022-01-18Short-circuit some trivially const Drop typesMichael Goulet-10/+9
2022-01-18Check const Drop impls considering ConstIfConst boundsMichael Goulet-12/+31
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-7/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-22/+13
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-10/+9
2022-01-15initial revertEllen-22/+13
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-7/+0
2022-01-12Rollup merge of #92432 - fee1-dead:constck-impl-constness, r=oli-obkMatthias Krüger-1/+5
Error when selected impl is not const in constck Catches bad things when checking a `default_method_body_is_const` body, such as: ```rust self.map(/* .. */).is_sorted(); ``` When `Map` does not yet have a `const` `impl` for `Iterator`. r? ```@oli-obk```
2022-01-11Deduplicate lines in long const-eval stack traceMichael Goulet-1/+29
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-3/+3
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-04rename StackPopClean::None to RootRalf Jung-7/+13
2022-01-03Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievinkMatthias Krüger-21/+1
Remove `NullOp::Box` Follow up of #89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely. r? `@jonas-schievink` `@rustbot` label T-compiler
2021-12-31Extend check for UnsafeCell in consts to cover unionsTomasz Miąsko-1/+8
A validity companion to changes from #90373.
2021-12-30Error when selected impl is not const in constckDeadbeef-1/+5
2021-12-24Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obkbors-139/+222
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to - determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI) - impose further restrictions on whether caller and callee are consistent in how a given argument is passed I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around. I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;) One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way. r? `@oli-obk` `@eddyb` Fixes https://github.com/rust-lang/rust/issues/56166 Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-4/+6
The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-20better name for AdjustForForeignAbiError error variant in InterpErrorRalf Jung-1/+3
2021-12-20don't ICE on variadic function callsRalf Jung-2/+9
2021-12-20also compare ArgAttributesRalf Jung-29/+38
2021-12-20compare calling convention instead of call ABIRalf Jung-37/+9
2021-12-20const_eval machine: use original instance for replaced MIR bodiesRalf Jung-1/+11
2021-12-20CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibilityRalf Jung-109/+192
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15miri: lift restriction on extern types being the only field in a structTomasz Miąsko-27/+11
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-15Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgrbors-1/+0
Rollup of 7 pull requests Successful merges: - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring) - #91859 (Iterator::cycle() — document empty iterator special case) - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`) - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking) - #91881 (Stabilize `iter::zip`) - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`) - #91940 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Rollup merge of #91856 - ouz-a:master, r=oli-obkMatthias Krüger-2/+3
Looser check for overflowing_binary_op Fix for issue #91636 tight check resulted in ICE, this makes the check a little looser. It seems `eq` allows comparing of `supertype` and `subtype` if `lhs = supertype` and `rhs = subtype` but not vice versa, is this intended behavior ?
2021-12-14comment updateouz-a-1/+1
2021-12-13Remove `in_band_lifetimes` from `rustc_const_eval`LegionMammal978-83/+123
See #91867 for more information.
2021-12-14Add regression test and commentouz-a-1/+2
2021-12-13formattingouz-a-1/+1
2021-12-13Looser check for binary_op_overflowouz-a-1/+1
2021-12-12Auto merge of #91549 - fee1-dead:const_env, r=spastorinobors-4/+6
Eliminate ConstnessAnd again Closes #91489. Closes #89432. Reverts #91491. Reverts #89450. r? `@spastorino`