diff options
| author | Jack Wrenn <jack@wrenn.fyi> | 2022-08-18 19:39:14 +0000 |
|---|---|---|
| committer | Jack Wrenn <jack@wrenn.fyi> | 2022-08-22 18:37:54 +0000 |
| commit | f46fffc276c19b2c81c9b5e84f4f8678fc4d6d0a (patch) | |
| tree | 5a5d0e994f5cf930365f2d03343e64d54e12f308 /compiler/rustc_transmute/src/maybe_transmutable | |
| parent | e0dc8d78019ca924203fe153ff0af7f64f68cb5d (diff) | |
| download | rust-f46fffc276c19b2c81c9b5e84f4f8678fc4d6d0a.tar.gz rust-f46fffc276c19b2c81c9b5e84f4f8678fc4d6d0a.zip | |
safe transmute: use `Assume` struct to provide analysis options
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
Diffstat (limited to 'compiler/rustc_transmute/src/maybe_transmutable')
| -rw-r--r-- | compiler/rustc_transmute/src/maybe_transmutable/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/maybe_transmutable/tests.rs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index 076d922d1b7..b6b6de38f66 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -105,7 +105,7 @@ where #[inline(always)] #[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))] pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> { - let assume_visibility = self.assume.visibility; + let assume_visibility = self.assume.safety; let query_or_answer = self.map_layouts(|src, dst, scope, context| { // Remove all `Def` nodes from `src`, without checking their visibility. let src = src.prune(&|def| true); diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs index d9d125687f6..4d5772a4f2e 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs @@ -13,7 +13,7 @@ mod bool { layout::Tree::<Def, !>::bool(), layout::Tree::<Def, !>::bool(), (), - crate::Assume { alignment: false, lifetimes: false, validity: true, visibility: false }, + crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false }, UltraMinimal, ) .answer(); @@ -26,7 +26,7 @@ mod bool { layout::Dfa::<!>::bool(), layout::Dfa::<!>::bool(), (), - crate::Assume { alignment: false, lifetimes: false, validity: true, visibility: false }, + crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false }, UltraMinimal, ) .answer(); |
