Skip to content

Commit 5f58985

Browse files
committed
Remove rustc_transmute's dependence on rustc_infer.
`TransmuteTypeEnv` only needs a `TyCtxt`, not an `InferCtxt`.
1 parent 00f2459 commit 5f58985

File tree

6 files changed

+9
-13
lines changed

6 files changed

+9
-13
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4500,7 +4500,6 @@ dependencies = [
45004500
"rustc_abi",
45014501
"rustc_data_structures",
45024502
"rustc_hir",
4503-
"rustc_infer",
45044503
"rustc_macros",
45054504
"rustc_middle",
45064505
"rustc_span",

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
25442544
let src = trait_pred.trait_ref.args.type_at(1);
25452545
let err_msg = format!("`{src}` cannot be safely transmuted into `{dst}`");
25462546

2547-
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
2547+
match rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx).is_transmutable(
25482548
obligation.cause,
25492549
src_and_dst,
25502550
assume,

compiler/rustc_trait_selection/src/solve/delegate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
236236
};
237237

238238
// FIXME(transmutability): This really should be returning nested goals for `Answer::If*`
239-
match rustc_transmute::TransmuteTypeEnv::new(&self.0).is_transmutable(
239+
match rustc_transmute::TransmuteTypeEnv::new(self.0.tcx).is_transmutable(
240240
ObligationCause::dummy(),
241241
rustc_transmute::Types { src, dst },
242242
assume,

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
424424
let src = predicate.trait_ref.args.type_at(1);
425425

426426
debug!(?src, ?dst);
427-
let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx);
427+
let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx);
428428
let maybe_transmutable = transmute_env.is_transmutable(
429429
obligation.cause.clone(),
430430
rustc_transmute::Types { dst, src },

compiler/rustc_transmute/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2024"
88
rustc_abi = { path = "../rustc_abi", optional = true }
99
rustc_data_structures = { path = "../rustc_data_structures" }
1010
rustc_hir = { path = "../rustc_hir", optional = true }
11-
rustc_infer = { path = "../rustc_infer", optional = true }
1211
rustc_macros = { path = "../rustc_macros", optional = true }
1312
rustc_middle = { path = "../rustc_middle", optional = true }
1413
rustc_span = { path = "../rustc_span", optional = true }
@@ -19,7 +18,6 @@ tracing = "0.1"
1918
rustc = [
2019
"dep:rustc_abi",
2120
"dep:rustc_hir",
22-
"dep:rustc_infer",
2321
"dep:rustc_macros",
2422
"dep:rustc_middle",
2523
"dep:rustc_span",

compiler/rustc_transmute/src/lib.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub enum Reason<T> {
8181
#[cfg(feature = "rustc")]
8282
mod rustc {
8383
use rustc_hir::lang_items::LangItem;
84-
use rustc_infer::infer::InferCtxt;
8584
use rustc_macros::TypeVisitable;
8685
use rustc_middle::traits::ObligationCause;
8786
use rustc_middle::ty::{Const, ParamEnv, Ty, TyCtxt};
@@ -97,13 +96,13 @@ mod rustc {
9796
pub dst: Ty<'tcx>,
9897
}
9998

100-
pub struct TransmuteTypeEnv<'cx, 'tcx> {
101-
infcx: &'cx InferCtxt<'tcx>,
99+
pub struct TransmuteTypeEnv<'tcx> {
100+
tcx: TyCtxt<'tcx>,
102101
}
103102

104-
impl<'cx, 'tcx> TransmuteTypeEnv<'cx, 'tcx> {
105-
pub fn new(infcx: &'cx InferCtxt<'tcx>) -> Self {
106-
Self { infcx }
103+
impl<'tcx> TransmuteTypeEnv<'tcx> {
104+
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
105+
Self { tcx }
107106
}
108107

109108
#[allow(unused)]
@@ -117,7 +116,7 @@ mod rustc {
117116
types.src,
118117
types.dst,
119118
assume,
120-
self.infcx.tcx,
119+
self.tcx,
121120
)
122121
.answer()
123122
}

0 commit comments

Comments
 (0)