about summary refs log tree commit diff
path: root/compiler/rustc_transmute/src/layout
AgeCommit message (Collapse)AuthorLines
2023-09-06Fix error report for size overflow from transmuteyukang-0/+3
2023-07-27Don't attempt to compute layout of type referencing errorMichael Goulet-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-7/+7
2023-07-01Put `LayoutError` behind reference to shrink resultNilstrieb-4/+4
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's shrink that.
2023-06-12Safe Transmute: Refactor error handling and Answer typeBryan Garza-2/+2
- Create `Answer` type that is not just a type alias of `Result` - Remove a usage of `map_layouts` to make the code easier to read - Don't hide errors related to Unknown Layout when computing transmutability
2023-05-24Safe Transmute: Check mutability before creating dst -> src obligationBryan Garza-6/+9
- Only create dst -> src obligation if Dst is mutable - Add some long comments to explain parts of the transmutability code that were unclear to me when reading - Update/add tests
2023-05-24Safe Transmute: Enable handling references, including recursive typesBryan Garza-12/+36
This patch enables support for references in Safe Transmute, by generating nested obligations during trait selection. Specifically, when we call `confirm_transmutability_candidate(...)`, we now recursively traverse the `rustc_transmute::Answer` tree and create obligations for all the `Answer` variants, some of which include multiple nested `Answer`s. Also, to handle recursive types, enable support for coinduction for the Safe Transmute trait (`BikeshedIntrinsicFrom`) by adding the `#[rustc_coinduction]` annotation. Also fix some small logic issues when reducing the `or` and `and` combinations in `rustc_transmute`, so that we don't end up with additional redundant `Answer`s in the tree. Co-authored-by: Jack Wrenn <jack@wrenn.fyi>
2023-04-16more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_default, ↵Matthias Krüger-1/+1
option_map_or_none}
2023-04-13Improve safe transmute error reportingBryan Garza-12/+16
This patch updates the error reporting when Safe Transmute is not possible between 2 types by including the reason. Also, fix some small bugs that occur when computing the `Answer` for transmutability.
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-2/+3
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-1/+1
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-18don't clone Copy typesMatthias Krüger-2/+2
2022-11-05Auto merge of #103831 - chenyukang:yukang/fix-103751-ice, r=nagisabors-2/+2
Fix capacity overflow issue during transmutability check Fixes #103751
2022-11-01fix #103751: Fix capacity overflow issue during transmutability checkyukang-2/+2
2022-10-30fix #103783, fix ICE checking transmutability of NaughtyLenArrayyukang-1/+2
2022-09-20rustc_transmute: fix big-endian discriminantsJosh Stone-6/+16
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-7/+0
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in #92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](https://github.com/rust-lang/compiler-team/issues/411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - https://github.com/rust-lang/compiler-team/issues/411 - https://github.com/rust-lang/rust/issues/99571
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-8/+8
by module
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-23safe transmute: use `FxIndex{Map,Set}` instead of `FxHash{Map,Set}`Jack Wrenn-7/+0
resolves query instability issues, and probably better for performance
2022-08-17Replace a try_fold in rustc_transmute to use ControlFlow instead of ResultDavid Tolnay-3/+4
2022-08-17Remove unstable Result::into_ok_or_errDavid Tolnay-6/+7
2022-08-02safe transmute: fix broken intradoc linkJack Wrenn-2/+2
2022-07-28safe transmute: use `AtomicU32` `State` ids to appease mipsJack Wrenn-6/+6
...instead of `AtomicU64`, which is unavailable. ref: https://github.com/rust-lang/rust/pull/92268#issuecomment-1197797990
2022-07-27safe transmute: lowercase tracing levelsJack Wrenn-1/+1
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r927095154
2022-07-27safe transmute: tweak `Nfa::union` to consume params by valueJack Wrenn-2/+2
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925274516
2022-07-27safe transmute: tweak tracingJack Wrenn-13/+5
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925246903 ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925250811 ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925255782
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-0/+993
This initial implementation handles transmutations between types with specified layouts, except when references are involved. Co-authored-by: Igor null <m1el.2027@gmail.com>