Ralf Jung
1d87efc1da
replace another Option<Span> by DUMMY_SP
2024-05-07 14:52:42 +02:00
Oli Scherer
126dcc618d
Use less fragile error handling
2024-04-17 09:50:44 +00:00
Oli Scherer
77fe9f0a72
Validate before reporting interning errors.
...
validation produces much higher quality errors and already handles most of the cases
2024-04-17 09:50:44 +00:00
xiaoxiangxianzi
3157114f0b
chore: fix some comments
...
Signed-off-by: xiaoxiangxianzi <zhaoyizheng@outlook.com >
2024-03-27 22:32:53 +08:00
Ben Kimock
9e0d1a3284
Print a backtrace in const eval if interrupted
2024-03-17 11:55:20 -04:00
Oli Scherer
a316c21dc8
Rename some things around validation error reporting to signal that it is in fact about validation failures
2024-03-14 12:21:35 +00:00
Oli Scherer
16046c77aa
Move the entire success path into eval_body_using_ecx
2024-03-14 12:21:29 +00:00
Oli Scherer
2e6c4900b6
Move validation into eval_body_using_ecx
2024-03-14 12:21:23 +00:00
Oli Scherer
cc7e0b2200
Share the InterpCx creation between static and const evaluation
2024-03-14 12:21:18 +00:00
Oli Scherer
02a0ac8058
Remove an argument that can be computed cheaply
2024-03-14 12:21:12 +00:00
Oli Scherer
d3b7b558aa
Directly pass in the stack instead of computing it from a machine
2024-03-14 12:21:06 +00:00
Oli Scherer
6b936b6c08
Move InterpCx into eval_in_interpreter
2024-03-14 11:40:42 +00:00
Oli Scherer
8b8efd157b
Move error handling into const_validate_mplace
2024-03-14 11:40:36 +00:00
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