Ralf Jung
da08a3f40c
interpret: more consistently use ImmTy in operators and casts
2023-09-20 21:57:54 +02:00
Ralf Jung
5a0a1ff0cd
move ConstValue into mir
...
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-19 11:11:02 +02:00
bors
cebb9cfd4f
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
...
move required_consts check to general post-mono-check function
This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.
Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709 : ensuring that all locals are dynamically sized.
I didn't expect this to change diagnostics, but it's just cycle errors that change.
r? `@oli-obk`
2023-09-18 19:41:21 +00:00
Ralf Jung
06a76ab415
make interpreter type Debug impl independent of Ty debug impl
2023-09-15 09:54:06 +02:00
Ralf Jung
9ac8b363e3
don't point at const usage site for resolution-time errors
...
also share the code that emits the actual error
2023-09-14 22:34:05 +02:00
Ralf Jung
89ac57db4d
move required_consts check to general post-mono-check function
2023-09-14 22:30:42 +02:00
bors
e437e57954
Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obk
...
consistently pass ty::Const through valtrees
Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748 .
2023-09-14 15:34:31 +00:00
Ralf Jung
7aa44eee99
don't force all slice-typed ConstValue to be ConstValue::Slice
2023-09-14 11:56:55 +02:00
Ralf Jung
06947be196
valtree_to_const_value: add fast-path for Scalar tuples/structs
2023-09-14 07:40:05 +02:00
Ralf Jung
430c386821
make it more clear which functions create fresh AllocId
2023-09-14 07:27:31 +02:00
Ralf Jung
0f8908da27
cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect
2023-09-14 07:27:30 +02:00
Ralf Jung
551f481ffb
use AllocId instead of Allocation in ConstValue::ByRef
2023-09-14 07:26:24 +02:00
Ralf Jung
3aedb85a27
a bit of cleanup in valtree_to_const_value
2023-09-14 07:22:44 +02:00
bors
eb2446a57e
Auto merge of #115820 - matthiaskrgr:rollup-kyglvpu, r=matthiaskrgr
...
Rollup of 6 pull requests
Successful merges:
- #115736 (Remove `verbose_generic_activity_with_arg`)
- #115771 (cleanup leftovers of const_err lint)
- #115798 (add helper method for finding the one non-1-ZST field)
- #115812 (Merge settings.css into rustdoc.css)
- #115815 (fix: return early when has tainted in mir pass)
- #115816 (Disabled socketpair for Vita)
r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-13 18:19:15 +00:00
Matthias Krüger
565b9c2264
Rollup merge of #115798 - RalfJung:non_1zst_field, r=wesleywiser
...
add helper method for finding the one non-1-ZST field
2023-09-13 18:37:42 +02:00
Matthias Krüger
1ec29fb24f
Rollup merge of #115771 - RalfJung:no-more-const-err-lint, r=oli-obk
...
cleanup leftovers of const_err lint
Some code / comments seem to not have been updated when const_err was turned into a hard error, so we can do a bit of cleanup here.
r? `@oli-obk`
2023-09-13 18:37:42 +02:00
Camille GILLOT
054ed8e7eb
Introduce Machine::POST_MONO_CHECKS.
2023-09-12 20:17:52 +00:00
Ralf Jung
60091fe924
add helper method for finding the one non-1-ZST field
2023-09-12 20:52:05 +02:00
Ralf Jung
fd91dfb494
cleanup leftovers of const_err lint
2023-09-12 13:41:42 +02:00
bors
cc7a9d6972
Auto merge of #115705 - cjgillot:const-prop-aggregate, r=oli-obk
...
Read from non-scalar constants and statics in dataflow const-prop
DataflowConstProp is designed to handle scalar values. When MIR features an assignment from a non-scalar constant, we need to manually decompose it into the custom state space.
This PR tweaks interpreter callbacks to allow reusing `eval_mir_constant` without having a stack frame to get a span from.
r? `@oli-obk`
cc `@jachris`
2023-09-12 09:02:27 +00:00
Camille GILLOT
6984030f80
Use write_immediate.
2023-09-11 16:29:42 +00:00
Camille GILLOT
bcfe1a4bf2
Remove cur_span hook.
2023-09-11 16:29:42 +00:00
Camille GILLOT
4901893721
Inline callback.
2023-09-11 16:29:41 +00:00
Camille GILLOT
d278ce126c
Return ImmTy in discriminant_for_variant.
2023-09-11 16:29:41 +00:00
Camille GILLOT
6ad6b4381c
Support non-scalar constants.
2023-09-11 16:29:41 +00:00
Ralf Jung
e00120906e
handle/hack for arbitrary-self dyn receivers
2023-09-09 15:38:23 +02:00
Ralf Jung
a38a3bfc6d
implement and test ABI compatibility for transparent wrappers around NPO types
2023-09-09 15:36:44 +02:00
Ralf Jung
b5bab2b1cc
implement and test fn ptr ABI compatibility rules
2023-09-09 15:36:44 +02:00
Ralf Jung
f993ddc079
give extra context to ABI mismatch errors
2023-09-09 15:36:44 +02:00
Ralf Jung
897a65804d
interpret: change ABI-compat test to be type-based, so the test is consistent across targets
2023-09-09 15:36:44 +02:00
bors
cd71a37f32
Auto merge of #115372 - RalfJung:abi-assert-eq, r=davidtwco
...
add rustc_abi(assert_eq) to test some guaranteed or at least highly expected ABI compatibility guarantees
This new repr(transparent) test is super useful, it would have found https://github.com/rust-lang/rust/issues/115336 and found https://github.com/rust-lang/rust/issues/115404 , https://github.com/rust-lang/rust/issues/115481 , https://github.com/rust-lang/rust/issues/115509 .
2023-09-08 11:56:08 +00:00
Ralf Jung
b0cf4c28ea
turns out Layout has some more things to worry about -- move ABI comparison into helper function
...
like is_bool, and some special magic extra fields
2023-09-08 09:14:07 +02:00
Ralf Jung
c3e14edd8b
accept some differences for rustc_abi(assert_eq), so that we can test more things to be compatible
2023-09-08 08:59:55 +02:00
bors
3d249706aa
Auto merge of #115608 - RalfJung:fn-arg-validity, r=oli-obk
...
miri: catch function calls where the argument is caller-invalid / the return value callee-invalid
When doing a type-changing copy, we must validate the data both at the old and new type.
Fixes https://github.com/rust-lang/miri/issues/3017
2023-09-08 04:10:14 +00:00
Ralf Jung
73d8dcb803
miri: catch function calls where the argument is caller-invalid / the return value callee-invalid
2023-09-06 16:36:00 +02:00
Camille GILLOT
26c48e6f95
Refactor how MIR represents composite debuginfo.
2023-09-05 17:20:07 +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
efc759238d
miri ABI check: fix handling of 1-ZST; don't accept sign differences
2023-08-31 17:27:23 +02:00
Ralf Jung
c37bd09d88
miri function ABI check: specifically look for repr(transparent)
2023-08-30 17:07:25 +02:00
Ralf Jung
1e95aa0c49
interpret: make sure we accept transparent newtypes as ABI-compatible
...
also we were missing the case for Vector arguments, so handle those as well
2023-08-30 17:04:54 +02:00
Ralf Jung
6d1ce9bd13
storage_live: avoid computing the layout unless necessary
2023-08-30 13:46:55 +02:00
Ralf Jung
f87e91de7d
unify passing of sized and unsized function arguments :-)
2023-08-30 13:46:55 +02:00
Ralf Jung
7cdeff266c
a bit of meta-related cleanup on Projectable
2023-08-30 13:46:55 +02:00
Ralf Jung
a09df43d9f
move marking-locals-live out of push_stack_frame, so it happens with argument passing
...
this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-30 13:46:54 +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
Matthias Krüger
23f86255ef
Rollup merge of #115272 - RalfJung:miri-error-print, r=saethlin
...
miri/diagnostics: don't forget to print_backtrace when ICEing on unexpected errors
This should fix the missing output encountered [here](https://github.com/rust-lang/rust/issues/115145#issuecomment-1694334410 ).
r? `@saethlin`
2023-08-30 07:18:11 +02:00
Ralf Jung
b2ebf1c23f
const_eval and codegen: audit uses of is_zst
2023-08-29 09:03:46 +02:00
bors
191dc54dbf
Auto merge of #115182 - RalfJung:abi-compat-sign, r=b-naber
...
miri ABI compatibility check: accept u32 and i32
If only the sign differs, then surely these types are compatible. (We do still check that `arg_ext` is the same, just in case.)
Also I made it so that the ABI check must *imply* that size and alignment are the same, but it doesn't actively check that itself. With how crazy ABI constraints get, having equal size and align really shouldn't be used as a signal for anything I think...
2023-08-28 22:56:10 +00:00
Matthias Krüger
88b476c388
Rollup merge of #115164 - RalfJung:no-in-place-packed, r=b-naber
...
MIR validation: reject in-place argument/return for packed fields
As discussed [here](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Packed.20fields.20and.20in-place.20function.20argument.2Freturn.20passing ).
2023-08-28 19:53:54 +02:00
Ralf Jung
beeb2b13cc
miri/diagnostics: don't forget to print_backtrace when ICEing on unexpected errors
...
then also use the new helper in a few other places
2023-08-27 15:42:25 +02:00