about summary refs log tree commit diff
path: root/compiler/rustc_transmute
AgeCommit message (Collapse)AuthorLines
2025-09-09Driveby fixesBoxy-3/+1
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-20/+21
2025-09-02Revert introduction of `[workspace.dependencies]`.Nicholas Nethercote-2/+2
This was done in #145740 and #145947. It is causing problems for people using r-a on anything that uses the rustc-dev rustup package, e.g. Miri, clippy. This repository has lots of submodules and subtrees and various different projects are carved out of pieces of it. It seems like `[workspace.dependencies]` will just be more trouble than it's worth.
2025-08-27Add `itertools` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Add `tracing` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-07-31Tidy up `Cargo.toml` files.Nicholas Nethercote-0/+2
- Add some missing `tidy-alphabetical-*` markers. - Remove some unnecessary blank lines.
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-1/+1
default data address space
2025-06-27tag_for_variant: properly pass TypingEnvRalf Jung-1/+3
2025-06-09transmutability: shift abstraction boundaryJack Wrenn-243/+293
Previously, `rustc_transmute`'s layout representations were genericized over `R`, a reference. Now, it's instead genericized over representations of type and region. This allows us to move reference transmutability logic from `rustc_trait_selection` to `rustc_transmutability` (and thus unit test it independently of the compiler), and — in a follow-up PR — will make it possible to support analyzing function pointer transmutability with minimal surgery.
2025-06-03Change `tag_field` to `FieldIdx` in `Variants::Multiple`Scott McMurray-1/+1
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
2025-05-02Rollup merge of #140509 - tmiasko:merge-contiguous-ranges, r=jswrennMatthias Krüger-7/+19
transmutability: merge contiguous runs with a common destination Based on #140380. r? `@jswrenn` `@joshlf`
2025-04-30transmutability: merge contiguous runs with a common destinationTomasz Miąsko-7/+19
2025-04-30transmutability: ensure_sufficient_stack when answering queryTomasz Miąsko-117/+125
2025-04-29transmutability: uninit transition matches unit byte onlyTomasz Miąsko-352/+173
The previous implementation was inconsistent about transitions that apply for an init byte. For example, when answering a query, an init byte could use corresponding init transition. Init byte could also use uninit transition, but only when the corresponding init transition was absent. This behaviour was incompatible with DFA union construction. Define an uninit transition to match an uninit byte only and update implementation accordingly. To describe that `Tree::uninit` is valid for any value, build an automaton that accepts any byte value. Additionally, represent byte ranges uniformly as a pair of integers to avoid special case for uninit byte.
2025-04-25transmutability: Support char, NonZeroXxxJoshua Liebow-Feeser-46/+213
Note that `NonZero` support is not wired up, as the author encountered bugs while attempting this. A future commit will wire up `NonZero` support.
2025-04-23transmutability: Mark edges by ranges, not valuesJoshua Liebow-Feeser-161/+777
In the `Tree` and `Dfa` representations of a type's layout, store byte ranges rather than needing to separately store each byte value. This permits us to, for example, represent a `u8` using a single 0..=255 edge in the DFA rather than using 256 separate edges. This leads to drastic performance improvements. For example, on the author's 2024 MacBook Pro, the time to convert the `Tree` representation of a `u64` to its equivalent DFA representation drops from ~8.5ms to ~1us, a reduction of ~8,500x. See `bench_dfa_from_tree`. Similarly, the time to execute a transmutability query from `u64` to `u64` drops from ~35us to ~1.7us, a reduction of ~20x. See `bench_transmute`.
2025-04-21cleanup redundant pattern instancesJonathan Gruner-1/+1
2025-04-20transmutability: remove NFA intermediate representationJack Wrenn-295/+239
Prior to this commit, the transmutability analysis used an intermediate NFA representation of type layout. We then determinized this representation into a DFA, upon which we ran the core transmutability analysis. Unfortunately, determinizing NFAs is expensive. In this commit, we avoid NFAs entirely by observing that Rust `union`s are the only source of nondeterminism and that it is comparatively cheap to compute the DFA union of DFAs. We also implement Graphviz DOT debug formatting of DFAs. Fixes rust-lang/project-safe-transmute#23 Fixes rust-lang/project-safe-transmute#24
2025-04-16transmutability: Refactor tests for simplicityJoshua Liebow-Feeser-66/+74
2025-04-02Remove `recursion_limit` increases.Nicholas Nethercote-1/+0
These are no longer needed now that `Nonterminal` is gone.
2025-03-18Add `#[cfg(test)]` for Transition in dfamu001999-0/+3
2025-03-12Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgrbors-1/+0
Rollup of 7 pull requests Successful merges: - #137314 (change definitely unproductive cycles to error) - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`) - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr) - #138331 (Use `RUSTC_LINT_FLAGS` more) - #138345 (Some autodiff cleanups) - #138387 (intrinsics: remove unnecessary leading underscore from argument names) - #138390 (fix incorrect tracing log) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-3/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-08Specify rust lints for `compiler/` crates via Cargo.Nicholas Nethercote-0/+3
By naming them in `[workspace.lints.rust]` in the top-level `Cargo.toml`, and then making all `compiler/` crates inherit them with `[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`, because they're a bit different.) The advantages of this over the current approach: - It uses a standard Cargo feature, rather than special handling in bootstrap. So, easier to understand, and less likely to get accidentally broken in the future. - It works for proc macro crates. It's a shame it doesn't work for rustc-specific lints, as the comments explain.
2025-03-07Increase recursion_limit in numerous crates.Nicholas Nethercote-0/+1
This is temporarily needed for `x doc compiler` to work. They can be removed once the `Nonterminal` is removed (#124141).
2025-02-28Remove `allow(dead_code)` attributes.Nicholas Nethercote-15/+1
By either removing the function, or change the attribute to something more precise.
2025-02-28Remove `allow(unused_variables)` for `rustc_transmute`.Nicholas Nethercote-25/+12
This was hiding some genuine sins, including unused arguments in numerous functions/methods (incl. trait methods), and some unnecessary computation.
2025-02-28Remove unused feature from `rustc_transmute`.Nicholas Nethercote-1/+0
2025-02-28Remove unnecessary `allow(unused)` attribute.Nicholas Nethercote-1/+0
2025-02-28Remove `rustc_transmute`'s dependence on `rustc_macros`.Nicholas Nethercote-4/+1
2025-02-28Remove `rustc_transmute`'s dependence on `rustc_infer`.Nicholas Nethercote-9/+6
`TransmuteTypeEnv` only needs a `TyCtxt`, not an `InferCtxt`.
2025-02-22Upgrade the compiler to edition 2024Michael Goulet-1/+1
2025-02-19Make fewer crates depend on rustc_ast_irMichael Goulet-2/+0
2025-02-08transmutability: fix ICE when passing wrong ADT to ASSUMELukas Markeffsky-18/+14
2025-01-30introduce `ty::Value`Lukas Markeffsky-4/+4
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-27Add `TooGeneric` variant to `LayoutError` and emit `Unknown` oneFedericoBruzzone-0/+1
- `check-pass` test for a MRE of #135020 - fail test for #135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
2024-12-18add comment explaining why ty_and_layout_field is not usedRalf Jung-1/+4
Co-authored-by: Jack Wrenn <me@jswrenn.com>
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-8/+7
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-6/+4
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-01fix safe-transmute handling of enumsRalf Jung-30/+27
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-2/+2
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-10-28Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errorsJubilee-3/+1
Add `LayoutS::is_uninhabited` and use it Use accessors for the things that accessors are good at: reducing everyone's need to be nosy and peek at the internals of every data structure.
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-3/+1
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-27rustc_transmute: Directly use types from rustc_abiJubilee Young-9/+9
2024-10-19Fix transmute goalMichael Goulet-6/+1
2024-10-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-2/+1
2024-10-04Fix some pub(crate) that were undetected bc of instrumentMichael Goulet-1/+1