about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/util
AgeCommit message (Collapse)AuthorLines
2025-08-19Pretty print the name of an future from calling async closureMichael Goulet-1/+30
2025-08-14Print regions in `type_name`.Nicholas Nethercote-10/+16
Currently they are skipped, which is a bit weird, and it sometimes causes malformed output like `Foo<>` and `dyn Bar<, A = u32>`. Most regions are erased by the time `type_name` does its work. So all regions are now printed as `'_` in non-optional places. Not perfect, but better than the status quo. `c_name` is updated to trim lifetimes from MIR pass names, so that the `PASS_NAMES` sanity check still works. It is also renamed as `simplify_pass_type_name` and made non-const, because it doesn't need to be const and the non-const implementation is much shorter. The commit also renames `should_print_region` as `should_print_optional_region`, which makes it clearer that it only applies to some regions. Fixes #145168.
2025-08-13Rollup merge of #144949 - nnethercote:more-Printer-cleanups, r=davidtwcoGuillaume Gomez-12/+12
More `Printer` cleanups A sequel to rust-lang/rust#144776. r? ```@davidtwco```
2025-08-07Reimplement `print_region` in `type_name.rs`.Nicholas Nethercote-1/+3
Broken by #144776; this is reachable after all. Fixes #144994. The commit also adds a lot more cases to the `type-name-basic.rs`, because it's currently very anaemic. This includes some cases where region omission does very badly; these are marked with FIXME.
2025-08-06Rename some `PrettyPrinter` methods.Nicholas Nethercote-2/+2
More consistency.
2025-08-06Rename some `Printer` methods.Nicholas Nethercote-5/+5
I find these name clearer, and starting them all with `print_` makes things more consistent.
2025-08-05Rename most of the printers.Nicholas Nethercote-5/+5
Three of them are named `AbsolutePathPrinter`, which is confusing, so give those names that better indicate how they are used. And then there is `SymbolPrinter` and `SymbolMangler`, which are renamed as `LegacySymbolMangler` and `V0SymbolMangler`, better indicating their similarity.
2025-08-05Rollup merge of #144890 - WaffleLapkin:project_fields, r=lcnrSamuel Tardieu-5/+5
Add `InterpCx::project_fields` I was hoping for a much bigger improvement and this is lukewarm at best ^^' Still, I think this makes sense.
2025-08-04add `project_fields` helper functionWaffle Lapkin-5/+5
2025-08-03Remove unused arg from `path_append_impl`.Nicholas Nethercote-1/+0
None of the impls use it.
2025-08-03Rename `Printer` variables.Nicholas Nethercote-3/+3
Currently they are mostly named `cx`, which is a terrible name for a type that impls `Printer`/`PrettyPrinter`, and is easy to confuse with other types like `TyCtxt`. This commit changes them to `p`. A couple of existing `p` variables had to be renamed to make way.
2025-08-03Remove `type_name::AbsolutePathPrinter::comma_sep`.Nicholas Nethercote-14/+1
It's equivalent to the default `PrettyPrinter::comma_sep`.
2025-08-03Mark `Printer` methods as unreachable where appropriate.Nicholas Nethercote-1/+1
This helps me understand the structure of the code a lot. If any of these are actually reachable, we can put the old code back, add a new test case, and we will have improved our test coverage.
2025-07-23Remove useless lifetime parameter.Camille GILLOT-1/+1
2025-07-16Comment more code and make tests clearerDeadbeef-6/+5
Co-Authored-By: Ralf Jung <post@ralfj.de>
2025-07-16add `const_make_global`; err for `const_allocate` ptrs if didn't callDeadbeef-4/+6
Co-Authored-By: Ralf Jung <post@ralfj.de> Co-Authored-By: Oli Scherer <github333195615777966@oli-obk.de>
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-06-28Rollup merge of #142708 - Darksonn:location-len-without-nul, r=Mark-SimulacrumMatthias Krüger-7/+5
Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang/rust#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
2025-06-27Add InterpCx::layout_of with tracing, shadowing LayoutOfStypox-1/+0
2025-06-19Do not include NUL-terminator in computed lengthAlice Ryhl-7/+5
2025-06-06Rollup merge of #142103 - scottmcm:fieldidx-in-interp, r=oli-obkGuillaume Gomez-4/+8
Update `InterpCx::project_field` to take `FieldIdx` As suggested by Ralf in https://github.com/rust-lang/rust/pull/142005#discussion_r2125839015
2025-06-05Update `InterpCx::project_field` to take `FieldIdx`Scott McMurray-4/+8
As suggested by Ralf in 142005.
2025-06-06Rollup merge of #142012 - oli-obk:no-optional-spans, r=fee1-deadMatthias Krüger-1/+1
Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None Turns out many locations actually have a span available that we could use, so I used it
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-1/+1
2025-06-04Add Location::file_with_nulTaylor Cramer-8/+13
This is useful for C/C++ APIs which expect the const char* returned from __FILE__ or std::source_location::file_name.
2025-05-27Rename unpack to kindMichael Goulet-1/+1
2025-04-24Remove `weak` alias terminologyBoxy-1/+1
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-1/+1
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-7/+9
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-05Pretty print pattern type values with `transmute` if they don't satisfy ↵Oli Scherer-13/+42
their pattern
2025-02-03Remove hook calling via `TyCtxtAt`.Nicholas Nethercote-5/+4
All hooks receive a `TyCtxtAt` argument. Currently hooks can be called through `TyCtxtAt` or `TyCtxt`. In the latter case, a `TyCtxtAt` is constructed with a dummy span and passed to the hook. However, in practice hooks are never called through `TyCtxtAt`, and always receive a dummy span. (I confirmed this via code inspection, and double-checked it by temporarily making the `TyCtxtAt` code path panic and running all the tests.) This commit removes all the `TyCtxtAt` machinery for hooks. All hooks now receive `TyCtxt` instead of `TyCtxtAt`. There are two existing hooks that use `TyCtxtAt::span`: `const_caller_location_provider` and `try_destructure_mir_constant_for_user_output`. For both hooks the span is always a dummy span, probably unintentionally. This dummy span use is now explicit. If a non-dummy span is needed for these two hooks it would be easy to add it as an extra argument because hooks are less constrained than queries.
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-1/+2
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-0/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-1/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-09interpret: clean up deduplicating allocation functionsRalf Jung-6/+3
2024-11-19`InterpCx` store `TypingEnv` instead of a `ParamEnv`lcnr-2/+2
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-16/+13
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-03compiler: Directly use rustc_abi in const_evalJubilee Young-1/+1
2024-10-31stop using `ParamEnv::reveal` while handling MIRlcnr-16/+7
2024-10-30Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errorsJubilee-7/+7
Rename `rustc_abi::Abi` to `BackendRepr` Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights. Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-7/+7
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
2024-10-29TypingMode :thinking:lcnr-2/+3
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-1/+1
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-01make InterpResult a dedicated type to avoid accidentally discarding the errorRalf Jung-2/+1
2024-09-30panic when an interpreter error gets unintentionally discardedRalf Jung-1/+3
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-16layout computation: eagerly error for unexpected unsized fieldsLukas Markeffsky-3/+5
2024-09-16make `LayoutCx` not genericLukas Markeffsky-2/+2
2024-09-08clarify comments and names in check_validity_requirementRalf Jung-9/+11
2024-09-08interpret: reset padding during validationRalf Jung-1/+1