diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs index a6688b668aab3..dcbe3f74c733e 100644 --- a/compiler/rustc_middle/src/ty/context/impl_interner.rs +++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs @@ -819,6 +819,7 @@ bidirectional_lang_item_map! { FnMut, FnOnce, FnPtrTrait, + Freeze, FusedIterator, Future, Iterator, diff --git a/compiler/rustc_next_trait_solver/src/delegate.rs b/compiler/rustc_next_trait_solver/src/delegate.rs index 24e321fc68c67..630e1dd68e041 100644 --- a/compiler/rustc_next_trait_solver/src/delegate.rs +++ b/compiler/rustc_next_trait_solver/src/delegate.rs @@ -2,10 +2,13 @@ use std::fmt::Debug; use std::ops::Deref; use rustc_type_ir::solve::{ - Certainty, ComputeGoalFastPathOutcome, FetchEligibleAssocItemResponse, Goal, NoSolution, + ComputeGoalFastPathOutcome, FetchEligibleAssocItemResponse, Goal, NoSolution, VisibleForLeakCheck, }; -use rustc_type_ir::{self as ty, CanonicalizerState, Const, InferCtxtLike, Interner, TypeFoldable}; +use rustc_type_ir::transmute::Answer; +use rustc_type_ir::{ + self as ty, CanonicalizerState, Const, InferCtxtLike, Interner, Region, TypeFoldable, +}; /// `SolverDelegate` is one of the two traits in the `rustc_type_ir` shared abstraction layer /// between rustc and rust-analyzer abstracting over the [InferCtxt][inferctxt-doc], which had to be @@ -113,7 +116,7 @@ pub trait SolverDelegate: Deref + Sized { src: ::Ty, dst: ::Ty, assume: Const, - ) -> Result; + ) -> Result, ::Ty>, NoSolution>; /// Obtain canonicalizer state, either by allocating it afresh (the default) or by reusing /// previously allocated state. diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index f97bc0bbeb626..3b372876f574b 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -16,6 +16,7 @@ use rustc_type_ir::solve::{ NoSolutionOrRerunNonErased, OpaqueTypesJank, QueryResultOrRerunNonErased, RerunCondition, RerunNonErased, RerunReason, RerunResultExt, SmallCopySet, TyOrConstInferVar, }; +use rustc_type_ir::transmute::Answer; use rustc_type_ir::{ self as ty, ClauseKind, Const, InferCtxtLike, Interner, MayBeErased, OpaqueTypeKey, PredicateKind, PredicateProxy, Region, RegionVid, TypeFoldable, TypeSuperVisitable, @@ -1565,7 +1566,7 @@ where src: I::Ty, dst: I::Ty, assume: Const, - ) -> Result { + ) -> Result, I::Ty>, NoSolution> { self.delegate.is_transmutable(dst, src, assume) } diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index 9ed4963577458..c9da77eced6d3 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -22,8 +22,11 @@ mod trait_goals; use derive_where::derive_where; use rustc_type_ir::inherent::*; +use rustc_type_ir::lang_items::SolverTraitLangItem; pub use rustc_type_ir::solve::*; -use rustc_type_ir::{self as ty, Const, Interner, Region, TypeVisitableExt}; +use rustc_type_ir::transmute::Condition; +use rustc_type_ir::{self as ty, Const, Interner, Region, TraitClause, TypeVisitableExt, Upcast}; +use thin_vec::{ThinVec, thin_vec}; use tracing::instrument; pub use self::eval_ctxt::{ @@ -491,3 +494,42 @@ pub struct GoalEvaluation { /// before rerunning it. pub stalled_on: Option>, } + +/// Flatten the `Condition` tree into a conjunction of predicates. +#[instrument(level = "debug", skip(interner, predicate))] +pub fn flatten_answer_tree( + interner: I, + predicate: TraitClause, + cond: Condition, I::Ty>, +) -> ThinVec { + match cond { + // FIXME(bryangarza): Add separate `IfAny` case, instead of treating as `IfAll` + // Not possible until the trait solver supports disjunctions of obligations + Condition::IfAll(conds) | Condition::IfAny(conds) => conds + .into_iter() + .flat_map(|cond| flatten_answer_tree(interner, predicate, cond)) + .collect(), + Condition::Immutable { ty } => { + let trait_ref = ty::TraitRef::new( + interner, + interner.require_trait_lang_item(SolverTraitLangItem::Freeze), + [I::GenericArg::from(ty)], + ); + thin_vec![trait_ref.upcast(interner)] + } + Condition::Outlives { long, short } => { + let outlives = ty::OutlivesClause(long, short); + thin_vec![outlives.upcast(interner)] + } + Condition::Transmutable { src, dst } => { + let transmute_trait = predicate.def_id(); + let assume = predicate.trait_ref.args.const_at(2); + let trait_ref = ty::TraitRef::new( + interner, + transmute_trait, + [I::GenericArg::from(dst), I::GenericArg::from(src), I::GenericArg::from(assume)], + ); + thin_vec![trait_ref.upcast(interner)] + } + } +} diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 31c0f72af8a28..ffa06f38a66c5 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -24,7 +24,7 @@ use crate::solve::assembly::{ use crate::solve::inspect::ProbeKind; use crate::solve::{ BuiltinImplSource, CandidateSource, Certainty, EvalCtxt, Goal, GoalSource, MaybeCause, - MergeCandidateInfo, NoSolution, ParamEnvSource, StalledOnCoroutines, + MergeCandidateInfo, NoSolution, ParamEnvSource, StalledOnCoroutines, flatten_answer_tree, has_only_region_constraints, }; @@ -656,6 +656,8 @@ where ecx: &mut EvalCtxt<'_, D>, goal: Goal, ) -> Result, NoSolutionOrRerunNonErased> { + use rustc_type_ir::transmute::Answer; + if goal.predicate.polarity != ty::ClausePolarity::Positive { return Err(NoSolution.into()); } @@ -678,11 +680,28 @@ where goal.predicate.trait_ref.args.const_at(2), )?; - let certainty = ecx.is_transmutable( + let answer = ecx.is_transmutable( goal.predicate.trait_ref.args.type_at(0), goal.predicate.trait_ref.args.type_at(1), assume, )?; + + let certainty = match answer { + Answer::No(_) => return Err(NoSolution.into()), + Answer::Yes => Certainty::Yes, + Answer::If(cond) => { + let tcx = ecx.cx(); + ecx.add_goals( + GoalSource::Misc, + flatten_answer_tree(tcx, goal.predicate, cond) + .into_iter() + .map(|predicate| Goal::new(tcx, goal.param_env, predicate)), + )?; + + Certainty::Yes + } + }; + ecx.evaluate_added_goals_and_make_canonical_response(certainty) }, ) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 47d1f1b22c090..4a1b674155795 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -31,6 +31,7 @@ use rustc_middle::ty::print::{ PrintPolyTraitClauseExt, PrintPolyTraitRefExt as _, PrintTraitClauseExt as _, PrintTraitRefExt as _, with_forced_trimmed_paths, }; +use rustc_middle::ty::transmute::{Answer, Reason}; use rustc_middle::ty::{ self, GenericArgKind, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, Unnormalized, Upcast, @@ -3253,7 +3254,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { trait_ref.args.type_at(0), assume, ), - rustc_transmute::Answer::Yes, + Answer::Yes, ); // If the normalized check unexpectedly passes, fall back to root obligation for reporting. @@ -3274,7 +3275,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { trait_pred: ty::PolyTraitClause<'tcx>, span: Span, ) -> GetSafeTransmuteErrorAndReason { - use rustc_transmute::Answer; self.probe(|_| { // We don't assemble a transmutability candidate for types that are generic // and we should have ambiguity for types that still have non-region infer. @@ -3311,69 +3311,61 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { { Answer::No(reason) => { let safe_transmute_explanation = match reason { - rustc_transmute::Reason::SrcIsNotYetSupported => { + Reason::SrcIsNotYetSupported => { format!("analyzing the transmutability of `{src}` is not yet supported") } - rustc_transmute::Reason::DstIsNotYetSupported => { + Reason::DstIsNotYetSupported => { format!("analyzing the transmutability of `{dst}` is not yet supported") } - rustc_transmute::Reason::DstIsBitIncompatible => { + Reason::DstIsBitIncompatible => { format!( "at least one value of `{src}` isn't a bit-valid value of `{dst}`" ) } - rustc_transmute::Reason::DstUninhabited => { + Reason::DstUninhabited => { format!("`{dst}` is uninhabited") } - rustc_transmute::Reason::DstMayHaveSafetyInvariants => { + Reason::DstMayHaveSafetyInvariants => { format!("`{dst}` may carry safety invariants") } - rustc_transmute::Reason::DstIsTooBig => { + Reason::DstIsTooBig => { format!("the size of `{src}` is smaller than the size of `{dst}`") } - rustc_transmute::Reason::DstRefIsTooBig { - src, - src_size, - dst, - dst_size, - } => { + Reason::DstRefIsTooBig { src, src_size, dst, dst_size } => { format!( "the size of `{src}` ({src_size} bytes) \ is smaller than that of `{dst}` ({dst_size} bytes)" ) } - rustc_transmute::Reason::SrcSizeOverflow => { + Reason::SrcSizeOverflow => { format!( "values of the type `{src}` are too big for the target architecture" ) } - rustc_transmute::Reason::DstSizeOverflow => { + Reason::DstSizeOverflow => { format!( "values of the type `{dst}` are too big for the target architecture" ) } - rustc_transmute::Reason::DstHasStricterAlignment { - src_min_align, - dst_min_align, - } => { + Reason::DstHasStricterAlignment { src_min_align, dst_min_align } => { format!( "the minimum alignment of `{src}` ({src_min_align}) should be \ greater than that of `{dst}` ({dst_min_align})" ) } - rustc_transmute::Reason::DstIsMoreUnique => { + Reason::DstIsMoreUnique => { format!( "`{src}` is a shared reference, but `{dst}` is a unique reference" ) } // Already reported by rustc - rustc_transmute::Reason::TypeError => { + Reason::TypeError => { return GetSafeTransmuteErrorAndReason::Silent; } - rustc_transmute::Reason::SrcLayoutUnknown => { + Reason::SrcLayoutUnknown => { format!("`{src}` has an unknown layout") } - rustc_transmute::Reason::DstLayoutUnknown => { + Reason::DstLayoutUnknown => { format!("`{dst}` has an unknown layout") } }; diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs index 3e0796bd1f585..2335868a17b40 100644 --- a/compiler/rustc_trait_selection/src/solve/delegate.rs +++ b/compiler/rustc_trait_selection/src/solve/delegate.rs @@ -19,15 +19,17 @@ use rustc_infer::traits::solve::{ }; use rustc_lint_defs::builtin::RECURSION_DEPTH_EXCEEDING_LIMIT; use rustc_middle::traits::query::NoSolution; -use rustc_middle::traits::solve::{Certainty, MaybeInfo}; +use rustc_middle::traits::solve::MaybeInfo; use rustc_middle::ty::print::{FmtPrinter, Print}; +use rustc_middle::ty::transmute::Answer; use rustc_middle::ty::{ - self, CanonicalizerState, MayBeErased, Ty, TyCtxt, TypeFlags, TypeFoldable, TypeSuperVisitable, - TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, + self, CanonicalizerState, MayBeErased, Region, Ty, TyCtxt, TypeFlags, TypeFoldable, + TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, }; use rustc_next_trait_solver::solve::{GoalStalledOn, GoalStalledOnOpaques, TyOrConstInferVar}; use rustc_span::{DUMMY_SP, Span}; use rustc_structures::Limit; +use rustc_transmute::TransmuteTypeEnv; use thin_vec::{ThinVec, thin_vec}; use super::inspect::InferCtxtProofTreeExt; @@ -491,20 +493,14 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< src: Ty<'tcx>, dst: Ty<'tcx>, assume: ty::Const<'tcx>, - ) -> Result { + ) -> Result, Ty<'tcx>>, NoSolution> { // Erase regions because we compute layouts in `rustc_transmute`, // which will ICE for region vars. let (dst, src) = self.tcx.erase_and_anonymize_regions((dst, src)); - let Some(assume) = rustc_transmute::Assume::from_const(self.tcx, assume) else { - return Err(NoSolution); - }; - - // FIXME(transmutability): This really should be returning nested goals for `Answer::If*` - match rustc_transmute::TransmuteTypeEnv::new(self.0.tcx).is_transmutable(src, dst, assume) { - rustc_transmute::Answer::Yes => Ok(Certainty::Yes), - rustc_transmute::Answer::No(_) | rustc_transmute::Answer::If(_) => Err(NoSolution), - } + rustc_transmute::Assume::from_const(self.tcx, assume) + .map(|assume| TransmuteTypeEnv::new(self.0.tcx).is_transmutable(src, dst, assume)) + .ok_or(NoSolution) } fn obtain_canonicalizer_state(&self) -> CanonicalizerState { diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 81517955181ee..6d5cddde61076 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -13,9 +13,8 @@ use rustc_attr_ir::lang_items::LangItem; use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk}; use rustc_infer::traits::ObligationCauseCode; use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData}; -use rustc_middle::ty::{ - self, GenericArgsRef, Region, SizedTraitKind, Ty, TyCtxt, Unnormalized, Upcast, -}; +use rustc_middle::ty::{self, GenericArgsRef, SizedTraitKind, Ty, Unnormalized, Upcast}; +use rustc_next_trait_solver::solve::flatten_answer_tree; use rustc_span::def_id::DefId; use rustc_span::{bug, span_bug}; use thin_vec::thin_vec; @@ -285,69 +284,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { &mut self, obligation: &PolyTraitObligation<'tcx>, ) -> Result, SelectionError<'tcx>> { - use rustc_transmute::{Answer, Assume, Condition}; - - /// Flatten the `Condition` tree into a conjunction of obligations. - #[instrument(level = "debug", skip(tcx, obligation))] - fn flatten_answer_tree<'tcx>( - tcx: TyCtxt<'tcx>, - obligation: &PolyTraitObligation<'tcx>, - cond: Condition, Ty<'tcx>>, - assume: Assume, - ) -> PredicateObligations<'tcx> { - match cond { - // FIXME(bryangarza): Add separate `IfAny` case, instead of treating as `IfAll` - // Not possible until the trait solver supports disjunctions of obligations - Condition::IfAll(conds) | Condition::IfAny(conds) => conds - .into_iter() - .flat_map(|cond| flatten_answer_tree(tcx, obligation, cond, assume)) - .collect(), - Condition::Immutable { ty } => { - let trait_ref = ty::TraitRef::new( - tcx, - tcx.require_lang_item(LangItem::Freeze, obligation.cause.span), - [ty::GenericArg::from(ty)], - ); - thin_vec![Obligation::with_depth( - tcx, - obligation.cause.clone(), - obligation.recursion_depth + 1, - obligation.param_env, - trait_ref, - )] - } - Condition::Outlives { long, short } => { - let outlives = ty::OutlivesClause(long, short); - thin_vec![Obligation::with_depth( - tcx, - obligation.cause.clone(), - obligation.recursion_depth + 1, - obligation.param_env, - outlives, - )] - } - Condition::Transmutable { src, dst } => { - let transmute_trait = obligation.predicate.def_id(); - let assume = obligation.predicate.skip_binder().trait_ref.args.const_at(2); - let trait_ref = ty::TraitRef::new( - tcx, - transmute_trait, - [ - ty::GenericArg::from(dst), - ty::GenericArg::from(src), - ty::GenericArg::from(assume), - ], - ); - thin_vec![Obligation::with_depth( - tcx, - obligation.cause.clone(), - obligation.recursion_depth + 1, - obligation.param_env, - trait_ref, - )] - } - } - } + use rustc_middle::ty::transmute::Answer; let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate); @@ -367,9 +304,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume); let fully_flattened = match maybe_transmutable { - Answer::No(_) => Err(SelectionError::Unimplemented)?, - Answer::If(cond) => flatten_answer_tree(self.tcx(), obligation, cond, assume), + Answer::No(_) => return Err(SelectionError::Unimplemented), Answer::Yes => PredicateObligations::new(), + Answer::If(cond) => { + flatten_answer_tree(self.tcx(), obligation.predicate.skip_binder(), cond) + .into_iter() + .map(|predicate| { + Obligation::new( + self.infcx.tcx, + obligation.cause.clone(), + obligation.param_env, + predicate, + ) + }) + .collect() + } }; debug!(?fully_flattened); diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index a7b07529f0bd1..c0ffc8babc723 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -3,8 +3,8 @@ //! The analysis converts compiler layouts into trees of bytes, references, and //! definition markers. It prunes destination paths that may carry safety invariants unless //! safety is assumed, then converts the trees into deterministic finite automata. -//! Comparing the automata produces an [`Answer`]; reference transitions can leave -//! [`Condition`]s for the trait solver to discharge. +//! Comparing the automata produces an [`rustc_middle::ty::transmute::Answer`]; reference transitions can leave +//! [`rustc_middle::ty::transmute::Condition`]s for the trait solver to discharge. // tidy-alphabetical-start #![cfg_attr(test, feature(test))] @@ -28,82 +28,11 @@ pub struct Assume { pub validity: bool, } -/// The result of a transmutability query under the supplied [`Assume`] options. -#[derive(Debug, Hash, Eq, PartialEq, Clone)] -pub enum Answer { - /// The analysis requires no further conditions. - Yes, - /// The analysis could not establish transmutability. - No(Reason), - /// Transmutability depends on conditions that the trait solver must discharge. - If(Condition), -} - -/// A condition which must hold for safe transmutation to be possible. -#[derive(Debug, Hash, Eq, PartialEq, Clone)] -pub enum Condition { - /// `Src` is transmutable into `Dst`, if `src` is transmutable into `dst`. - Transmutable { src: T, dst: T }, - - /// The region `long` must outlive `short`. - Outlives { long: R, short: R }, - - /// The type `ty` must satisfy `Freeze`. - Immutable { ty: T }, - - /// `Src` is transmutable into `Dst`, if all of the enclosed requirements are met. - IfAll(Vec>), - - /// `Src` is transmutable into `Dst` if any of the enclosed requirements are met. - IfAny(Vec>), -} - -/// Answers "why wasn't the source type transmutable into the destination type?" -#[derive(Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Clone)] -pub enum Reason { - /// The layout of the source type is not yet supported. - SrcIsNotYetSupported, - /// The layout of the destination type is not yet supported. - DstIsNotYetSupported, - /// The layout of the destination type is bit-incompatible with the source type. - DstIsBitIncompatible, - /// The destination type is uninhabited. - DstUninhabited, - /// The destination type may carry safety invariants. - DstMayHaveSafetyInvariants, - /// `Dst` is larger than `Src`, and the excess bytes were not exclusively uninitialized. - DstIsTooBig, - /// The destination referent is larger than the source referent. - DstRefIsTooBig { - /// The referent of the source type. - src: T, - /// The size of the source type's referent. - src_size: usize, - /// The too-large referent of the destination type. - dst: T, - /// The size of the destination type's referent. - dst_size: usize, - }, - /// The destination referent requires stricter alignment than the source referent. - DstHasStricterAlignment { src_min_align: usize, dst_min_align: usize }, - /// Can't go from shared pointer to unique pointer - DstIsMoreUnique, - /// Encountered a type error - TypeError, - /// The layout of src is unknown - SrcLayoutUnknown, - /// The layout of dst is unknown - DstLayoutUnknown, - /// The size of src is overflow - SrcSizeOverflow, - /// The size of dst is overflow - DstSizeOverflow, -} - #[cfg(feature = "rustc")] mod rustc { use rustc_attr_ir::lang_items::LangItem; use rustc_middle::ty::consts::ConstExt; + use rustc_middle::ty::transmute::Answer; use rustc_middle::ty::{Const, Region, Ty, TyCtxt}; use super::*; @@ -122,7 +51,7 @@ mod rustc { src: Ty<'tcx>, dst: Ty<'tcx>, assume: crate::Assume, - ) -> crate::Answer, Ty<'tcx>> { + ) -> Answer, Ty<'tcx>> { crate::maybe_transmutable::MaybeTransmutableQuery::new(src, dst, assume, self.tcx) .answer() } diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index e9351d4081b6e..be4b1a882d966 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -4,9 +4,11 @@ pub(crate) mod query_context; #[cfg(test)] mod tests; +use rustc_middle::ty::transmute::{Answer, Condition, Reason}; + +use crate::Map; use crate::layout::{self, Def, Dfa, Reference, Tree, dfa, union}; use crate::maybe_transmutable::query_context::QueryContext; -use crate::{Answer, Condition, Map, Reason}; pub(crate) struct MaybeTransmutableQuery where @@ -299,67 +301,6 @@ where } } -impl Answer { - /// Requires both answers, combining their conditions into a conjunction. - fn and(self, rhs: Answer) -> Answer { - let lhs = self; - match (lhs, rhs) { - // Prefer a specific reason over generic bit incompatibility; - // otherwise, retain the left-hand reason. - (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason)) - | (Answer::No(reason), Answer::No(_)) - // If either is an error, return it - | (Answer::No(reason), _) | (_, Answer::No(reason)) => Answer::No(reason), - // If only one side has a condition, pass it along - (Answer::Yes, other) | (other, Answer::Yes) => other, - // If both sides have IfAll conditions, merge them - (Answer::If(Condition::IfAll(mut lhs)), Answer::If(Condition::IfAll(ref mut rhs))) => { - lhs.append(rhs); - Answer::If(Condition::IfAll(lhs)) - } - // If only one side is an IfAll, add the other Condition to it - (Answer::If(cond), Answer::If(Condition::IfAll(mut conds))) - | (Answer::If(Condition::IfAll(mut conds)), Answer::If(cond)) => { - conds.push(cond); - Answer::If(Condition::IfAll(conds)) - } - // Otherwise, both lhs and rhs conditions can be combined in a parent IfAll - (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAll(vec![lhs, rhs])), - } - } - - /// Combines alternative answers and collects their conditions in an `IfAny`. - /// - /// Currently, combining `Yes` with `If` retains the condition. This differs - /// from Boolean disjunction, where unconditional success would suffice. - fn or(self, rhs: Answer) -> Answer { - let lhs = self; - match (lhs, rhs) { - // Prefer a specific reason over generic bit incompatibility; - // otherwise, retain the left-hand reason. - (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason)) - | (Answer::No(reason), Answer::No(_)) => Answer::No(reason), - // Otherwise, errors can be ignored for the rest of the pattern matching - (Answer::No(_), other) | (other, Answer::No(_)) => other.or(Answer::Yes), - // If only one side has a condition, pass it along - (Answer::Yes, other) | (other, Answer::Yes) => other, - // If both sides have IfAny conditions, merge them - (Answer::If(Condition::IfAny(mut lhs)), Answer::If(Condition::IfAny(ref mut rhs))) => { - lhs.append(rhs); - Answer::If(Condition::IfAny(lhs)) - } - // If only one side is an IfAny, add the other Condition to it - (Answer::If(cond), Answer::If(Condition::IfAny(mut conds))) - | (Answer::If(Condition::IfAny(mut conds)), Answer::If(cond)) => { - conds.push(cond); - Answer::If(Condition::IfAny(conds)) - } - // Otherwise, both lhs and rhs conditions can be combined in a parent IfAny - (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAny(vec![lhs, rhs])), - } - } -} - enum Quantifier { ThereExists, ForAll, diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs index 371a362c09ff3..56d31cb83f57f 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs @@ -1,9 +1,10 @@ extern crate test; use itertools::Itertools; +use rustc_middle::ty::transmute::{Answer, Condition, Reason}; use super::query_context::test::{Def, UltraMinimal}; -use crate::{Answer, Assume, Condition, Reason, layout}; +use crate::{Assume, layout}; type Tree = layout::Tree; type Dfa = layout::Dfa; @@ -36,21 +37,18 @@ impl Representation for Dfa { } } -fn is_transmutable( - src: &R, - dst: &R, - assume: Assume, -) -> crate::Answer { +fn is_transmutable(src: &R, dst: &R, assume: Assume) -> Answer { let src = src.clone(); let dst = dst.clone(); R::is_transmutable(src, dst, assume) } mod answers { + use rustc_middle::ty::transmute::{Condition, Reason}; + use crate::maybe_transmutable::Quantifier; - use crate::{Condition, Reason}; - type Answer = crate::Answer; + type Answer = rustc_middle::ty::transmute::Answer; const OUTLIVES: Condition = Condition::Outlives { long: 1, short: 0 }; const IMMUTABLE: Condition = Condition::Immutable { ty: () }; @@ -141,11 +139,11 @@ mod answers { } mod safety { + use rustc_middle::ty::transmute::{Answer, Reason}; + use super::*; - use crate::Answer; - const DST_HAS_SAFETY_INVARIANTS: Answer = - Answer::No(crate::Reason::DstMayHaveSafetyInvariants); + const DST_HAS_SAFETY_INVARIANTS: Answer = Answer::No(Reason::DstMayHaveSafetyInvariants); #[test] fn src_safe_dst_safe() { @@ -354,7 +352,6 @@ mod uninit { mod alt { use super::*; - use crate::Answer; #[test] fn should_permit_identity_transmutation() { @@ -445,7 +442,6 @@ mod char { mod nonzero { use super::*; - use crate::{Answer, Reason}; const NONZERO_BYTE_WIDTHS: [u64; 5] = [1, 2, 4, 8, 16]; diff --git a/compiler/rustc_type_ir/src/lang_items.rs b/compiler/rustc_type_ir/src/lang_items.rs index 0bc901e07ea96..246d6241ec8ba 100644 --- a/compiler/rustc_type_ir/src/lang_items.rs +++ b/compiler/rustc_type_ir/src/lang_items.rs @@ -46,6 +46,7 @@ pub enum SolverTraitLangItem { FnMut, FnOnce, FnPtrTrait, + Freeze, FusedIterator, Future, Iterator, diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 0be6a2c4152dc..eab69fa224d92 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -61,6 +61,7 @@ pub mod relate; pub mod search_graph; pub mod solve; pub mod sty; +pub mod transmute; pub mod walk; // These modules are not `pub` since they are glob-imported. diff --git a/compiler/rustc_type_ir/src/transmute.rs b/compiler/rustc_type_ir/src/transmute.rs new file mode 100644 index 0000000000000..f74bd3b954d1a --- /dev/null +++ b/compiler/rustc_type_ir/src/transmute.rs @@ -0,0 +1,132 @@ +/// The result of a transmutability query under the supplied `Assume` options. +#[derive(Debug, Hash, Eq, PartialEq, Clone)] +pub enum Answer { + /// The analysis requires no further conditions. + Yes, + /// The analysis could not establish transmutability. + No(Reason), + /// Transmutability depends on conditions that the trait solver must discharge. + If(Condition), +} + +/// A condition which must hold for safe transmutation to be possible. +#[derive(Debug, Hash, Eq, PartialEq, Clone)] +pub enum Condition { + /// `Src` is transmutable into `Dst`, if `src` is transmutable into `dst`. + Transmutable { src: T, dst: T }, + + /// The region `long` must outlive `short`. + Outlives { long: R, short: R }, + + /// The type `ty` must satisfy `Freeze`. + Immutable { ty: T }, + + /// `Src` is transmutable into `Dst`, if all of the enclosed requirements are met. + IfAll(Vec>), + + /// `Src` is transmutable into `Dst` if any of the enclosed requirements are met. + IfAny(Vec>), +} + +/// Answers "why wasn't the source type transmutable into the destination type?" +#[derive(Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Clone)] +pub enum Reason { + /// The layout of the source type is not yet supported. + SrcIsNotYetSupported, + /// The layout of the destination type is not yet supported. + DstIsNotYetSupported, + /// The layout of the destination type is bit-incompatible with the source type. + DstIsBitIncompatible, + /// The destination type is uninhabited. + DstUninhabited, + /// The destination type may carry safety invariants. + DstMayHaveSafetyInvariants, + /// `Dst` is larger than `Src`, and the excess bytes were not exclusively uninitialized. + DstIsTooBig, + /// The destination referent is larger than the source referent. + DstRefIsTooBig { + /// The referent of the source type. + src: T, + /// The size of the source type's referent. + src_size: usize, + /// The too-large referent of the destination type. + dst: T, + /// The size of the destination type's referent. + dst_size: usize, + }, + /// The destination referent requires stricter alignment than the source referent. + DstHasStricterAlignment { src_min_align: usize, dst_min_align: usize }, + /// Can't go from shared pointer to unique pointer + DstIsMoreUnique, + /// Encountered a type error + TypeError, + /// The layout of src is unknown + SrcLayoutUnknown, + /// The layout of dst is unknown + DstLayoutUnknown, + /// The size of src is overflow + SrcSizeOverflow, + /// The size of dst is overflow + DstSizeOverflow, +} + +impl Answer { + /// Requires both answers, combining their conditions into a conjunction. + pub fn and(self, rhs: Answer) -> Answer { + let lhs = self; + match (lhs, rhs) { + // Prefer a specific reason over generic bit incompatibility; + // otherwise, retain the left-hand reason. + (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason)) + | (Answer::No(reason), Answer::No(_)) + // If either is an error, return it + | (Answer::No(reason), _) | (_, Answer::No(reason)) => Answer::No(reason), + // If only one side has a condition, pass it along + (Answer::Yes, other) | (other, Answer::Yes) => other, + // If both sides have IfAll conditions, merge them + (Answer::If(Condition::IfAll(mut lhs)), Answer::If(Condition::IfAll(ref mut rhs))) => { + lhs.append(rhs); + Answer::If(Condition::IfAll(lhs)) + } + // If only one side is an IfAll, add the other Condition to it + (Answer::If(cond), Answer::If(Condition::IfAll(mut conds))) + | (Answer::If(Condition::IfAll(mut conds)), Answer::If(cond)) => { + conds.push(cond); + Answer::If(Condition::IfAll(conds)) + } + // Otherwise, both lhs and rhs conditions can be combined in a parent IfAll + (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAll(vec![lhs, rhs])), + } + } + + /// Combines alternative answers and collects their conditions in an `IfAny`. + /// + /// Currently, combining `Yes` with `If` retains the condition. This differs + /// from Boolean disjunction, where unconditional success would suffice. + pub fn or(self, rhs: Answer) -> Answer { + let lhs = self; + match (lhs, rhs) { + // Prefer a specific reason over generic bit incompatibility; + // otherwise, retain the left-hand reason. + (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason)) + | (Answer::No(reason), Answer::No(_)) => Answer::No(reason), + // Otherwise, errors can be ignored for the rest of the pattern matching + (Answer::No(_), other) | (other, Answer::No(_)) => other.or(Answer::Yes), + // If only one side has a condition, pass it along + (Answer::Yes, other) | (other, Answer::Yes) => other, + // If both sides have IfAny conditions, merge them + (Answer::If(Condition::IfAny(mut lhs)), Answer::If(Condition::IfAny(ref mut rhs))) => { + lhs.append(rhs); + Answer::If(Condition::IfAny(lhs)) + } + // If only one side is an IfAny, add the other Condition to it + (Answer::If(cond), Answer::If(Condition::IfAny(mut conds))) + | (Answer::If(Condition::IfAny(mut conds)), Answer::If(cond)) => { + conds.push(cond); + Answer::If(Condition::IfAny(conds)) + } + // Otherwise, both lhs and rhs conditions can be combined in a parent IfAny + (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAny(vec![lhs, rhs])), + } + } +} diff --git a/tests/ui/transmutability/alignment/align-pass.next.stderr b/tests/ui/transmutability/alignment/align-pass.next.stderr deleted file mode 100644 index 2095e97cc3915..0000000000000 --- a/tests/ui/transmutability/alignment/align-pass.next.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: `&[u16; 0]` cannot be safely transmuted into `&[u8; 0]` - --> $DIR/align-pass.rs:25:56 - | -LL | assert::is_maybe_transmutable::<&'static [u16; 0], &'static [u8; 0]>(); - | ^^^^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&'static [u16; 0], Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `&'static [u8; 0]` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/align-pass.rs:13:14 - | -LL | pub fn is_maybe_transmutable() -LL | where -LL | Dst: TransmuteFrom - | |__________^ required by this bound in `is_maybe_transmutable` -help: consider removing the leading `&`-reference - | -LL - assert::is_maybe_transmutable::<&'static [u16; 0], &'static [u8; 0]>(); -LL + assert::is_maybe_transmutable::<&'static [u16; 0], [u8; 0]>(); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/alignment/align-pass.rs b/tests/ui/transmutability/alignment/align-pass.rs index fa40c3a3ade43..a87f1db089c16 100644 --- a/tests/ui/transmutability/alignment/align-pass.rs +++ b/tests/ui/transmutability/alignment/align-pass.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/references/accept_assume_lifetime_extension.next.stderr b/tests/ui/transmutability/references/accept_assume_lifetime_extension.next.stderr deleted file mode 100644 index 4c469fd2222e3..0000000000000 --- a/tests/ui/transmutability/references/accept_assume_lifetime_extension.next.stderr +++ /dev/null @@ -1,138 +0,0 @@ -error[E0277]: `&u8` cannot be safely transmuted into `&u8` - --> $DIR/accept_assume_lifetime_extension.rs:24:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `std::mem::TransmuteFrom<&u8, std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `&u8` -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `&&u8` cannot be safely transmuted into `&&u8` - --> $DIR/accept_assume_lifetime_extension.rs:32:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `std::mem::TransmuteFrom<&&u8, std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `&&u8` -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `(&u8,)` cannot be safely transmuted into `(&u8,)` - --> $DIR/accept_assume_lifetime_extension.rs:40:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `std::mem::TransmuteFrom<(&u8,), std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `(&u8,)` -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `(&u8, u8)` cannot be safely transmuted into `(&u8, u8)` - --> $DIR/accept_assume_lifetime_extension.rs:44:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `std::mem::TransmuteFrom<(&u8, u8), std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `(&u8, u8)` -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `r#struct::Struct<'_>` cannot be safely transmuted into `r#struct::Struct<'_>` - --> $DIR/accept_assume_lifetime_extension.rs:54:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | -help: the nightly-only, unstable trait `std::mem::TransmuteFrom, std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `r#struct::Struct<'_>` - --> $DIR/accept_assume_lifetime_extension.rs:51:5 - | -LL | struct Struct<'a>(&'a u8); - | ^^^^^^^^^^^^^^^^^ -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `Single<'_>` cannot be safely transmuted into `Single<'_>` - --> $DIR/accept_assume_lifetime_extension.rs:66:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | -help: the nightly-only, unstable trait `std::mem::TransmuteFrom, std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `Single<'_>` - --> $DIR/accept_assume_lifetime_extension.rs:61:5 - | -LL | enum Single<'a> { - | ^^^^^^^^^^^^^^^ -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `Multi<'_>` cannot be safely transmuted into `Multi<'_>` - --> $DIR/accept_assume_lifetime_extension.rs:76:18 - | -LL | unsafe { transmute(src) } - | ^^^^^^^^^^^^^^ unsatisfied trait bound - | -help: the nightly-only, unstable trait `std::mem::TransmuteFrom, std::mem::Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `Multi<'_>` - --> $DIR/accept_assume_lifetime_extension.rs:69:5 - | -LL | enum Multi<'a> { - | ^^^^^^^^^^^^^^ -note: required by a bound in `transmute` - --> $DIR/accept_assume_lifetime_extension.rs:15:10 - | -LL | unsafe fn transmute(src: Src) -> Dst -LL | where -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error[E0277]: `&u8` cannot be safely transmuted into `&u8` - --> $DIR/accept_assume_lifetime_extension.rs:84:18 - | -LL | unsafe { extend_hrtb(src) } - | ^^^^^^^^^^^^---^ - | | | - | | `&u8` doesn't satisfy the trait bound - | unsatisfied trait bound - | - = help: the nightly-only, unstable trait `for<'b> std::mem::TransmuteFrom<&u8, std::mem::Assume { alignment: false, lifetimes: true, safety: false, validity: false }>` is not implemented for `&'b u8` -note: required by a bound in `extend_hrtb` - --> $DIR/accept_assume_lifetime_extension.rs:89:25 - | -LL | unsafe fn extend_hrtb<'a>(src: &'a u8) -> &'static u8 -LL | where -LL | for<'b> &'b u8: TransmuteFrom<&'a u8, { Assume::LIFETIMES }>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `extend_hrtb` - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/accept_assume_lifetime_extension.rs b/tests/ui/transmutability/references/accept_assume_lifetime_extension.rs index 86feb3c40eb7d..fea6675d751c9 100644 --- a/tests/ui/transmutability/references/accept_assume_lifetime_extension.rs +++ b/tests/ui/transmutability/references/accept_assume_lifetime_extension.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass //! Accept lifetime extensions with `Assume::LIFETIMES`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.next.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.next.stderr deleted file mode 100644 index 32156298a1f6f..0000000000000 --- a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.next.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0277]: `&A` cannot be safely transmuted into `&B` - --> $DIR/recursive-wrapper-types-bit-compatible.rs:27:49 - | -LL | assert::is_maybe_transmutable::<&'static A, &'static B>(); - | ^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&'static A, Assume { alignment: true, lifetimes: false, safety: true, validity: false }>` is not implemented for `&'static B` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/recursive-wrapper-types-bit-compatible.rs:13:14 - | -LL | pub fn is_maybe_transmutable() -LL | where -LL | Dst: TransmuteFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs index f1bb503549968..e3fad55910e92 100644 --- a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/references/recursive-wrapper-types.next.stderr b/tests/ui/transmutability/references/recursive-wrapper-types.next.stderr deleted file mode 100644 index 8ea346d7c08b5..0000000000000 --- a/tests/ui/transmutability/references/recursive-wrapper-types.next.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0277]: `&A` cannot be safely transmuted into `&B` - --> $DIR/recursive-wrapper-types.rs:27:49 - | -LL | assert::is_maybe_transmutable::<&'static A, &'static B>(); - | ^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&'static A, Assume { alignment: true, lifetimes: false, safety: true, validity: false }>` is not implemented for `&'static B` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/recursive-wrapper-types.rs:13:14 - | -LL | pub fn is_maybe_transmutable() -LL | where -LL | Dst: TransmuteFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error[E0277]: `&B` cannot be safely transmuted into `&A` - --> $DIR/recursive-wrapper-types.rs:28:49 - | -LL | assert::is_maybe_transmutable::<&'static B, &'static A>(); - | ^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&'static B, Assume { alignment: true, lifetimes: false, safety: true, validity: false }>` is not implemented for `&'static A` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/recursive-wrapper-types.rs:13:14 - | -LL | pub fn is_maybe_transmutable() -LL | where -LL | Dst: TransmuteFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types.rs b/tests/ui/transmutability/references/recursive-wrapper-types.rs index 7ff458aa2512b..b1626d21e9731 100644 --- a/tests/ui/transmutability/references/recursive-wrapper-types.rs +++ b/tests/ui/transmutability/references/recursive-wrapper-types.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/references/u8-to-unit.next.stderr b/tests/ui/transmutability/references/u8-to-unit.next.stderr deleted file mode 100644 index 0897833202826..0000000000000 --- a/tests/ui/transmutability/references/u8-to-unit.next.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: `&u8` cannot be safely transmuted into `&Unit` - --> $DIR/u8-to-unit.rs:26:50 - | -LL | assert::is_maybe_transmutable::<&'static u8, &'static Unit>(); - | ^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&'static u8, Assume { alignment: false, lifetimes: true, safety: true, validity: false }>` is not implemented for `&'static Unit` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/u8-to-unit.rs:13:14 - | -LL | pub fn is_maybe_transmutable() -LL | where -LL | Dst: TransmuteFrom - | |__________^ required by this bound in `is_maybe_transmutable` -help: consider removing the leading `&`-reference - | -LL - assert::is_maybe_transmutable::<&'static u8, &'static Unit>(); -LL + assert::is_maybe_transmutable::<&'static u8, Unit>(); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/u8-to-unit.rs b/tests/ui/transmutability/references/u8-to-unit.rs index df124cafda3d6..09f1a5d64bb45 100644 --- a/tests/ui/transmutability/references/u8-to-unit.rs +++ b/tests/ui/transmutability/references/u8-to-unit.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/references/unit-to-itself.next.stderr b/tests/ui/transmutability/references/unit-to-itself.next.stderr deleted file mode 100644 index 4a15b3b3d5c30..0000000000000 --- a/tests/ui/transmutability/references/unit-to-itself.next.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` - --> $DIR/unit-to-itself.rs:26:52 - | -LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); - | ^^^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&'static Unit, Assume { alignment: true, lifetimes: false, safety: true, validity: false }>` is not implemented for `&'static Unit` -note: required by a bound in `is_maybe_transmutable` - --> $DIR/unit-to-itself.rs:13:14 - | -LL | pub fn is_maybe_transmutable() -LL | where -LL | Dst: TransmuteFrom - | |__________^ required by this bound in `is_maybe_transmutable` -help: consider removing the leading `&`-reference - | -LL - assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); -LL + assert::is_maybe_transmutable::<&'static Unit, Unit>(); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/unit-to-itself.rs b/tests/ui/transmutability/references/unit-to-itself.rs index 87d001222f96e..5e001432caec9 100644 --- a/tests/ui/transmutability/references/unit-to-itself.rs +++ b/tests/ui/transmutability/references/unit-to-itself.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.next.stderr b/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.next.stderr deleted file mode 100644 index 2cbaa71262cea..0000000000000 --- a/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.next.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `&mut Src` cannot be safely transmuted into `&mut u8` - --> $DIR/should_accept_if_ref_src_has_safety_invariant.rs:29:41 - | -LL | assert::is_transmutable::<&mut Src, &mut Dst>(); - | ^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `TransmuteFrom<&mut Src, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `&mut u8` -note: required by a bound in `is_transmutable` - --> $DIR/should_accept_if_ref_src_has_safety_invariant.rs:19:14 - | -LL | pub fn is_transmutable() -LL | where -LL | Dst: TransmuteFrom - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs b/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs index 32d70c3298eda..ed89ad3c3a679 100644 --- a/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs +++ b/tests/ui/transmutability/safety/assume/should_accept_if_ref_src_has_safety_invariant.rs @@ -1,8 +1,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass //! When safety is assumed, a transmutation over exclusive references should be //! accepted if the source type potentially carries safety invariants. diff --git a/tests/ui/transmutability/transmute-higher-ranked.next.stderr b/tests/ui/transmutability/transmute-higher-ranked.next.stderr deleted file mode 100644 index 9d86559f62bcc..0000000000000 --- a/tests/ui/transmutability/transmute-higher-ranked.next.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `&&u32` cannot be safely transmuted into `&&i32` - --> $DIR/transmute-higher-ranked.rs:21:5 - | -LL | transmute(); - | ^^^^^^^^^^^ unsatisfied trait bound - | - = help: the nightly-only, unstable trait `for<'a> TransmuteFrom<&'a &'a u32, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `&'a &'a i32` -note: required by a bound in `transmute` - --> $DIR/transmute-higher-ranked.rs:16:26 - | -LL | pub fn transmute() -LL | where -LL | for<'a> &'a &'a i32: TransmuteFrom<&'a &'a u32>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `transmute` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/transmute-higher-ranked.rs b/tests/ui/transmutability/transmute-higher-ranked.rs index fc0753942906a..43c417daa2637 100644 --- a/tests/ui/transmutability/transmute-higher-ranked.rs +++ b/tests/ui/transmutability/transmute-higher-ranked.rs @@ -4,8 +4,7 @@ //@ revisions: old next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] known-bug: trait-system-refactor-initiative#152 -//@[old] check-pass +//@ check-pass #![feature(transmutability)] diff --git a/tests/ui/transmutability/vec-recycle-next-solver.rs b/tests/ui/transmutability/vec-recycle-next-solver.rs new file mode 100644 index 0000000000000..ba68a31cea624 --- /dev/null +++ b/tests/ui/transmutability/vec-recycle-next-solver.rs @@ -0,0 +1,16 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver +//@ check-pass + +#![feature(vec_recycle, transmutability)] + +fn main() { + let a: Vec = vec![0; 100]; + let capacity = a.capacity(); + let addr = a.as_ptr().addr(); + let b: Vec = a.recycle(); + assert_eq!(b.len(), 0); + assert_eq!(b.capacity(), capacity); + assert_eq!(b.as_ptr().addr(), addr); +} diff --git a/tests/ui/transmutability/with-condition-nested-goals.current.stderr b/tests/ui/transmutability/with-condition-nested-goals.current.stderr new file mode 100644 index 0000000000000..27fbf8e92e811 --- /dev/null +++ b/tests/ui/transmutability/with-condition-nested-goals.current.stderr @@ -0,0 +1,11 @@ +error[E0277]: `i32` cannot be safely transmuted into `[NewType; 4]` + --> $DIR/with-condition-nested-goals.rs:16:74 + | +LL | let bytes: &[NewType; 4] = unsafe { TransmuteFrom::<&i32>::transmute(&1i32) }; + | -------------------------------- ^^^^^ `[NewType; 4]` may carry safety invariants + | | + | required by a bound introduced by this call + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/with-condition-nested-goals.next.stderr b/tests/ui/transmutability/with-condition-nested-goals.next.stderr new file mode 100644 index 0000000000000..dbb0747c3ff63 --- /dev/null +++ b/tests/ui/transmutability/with-condition-nested-goals.next.stderr @@ -0,0 +1,13 @@ +error[E0277]: `&i32` cannot be safely transmuted into `&[NewType; 4]` + --> $DIR/with-condition-nested-goals.rs:16:74 + | +LL | let bytes: &[NewType; 4] = unsafe { TransmuteFrom::<&i32>::transmute(&1i32) }; + | -------------------------------- ^^^^^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | + = help: the nightly-only, unstable trait `TransmuteFrom<&i32, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `&[NewType; 4]` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/with-condition-nested-goals.rs b/tests/ui/transmutability/with-condition-nested-goals.rs new file mode 100644 index 0000000000000..1561a0a20fe55 --- /dev/null +++ b/tests/ui/transmutability/with-condition-nested-goals.rs @@ -0,0 +1,19 @@ +//! This UI test ensures that transmutability check tests nested goals. +//! If the nested goals regarding the NewType implementing the trait +//! was not being tested, this transmute call would compile. +// +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver +//@ check-fail + +#![feature(transmutability)] +use std::mem::TransmuteFrom; + +struct NewType(u8); + +fn main() { + let bytes: &[NewType; 4] = unsafe { TransmuteFrom::<&i32>::transmute(&1i32) }; + //[current]~^ ERROR `i32` cannot be safely transmuted into `[NewType; 4]` + //[next]~^^ ERROR `&i32` cannot be safely transmuted into `&[NewType; 4]` +} diff --git a/tests/ui/transmute/ambiguity-in-closure-arg.stderr b/tests/ui/transmute/ambiguity-in-closure-arg.current.stderr similarity index 87% rename from tests/ui/transmute/ambiguity-in-closure-arg.stderr rename to tests/ui/transmute/ambiguity-in-closure-arg.current.stderr index 24a10a6d210b4..3a38bb35ac793 100644 --- a/tests/ui/transmute/ambiguity-in-closure-arg.stderr +++ b/tests/ui/transmute/ambiguity-in-closure-arg.current.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/ambiguity-in-closure-arg.rs:6:44 + --> $DIR/ambiguity-in-closure-arg.rs:11:44 | LL | unsafe { std::mem::transmute::<_, ()>(|o_b: Unconstrained<_>| {}) }; | ^^^^^^^^^^^^^^^^^^^^^ cannot infer type diff --git a/tests/ui/transmute/ambiguity-in-closure-arg.next.stderr b/tests/ui/transmute/ambiguity-in-closure-arg.next.stderr new file mode 100644 index 0000000000000..3a38bb35ac793 --- /dev/null +++ b/tests/ui/transmute/ambiguity-in-closure-arg.next.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/ambiguity-in-closure-arg.rs:11:44 + | +LL | unsafe { std::mem::transmute::<_, ()>(|o_b: Unconstrained<_>| {}) }; + | ^^^^^^^^^^^^^^^^^^^^^ cannot infer type + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/transmute/ambiguity-in-closure-arg.rs b/tests/ui/transmute/ambiguity-in-closure-arg.rs index 4c2d1ce2ad463..1926fb15f7b2d 100644 --- a/tests/ui/transmute/ambiguity-in-closure-arg.rs +++ b/tests/ui/transmute/ambiguity-in-closure-arg.rs @@ -1,4 +1,9 @@ -// Minimized test for . +//! Minimized test for . + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver +//@ check-fail struct Unconstrained(T); diff --git a/tests/ui/transmute/diverging-fn-transmute.stderr b/tests/ui/transmute/diverging-fn-transmute.current.stderr similarity index 92% rename from tests/ui/transmute/diverging-fn-transmute.stderr rename to tests/ui/transmute/diverging-fn-transmute.current.stderr index b9aeae7ed62b1..37b13e17a70e8 100644 --- a/tests/ui/transmute/diverging-fn-transmute.stderr +++ b/tests/ui/transmute/diverging-fn-transmute.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/diverging-fn-transmute.rs:5:9 + --> $DIR/diverging-fn-transmute.rs:7:9 | LL | fn assert_sizeof() -> ! { | - expected `!` because of return type diff --git a/tests/ui/transmute/diverging-fn-transmute.next.stderr b/tests/ui/transmute/diverging-fn-transmute.next.stderr new file mode 100644 index 0000000000000..37b13e17a70e8 --- /dev/null +++ b/tests/ui/transmute/diverging-fn-transmute.next.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/diverging-fn-transmute.rs:7:9 + | +LL | fn assert_sizeof() -> ! { + | - expected `!` because of return type +LL | unsafe { +LL | ::std::mem::transmute::(panic!()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `!`, found `[u8; 8]` + | + = note: expected type `!` + found array `[u8; 8]` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/transmute/diverging-fn-transmute.rs b/tests/ui/transmute/diverging-fn-transmute.rs index aca82037a0c2c..aedd3c53514c2 100644 --- a/tests/ui/transmute/diverging-fn-transmute.rs +++ b/tests/ui/transmute/diverging-fn-transmute.rs @@ -1,5 +1,7 @@ //! Regression test for issue #35849: transmute with panic in diverging function - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver fn assert_sizeof() -> ! { unsafe { ::std::mem::transmute::(panic!()) diff --git a/tests/ui/transmute/lifetimes.rs b/tests/ui/transmute/lifetimes.rs index 0114e6205bb38..926d2129821f7 100644 --- a/tests/ui/transmute/lifetimes.rs +++ b/tests/ui/transmute/lifetimes.rs @@ -1,5 +1,7 @@ //@ check-pass - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver use std::ptr::NonNull; struct Foo<'a, T: ?Sized>(&'a (), NonNull); diff --git a/tests/ui/transmute/main.stderr b/tests/ui/transmute/main.current.stderr similarity index 92% rename from tests/ui/transmute/main.stderr rename to tests/ui/transmute/main.current.stderr index 6cb0d7f67e085..2a8a131a5e53c 100644 --- a/tests/ui/transmute/main.stderr +++ b/tests/ui/transmute/main.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/main.rs:17:17 + --> $DIR/main.rs:19:17 | LL | let x: u8 = transmute(10u16); | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let x: u8 = transmute(10u16); = note: target type: `u8` (8 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/main.rs:21:17 + --> $DIR/main.rs:23:17 | LL | let x: u8 = transmute("test"); | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let x: u8 = transmute("test"); = note: target type: `u8` (8 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/main.rs:26:18 + --> $DIR/main.rs:28:18 | LL | let x: Foo = transmute(10); | ^^^^^^^^^ diff --git a/tests/ui/transmute/main.next.stderr b/tests/ui/transmute/main.next.stderr new file mode 100644 index 0000000000000..2a8a131a5e53c --- /dev/null +++ b/tests/ui/transmute/main.next.stderr @@ -0,0 +1,30 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/main.rs:19:17 + | +LL | let x: u8 = transmute(10u16); + | ^^^^^^^^^ + | + = note: source type: `u16` (16 bits) + = note: target type: `u8` (8 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/main.rs:23:17 + | +LL | let x: u8 = transmute("test"); + | ^^^^^^^^^ + | + = note: source type: `&str` ($STR bits) + = note: target type: `u8` (8 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/main.rs:28:18 + | +LL | let x: Foo = transmute(10); + | ^^^^^^^^^ + | + = note: source type: `i32` (32 bits) + = note: target type: `Foo` (0 bits) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/main.rs b/tests/ui/transmute/main.rs index e4a5f9103cd79..941944f749466 100644 --- a/tests/ui/transmute/main.rs +++ b/tests/ui/transmute/main.rs @@ -1,6 +1,8 @@ //@ normalize-stderr-32bit: "`&str` \(64 bits\)" -> "`&str` ($$STR bits)" //@ normalize-stderr-64bit: "`&str` \(128 bits\)" -> "`&str` ($$STR bits)" - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver use std::mem::transmute; pub trait TypeConstructor<'a> { diff --git a/tests/ui/transmute/recursive-size-skeleton.stderr b/tests/ui/transmute/recursive-size-skeleton.current.stderr similarity index 88% rename from tests/ui/transmute/recursive-size-skeleton.stderr rename to tests/ui/transmute/recursive-size-skeleton.current.stderr index 05bdf6ae49905..a1a61480b8e26 100644 --- a/tests/ui/transmute/recursive-size-skeleton.stderr +++ b/tests/ui/transmute/recursive-size-skeleton.current.stderr @@ -1,5 +1,5 @@ error: reached the recursion limit while computing the size of `Thing` - --> $DIR/recursive-size-skeleton.rs:20:27 + --> $DIR/recursive-size-skeleton.rs:22:27 | LL | let _: i32 = unsafe { transmute(value) }; | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let _: i32 = unsafe { transmute(value) }; = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/recursive-size-skeleton.rs:20:27 + --> $DIR/recursive-size-skeleton.rs:22:27 | LL | let _: i32 = unsafe { transmute(value) }; | ^^^^^^^^^ diff --git a/tests/ui/transmute/recursive-size-skeleton.next.stderr b/tests/ui/transmute/recursive-size-skeleton.next.stderr new file mode 100644 index 0000000000000..a1a61480b8e26 --- /dev/null +++ b/tests/ui/transmute/recursive-size-skeleton.next.stderr @@ -0,0 +1,20 @@ +error: reached the recursion limit while computing the size of `Thing` + --> $DIR/recursive-size-skeleton.rs:22:27 + | +LL | let _: i32 = unsafe { transmute(value) }; + | ^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/recursive-size-skeleton.rs:22:27 + | +LL | let _: i32 = unsafe { transmute(value) }; + | ^^^^^^^^^ + | + = note: source type: `Thing` (the type has an unknown layout) + = note: target type: `i32` (32 bits) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/recursive-size-skeleton.rs b/tests/ui/transmute/recursive-size-skeleton.rs index b2395a8f5aa4b..138bc0eb34324 100644 --- a/tests/ui/transmute/recursive-size-skeleton.rs +++ b/tests/ui/transmute/recursive-size-skeleton.rs @@ -3,7 +3,9 @@ // through a normalizing type alias used to recurse without bound and // blow the stack. We now bail out via the recursion limit and emit a // regular error instead of ICE-ing. - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver use std::mem::transmute; trait Trait { diff --git a/tests/ui/transmute/transmute-array-to-scalar.rs b/tests/ui/transmute/transmute-array-to-scalar.rs index cd6dbb040c8bb..c80d13fa7db03 100644 --- a/tests/ui/transmute/transmute-array-to-scalar.rs +++ b/tests/ui/transmute/transmute-array-to-scalar.rs @@ -1,7 +1,9 @@ //! Verify transmuting from a single-element array to a scalar is allowed. //! //! Regression test: - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver //@ run-pass pub fn main() { diff --git a/tests/ui/transmute/transmute-associated-type-to-slice.stderr b/tests/ui/transmute/transmute-associated-type-to-slice.current.stderr similarity index 87% rename from tests/ui/transmute/transmute-associated-type-to-slice.stderr rename to tests/ui/transmute/transmute-associated-type-to-slice.current.stderr index ada3153165e57..ac59b0c70be65 100644 --- a/tests/ui/transmute/transmute-associated-type-to-slice.stderr +++ b/tests/ui/transmute/transmute-associated-type-to-slice.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-associated-type-to-slice.rs:13:14 + --> $DIR/transmute-associated-type-to-slice.rs:15:14 | LL | unsafe { std::mem::transmute(a) } | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-associated-type-to-slice.next.stderr b/tests/ui/transmute/transmute-associated-type-to-slice.next.stderr new file mode 100644 index 0000000000000..ac59b0c70be65 --- /dev/null +++ b/tests/ui/transmute/transmute-associated-type-to-slice.next.stderr @@ -0,0 +1,12 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-associated-type-to-slice.rs:15:14 + | +LL | unsafe { std::mem::transmute(a) } + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `&ArrayPeano` (N bits) + = note: target type: `&[T]` (N bits) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-associated-type-to-slice.rs b/tests/ui/transmute/transmute-associated-type-to-slice.rs index 9521a944391cc..5b56c541143a8 100644 --- a/tests/ui/transmute/transmute-associated-type-to-slice.rs +++ b/tests/ui/transmute/transmute-associated-type-to-slice.rs @@ -1,6 +1,8 @@ //! regression test for //@ normalize-stderr: "\d+ bits" -> "N bits" - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver trait MyTrait { type MyType; } diff --git a/tests/ui/transmute/transmute-bool-u8.rs b/tests/ui/transmute/transmute-bool-u8.rs index 502683b6d1366..9bd4ac212d399 100644 --- a/tests/ui/transmute/transmute-bool-u8.rs +++ b/tests/ui/transmute/transmute-bool-u8.rs @@ -1,4 +1,7 @@ //! regression test for +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver //@ build-pass #![allow(unnecessary_transmutes)] use std::mem::transmute; diff --git a/tests/ui/transmute/transmute-different-sizes.stderr b/tests/ui/transmute/transmute-different-sizes.current.stderr similarity index 86% rename from tests/ui/transmute/transmute-different-sizes.stderr rename to tests/ui/transmute/transmute-different-sizes.current.stderr index fe611f7ba18d1..d8b1898b25e91 100644 --- a/tests/ui/transmute/transmute-different-sizes.stderr +++ b/tests/ui/transmute/transmute-different-sizes.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:11:17 + --> $DIR/transmute-different-sizes.rs:13:17 | LL | let _: i8 = transmute(16i16); | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _: i8 = transmute(16i16); = note: target type: `i8` (N bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:16:17 + --> $DIR/transmute-different-sizes.rs:18:17 | LL | let _: i8 = transmute(x); | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _: i8 = transmute(x); = note: target type: `i8` (N bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:27:5 + --> $DIR/transmute-different-sizes.rs:29:5 | LL | transmute(x) | ^^^^^^^^^ @@ -26,7 +26,7 @@ LL | transmute(x) = note: target type: `::Output` (this type does not have a fixed size) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:38:5 + --> $DIR/transmute-different-sizes.rs:40:5 | LL | transmute(from) | ^^^^^^^^^ @@ -35,7 +35,7 @@ LL | transmute(from) = note: target type: `PtrAndOverAlignZST` (size can vary because of ::Metadata) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:47:5 + --> $DIR/transmute-different-sizes.rs:49:5 | LL | std::mem::transmute(from) | ^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | std::mem::transmute(from) = note: target type: `PtrAndEmptyArray` (size can vary because of ::Metadata) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:55:14 + --> $DIR/transmute-different-sizes.rs:57:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ @@ -53,7 +53,7 @@ LL | unsafe { transmute(x) } = note: target type: `*const T` (pointer to `T`) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:66:14 + --> $DIR/transmute-different-sizes.rs:68:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ @@ -62,7 +62,7 @@ LL | unsafe { transmute(x) } = note: target type: `NotANewtype<&T>` (size can vary because of ::Metadata) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-different-sizes.rs:79:14 + --> $DIR/transmute-different-sizes.rs:81:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-different-sizes.next.stderr b/tests/ui/transmute/transmute-different-sizes.next.stderr new file mode 100644 index 0000000000000..d8b1898b25e91 --- /dev/null +++ b/tests/ui/transmute/transmute-different-sizes.next.stderr @@ -0,0 +1,75 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:13:17 + | +LL | let _: i8 = transmute(16i16); + | ^^^^^^^^^ + | + = note: source type: `i16` (N bits) + = note: target type: `i8` (N bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:18:17 + | +LL | let _: i8 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `&T` (N bits) + = note: target type: `i8` (N bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:29:5 + | +LL | transmute(x) + | ^^^^^^^^^ + | + = note: source type: `u16` (N bits) + = note: target type: `::Output` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:40:5 + | +LL | transmute(from) + | ^^^^^^^^^ + | + = note: source type: `*mut T` (pointer to `T`) + = note: target type: `PtrAndOverAlignZST` (size can vary because of ::Metadata) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:49:5 + | +LL | std::mem::transmute(from) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `*mut T` (pointer to `T`) + = note: target type: `PtrAndEmptyArray` (size can vary because of ::Metadata) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:57:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `OverAlignWrap<*const T>` (size can vary because of ::Metadata) + = note: target type: `*const T` (pointer to `T`) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:68:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&T` (pointer to `T`) + = note: target type: `NotANewtype<&T>` (size can vary because of ::Metadata) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:81:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&T` (pointer to `T`) + = note: target type: `NotNullPointerOptimized<&T>` (size can vary because of ::Metadata) + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-different-sizes.rs b/tests/ui/transmute/transmute-different-sizes.rs index 4f1f758677145..c269b571d9e31 100644 --- a/tests/ui/transmute/transmute-different-sizes.rs +++ b/tests/ui/transmute/transmute-different-sizes.rs @@ -1,5 +1,7 @@ //@ normalize-stderr: "\d+ bits" -> "N bits" - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver // Tests that `transmute` cannot be called on types of different size. #![allow(warnings)] diff --git a/tests/ui/transmute/transmute-fat-pointers.stderr b/tests/ui/transmute/transmute-fat-pointers.current.stderr similarity index 86% rename from tests/ui/transmute/transmute-fat-pointers.stderr rename to tests/ui/transmute/transmute-fat-pointers.current.stderr index 56a4f7f33d152..e94ff321e9197 100644 --- a/tests/ui/transmute/transmute-fat-pointers.stderr +++ b/tests/ui/transmute/transmute-fat-pointers.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-fat-pointers.rs:11:14 + --> $DIR/transmute-fat-pointers.rs:13:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | unsafe { transmute(x) } = note: target type: `&U` (pointer to `U`) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-fat-pointers.rs:15:14 + --> $DIR/transmute-fat-pointers.rs:17:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { transmute(x) } = note: target type: `&U` (pointer to `U`) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-fat-pointers.rs:27:14 + --> $DIR/transmute-fat-pointers.rs:29:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ @@ -26,7 +26,7 @@ LL | unsafe { transmute(x) } = note: target type: `&U` (N bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-fat-pointers.rs:31:14 + --> $DIR/transmute-fat-pointers.rs:33:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-fat-pointers.next.stderr b/tests/ui/transmute/transmute-fat-pointers.next.stderr new file mode 100644 index 0000000000000..e94ff321e9197 --- /dev/null +++ b/tests/ui/transmute/transmute-fat-pointers.next.stderr @@ -0,0 +1,39 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fat-pointers.rs:13:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&[T]` (N bits) + = note: target type: `&U` (pointer to `U`) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fat-pointers.rs:17:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&T` (pointer to `T`) + = note: target type: `&U` (pointer to `U`) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fat-pointers.rs:29:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&T` (pointer to `T`) + = note: target type: `&U` (N bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fat-pointers.rs:33:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&T` (N bits) + = note: target type: `&U` (pointer to `U`) + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-fat-pointers.rs b/tests/ui/transmute/transmute-fat-pointers.rs index c03d0d34feb1b..eba750d9229a6 100644 --- a/tests/ui/transmute/transmute-fat-pointers.rs +++ b/tests/ui/transmute/transmute-fat-pointers.rs @@ -1,5 +1,7 @@ //@ normalize-stderr: "\d+ bits" -> "N bits" - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver // Tests that are conservative around thin/fat pointer mismatches. #![allow(dead_code)] diff --git a/tests/ui/transmute/transmute-from-fn-item-types-error.stderr b/tests/ui/transmute/transmute-from-fn-item-types-error.current.stderr similarity index 84% rename from tests/ui/transmute/transmute-from-fn-item-types-error.stderr rename to tests/ui/transmute/transmute-from-fn-item-types-error.current.stderr index aefe3fb8e25fd..c77725b1c4eb0 100644 --- a/tests/ui/transmute/transmute-from-fn-item-types-error.stderr +++ b/tests/ui/transmute/transmute-from-fn-item-types-error.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-from-fn-item-types-error.rs:4:13 + --> $DIR/transmute-from-fn-item-types-error.rs:7:13 | LL | let i = mem::transmute(bar); | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let i = mem::transmute(bar); = note: target type: `i8` (8 bits) error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:8:13 + --> $DIR/transmute-from-fn-item-types-error.rs:11:13 | LL | let p = mem::transmute(foo); | ^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | let p = mem::transmute(foo); = help: cast with `as` to a pointer instead error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:12:14 + --> $DIR/transmute-from-fn-item-types-error.rs:15:14 | LL | let of = mem::transmute(main); | ^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let of = mem::transmute(main); = help: cast with `as` to a pointer instead error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-from-fn-item-types-error.rs:21:5 + --> $DIR/transmute-from-fn-item-types-error.rs:24:5 | LL | mem::transmute::<_, u8>(main); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | mem::transmute::<_, u8>(main); = note: target type: `u8` (8 bits) error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:25:5 + --> $DIR/transmute-from-fn-item-types-error.rs:28:5 | LL | mem::transmute::<_, *mut ()>(foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | mem::transmute::<_, *mut ()>(foo); = help: cast with `as` to a pointer instead error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:29:5 + --> $DIR/transmute-from-fn-item-types-error.rs:32:5 | LL | mem::transmute::<_, fn()>(bar); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | mem::transmute::<_, fn()>(bar); = help: cast with `as` to a pointer instead error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:38:5 + --> $DIR/transmute-from-fn-item-types-error.rs:41:5 | LL | mem::transmute::<_, *mut ()>(Some(foo)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | mem::transmute::<_, *mut ()>(Some(foo)); = help: cast with `as` to a pointer instead error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:42:5 + --> $DIR/transmute-from-fn-item-types-error.rs:45:5 | LL | mem::transmute::<_, fn()>(Some(bar)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,7 +77,7 @@ LL | mem::transmute::<_, fn()>(Some(bar)); = help: cast with `as` to a pointer instead error[E0591]: can't transmute zero-sized type - --> $DIR/transmute-from-fn-item-types-error.rs:46:5 + --> $DIR/transmute-from-fn-item-types-error.rs:49:5 | LL | mem::transmute::<_, Option>(Some(baz)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-from-fn-item-types-error.next.stderr b/tests/ui/transmute/transmute-from-fn-item-types-error.next.stderr new file mode 100644 index 0000000000000..c77725b1c4eb0 --- /dev/null +++ b/tests/ui/transmute/transmute-from-fn-item-types-error.next.stderr @@ -0,0 +1,92 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-from-fn-item-types-error.rs:7:13 + | +LL | let i = mem::transmute(bar); + | ^^^^^^^^^^^^^^ + | + = note: source type: `unsafe fn() {bar}` (0 bits) + = note: target type: `i8` (8 bits) + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:11:13 + | +LL | let p = mem::transmute(foo); + | ^^^^^^^^^^^^^^ + | + = note: source type: unsafe fn() -> (i8, *const (), Option) {foo} + = note: target type: *const () + = help: cast with `as` to a pointer instead + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:15:14 + | +LL | let of = mem::transmute(main); + | ^^^^^^^^^^^^^^ + | + = note: source type: fn() {main} + = note: target type: Option + = help: cast with `as` to a pointer instead + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-from-fn-item-types-error.rs:24:5 + | +LL | mem::transmute::<_, u8>(main); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `fn() {main}` (0 bits) + = note: target type: `u8` (8 bits) + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:28:5 + | +LL | mem::transmute::<_, *mut ()>(foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: unsafe fn() -> (i8, *const (), Option) {foo} + = note: target type: *mut () + = help: cast with `as` to a pointer instead + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:32:5 + | +LL | mem::transmute::<_, fn()>(bar); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: unsafe fn() {bar} + = note: target type: fn() + = help: cast with `as` to a pointer instead + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:41:5 + | +LL | mem::transmute::<_, *mut ()>(Some(foo)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: unsafe fn() -> (i8, *const (), Option) {foo} + = note: target type: *mut () + = help: cast with `as` to a pointer instead + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:45:5 + | +LL | mem::transmute::<_, fn()>(Some(bar)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: unsafe fn() {bar} + = note: target type: fn() + = help: cast with `as` to a pointer instead + +error[E0591]: can't transmute zero-sized type + --> $DIR/transmute-from-fn-item-types-error.rs:49:5 + | +LL | mem::transmute::<_, Option>(Some(baz)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: unsafe fn() {baz} + = note: target type: Option + = help: cast with `as` to a pointer instead + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0512, E0591. +For more information about an error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-from-fn-item-types-error.rs b/tests/ui/transmute/transmute-from-fn-item-types-error.rs index f858a199e48e3..c1161305406d1 100644 --- a/tests/ui/transmute/transmute-from-fn-item-types-error.rs +++ b/tests/ui/transmute/transmute-from-fn-item-types-error.rs @@ -1,3 +1,6 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver use std::mem; unsafe fn foo() -> (i8, *const (), Option) { diff --git a/tests/ui/transmute/transmute-impl.stderr b/tests/ui/transmute/transmute-impl.current.stderr similarity index 91% rename from tests/ui/transmute/transmute-impl.stderr rename to tests/ui/transmute/transmute-impl.current.stderr index 6ed1cd6cec455..598f43cddced0 100644 --- a/tests/ui/transmute/transmute-impl.stderr +++ b/tests/ui/transmute/transmute-impl.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-impl.rs:21:18 + --> $DIR/transmute-impl.rs:23:18 | LL | unsafe { transmute(x) } | ^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-impl.next.stderr b/tests/ui/transmute/transmute-impl.next.stderr new file mode 100644 index 0000000000000..598f43cddced0 --- /dev/null +++ b/tests/ui/transmute/transmute-impl.next.stderr @@ -0,0 +1,12 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-impl.rs:23:18 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^ + | + = note: source type: `&T` (pointer to `T`) + = note: target type: `&isize` (N bits) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-impl.rs b/tests/ui/transmute/transmute-impl.rs index 84951a0ee6035..1e5cf6509f6ba 100644 --- a/tests/ui/transmute/transmute-impl.rs +++ b/tests/ui/transmute/transmute-impl.rs @@ -1,5 +1,7 @@ //@ normalize-stderr: "\d+ bits" -> "N bits" - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver // Tests that are conservative around thin/fat pointer mismatches. #![allow(dead_code)] diff --git a/tests/ui/transmute/transmute-imut-to-mut.stderr b/tests/ui/transmute/transmute-imut-to-mut.current.stderr similarity index 89% rename from tests/ui/transmute/transmute-imut-to-mut.stderr rename to tests/ui/transmute/transmute-imut-to-mut.current.stderr index d37050fa58af6..265426641d57e 100644 --- a/tests/ui/transmute/transmute-imut-to-mut.stderr +++ b/tests/ui/transmute/transmute-imut-to-mut.current.stderr @@ -1,5 +1,5 @@ error: transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell - --> $DIR/transmute-imut-to-mut.rs:6:32 + --> $DIR/transmute-imut-to-mut.rs:8:32 | LL | let _a: &mut u8 = unsafe { transmute(&1u8) }; | ^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-imut-to-mut.next.stderr b/tests/ui/transmute/transmute-imut-to-mut.next.stderr new file mode 100644 index 0000000000000..265426641d57e --- /dev/null +++ b/tests/ui/transmute/transmute-imut-to-mut.next.stderr @@ -0,0 +1,10 @@ +error: transmuting &T to &mut T is undefined behavior, even if the reference is unused, consider instead using an UnsafeCell + --> $DIR/transmute-imut-to-mut.rs:8:32 + | +LL | let _a: &mut u8 = unsafe { transmute(&1u8) }; + | ^^^^^^^^^ + | + = note: `#[deny(mutable_transmutes)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/transmute/transmute-imut-to-mut.rs b/tests/ui/transmute/transmute-imut-to-mut.rs index 9f3f76c1ef3e0..85c067366e549 100644 --- a/tests/ui/transmute/transmute-imut-to-mut.rs +++ b/tests/ui/transmute/transmute-imut-to-mut.rs @@ -1,5 +1,7 @@ // Tests that transmuting from &T to &mut T is Undefined Behavior. - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver use std::mem::transmute; fn main() { diff --git a/tests/ui/transmute/transmute-in-async-fn.stderr b/tests/ui/transmute/transmute-in-async-fn.current.stderr similarity index 89% rename from tests/ui/transmute/transmute-in-async-fn.stderr rename to tests/ui/transmute/transmute-in-async-fn.current.stderr index 2f5e471302b51..730e9550f9927 100644 --- a/tests/ui/transmute/transmute-in-async-fn.stderr +++ b/tests/ui/transmute/transmute-in-async-fn.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-in-async-fn.rs:4:14 + --> $DIR/transmute-in-async-fn.rs:7:14 | LL | unsafe { std::mem::transmute(1u64) } | ^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | unsafe { std::mem::transmute(1u64) } = note: target type: `u32` (32 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-in-async-fn.rs:9:31 + --> $DIR/transmute-in-async-fn.rs:12:31 | LL | let closure = || unsafe { std::mem::transmute(1u64) }; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-in-async-fn.next.stderr b/tests/ui/transmute/transmute-in-async-fn.next.stderr new file mode 100644 index 0000000000000..730e9550f9927 --- /dev/null +++ b/tests/ui/transmute/transmute-in-async-fn.next.stderr @@ -0,0 +1,21 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-in-async-fn.rs:7:14 + | +LL | unsafe { std::mem::transmute(1u64) } + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `u64` (64 bits) + = note: target type: `u32` (32 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-in-async-fn.rs:12:31 + | +LL | let closure = || unsafe { std::mem::transmute(1u64) }; + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `u64` (64 bits) + = note: target type: `u32` (32 bits) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-in-async-fn.rs b/tests/ui/transmute/transmute-in-async-fn.rs index 83574ee5b8bde..49270406315ec 100644 --- a/tests/ui/transmute/transmute-in-async-fn.rs +++ b/tests/ui/transmute/transmute-in-async-fn.rs @@ -1,4 +1,7 @@ -//@compile-flags: -Zmir-enable-passes=+DataflowConstProp --crate-type lib +//@ compile-flags: -Zmir-enable-passes=+DataflowConstProp --crate-type lib +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver //@ edition:2021 pub async fn a() -> u32 { unsafe { std::mem::transmute(1u64) } diff --git a/tests/ui/transmute/transmute-same-associated-type.rs b/tests/ui/transmute/transmute-same-associated-type.rs index 8bc452c6df4f6..0ea1b799b412a 100644 --- a/tests/ui/transmute/transmute-same-associated-type.rs +++ b/tests/ui/transmute/transmute-same-associated-type.rs @@ -1,5 +1,7 @@ //! Verify transmuting is allowed when `Src` and `Dst` are the same associated type. - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver //@ check-pass trait Foo { diff --git a/tests/ui/transmute/transmute-slice-to-dst.rs b/tests/ui/transmute/transmute-slice-to-dst.rs index c1f77bee284dd..60386af186b6b 100644 --- a/tests/ui/transmute/transmute-slice-to-dst.rs +++ b/tests/ui/transmute/transmute-slice-to-dst.rs @@ -1,5 +1,8 @@ //! regression test for //@ build-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver //@ compile-flags: -g pub struct Dst { diff --git a/tests/ui/transmute/transmute-type-parameters.stderr b/tests/ui/transmute/transmute-type-parameters.current.stderr similarity index 86% rename from tests/ui/transmute/transmute-type-parameters.stderr rename to tests/ui/transmute/transmute-type-parameters.current.stderr index 220b929d4fd2e..e1c3bca593af4 100644 --- a/tests/ui/transmute/transmute-type-parameters.stderr +++ b/tests/ui/transmute/transmute-type-parameters.current.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-type-parameters.rs:6:18 + --> $DIR/transmute-type-parameters.rs:8:18 | LL | let _: i32 = transmute(x); | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _: i32 = transmute(x); = note: target type: `i32` (32 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-type-parameters.rs:11:18 + --> $DIR/transmute-type-parameters.rs:13:18 | LL | let _: i32 = transmute(x); | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _: i32 = transmute(x); = note: target type: `i32` (32 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-type-parameters.rs:16:18 + --> $DIR/transmute-type-parameters.rs:18:18 | LL | let _: i32 = transmute(x); | ^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _: i32 = transmute(x); = note: target type: `i32` (32 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-type-parameters.rs:25:18 + --> $DIR/transmute-type-parameters.rs:27:18 | LL | let _: i32 = transmute(x); | ^^^^^^^^^ @@ -35,7 +35,7 @@ LL | let _: i32 = transmute(x); = note: target type: `i32` (32 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-type-parameters.rs:35:18 + --> $DIR/transmute-type-parameters.rs:37:18 | LL | let _: i32 = transmute(x); | ^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _: i32 = transmute(x); = note: target type: `i32` (32 bits) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/transmute-type-parameters.rs:40:18 + --> $DIR/transmute-type-parameters.rs:42:18 | LL | let _: i32 = transmute(x); | ^^^^^^^^^ diff --git a/tests/ui/transmute/transmute-type-parameters.next.stderr b/tests/ui/transmute/transmute-type-parameters.next.stderr new file mode 100644 index 0000000000000..e1c3bca593af4 --- /dev/null +++ b/tests/ui/transmute/transmute-type-parameters.next.stderr @@ -0,0 +1,57 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-type-parameters.rs:8:18 + | +LL | let _: i32 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `T` (this type does not have a fixed size) + = note: target type: `i32` (32 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-type-parameters.rs:13:18 + | +LL | let _: i32 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `(T, i32)` (size can vary because of T) + = note: target type: `i32` (32 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-type-parameters.rs:18:18 + | +LL | let _: i32 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `[T; 10]` (size can vary because of T) + = note: target type: `i32` (32 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-type-parameters.rs:27:18 + | +LL | let _: i32 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `Bad` (size can vary because of T) + = note: target type: `i32` (32 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-type-parameters.rs:37:18 + | +LL | let _: i32 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `Worse` (size can vary because of T) + = note: target type: `i32` (32 bits) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-type-parameters.rs:42:18 + | +LL | let _: i32 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: `Option` (size can vary because of T) + = note: target type: `i32` (32 bits) + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-type-parameters.rs b/tests/ui/transmute/transmute-type-parameters.rs index 5f44b2d0f0163..cb9fc3cbb86a0 100644 --- a/tests/ui/transmute/transmute-type-parameters.rs +++ b/tests/ui/transmute/transmute-type-parameters.rs @@ -1,5 +1,7 @@ // Tests that `transmute` cannot be called on type parameters. - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver use std::mem::transmute; unsafe fn f(x: T) { diff --git a/tests/ui/transmute/transmute-zst-generics.rs b/tests/ui/transmute/transmute-zst-generics.rs index b80ec794f83f9..31ee48bac3687 100644 --- a/tests/ui/transmute/transmute-zst-generics.rs +++ b/tests/ui/transmute/transmute-zst-generics.rs @@ -1,5 +1,7 @@ //@ run-pass - +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver // Transmuting to/from ZSTs that contain generics. #![feature(transmute_generic_consts)] diff --git a/tests/ui/transmute/unnecessary-transmutation.fixed b/tests/ui/transmute/unnecessary-transmutation.current.fixed similarity index 96% rename from tests/ui/transmute/unnecessary-transmutation.fixed rename to tests/ui/transmute/unnecessary-transmutation.current.fixed index 08010ec8b84e4..567507f7dc54d 100644 --- a/tests/ui/transmute/unnecessary-transmutation.fixed +++ b/tests/ui/transmute/unnecessary-transmutation.current.fixed @@ -1,4 +1,8 @@ //@ run-rustfix +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver + #![deny(unnecessary_transmutes)] #![allow(unused_unsafe, unused_imports, unused_variables, unused_parens)] use std::mem::transmute; diff --git a/tests/ui/transmute/unnecessary-transmutation.stderr b/tests/ui/transmute/unnecessary-transmutation.current.stderr similarity index 92% rename from tests/ui/transmute/unnecessary-transmutation.stderr rename to tests/ui/transmute/unnecessary-transmutation.current.stderr index 8399f760ceb37..84532449c5dc8 100644 --- a/tests/ui/transmute/unnecessary-transmutation.stderr +++ b/tests/ui/transmute/unnecessary-transmutation.current.stderr @@ -1,12 +1,12 @@ error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:7:14 + --> $DIR/unnecessary-transmutation.rs:11:14 | LL | unsafe { transmute(x) } | ^^^^^^^^^^^^ | = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order note: the lint level is defined here - --> $DIR/unnecessary-transmutation.rs:2:9 + --> $DIR/unnecessary-transmutation.rs:6:9 | LL | #![deny(unnecessary_transmutes)] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + unsafe { u32::to_ne_bytes(x) } | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:12:14 + --> $DIR/unnecessary-transmutation.rs:16:14 | LL | unsafe { transmute(from) } | ^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL + unsafe { (from) as u8 } | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:16:29 + --> $DIR/unnecessary-transmutation.rs:20:29 | LL | pub static X: u8 = unsafe { transmute(true) }; | ^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL + pub static X: u8 = unsafe { (true) as u8 }; | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:18:28 + --> $DIR/unnecessary-transmutation.rs:22:28 | LL | pub const Y: u8 = unsafe { transmute(true) }; | ^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL + pub const Y: u8 = unsafe { (true) as u8 }; | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:24:18 + --> $DIR/unnecessary-transmutation.rs:28:18 | LL | unsafe { transmute(x) } | ^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL + unsafe { (x) as u8 } | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:30:22 + --> $DIR/unnecessary-transmutation.rs:34:22 | LL | const { unsafe { transmute::<_, u8>(true) } }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,7 +77,7 @@ LL + const { unsafe { (true) as u8 } }; | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:33:22 + --> $DIR/unnecessary-transmutation.rs:37:22 | LL | let x: u16 = transmute(*b"01"); | ^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL + let x: u16 = u16::from_ne_bytes(*b"01"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:35:26 + --> $DIR/unnecessary-transmutation.rs:39:26 | LL | let x: [u8; 2] = transmute(x); | ^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL + let x: [u8; 2] = u16::to_ne_bytes(x); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:37:22 + --> $DIR/unnecessary-transmutation.rs:41:22 | LL | let x: u32 = transmute(*b"0123"); | ^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL + let x: u32 = u32::from_ne_bytes(*b"0123"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:39:26 + --> $DIR/unnecessary-transmutation.rs:43:26 | LL | let x: [u8; 4] = transmute(x); | ^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL + let x: [u8; 4] = u32::to_ne_bytes(x); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:41:22 + --> $DIR/unnecessary-transmutation.rs:45:22 | LL | let x: u64 = transmute(*b"feriscat"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL + let x: u64 = u64::from_ne_bytes(*b"feriscat"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:43:26 + --> $DIR/unnecessary-transmutation.rs:47:26 | LL | let x: [u8; 8] = transmute(x); | ^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + let x: [u8; 8] = u64::to_ne_bytes(x); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:46:22 + --> $DIR/unnecessary-transmutation.rs:50:22 | LL | let y: i16 = transmute(*b"01"); | ^^^^^^^^^^^^^^^^^ @@ -168,7 +168,7 @@ LL + let y: i16 = i16::from_ne_bytes(*b"01"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:48:26 + --> $DIR/unnecessary-transmutation.rs:52:26 | LL | let y: [u8; 2] = transmute(y); | ^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + let y: [u8; 2] = i16::to_ne_bytes(y); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:50:22 + --> $DIR/unnecessary-transmutation.rs:54:22 | LL | let y: i32 = transmute(*b"0123"); | ^^^^^^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ LL + let y: i32 = i32::from_ne_bytes(*b"0123"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:52:26 + --> $DIR/unnecessary-transmutation.rs:56:26 | LL | let y: [u8; 4] = transmute(y); | ^^^^^^^^^^^^ @@ -207,7 +207,7 @@ LL + let y: [u8; 4] = i32::to_ne_bytes(y); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:54:22 + --> $DIR/unnecessary-transmutation.rs:58:22 | LL | let y: i64 = transmute(*b"feriscat"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +220,7 @@ LL + let y: i64 = i64::from_ne_bytes(*b"feriscat"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:56:26 + --> $DIR/unnecessary-transmutation.rs:60:26 | LL | let y: [u8; 8] = transmute(y); | ^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL + let y: [u8; 8] = i64::to_ne_bytes(y); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:59:22 + --> $DIR/unnecessary-transmutation.rs:63:22 | LL | let z: f32 = transmute(*b"0123"); | ^^^^^^^^^^^^^^^^^^^ @@ -246,7 +246,7 @@ LL + let z: f32 = f32::from_ne_bytes(*b"0123"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:61:26 + --> $DIR/unnecessary-transmutation.rs:65:26 | LL | let z: [u8; 4] = transmute(z); | ^^^^^^^^^^^^ @@ -259,7 +259,7 @@ LL + let z: [u8; 4] = f32::to_ne_bytes(z); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:63:22 + --> $DIR/unnecessary-transmutation.rs:67:22 | LL | let z: f64 = transmute(*b"feriscat"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -272,7 +272,7 @@ LL + let z: f64 = f64::from_ne_bytes(*b"feriscat"); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:65:26 + --> $DIR/unnecessary-transmutation.rs:69:26 | LL | let z: [u8; 8] = transmute(z); | ^^^^^^^^^^^^ @@ -285,7 +285,7 @@ LL + let z: [u8; 8] = f64::to_ne_bytes(z); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:68:22 + --> $DIR/unnecessary-transmutation.rs:72:22 | LL | let y: u32 = transmute('🦀'); | ^^^^^^^^^^^^^^^ @@ -297,7 +297,7 @@ LL + let y: u32 = u32::from('🦀'); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:70:23 + --> $DIR/unnecessary-transmutation.rs:74:23 | LL | let y: char = transmute(y); | ^^^^^^^^^^^^ @@ -310,7 +310,7 @@ LL + let y: char = char::from_u32_unchecked(y); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:72:22 + --> $DIR/unnecessary-transmutation.rs:76:22 | LL | let y: i32 = transmute('🐱'); | ^^^^^^^^^^^^^^^ @@ -322,7 +322,7 @@ LL + let y: i32 = u32::from('🐱').cast_signed(); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:74:23 + --> $DIR/unnecessary-transmutation.rs:78:23 | LL | let y: char = transmute(y); | ^^^^^^^^^^^^ @@ -335,7 +335,7 @@ LL + let y: char = char::from_u32_unchecked(i32::cast_unsigned(y)); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:77:22 + --> $DIR/unnecessary-transmutation.rs:81:22 | LL | let x: u16 = transmute(8i16); | ^^^^^^^^^^^^^^^ @@ -347,7 +347,7 @@ LL + let x: u16 = i16::cast_unsigned(8i16); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:79:22 + --> $DIR/unnecessary-transmutation.rs:83:22 | LL | let x: i16 = transmute(x); | ^^^^^^^^^^^^ @@ -359,7 +359,7 @@ LL + let x: i16 = u16::cast_signed(x); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:81:22 + --> $DIR/unnecessary-transmutation.rs:85:22 | LL | let x: u32 = transmute(4i32); | ^^^^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL + let x: u32 = i32::cast_unsigned(4i32); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:83:22 + --> $DIR/unnecessary-transmutation.rs:87:22 | LL | let x: i32 = transmute(x); | ^^^^^^^^^^^^ @@ -383,7 +383,7 @@ LL + let x: i32 = u32::cast_signed(x); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:85:22 + --> $DIR/unnecessary-transmutation.rs:89:22 | LL | let x: u64 = transmute(7i64); | ^^^^^^^^^^^^^^^ @@ -395,7 +395,7 @@ LL + let x: u64 = i64::cast_unsigned(7i64); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:87:22 + --> $DIR/unnecessary-transmutation.rs:91:22 | LL | let x: i64 = transmute(x); | ^^^^^^^^^^^^ @@ -407,7 +407,7 @@ LL + let x: i64 = u64::cast_signed(x); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:90:22 + --> $DIR/unnecessary-transmutation.rs:94:22 | LL | let y: f32 = transmute(1u32); | ^^^^^^^^^^^^^^^ @@ -419,7 +419,7 @@ LL + let y: f32 = f32::from_bits(1u32); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:92:22 + --> $DIR/unnecessary-transmutation.rs:96:22 | LL | let y: u32 = transmute(y); | ^^^^^^^^^^^^ @@ -431,7 +431,7 @@ LL + let y: u32 = f32::to_bits(y); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:94:22 + --> $DIR/unnecessary-transmutation.rs:98:22 | LL | let y: f64 = transmute(3u64); | ^^^^^^^^^^^^^^^ @@ -443,7 +443,7 @@ LL + let y: f64 = f64::from_bits(3u64); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:96:22 + --> $DIR/unnecessary-transmutation.rs:100:22 | LL | let y: u64 = transmute(2.0); | ^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL + let y: u64 = f64::to_bits(2.0); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:99:22 + --> $DIR/unnecessary-transmutation.rs:103:22 | LL | let y: f64 = transmute(1i64); | ^^^^^^^^^^^^^^^ @@ -467,7 +467,7 @@ LL + let y: f64 = f64::from_bits(i64::cast_unsigned(1i64)); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:101:22 + --> $DIR/unnecessary-transmutation.rs:105:22 | LL | let y: i64 = transmute(1f64); | ^^^^^^^^^^^^^^^ @@ -479,7 +479,7 @@ LL + let y: i64 = f64::to_bits(1f64).cast_signed(); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:106:21 + --> $DIR/unnecessary-transmutation.rs:110:21 | LL | let z: u8 = transmute(z); | ^^^^^^^^^^^^ @@ -491,7 +491,7 @@ LL + let z: u8 = u8::from(z); | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:111:21 + --> $DIR/unnecessary-transmutation.rs:115:21 | LL | let z: i8 = transmute(z); | ^^^^^^^^^^^^ diff --git a/tests/ui/transmute/unnecessary-transmutation.next.fixed b/tests/ui/transmute/unnecessary-transmutation.next.fixed new file mode 100644 index 0000000000000..567507f7dc54d --- /dev/null +++ b/tests/ui/transmute/unnecessary-transmutation.next.fixed @@ -0,0 +1,118 @@ +//@ run-rustfix +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver + +#![deny(unnecessary_transmutes)] +#![allow(unused_unsafe, unused_imports, unused_variables, unused_parens)] +use std::mem::transmute; + +pub fn bytes_at_home(x: u32) -> [u8; 4] { + unsafe { u32::to_ne_bytes(x) } + //~^ ERROR +} + +pub const fn intinator_const(from: bool) -> u8 { + unsafe { (from) as u8 } + //~^ ERROR +} + +pub static X: u8 = unsafe { (true) as u8 }; +//~^ ERROR +pub const Y: u8 = unsafe { (true) as u8 }; +//~^ ERROR + +pub struct Z {} +impl Z { + pub const fn intinator_assoc(x: bool) -> u8 { + unsafe { (x) as u8 } + //~^ ERROR + } +} + +fn main() { + const { unsafe { (true) as u8 } }; + //~^ ERROR + unsafe { + let x: u16 = u16::from_ne_bytes(*b"01"); + //~^ ERROR + let x: [u8; 2] = u16::to_ne_bytes(x); + //~^ ERROR + let x: u32 = u32::from_ne_bytes(*b"0123"); + //~^ ERROR + let x: [u8; 4] = u32::to_ne_bytes(x); + //~^ ERROR + let x: u64 = u64::from_ne_bytes(*b"feriscat"); + //~^ ERROR + let x: [u8; 8] = u64::to_ne_bytes(x); + //~^ ERROR + + let y: i16 = i16::from_ne_bytes(*b"01"); + //~^ ERROR + let y: [u8; 2] = i16::to_ne_bytes(y); + //~^ ERROR + let y: i32 = i32::from_ne_bytes(*b"0123"); + //~^ ERROR + let y: [u8; 4] = i32::to_ne_bytes(y); + //~^ ERROR + let y: i64 = i64::from_ne_bytes(*b"feriscat"); + //~^ ERROR + let y: [u8; 8] = i64::to_ne_bytes(y); + //~^ ERROR + + let z: f32 = f32::from_ne_bytes(*b"0123"); + //~^ ERROR + let z: [u8; 4] = f32::to_ne_bytes(z); + //~^ ERROR + let z: f64 = f64::from_ne_bytes(*b"feriscat"); + //~^ ERROR + let z: [u8; 8] = f64::to_ne_bytes(z); + //~^ ERROR + + let y: u32 = u32::from('🦀'); + //~^ ERROR + let y: char = char::from_u32_unchecked(y); + //~^ ERROR + let y: i32 = u32::from('🐱').cast_signed(); + //~^ ERROR + let y: char = char::from_u32_unchecked(i32::cast_unsigned(y)); + //~^ ERROR + + let x: u16 = i16::cast_unsigned(8i16); + //~^ ERROR + let x: i16 = u16::cast_signed(x); + //~^ ERROR + let x: u32 = i32::cast_unsigned(4i32); + //~^ ERROR + let x: i32 = u32::cast_signed(x); + //~^ ERROR + let x: u64 = i64::cast_unsigned(7i64); + //~^ ERROR + let x: i64 = u64::cast_signed(x); + //~^ ERROR + + let y: f32 = f32::from_bits(1u32); + //~^ ERROR + let y: u32 = f32::to_bits(y); + //~^ ERROR + let y: f64 = f64::from_bits(3u64); + //~^ ERROR + let y: u64 = f64::to_bits(2.0); + //~^ ERROR + + let y: f64 = f64::from_bits(i64::cast_unsigned(1i64)); + //~^ ERROR + let y: i64 = f64::to_bits(1f64).cast_signed(); + //~^ ERROR + + let z: bool = transmute(1u8); + // clippy + let z: u8 = u8::from(z); + //~^ ERROR + + let z: bool = transmute(1i8); + // clippy + let z: i8 = i8::from(z); + //~^ ERROR + } +} diff --git a/tests/ui/transmute/unnecessary-transmutation.next.stderr b/tests/ui/transmute/unnecessary-transmutation.next.stderr new file mode 100644 index 0000000000000..84532449c5dc8 --- /dev/null +++ b/tests/ui/transmute/unnecessary-transmutation.next.stderr @@ -0,0 +1,506 @@ +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:11:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +note: the lint level is defined here + --> $DIR/unnecessary-transmutation.rs:6:9 + | +LL | #![deny(unnecessary_transmutes)] + | ^^^^^^^^^^^^^^^^^^^^^^ +help: replace this with + | +LL - unsafe { transmute(x) } +LL + unsafe { u32::to_ne_bytes(x) } + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:16:14 + | +LL | unsafe { transmute(from) } + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - unsafe { transmute(from) } +LL + unsafe { (from) as u8 } + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:20:29 + | +LL | pub static X: u8 = unsafe { transmute(true) }; + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - pub static X: u8 = unsafe { transmute(true) }; +LL + pub static X: u8 = unsafe { (true) as u8 }; + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:22:28 + | +LL | pub const Y: u8 = unsafe { transmute(true) }; + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - pub const Y: u8 = unsafe { transmute(true) }; +LL + pub const Y: u8 = unsafe { (true) as u8 }; + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:28:18 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - unsafe { transmute(x) } +LL + unsafe { (x) as u8 } + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:34:22 + | +LL | const { unsafe { transmute::<_, u8>(true) } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - const { unsafe { transmute::<_, u8>(true) } }; +LL + const { unsafe { (true) as u8 } }; + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:37:22 + | +LL | let x: u16 = transmute(*b"01"); + | ^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let x: u16 = transmute(*b"01"); +LL + let x: u16 = u16::from_ne_bytes(*b"01"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:39:26 + | +LL | let x: [u8; 2] = transmute(x); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let x: [u8; 2] = transmute(x); +LL + let x: [u8; 2] = u16::to_ne_bytes(x); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:41:22 + | +LL | let x: u32 = transmute(*b"0123"); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let x: u32 = transmute(*b"0123"); +LL + let x: u32 = u32::from_ne_bytes(*b"0123"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:43:26 + | +LL | let x: [u8; 4] = transmute(x); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let x: [u8; 4] = transmute(x); +LL + let x: [u8; 4] = u32::to_ne_bytes(x); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:45:22 + | +LL | let x: u64 = transmute(*b"feriscat"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let x: u64 = transmute(*b"feriscat"); +LL + let x: u64 = u64::from_ne_bytes(*b"feriscat"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:47:26 + | +LL | let x: [u8; 8] = transmute(x); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let x: [u8; 8] = transmute(x); +LL + let x: [u8; 8] = u64::to_ne_bytes(x); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:50:22 + | +LL | let y: i16 = transmute(*b"01"); + | ^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let y: i16 = transmute(*b"01"); +LL + let y: i16 = i16::from_ne_bytes(*b"01"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:52:26 + | +LL | let y: [u8; 2] = transmute(y); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let y: [u8; 2] = transmute(y); +LL + let y: [u8; 2] = i16::to_ne_bytes(y); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:54:22 + | +LL | let y: i32 = transmute(*b"0123"); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let y: i32 = transmute(*b"0123"); +LL + let y: i32 = i32::from_ne_bytes(*b"0123"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:56:26 + | +LL | let y: [u8; 4] = transmute(y); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let y: [u8; 4] = transmute(y); +LL + let y: [u8; 4] = i32::to_ne_bytes(y); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:58:22 + | +LL | let y: i64 = transmute(*b"feriscat"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let y: i64 = transmute(*b"feriscat"); +LL + let y: i64 = i64::from_ne_bytes(*b"feriscat"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:60:26 + | +LL | let y: [u8; 8] = transmute(y); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let y: [u8; 8] = transmute(y); +LL + let y: [u8; 8] = i64::to_ne_bytes(y); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:63:22 + | +LL | let z: f32 = transmute(*b"0123"); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let z: f32 = transmute(*b"0123"); +LL + let z: f32 = f32::from_ne_bytes(*b"0123"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:65:26 + | +LL | let z: [u8; 4] = transmute(z); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let z: [u8; 4] = transmute(z); +LL + let z: [u8; 4] = f32::to_ne_bytes(z); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:67:22 + | +LL | let z: f64 = transmute(*b"feriscat"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let z: f64 = transmute(*b"feriscat"); +LL + let z: f64 = f64::from_ne_bytes(*b"feriscat"); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:69:26 + | +LL | let z: [u8; 8] = transmute(z); + | ^^^^^^^^^^^^ + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +help: replace this with + | +LL - let z: [u8; 8] = transmute(z); +LL + let z: [u8; 8] = f64::to_ne_bytes(z); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:72:22 + | +LL | let y: u32 = transmute('🦀'); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: u32 = transmute('🦀'); +LL + let y: u32 = u32::from('🦀'); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:74:23 + | +LL | let y: char = transmute(y); + | ^^^^^^^^^^^^ + | + = help: consider using `char::from_u32(…).unwrap()` +help: replace this with + | +LL - let y: char = transmute(y); +LL + let y: char = char::from_u32_unchecked(y); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:76:22 + | +LL | let y: i32 = transmute('🐱'); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: i32 = transmute('🐱'); +LL + let y: i32 = u32::from('🐱').cast_signed(); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:78:23 + | +LL | let y: char = transmute(y); + | ^^^^^^^^^^^^ + | + = help: consider using `char::from_u32(i32::cast_unsigned(…)).unwrap()` +help: replace this with + | +LL - let y: char = transmute(y); +LL + let y: char = char::from_u32_unchecked(i32::cast_unsigned(y)); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:81:22 + | +LL | let x: u16 = transmute(8i16); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let x: u16 = transmute(8i16); +LL + let x: u16 = i16::cast_unsigned(8i16); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:83:22 + | +LL | let x: i16 = transmute(x); + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - let x: i16 = transmute(x); +LL + let x: i16 = u16::cast_signed(x); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:85:22 + | +LL | let x: u32 = transmute(4i32); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let x: u32 = transmute(4i32); +LL + let x: u32 = i32::cast_unsigned(4i32); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:87:22 + | +LL | let x: i32 = transmute(x); + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - let x: i32 = transmute(x); +LL + let x: i32 = u32::cast_signed(x); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:89:22 + | +LL | let x: u64 = transmute(7i64); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let x: u64 = transmute(7i64); +LL + let x: u64 = i64::cast_unsigned(7i64); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:91:22 + | +LL | let x: i64 = transmute(x); + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - let x: i64 = transmute(x); +LL + let x: i64 = u64::cast_signed(x); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:94:22 + | +LL | let y: f32 = transmute(1u32); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: f32 = transmute(1u32); +LL + let y: f32 = f32::from_bits(1u32); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:96:22 + | +LL | let y: u32 = transmute(y); + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: u32 = transmute(y); +LL + let y: u32 = f32::to_bits(y); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:98:22 + | +LL | let y: f64 = transmute(3u64); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: f64 = transmute(3u64); +LL + let y: f64 = f64::from_bits(3u64); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:100:22 + | +LL | let y: u64 = transmute(2.0); + | ^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: u64 = transmute(2.0); +LL + let y: u64 = f64::to_bits(2.0); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:103:22 + | +LL | let y: f64 = transmute(1i64); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: f64 = transmute(1i64); +LL + let y: f64 = f64::from_bits(i64::cast_unsigned(1i64)); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:105:22 + | +LL | let y: i64 = transmute(1f64); + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: i64 = transmute(1f64); +LL + let y: i64 = f64::to_bits(1f64).cast_signed(); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:110:21 + | +LL | let z: u8 = transmute(z); + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - let z: u8 = transmute(z); +LL + let z: u8 = u8::from(z); + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:115:21 + | +LL | let z: i8 = transmute(z); + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - let z: i8 = transmute(z); +LL + let z: i8 = i8::from(z); + | + +error: aborting due to 40 previous errors + diff --git a/tests/ui/transmute/unnecessary-transmutation.rs b/tests/ui/transmute/unnecessary-transmutation.rs index 43eefb97dc28f..273529f5e5d78 100644 --- a/tests/ui/transmute/unnecessary-transmutation.rs +++ b/tests/ui/transmute/unnecessary-transmutation.rs @@ -1,4 +1,8 @@ //@ run-rustfix +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver + #![deny(unnecessary_transmutes)] #![allow(unused_unsafe, unused_imports, unused_variables, unused_parens)] use std::mem::transmute; diff --git a/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs b/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs index 756ce7b3d5074..5f7ce0005bd0e 100644 --- a/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs +++ b/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs @@ -1,4 +1,7 @@ //@ aux-crate: zerocopy=unnecessary-transmute-path-remap-ice-140277-trans.rs +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver //@ check-pass // tests for a regression in linting for unnecessary transmutes // where a span was inacessible for snippet procuring,