about summary refs log tree commit diff
path: root/compiler/rustc_transmute/src
AgeCommit message (Collapse)AuthorLines
2023-10-06Remove the `MaybeTransmutableQuery<&'l Dfa<...>, C>` impl.Nicholas Nethercote-16/+0
Because there is also a `MaybeTransmutableQuery<Dfa<...>, C>` impl, and we don't need both.
2023-10-06Fix a comment.Nicholas Nethercote-3/+1
It was duplicated from the method above.
2023-10-06Remove `map_layouts`.Nicholas Nethercote-57/+33
As per the `FIXME` comment, it's an abstraction that makes the code harder to read.
2023-10-06Make the comment order match variant declaration order.Nicholas Nethercote-1/+1
2023-10-06Remove an unnecessary `pub(crate)`.Nicholas Nethercote-1/+1
2023-09-13make the eval() functions on our const types return the resulting valueRalf Jung-7/+4
2023-09-06Fix error report for size overflow from transmuteyukang-0/+9
2023-07-27Don't attempt to compute layout of type referencing errorMichael Goulet-1/+1
2023-07-18Auto merge of #113677 - bryangarza:unevaluated-const-ice_issue-110892, ↵bors-1/+12
r=davidtwco Safe Transmute: Fix ICE (due to UnevaluatedConst) This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names). Fixes #110892
2023-07-17Safe Transmute: Fix ICE (due to UnevaluatedConst)Bryan Garza-1/+12
This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names). Fixes #110892
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-89/+99
- 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: Update definition of Condition typeBryan Garza-14/+17
- Change `Condition` to not contain `Answer`s but instead just contain other `Condition`s directly. - Also improve error reporting for `DstHasStricterAlignment`
2023-05-24Safe Transmute: Check mutability before creating dst -> src obligationBryan Garza-7/+32
- 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: Fix propagation of errorsBryan Garza-15/+30
- Make sure that the most specific Reason is the one that bubbles up when we are folding over the `Answer` tree. `Reason::DstIsBitIncompatible` is the least specific, so that should be used only when there isn't anything else available. - Small fixes where we used the wrong Reason variant. - Tiny cleanups
2023-05-24Safe Transmute: Change Answer type to ResultBryan Garza-117/+90
This patch updates the `Answer` type from `rustc_transmute` so that it just a type alias to `Result`. This makes it so that the standard methods for `Result` can be used to process the `Answer` tree, including being able to make use of the `?` operator on `Answer`s. Also, remove some unused functions
2023-05-24Safe Transmute: Enable handling references, including recursive typesBryan Garza-51/+178
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-26Remove unused `TypeFoldable`/`TypeVisitable` impls.Nicholas Nethercote-2/+2
2023-04-16Erase regions when confirming transmutability candidateMichael Goulet-6/+3
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-28/+33
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-04-09Some simple `clippy::perf` fixesNilstrieb-1/+1
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-3/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-22Remove type-traversal trait aliasesAlan Egerton-1/+1
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-2/+3
2023-01-18Also remove `#![feature(control_flow_enum)]` where possibleScott McMurray-1/+1
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-19Rollup merge of #105864 - matthiaskrgr:compl, r=NilstriebDylan DPC-5/+1
clippy::complexity fixes filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool r? `@compiler-errors`
2022-12-19clippy::complexity fixesMatthias Krüger-5/+1
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
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-04Rollup merge of #103915 - chenyukang:yukang/fix-103874, r=lcnrMatthias Krüger-1/+1
Improve use of ErrorGuaranteed and code cleanup Part of #103874
2022-11-03change error_reported to use Result instead of an optionyukang-1/+1
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-10-07Remove TypeckResults from InferCtxtCameron Steffen-2/+2
2022-10-03check if const is ADT or notTakayuki Maeda-5/+10
2022-09-20rustc_transmute: fix big-endian discriminantsJosh Stone-6/+16
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-16/+59
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-11/+11
by module
2022-08-31safe transmute: use `to_valtree` to destructure const `Assume`Jack Wrenn-7/+4
ref: https://github.com/rust-lang/rust/pull/100726#discussion_r954813220
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-26Rollup merge of #100604 - dtolnay:okorerr, r=m-ou-seYuki Okushi-16/+11
Remove unstable Result::into_ok_or_err Pending FCP: https://github.com/rust-lang/rust/issues/82223#issuecomment-1214920203 ```@rustbot``` label +waiting-on-fcp
2022-08-23safe transmute: use `FxIndex{Map,Set}` instead of `FxHash{Map,Set}`Jack Wrenn-12/+1
resolves query instability issues, and probably better for performance
2022-08-22safe transmute: use `Assume` struct to provide analysis optionsJack Wrenn-4/+61
This was left as a TODO in #92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: https://github.com/rust-lang/compiler-team/issues/411 ref: https://github.com/rust-lang/rust/issues/99571
2022-08-21ADD - diagnostic lints to rustc_transmuteJhonny Bill Mena-0/+2
Module is complete because it has zero diagnostics.
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-14/+8
2022-08-02safe transmute: fix broken intradoc linkJack Wrenn-2/+2