Oli Scherer
93888cd0a4
Move only usage of take_static_root_alloc to its definition and inline it
2024-03-14 11:40:30 +00:00
Oli Scherer
d6c999754c
Generalize eval_in_interpreter with a helper trait
2024-03-14 11:40:23 +00:00
Oli Scherer
71f1943cbf
Fix accidental re-addition of removed code in a previous PR
2024-03-14 11:39:27 +00:00
Oli Scherer
d3514a036d
Ensure nested allocations in statics do not get deduplicated
2024-03-12 05:53:46 +00:00
Oli Scherer
9816915954
Change DefKind::Static to a struct variant
2024-03-12 05:53:46 +00:00
Jubilee
f6ca4258d2
Rollup merge of #122249 - RalfJung:machine-read-hook, r=oli-obk
...
interpret: do not call machine read hooks during validation
Fixes https://github.com/rust-lang/miri/issues/3347
r? ``@oli-obk``
2024-03-11 09:29:36 -07:00
Jubilee
9300fbbed1
Rollup merge of #121893 - RalfJung:const-interior-mut-tests, r=oli-obk
...
Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking
Basically these are the parts of https://github.com/rust-lang/rust/pull/121786 that can be salvaged.
r? ``@oli-obk``
2024-03-11 09:29:34 -07:00
Ralf Jung
279465b5e8
const-checking: add some corner case tests, and fix some nits
2024-03-11 14:15:24 +01:00
Ralf Jung
7d99e80c55
MIR printing: print the path of uneval'd const; refer to promoteds in a consistent way
2024-03-10 14:59:41 +01:00
Ralf Jung
bf47df8b0b
interpret: do not call machine read hooks during validation
2024-03-09 20:00:24 +01:00
Ralf Jung
9eabdc2a4c
make it possible for outside crates to inspect a mir::ConstValue with the interpreter
2024-02-21 14:32:52 +01:00
Oli Scherer
73b38c661d
Do not allocate a second "background" alloc id for the main allocation of a static.
...
Instead we re-use the static's alloc id within the interpreter for its initializer to refer to the `Allocation` that only exists within the interpreter.
2024-02-15 10:25:18 +00:00
Oli Scherer
e2386270df
Return ConstAllocation from eval_static_initializer query directly
2024-02-15 10:25:18 +00:00
Ralf Jung
5fa69deb00
fix cycle error when a static and a promoted are mutually recursive
...
This also now allows promoteds everywhere to point to 'extern static', because why not?
We still check that constants cannot transitively reach 'extern static' through references.
(We allow it through raw pointers.)
2024-02-12 09:48:14 +01:00
Ralf Jung
77f8c3caea
detect consts that reference extern statics
2024-02-10 16:13:48 +01:00
Ralf Jung
4e77e368eb
unstably allow constants to refer to statics and read from immutable statics
2024-02-10 16:12:55 +01:00
Oli Scherer
b6d0225caf
prefer instrumentation over entry/exit tracing statements
2024-01-29 08:53:54 +00:00
Oli Scherer
7a2b66319e
interning doesn't check alignment anymroe, because it doesn't do any more projections.
2024-01-29 08:53:54 +00:00
Ralf Jung
2f1a8e2d7a
const-eval interner: from-scratch rewrite using mutability information from provenance rather than types
2024-01-22 09:28:00 +01:00
Oli Scherer
867831a170
Always use RevealAll for const eval queries
2024-01-19 11:32:34 +00:00
Ralf Jung
4d93590d59
compile-time evaluation: emit a lint when a write through an immutable pointer occurs
2023-12-07 17:46:36 +01:00
Ralf Jung
cb86303342
ctfe interpreter: extend provenance so that it can track whether a pointer is immutable
2023-12-07 17:46:36 +01:00
Nilstrieb
21a870515b
Fix clippy::needless_borrow in the compiler
...
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.
Then I had to remove a few unnecessary parens and muts that were exposed
now.
2023-11-21 20:13:40 +01:00
bors
9c20ddd956
Auto merge of #117507 - nnethercote:rustc_span, r=Nilstrieb
...
`rustc_span` cleanups
Just some things I found while looking over this crate.
r? `@oli-obk`
2023-11-03 14:57:40 +00:00
Nicholas Nethercote
f405ce86c2
Minimize pub usage in source_map.rs.
...
Most notably, this commit changes the `pub use crate::*;` in that file
to `use crate::*;`. This requires a lot of `use` items in other crates
to be adjusted, because everything defined within `rustc_span::*` was
also available via `rustc_span::source_map::*`, which is bizarre.
The commit also removes `SourceMap::span_to_relative_line_string`, which
is unused.
2023-11-02 19:35:00 +11:00
Camille GILLOT
f512f91258
Comment for_diagnostics flag.
2023-11-01 19:01:55 +00:00
Camille GILLOT
224e29030a
Specify diagnostic path.
2023-11-01 18:36:38 +00:00
Camille GILLOT
c2f49e9edf
Do not assert in op_to_const.
2023-11-01 16:49:18 +00:00
Ralf Jung
351d532a27
interpret: call caller_location logic the same way codegen does, and share some code
2023-10-28 15:40:03 +02:00
Oli Scherer
fec0b54978
Split eval_to_allocation_raw_provider
2023-10-23 08:35:26 +00:00
Oli Scherer
f85b139704
Pull out const error reporting into its own function
2023-10-23 08:35:26 +00:00
Oli Scherer
5784e9e83e
Pull mplace validation logic out into an interpreter method
2023-10-23 08:35:26 +00:00
Oli Scherer
0fce74e1c0
The mutability was ignored anyway, so just check for staticness
2023-10-23 08:35:26 +00: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
a993a8bf3f
const-eval: make misalignment a hard error
2023-09-26 15:32:55 +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
Ralf Jung
89ac57db4d
move required_consts check to general post-mono-check function
2023-09-14 22:30:42 +02: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
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
fd91dfb494
cleanup leftovers of const_err lint
2023-09-12 13:41:42 +02:00
Ralf Jung
fa5f13775a
interpret: make MemPlace, Place, Operand types private to the interpreter
2023-09-04 17:53:38 +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
Deadbeef
e6b423aebb
Remove constness from ParamEnv
2023-07-27 15:50:42 +00:00
Matthias Krüger
fa21a8c6f8
Rollup merge of #114075 - matthiaskrgr:fmt_args_rustc_3, r=wesleywiser
...
inline format!() args from rustc_codegen_llvm to the end (4)
r? `@WaffleLapkin`
2023-07-27 06:04:13 +02:00
Matthias Krüger
c64ef5e070
inline format!() args from rustc_codegen_llvm to the end (4)
...
r? @WaffleLapkin
2023-07-25 23:20:28 +02:00
Ralf Jung
da3f0d0eb7
make MPlaceTy non-Copy
2023-07-25 22:35:07 +02:00
Mahdi Dibaiee
e55583c4b8
refactor(rustc_middle): Substs -> GenericArg
2023-07-14 13:27:35 +01:00
Nilstrieb
70b6a74c3c
Add enum for can_access_statics boolean
...
`/*can_access_statics:*/ false` is one of the ways to do this, but not
the one I like.
2023-06-24 20:40:40 +00:00