@@ -31,6 +31,7 @@ use rustc_middle::ty::print::{
3131 PrintPolyTraitClauseExt , PrintPolyTraitRefExt as _, PrintTraitClauseExt as _,
3232 PrintTraitRefExt as _, with_forced_trimmed_paths,
3333} ;
34+ use rustc_middle:: ty:: transmute:: { Answer , Reason } ;
3435use rustc_middle:: ty:: {
3536 self , GenericArgKind , GenericParamDefKind , TraitRef , Ty , TyCtxt , TypeFoldable , TypeFolder ,
3637 TypeSuperFoldable , TypeVisitableExt , Unnormalized , Upcast ,
@@ -3253,7 +3254,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
32533254 trait_ref. args. type_at( 0 ) ,
32543255 assume,
32553256 ) ,
3256- rustc_transmute :: Answer :: Yes ,
3257+ Answer :: Yes ,
32573258 ) ;
32583259
32593260 // If the normalized check unexpectedly passes, fall back to root obligation for reporting.
@@ -3274,7 +3275,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
32743275 trait_pred : ty:: PolyTraitClause < ' tcx > ,
32753276 span : Span ,
32763277 ) -> GetSafeTransmuteErrorAndReason {
3277- use rustc_transmute:: Answer ;
32783278 self . probe ( |_| {
32793279 // We don't assemble a transmutability candidate for types that are generic
32803280 // and we should have ambiguity for types that still have non-region infer.
@@ -3311,69 +3311,61 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
33113311 {
33123312 Answer :: No ( reason) => {
33133313 let safe_transmute_explanation = match reason {
3314- rustc_transmute :: Reason :: SrcIsNotYetSupported => {
3314+ Reason :: SrcIsNotYetSupported => {
33153315 format ! ( "analyzing the transmutability of `{src}` is not yet supported" )
33163316 }
3317- rustc_transmute :: Reason :: DstIsNotYetSupported => {
3317+ Reason :: DstIsNotYetSupported => {
33183318 format ! ( "analyzing the transmutability of `{dst}` is not yet supported" )
33193319 }
3320- rustc_transmute :: Reason :: DstIsBitIncompatible => {
3320+ Reason :: DstIsBitIncompatible => {
33213321 format ! (
33223322 "at least one value of `{src}` isn't a bit-valid value of `{dst}`"
33233323 )
33243324 }
3325- rustc_transmute :: Reason :: DstUninhabited => {
3325+ Reason :: DstUninhabited => {
33263326 format ! ( "`{dst}` is uninhabited" )
33273327 }
3328- rustc_transmute :: Reason :: DstMayHaveSafetyInvariants => {
3328+ Reason :: DstMayHaveSafetyInvariants => {
33293329 format ! ( "`{dst}` may carry safety invariants" )
33303330 }
3331- rustc_transmute :: Reason :: DstIsTooBig => {
3331+ Reason :: DstIsTooBig => {
33323332 format ! ( "the size of `{src}` is smaller than the size of `{dst}`" )
33333333 }
3334- rustc_transmute:: Reason :: DstRefIsTooBig {
3335- src,
3336- src_size,
3337- dst,
3338- dst_size,
3339- } => {
3334+ Reason :: DstRefIsTooBig { src, src_size, dst, dst_size } => {
33403335 format ! (
33413336 "the size of `{src}` ({src_size} bytes) \
33423337 is smaller than that of `{dst}` ({dst_size} bytes)"
33433338 )
33443339 }
3345- rustc_transmute :: Reason :: SrcSizeOverflow => {
3340+ Reason :: SrcSizeOverflow => {
33463341 format ! (
33473342 "values of the type `{src}` are too big for the target architecture"
33483343 )
33493344 }
3350- rustc_transmute :: Reason :: DstSizeOverflow => {
3345+ Reason :: DstSizeOverflow => {
33513346 format ! (
33523347 "values of the type `{dst}` are too big for the target architecture"
33533348 )
33543349 }
3355- rustc_transmute:: Reason :: DstHasStricterAlignment {
3356- src_min_align,
3357- dst_min_align,
3358- } => {
3350+ Reason :: DstHasStricterAlignment { src_min_align, dst_min_align } => {
33593351 format ! (
33603352 "the minimum alignment of `{src}` ({src_min_align}) should be \
33613353 greater than that of `{dst}` ({dst_min_align})"
33623354 )
33633355 }
3364- rustc_transmute :: Reason :: DstIsMoreUnique => {
3356+ Reason :: DstIsMoreUnique => {
33653357 format ! (
33663358 "`{src}` is a shared reference, but `{dst}` is a unique reference"
33673359 )
33683360 }
33693361 // Already reported by rustc
3370- rustc_transmute :: Reason :: TypeError => {
3362+ Reason :: TypeError => {
33713363 return GetSafeTransmuteErrorAndReason :: Silent ;
33723364 }
3373- rustc_transmute :: Reason :: SrcLayoutUnknown => {
3365+ Reason :: SrcLayoutUnknown => {
33743366 format ! ( "`{src}` has an unknown layout" )
33753367 }
3376- rustc_transmute :: Reason :: DstLayoutUnknown => {
3368+ Reason :: DstLayoutUnknown => {
33773369 format ! ( "`{dst}` has an unknown layout" )
33783370 }
33793371 } ;
0 commit comments