diff options
Diffstat (limited to 'compiler/rustc_transmute/src')
| -rw-r--r-- | compiler/rustc_transmute/src/layout/dfa.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/layout/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/layout/nfa.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/layout/tree.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/lib.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/maybe_transmutable/mod.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/maybe_transmutable/query_context.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_transmute/src/maybe_transmutable/tests.rs | 9 |
8 files changed, 31 insertions, 45 deletions
diff --git a/compiler/rustc_transmute/src/layout/dfa.rs b/compiler/rustc_transmute/src/layout/dfa.rs index 3378d1c6754..58bd517d7e8 100644 --- a/compiler/rustc_transmute/src/layout/dfa.rs +++ b/compiler/rustc_transmute/src/layout/dfa.rs @@ -1,9 +1,11 @@ -use super::{nfa, Byte, Nfa, Ref}; -use crate::Map; use std::fmt; use std::sync::atomic::{AtomicU32, Ordering}; + use tracing::instrument; +use super::{nfa, Byte, Nfa, Ref}; +use crate::Map; + #[derive(PartialEq, Clone, Debug)] pub(crate) struct Dfa<R> where diff --git a/compiler/rustc_transmute/src/layout/mod.rs b/compiler/rustc_transmute/src/layout/mod.rs index 0377ed5d4c5..bbf155581f9 100644 --- a/compiler/rustc_transmute/src/layout/mod.rs +++ b/compiler/rustc_transmute/src/layout/mod.rs @@ -60,9 +60,10 @@ impl Ref for ! { #[cfg(feature = "rustc")] pub mod rustc { + use std::fmt::{self, Write}; + use rustc_middle::mir::Mutability; use rustc_middle::ty::{self, Ty}; - use std::fmt::{self, Write}; /// A reference in the layout. #[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)] diff --git a/compiler/rustc_transmute/src/layout/nfa.rs b/compiler/rustc_transmute/src/layout/nfa.rs index 3c5963202c6..0dd26badc88 100644 --- a/compiler/rustc_transmute/src/layout/nfa.rs +++ b/compiler/rustc_transmute/src/layout/nfa.rs @@ -1,8 +1,9 @@ -use super::{Byte, Ref, Tree, Uninhabited}; -use crate::{Map, Set}; use std::fmt; use std::sync::atomic::{AtomicU32, Ordering}; +use super::{Byte, Ref, Tree, Uninhabited}; +use crate::{Map, Set}; + /// A non-deterministic finite automaton (NFA) that represents the layout of a type. /// The transmutability of two given types is computed by comparing their `Nfa`s. #[derive(PartialEq, Debug)] diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 865f9487213..5c25f913ffe 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -1,6 +1,7 @@ -use super::{Byte, Def, Ref}; use std::ops::ControlFlow; +use super::{Byte, Def, Ref}; + #[cfg(test)] mod tests; @@ -170,24 +171,14 @@ where #[cfg(feature = "rustc")] pub(crate) mod rustc { + use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf}; + use rustc_middle::ty::{self, AdtDef, AdtKind, List, ScalarInt, Ty, TyCtxt, TypeVisitableExt}; + use rustc_span::ErrorGuaranteed; + use rustc_target::abi::{FieldsShape, Size, TyAndLayout, Variants}; + use super::Tree; use crate::layout::rustc::{Def, Ref}; - use rustc_middle::ty::layout::HasTyCtxt; - use rustc_middle::ty::layout::LayoutCx; - use rustc_middle::ty::layout::LayoutError; - use rustc_middle::ty::layout::LayoutOf; - use rustc_middle::ty::AdtDef; - use rustc_middle::ty::AdtKind; - use rustc_middle::ty::List; - use rustc_middle::ty::ScalarInt; - use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; - use rustc_span::ErrorGuaranteed; - use rustc_target::abi::FieldsShape; - use rustc_target::abi::Size; - use rustc_target::abi::TyAndLayout; - use rustc_target::abi::Variants; - #[derive(Debug, Copy, Clone)] pub(crate) enum Err { /// The layout of the type is not yet supported. diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 2b052412e6b..31664ee6c4f 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -79,19 +79,15 @@ pub enum Reason<T> { #[cfg(feature = "rustc")] mod rustc { - use super::*; - use rustc_hir::lang_items::LangItem; use rustc_infer::infer::InferCtxt; use rustc_macros::TypeVisitable; use rustc_middle::traits::ObligationCause; - use rustc_middle::ty::Const; - use rustc_middle::ty::ParamEnv; - use rustc_middle::ty::Ty; - use rustc_middle::ty::TyCtxt; - use rustc_middle::ty::ValTree; + use rustc_middle::ty::{Const, ParamEnv, Ty, TyCtxt, ValTree}; use rustc_span::DUMMY_SP; + use super::*; + /// The source and destination types of a transmutation. #[derive(TypeVisitable, Debug, Clone, Copy)] pub struct Types<'tcx> { diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index dee5a72c3bc..7c66a827db9 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -4,11 +4,9 @@ pub(crate) mod query_context; #[cfg(test)] mod tests; -use crate::{ - layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited}, - maybe_transmutable::query_context::QueryContext, - Answer, Condition, Map, Reason, -}; +use crate::layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited}; +use crate::maybe_transmutable::query_context::QueryContext; +use crate::{Answer, Condition, Map, Reason}; pub(crate) struct MaybeTransmutableQuery<L, C> where @@ -32,15 +30,12 @@ where // FIXME: Nix this cfg, so we can write unit tests independently of rustc #[cfg(feature = "rustc")] mod rustc { + use rustc_middle::ty::layout::{LayoutCx, LayoutOf}; + use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; + use super::*; use crate::layout::tree::rustc::Err; - use rustc_middle::ty::layout::LayoutCx; - use rustc_middle::ty::layout::LayoutOf; - use rustc_middle::ty::ParamEnv; - use rustc_middle::ty::Ty; - use rustc_middle::ty::TyCtxt; - impl<'tcx> MaybeTransmutableQuery<Ty<'tcx>, TyCtxt<'tcx>> { /// This method begins by converting `src` and `dst` from `Ty`s to `Tree`s, /// then computes an answer using those trees. diff --git a/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs b/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs index 1ccb6f36c8e..95373916a71 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs @@ -34,9 +34,10 @@ pub(crate) mod test { #[cfg(feature = "rustc")] mod rustc { - use super::*; use rustc_middle::ty::{Ty, TyCtxt}; + use super::*; + impl<'tcx> super::QueryContext for TyCtxt<'tcx> { type Def = layout::rustc::Def<'tcx>; type Ref = layout::rustc::Ref<'tcx>; diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs index 9c7abf1cbd6..c3be4203cce 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs @@ -1,12 +1,12 @@ +use itertools::Itertools; + use super::query_context::test::{Def, UltraMinimal}; use crate::maybe_transmutable::MaybeTransmutableQuery; use crate::{layout, Reason}; -use itertools::Itertools; mod safety { - use crate::Answer; - use super::*; + use crate::Answer; type Tree = layout::Tree<Def, !>; @@ -63,9 +63,8 @@ mod safety { } mod bool { - use crate::Answer; - use super::*; + use crate::Answer; #[test] fn should_permit_identity_transmutation_tree() { |
