Waffle Lapkin
cf7b67420b
add project_fields helper function
2025-08-04 11:34:46 +02:00
Oli Scherer
486ffda9dc
Add opaque TypeId handles for CTFE
2025-07-09 16:37:11 +00:00
Matthias Krüger
2d59c4e0fe
Rollup merge of #143046 - RalfJung:zst-unsafe-cell, r=lcnr,oli-obk
...
const validation: properly ignore zero-sized UnsafeCell
Fixes https://github.com/rust-lang/rust/issues/142948
r? `@oli-obk`
2025-06-27 22:13:05 +02:00
Stypox
708dc15cf1
Add InterpCx::layout_of with tracing, shadowing LayoutOf
2025-06-27 11:49:22 +02:00
Ralf Jung
7de39f55dd
make size_and_align_of_mplace work on all projectable
2025-06-26 10:28:15 +02:00
Scott McMurray
8bce2255e8
Update InterpCx::project_field to take FieldIdx
...
As suggested by Ralf in 142005.
2025-06-05 19:15:56 -07:00
Michael Goulet
fc1a9186dc
Implement MIR, CTFE, and codegen for unsafe binders
2025-01-31 17:19:53 +00:00
Josh Triplett
a105cd6066
Use field init shorthand where possible
...
Field init shorthand allows writing initializers like `tcx: tcx` as
`tcx`. The compiler already uses it extensively. Fix the last few places
where it isn't yet used.
2024-12-17 14:33:10 -08:00
Jubilee Young
bbd18e29da
compiler: Directly use rustc_abi in const_eval
2024-11-03 13:38:47 -08:00
Ralf Jung
a8f9a32650
interpret: Immediate::offset: use shared sanity-check function to ensure invariant
2024-10-03 08:26:25 +02:00
Ralf Jung
c4ce8c114b
make InterpResult a dedicated type to avoid accidentally discarding the error
2024-10-01 21:45:35 +02:00
Michael Goulet
c682aa162b
Reformat using the new identifier sorting from rustfmt
2024-09-22 19:11:29 -04:00
Matthias Krüger
96195a5e24
Rollup merge of #130342 - RalfJung:slice-idx-overflow, r=saethlin
...
interpret, miri: fix dealing with overflow during slice indexing and allocation
This is mostly to fix https://github.com/rust-lang/rust/issues/130284 .
I then realized we're using somewhat sketchy arguments for a similar multiplication in `copy`/`copy_nonoverlapping`/`write_bytes`, so I made them all share the same function that checks exactly the right thing. (The intrinsics would previously fail on allocations larger than `1 << 47` bytes... which are theoretically possible maybe? Anyway it seems conceptually wrong to use any other bound than `isize::MAX` here.)
2024-09-15 16:01:38 +02:00
León Orell Valerian Liehr
03e8b6bbfa
Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnr
...
Lifetime cleanups
The last commit is very opinionated, let's see how we go.
r? `@oli-obk`
2024-09-14 18:12:13 +02:00
Ralf Jung
3b806d337c
interpret: fix dealing with overflow during slice indexing
2024-09-14 10:00:07 +02:00
Ralf Jung
e2bc16c101
interpret: simplify SIMD type handling
2024-09-13 15:26:08 +02:00
Nicholas Nethercote
8d32578fe1
Rename and reorder lots of lifetimes.
...
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and
'me with vanilla 'a. These are cases where the original name isn't
really any more informative than 'a.
- Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime
applies to multiple fields and so the original lifetime name isn't
really accurate.
- Put 'tcx last in lifetime lists, and 'a before 'b.
2024-09-13 15:46:20 +10:00
Nicholas Nethercote
84ac80f192
Reformat use declarations.
...
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Ralf Jung
763e3131cc
don't ICE when encountering an extern type field during validation
2024-06-22 17:39:01 +02:00
Ralf Jung
4c208ac233
use is_none_or in some places in the compiler
2024-06-12 16:20:07 +02:00
Ralf Jung
d5fb8257e7
interpret: do not ICE on padded non-pow2 SIMD vectors
2024-06-09 11:54:23 +02:00
Ralf Jung
e8379c9598
interpret: get rid of 'mir lifetime everywhere
2024-05-27 08:25:57 +02:00
Nicholas Nethercote
7a5d814a04
Remove #[macro_use] extern crate tracing from rustc_const_eval.
2024-05-23 18:02:38 +10:00
Nicholas Nethercote
4497d345a8
Remove extern crate rustc_middle from rustc_const_eval.
...
This requires exporting the interpreter macros so they can be used with
`use crate::interpret::*`.
2024-05-13 08:02:14 +10:00
Ralf Jung
4497990dff
remove some frame parameters that are no longer needed
2024-03-09 18:28:14 +01:00
Ralf Jung
29db7890ba
interpret/visitor: ensure we only see normalized types
2024-02-10 17:00:24 +01:00
Ralf Jung
1025a12b64
interpret: project_downcast: do not ICE for uninhabited variants
2024-01-26 09:01:56 +01:00
Oli Scherer
1f398abcb6
const prop nonsense eliminated
2024-01-23 16:34:43 +00:00
Ralf Jung
5d87d8307f
interpret: extend comment on the inhabitedness check in downcast
2023-12-14 09:50:47 +01:00
Ralf Jung
9ef1e35166
reject projecting to fields whose offset we cannot compute
2023-12-12 08:15:17 +01:00
Ralf Jung
ef15a8182b
codegen, miri: fix computing the offset of an unsized field in a packed struct
2023-12-03 08:26:51 +01:00
klensy
aff6c741d4
remove unused pub fn
2023-11-23 14:11:02 +03:00
Ralf Jung
f3f9b795bd
place evaluation: require the original pointer to be aligned if an access happens
2023-10-15 18:13:31 +02:00
Ralf Jung
ea9a24e32e
avoid re-checking the offset while iterating an array/slice
2023-10-15 18:12:46 +02:00
Ralf Jung
b1ebf002c3
don't UB on dangling ptr deref, instead check inbounds on projections
2023-10-15 18:12:46 +02:00
ouz-a
cd7f471931
Add docs, remove code, change subtyper code
2023-10-02 23:39:44 +03:00
ouz-a
3148e6a993
subtyping_projections
2023-10-02 23:37:49 +03:00
Oli Scherer
2d4201f7c6
Skip reinterning if nothing changed
2023-09-28 16:13:38 +00:00
Oli Scherer
6ea2db7c2d
Strip OpaqueCast during RevealAll.
2023-09-28 16:13:38 +00:00
Ralf Jung
fa5f13775a
interpret: make MemPlace, Place, Operand types private to the interpreter
2023-09-04 17:53:38 +02:00
Ralf Jung
7cdeff266c
a bit of meta-related cleanup on Projectable
2023-08-30 13:46:55 +02:00
Ralf Jung
bdd5855b8e
interpret: fix projecting into an unsized field of a local
...
new invariant: Place::Local never refers to something unsized
2023-08-30 13:43:34 +02:00
Ralf Jung
efd54ccf5a
interpret: use ConstPropNonsense for more const-prop induced issues
2023-08-06 15:20:03 +02:00
Ralf Jung
7d5886504c
rename deref_operand → deref_pointer and some Miri helper functions
2023-08-01 13:40:29 +02:00
Ralf Jung
00fb45dccd
interpret: make write functions generic over the place type
2023-07-25 22:33:58 +02:00
Ralf Jung
a2bcafa500
interpret: refactor projection code to work on a common trait, and use that for visitors
2023-07-25 14:30:58 +02:00
Ralf Jung
a593de4fab
interpret: support projecting into Place::Local without force_allocation
2023-07-24 15:35:47 +02:00
Boxy
12138b8e5e
Move TyCtxt::mk_x to Ty::new_x where applicable
2023-07-05 20:27:07 +01:00
Oli Scherer
38b7cdf393
Use target instead of machine for mir interpreter integer handling.
...
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-15 08:56:18 +00:00
Ralf Jung
158894464c
interpret: add read_machine_[ui]size convenience methods
2022-12-12 11:10:19 +01:00