about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
AgeCommit message (Collapse)AuthorLines
2024-05-27interpret: the MIR is actually at lifetime 'tcxRalf Jung-23/+21
2024-05-23Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726bors-0/+18
Remove more `#[macro_use] extern crate tracing` Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. Continuing the work from #124511 and #124914. r? `@jackh726`
2024-05-23Allow const eval failures if the cause is a type layout issueOli Scherer-3/+14
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_const_eval`.Nicholas Nethercote-0/+18
2024-05-23Auto merge of #125359 - RalfJung:interpret-overflowing-ops, r=oli-obkbors-187/+126
interpret: make overflowing binops just normal binops Follow-up to https://github.com/rust-lang/rust/pull/125173 (Cc `@scottmcm)`
2024-05-22Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcmbors-22/+30
offset: allow zero-byte offset on arbitrary pointers As per prior `@rust-lang/opsem` [discussion](https://github.com/rust-lang/opsem-team/issues/10) and [FCP](https://github.com/rust-lang/unsafe-code-guidelines/issues/472#issuecomment-1793409130): - Zero-sized reads and writes are allowed on all sufficiently aligned pointers, including the null pointer - Inbounds-offset-by-zero is allowed on all pointers, including the null pointer - `offset_from` on two pointers derived from the same allocation is always allowed when they have the same address This removes surprising UB (in particular, even C++ allows "nullptr + 0", which we currently disallow), and it brings us one step closer to an important theoretical property for our semantics ("provenance monotonicity": if operations are valid on bytes without provenance, then adding provenance can't make them invalid). The minimum LLVM we require (v17) includes https://reviews.llvm.org/D154051, so we can finally implement this. The `offset_from` change is needed to maintain the equivalence with `offset`: if `let ptr2 = ptr1.offset(N)` is well-defined, then `ptr2.offset_from(ptr1)` should be well-defined and return N. Now consider the case where N is 0 and `ptr1` dangles: we want to still allow offset_from here. I think we should change offset_from further, but that's a separate discussion. Fixes https://github.com/rust-lang/rust/issues/65108 [Tracking issue](https://github.com/rust-lang/rust/issues/117945) | [T-lang summary](https://github.com/rust-lang/rust/pull/117329#issuecomment-1951981106) Cc `@nikic`
2024-05-22clarify commentRalf Jung-1/+3
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2024-05-21improve comment wordingRalf Jung-1/+2
2024-05-21interpret: make overflowing binops just normal binopsRalf Jung-186/+123
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-9/+5
2024-05-13offset, offset_from: allow zero-byte offset on arbitrary pointersRalf Jung-22/+29
2024-05-13Remove `extern crate rustc_middle` from `rustc_const_eval`.Nicholas Nethercote-31/+53
This requires exporting the interpreter macros so they can be used with `use crate::interpret::*`.
2024-05-10Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoeristerMatthias Krüger-5/+5
Make `Ty::builtin_deref` just return a `Ty` Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2024-05-09Make builtin_deref just return a TyMichael Goulet-5/+5
2024-05-09interpret/miri: better errors on failing offset_fromRalf Jung-13/+16
2024-05-04Rollup merge of #124720 - RalfJung:interpret-drop, r=compiler-errorsMatthias Krüger-6/+9
interpret: Drop: always evaluate place That way we can also avoid dealing with `instantiate_from_frame_and_normalize_erasing_regions`.
2024-05-04some comments or dynamic drop handlingRalf Jung-0/+6
2024-05-04interpret: Drop: always evaluate placeRalf Jung-6/+3
2024-05-04interpret, miri: uniform treatments of intrinsics/functions with and without ↵Ralf Jung-6/+3
return block
2024-05-04Rollup merge of #124293 - oli-obk:miri_intrinsic_fallback_body, r=RalfJungMatthias Krüger-4/+21
Let miri and const eval execute intrinsics' fallback bodies fixes https://github.com/rust-lang/miri/issues/3397 r? ``@RalfJung``
2024-05-03Let miri and const eval execute intrinsics' fallback bodiesOli Scherer-4/+21
2024-05-02interpret: hide some reexports in rustdocRalf Jung-0/+1
2024-04-23properly fill a promoted's required_constsRalf Jung-4/+2
then we can also make all_required_consts_are_checked a constant instead of a function
2024-04-23interpret: sanity-check that required_consts captures all consts that can failRalf Jung-13/+16
2024-04-23Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyoMatthias Krüger-10/+21
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics) This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226. Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it. r? ``@scottmcm``
2024-04-23Rollup merge of #124220 - RalfJung:interpret-wrong-vtable, r=oli-obkMatthias Krüger-24/+50
Miri: detect wrong vtables in wide pointers Fixes https://github.com/rust-lang/miri/issues/3497. Needed to catch the UB that https://github.com/rust-lang/rust/pull/123572 will start exploiting. r? `@oli-obk`
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+1
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-21Address PR feedbackScott McMurray-15/+12
2024-04-21Use it in the library, and `InstSimplify` it away in the easy placesScott McMurray-1/+27
2024-04-21Miri: detect wrong vtables in wide pointersRalf Jung-24/+50
2024-04-19Auto merge of #124113 - RalfJung:interpret-scalar-ops, r=oli-obkbors-58/+82
interpret: use ScalarInt for bin-ops; avoid PartialOrd for ScalarInt Best reviewed commit-by-commit r? `@oli-obk`
2024-04-19ScalarInt: add methods to assert being a (u)int of given sizeRalf Jung-7/+6
2024-04-18interpret/binary_int_op: avoid dropping to raw ints until we determined the signRalf Jung-56/+81
2024-04-18Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstriebbors-2/+2
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-2/+2
We want to run them on all 64-bit platforms.
2024-04-18Auto merge of #122684 - oli-obk:delay_interning_errors_to_after_validaiton, ↵bors-84/+101
r=RalfJung Delay interning errors to after validation fixes https://github.com/rust-lang/rust/issues/122398 fixes #122548 This improves diagnostics since validation errors are usually more helpful compared with interning errors that just make broad statements about the entire constant r? `@RalfJung`
2024-04-17Use less fragile error handlingOli Scherer-15/+11
2024-04-17Validate before reporting interning errors.Oli Scherer-20/+26
validation produces much higher quality errors and already handles most of the cases
2024-04-17Simplify alloc id mutability checkOli Scherer-10/+15
2024-04-17Deduplicate logic for checking the mutability of allocationsOli Scherer-79/+75
2024-04-17Run the "is this static mutable" logic the same way as in `in_mutable_memory`Oli Scherer-14/+16
2024-04-17Validate nested static itemsOli Scherer-7/+19
2024-04-17interpret: rename base_pointer -> root_pointerRalf Jung-18/+18
also in Miri, "base tag" -> "root tag"
2024-04-17interpret: pass MemoryKind to adjust_alloc_base_pointerRalf Jung-11/+24
2024-04-16Add simple async drop glue generationzetanumbers-0/+1
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Rollup merge of #124024 - RalfJung:interpret-comment, r=oli-obkMatthias Krüger-3/+0
interpret: remove outdated comment In https://github.com/rust-lang/rust/pull/107756, allocation became generally fallible, so the "only panic if there is provenance" no longer applies. r? ``@oli-obk``
2024-04-16interpret: remove outdated commentRalf Jung-3/+0
2024-04-16interpret: pass MemoryKind to before_memory_deallocationRalf Jung-0/+2
2024-04-16Add an assertion in const evalMaybe Waffle-2/+8
2024-04-16Change intrinsic types to use `u32` instead of `T` to match stable reexportsMaybe Waffle-8/+13