Ralf Jung
23fd2860fa
stronger consistency check in ImmTy::from_immediate
2023-09-20 22:28:46 +02:00
Ralf Jung
bdbf545f42
interpret: less debug-printing of types
2023-09-20 22:25:42 +02:00
Ralf Jung
da08a3f40c
interpret: more consistently use ImmTy in operators and casts
2023-09-20 21:57:54 +02:00
Ralf Jung
a2374e65aa
the Const::eval_bits methods don't need to be given the Ty
2023-09-20 07:27:21 +02:00
Ralf Jung
ea22adbabd
adjust constValue::Slice to work for arbitrary slice types
2023-09-19 20:17:43 +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
John Kåre Alsaker
6a02baaa3d
Partially outline code inside the panic! macro
2023-09-08 14:05:57 +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
Ralf Jung
ad7045e160
still accept references to u8 slices and str in packed fields
2023-09-06 08:32:30 +02:00
Ralf Jung
8b3435c10f
fix detecting references to packed unsized fields
2023-09-05 22:29:51 +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
bors
296c7a683c
Auto merge of #115184 - saethlin:local-allocated-spans, r=RalfJung
...
Record allocation spans inside force_allocation
This expands https://github.com/rust-lang/miri/pull/2940 to cover locals
r? `@RalfJung`
2023-08-25 17:03:33 +00:00
Ben Kimock
8ecdefb3db
Add a doc comment for the new hook
...
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-25 11:58:31 -04:00
Ben Kimock
ec21d584ee
Record allocation spans inside force_allocation
2023-08-25 11:16:52 -04:00
bors
25ed43ddf3
Auto merge of #115138 - cjgillot:dse-move-packed, r=compiler-errors
...
Do not convert copies of packed projections to moves.
This code path was introduced in https://github.com/rust-lang/rust/pull/113758
After seeing https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Packed.20fields.20and.20in-place.20function.20argument.2Freturn.20passing , this may be UB, so should be disallowed.
This should not appear in normally-built MIR, which introduces temporary copies for packed projections.
2023-08-25 13:27:21 +00:00
Ralf Jung
5194060ded
miri ABI compatibility check: accept u32 and i32
2023-08-24 21:02:21 +02:00
Camille GILLOT
15a68610dd
Only check packed ADT.
2023-08-24 15:42:55 +00:00
Ralf Jung
4c53783f3c
when terminating during unwinding, show the reason why
2023-08-24 13:28:26 +02:00
Ralf Jung
739144fc5b
MIR validation: reject in-place argument/return for packed fields
2023-08-24 11:38:19 +02:00
Ralf Jung
807e5b8022
avoid return in tail position
...
Co-authored-by: fee1-dead <ent3rm4n@gmail.com>
2023-08-20 15:52:40 +02:00
Ralf Jung
ac3bca24b7
interpret: have assert_* intrinsics call the panic machinery instead of a direct abort
2023-08-20 15:52:40 +02:00
Ralf Jung
788fd44a3b
interpret/miri: call panic_cannot_unwind lang item instead of hard-coding the same message
2023-08-20 15:52:40 +02:00
Ralf Jung
818ec8e23a
give some unwind-related terminators a more clear name
2023-08-20 15:52:38 +02:00
bors
ff55fa3026
Auto merge of #113124 - nbdd0121:eh_frame, r=cjgillot
...
Add MIR validation for unwind out from nounwind functions + fixes to make validation pass
`@Nilstrieb` This is the MIR validation you asked in https://github.com/rust-lang/rust/pull/112403#discussion_r1222739722 .
Two passes need to be fixed to get the validation to pass:
* `RemoveNoopLandingPads` currently unconditionally introduce a resume block (even there is none to begin with!), changed to not do that
* Generator state transform introduces a `assert` which may unwind, and its drop elaboration also introduces many new `UnwindAction`s, so in this case run the AbortUnwindingCalls after the transformation.
I believe this PR should also fix Rust-for-Linux/linux#1016 , cc `@ojeda`
r? `@Nilstrieb`
2023-08-20 09:58:52 +00:00
Ralf Jung
410bd45ff2
const-eval: ensure we never const-execute a function marked rustc_do_not_const_check
2023-08-19 14:33:31 +02:00
Gary Guo
eb4d6d9ff7
Add missing instantiation of generator ty in validator
2023-08-18 16:40:10 +01:00
Gary Guo
56b933763e
Add MIR validation for unwind out from nounwind functions
2023-08-18 13:51:42 +01:00
Camille GILLOT
933b618360
Revert "Implement references VarDebugInfo."
...
This reverts commit 2ec0071913
.
2023-08-17 17:02:04 +00:00
Camille GILLOT
388f6a6413
Make TerminatorEdge plural.
2023-08-16 18:12:18 +00:00
Camille GILLOT
5173d85043
Allow apply_terminator_effect to customize edges.
2023-08-16 18:12:17 +00:00
Deadbeef
f441fa08da
Remove constness from ImplSource::Param
2023-08-14 02:17:30 +00:00
bors
e3590fccfb
Auto merge of #114637 - matthiaskrgr:rollup-544y8p5, r=matthiaskrgr
...
Rollup of 11 pull requests
Successful merges:
- #106425 (Make ExitStatus implement Default)
- #113480 (add aarch64-unknown-teeos target)
- #113586 (Mention style for new syntax in tracking issue template)
- #113593 (CFI: Fix error compiling core with LLVM CFI enabled)
- #114612 (update llvm-wrapper include to silence deprecation warning)
- #114613 (Prevent constant rebuilds of `rustc-main` (and thus everything else))
- #114615 (interpret: remove incomplete protection against invalid where clauses)
- #114628 (Allowing re-implementation of mir_drops_elaborated query)
- #114629 (tests: Uncomment now valid GAT code behind FIXME)
- #114630 (Migrate GUI colors test to original CSS color format)
- #114631 (add provisional cache test for new solver)
r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-08 22:00:40 +00:00
Matthias Krüger
5c5ae6c5f3
Rollup merge of #114615 - RalfJung:interpret-invalid-where, r=lcnr
...
interpret: remove incomplete protection against invalid where clauses
Cc https://github.com/rust-lang/rust/issues/97477 , https://github.com/rust-lang/project-const-generics/issues/37
r? ``@lcnr``
2023-08-08 21:44:45 +02:00
bors
f88a8b71ce
Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obk
...
correctly lower `impl const` to bind to host effect param
r? `@oli-obk`
2023-08-08 19:23:41 +00:00
Ralf Jung
a7132bf387
interpret: remove incomplete protection against invalid where clauses
2023-08-08 10:35:22 +02:00
bors
6d55184d05
Auto merge of #114520 - RalfJung:unsized-valtrees, r=oli-obk
...
simplify handling of valtrees for unsized types
2023-08-08 07:48:01 +00:00
Matthias Krüger
cbe2522652
Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillot
...
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly
As discussed in #113435 , this lets the backends be the place that can have the "don't call the function if n == 0" logic, if it's needed for the target. (I didn't actually *add* those checks, though, since as I understood it we didn't actually need them on known targets?)
Doing this also let me make it `const` (unstable), which I don't think `extern "C" fn memcmp` can be.
cc `@RalfJung` `@Amanieu`
2023-08-07 05:29:12 +02:00
Scott McMurray
502af03445
Add a new compare_bytes
intrinsic instead of calling memcmp
directly
2023-08-06 15:47:40 -07:00
Matthias Krüger
74dce18639
Rollup merge of #114542 - RalfJung:const-prop-nonsense, r=compiler-errors
...
interpret: use ConstPropNonsense for more const-prop induced issues
2023-08-07 00:06:06 +02:00
Ralf Jung
997ec63fb1
simplify handling of valtrees for unsized types
2023-08-06 21:25:49 +02:00
Ralf Jung
b6e3bc23ef
remove an unnecessary special case in valtree_into_mplace
2023-08-06 21:25:49 +02:00
Matthias Krüger
13de583583
Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJung
...
Add documentation to has_deref
Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose.
cc https://github.com/rust-lang/rust/issues/114401
r? `@RalfJung`
2023-08-06 17:26:29 +02:00
ouz-a
6df546281b
cleanup misinformation regarding has_deref
2023-08-06 17:29:09 +03:00
Deadbeef
92f4c59e48
lower impl const to bind to host effect param
2023-08-06 13:34:53 +00:00
Ralf Jung
efd54ccf5a
interpret: use ConstPropNonsense for more const-prop induced issues
2023-08-06 15:20:03 +02:00
Ralf Jung
3345077b42
interpret: add mplace_to_ref helper method
2023-08-04 15:00:57 +02:00
Matthias Krüger
00dcc7b97c
Rollup merge of #114372 - RalfJung:const-pointer-as-int, r=oli-obk
...
const validation: point at where we found a pointer but expected an integer
Instead of validation just printing "unable to turn pointer into bytes", make this a regular validation error that says where in the value the bad pointer was found. Also distinguish "expected integer, got pointer" from "expected pointer, got partial pointer or mix of pointers".
To avoid duplicating things too much I refactored the diagnostics for validity a bit, so that "got uninit, expected X" and "got pointer, expected X" can share the "X" part. Also all the errors emitted for validation are now grouped under `const_eval_validation` so that they are in a single group in the ftl file.
r? `@oli-obk`
2023-08-03 17:29:08 +02:00
Matthias Krüger
01fdb9d148
Rollup merge of #114363 - RalfJung:interpret-not-miri, r=jackh726
...
avoid 'miri' when refering to the shared interpreter
This is basically the rustc source code version of https://github.com/rust-lang/rustc-dev-guide/pull/1471 .
2023-08-03 08:12:39 +02:00
Ralf Jung
7767cbb3b0
const validation: point at where we found a pointer but expected an integer
2023-08-02 18:51:50 +02:00
Deadbeef
4fec845c3f
Remove constness from TraitPredicate
2023-08-02 15:38:00 +00:00
Ralf Jung
2984670cea
avoid 'miri' when refering to the shared interpreter
2023-08-02 16:52:03 +02:00
Nilstrieb
46f6b05eb7
Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk
...
Use `upvar_tys` in more places, make it return a list
Just a cleanup that fell out of a PR that I was gonna write, but that PR kinda got stuck.
2023-08-02 13:46:54 +02:00
bors
64ad036307
Auto merge of #114333 - RalfJung:dangling-ptr-offset, r=oli-obk
...
Miri: fix error on dangling pointer inbounds offset
We used to claim that the pointer was "dereferenced", but that is just not true.
Can be reviewed commit-by-commit. The first commit is an unrelated rename that didn't seem worth splitting into its own PR.
r? `@oli-obk`
2023-08-02 09:12:32 +00:00
Michael Goulet
99969d282b
Use upvar_tys in more places, make it a list
2023-08-01 23:19:31 +00:00