lcnr
9cba14b95b
use TypingEnv when no infcx is available
...
the behavior of the type system not only depends on the current
assumptions, but also the currentnphase of the compiler. This is
mostly necessary as we need to decide whether and how to reveal
opaque types. We track this via the `TypingMode`.
2024-11-18 10:38:56 +01:00
Boxy
6dad074907
Handle infer vars in anon consts on stable
2024-11-12 21:36:42 +00:00
Boxy
bea0148ac6
Consolidate type system const evaluation under traits::evaluate_const
...
mew
2024-11-12 02:54:03 +00:00
Jubilee Young
236fe33345
compiler: Directly use rustc_abi in metadata and middle
...
Stop reexporting ReprOptions from middle::ty
2024-11-03 13:38:47 -08:00
Michael Goulet
38bbcc001e
Rename normalize to normalize_internal, remove unnecessary usages
2024-10-19 18:07:35 +00:00
Michael Goulet
e83e4e8112
Get rid of const eval_* and try_eval_* helpers
2024-10-19 18:07:35 +00:00
Ralf Jung
c4ce8c114b
make InterpResult a dedicated type to avoid accidentally discarding the error
2024-10-01 21:45:35 +02:00
Ralf Jung
c55c4c9f9d
tweak Const::identity_unevaluated name and docs
2024-09-28 21:28:08 +02:00
Ralf Jung
921a5ef6d7
try to get rid of mir::Const::normalize
2024-09-28 21:15:18 +02:00
Michael Goulet
c682aa162b
Reformat using the new identifier sorting from rustfmt
2024-09-22 19:11:29 -04:00
Alexander Cyon
00de006f22
chore: Fix typos in 'compiler' (batch 2)
2024-09-02 07:50:22 +02: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
3c57ea0df7
ScalarInt: size mismatches are a bug, do not delay the panic
2024-06-10 13:43:16 +02:00
Boxy
60a5bebbe5
Add Ty to mir::Const::Ty
2024-06-05 22:25:41 +01:00
Boxy
a9702a6668
Add Ty to ConstKind::Value
2024-06-05 22:25:41 +01:00
Boxy
58feec9b85
Basic removal of Ty from places (boring)
2024-06-05 22:25:38 +01:00
Michael Goulet
bbcdb4fd3e
Give EarlyBinder a tcx parameter
...
We are gonna need it to uplift EarlyBinder
2024-05-26 20:04:05 -04:00
Nicholas Nethercote
7418aa1a07
Remove extern crate rustc_data_structures from numerous crates.
2024-04-29 18:45:14 +10:00
Nicholas Nethercote
6ce258f657
Remove extern crate rustc_macros from rustc_middle.
2024-04-29 11:19:16 +10:00
Ralf Jung
8436045e24
filter required_consts during inlining
2024-04-23 23:02:54 +02:00
Ralf Jung
173d1bd36b
properly fill a promoted's required_consts
...
then we can also make all_required_consts_are_checked a constant instead of a function
2024-04-23 23:02:54 +02:00
bors
ce3263e60e
Auto merge of #124113 - RalfJung:interpret-scalar-ops, r=oli-obk
...
interpret: use ScalarInt for bin-ops; avoid PartialOrd for ScalarInt
Best reviewed commit-by-commit
r? `@oli-obk`
2024-04-19 17:00:28 +00:00
Ralf Jung
d3f927db87
avoid PartialOrd on ScalarInt
...
we don't know their sign so we cannot, in general, order them properly
2024-04-19 17:17:31 +02:00
Ralf Jung
42220f0930
ScalarInt: add methods to assert being a (u)int of given size
2024-04-19 13:51:52 +02:00
Nicholas Nethercote
0d97669a17
Simplify static_assert_sizes.
...
We want to run them on all 64-bit platforms.
2024-04-18 15:36:25 +10:00
Zalathar
2d47cd77ac
Check x86_64 size assertions on aarch64, too
...
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to
notice when these assertions have been violated.
2024-04-03 16:53:03 +11:00
Urgau
106146fd95
Replace RemapFileNameExt::for_codegen with explicit calls
2024-03-28 18:47:26 +01:00
Oli Scherer
1cf345e10a
Remove unnecessary Partial/Ord impl
2024-03-21 10:04:20 +00:00
Oli Scherer
adda9da604
Avoid various uses of Option<Span> in favor of using DUMMY_SP in the few cases that used None
2024-03-18 09:34:08 +00: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
Oli Scherer
61361c16aa
Fix Stable trait and its impls to work with the new with_tables
2024-01-19 09:42:51 +00:00
surechen
40ae34194c
remove redundant imports
...
detects redundant imports that can be eliminated.
for #117772 :
In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08: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
Michael Goulet
8bf9c18914
Review comment
2023-11-25 18:00:35 +00:00
Michael Goulet
a992defc8b
Remove mir::Const::from_anon_const
2023-11-25 17:52:43 +00: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
Oli Scherer
77174d3f29
Turn const_caller_location from a query to a hook
2023-10-31 16:15:18 +00:00
Camille GILLOT
5b7cc9d704
Do not ICE on constant evaluation failure in GVN.
2023-10-31 10:44:28 +00:00
Guillaume Gomez
73100d8e93
Rollup merge of #117317 - RalfJung:track-caller, r=oli-obk
...
share some track_caller logic between interpret and codegen
Also move the code that implements the track_caller intrinsics out of the core interpreter engine -- it's just a helper creating a const-allocation, doesn't need to be part of the interpreter core.
2023-10-30 17:33:16 +01: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
Camille Gillot
24be43356e
Apply suggestions from code review
...
Co-authored-by: Ralf Jung <post@ralfj.de >
2023-10-27 20:51:25 +02:00
Camille GILLOT
72f0e0e795
Rename has_provance and tweaks comments.
2023-10-25 17:59:30 +00:00
Camille GILLOT
50559ceec4
Valtrees for primitive types are fine.
2023-10-25 06:46:48 +00:00
Camille GILLOT
f6aa3ee7e8
Complete comments.
2023-10-25 06:46:48 +00:00
Camille GILLOT
5e78b9cdb3
Disambiguate non-deterministic constants.
2023-10-25 06:46:48 +00:00
Camille GILLOT
38c86b0798
Evaluate computed values to constants.
2023-10-25 06:46:47 +00:00
Ralf Jung
cbe892fd65
fix fast-path for try_eval_scalar_int
2023-10-05 22:00:24 +02:00
Nadrieril
eac7bcde5f
Move eval_bits optimization upstream
2023-10-01 21:12:24 +02:00
Guillaume Gomez
208f6ed95c
Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
...
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const
Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.
Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.
However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...
``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
Ralf Jung
c94410c145
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const
2023-09-21 08:12:30 +02:00