Skip to content

Commit 06e66d7

Browse files
Rip out built-in PointerLike impl
1 parent bfe809d commit 06e66d7

File tree

8 files changed

+1
-104
lines changed

8 files changed

+1
-104
lines changed

compiler/rustc_middle/src/ty/context.rs

-14
Original file line numberDiff line numberDiff line change
@@ -602,19 +602,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
602602
self.coroutine_is_async_gen(coroutine_def_id)
603603
}
604604

605-
// We don't use `TypingEnv` here as it's only defined in `rustc_middle` and
606-
// `rustc_next_trait_solver` shouldn't have to know about it.
607-
fn layout_is_pointer_like(
608-
self,
609-
typing_mode: ty::TypingMode<'tcx>,
610-
param_env: ty::ParamEnv<'tcx>,
611-
ty: Ty<'tcx>,
612-
) -> bool {
613-
let typing_env = ty::TypingEnv { typing_mode, param_env };
614-
self.layout_of(self.erase_regions(typing_env).as_query_input(self.erase_regions(ty)))
615-
.is_ok_and(|layout| layout.layout.is_pointer_like(&self.data_layout))
616-
}
617-
618605
type UnsizingParams = &'tcx rustc_index::bit_set::BitSet<u32>;
619606
fn unsizing_params_for_adt(self, adt_def_id: DefId) -> Self::UnsizingParams {
620607
self.unsizing_params_for_adt(adt_def_id)
@@ -688,7 +675,6 @@ bidirectional_lang_item_map! {
688675
Metadata,
689676
Option,
690677
PointeeTrait,
691-
PointerLike,
692678
Poll,
693679
Sized,
694680
TransmuteTrait,

compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,6 @@ where
159159
goal: Goal<I, Self>,
160160
) -> Result<Candidate<I>, NoSolution>;
161161

162-
/// A type is `PointerLike` if we can compute its layout, and that layout
163-
/// matches the layout of `usize`.
164-
fn consider_builtin_pointer_like_candidate(
165-
ecx: &mut EvalCtxt<'_, D>,
166-
goal: Goal<I, Self>,
167-
) -> Result<Candidate<I>, NoSolution>;
168-
169162
/// A type is a `FnPtr` if it is of `FnPtr` type.
170163
fn consider_builtin_fn_ptr_trait_candidate(
171164
ecx: &mut EvalCtxt<'_, D>,
@@ -449,9 +442,6 @@ where
449442
ty::ClosureKind::FnOnce,
450443
)
451444
}
452-
Some(TraitSolverLangItem::PointerLike) => {
453-
G::consider_builtin_pointer_like_candidate(self, goal)
454-
}
455445
Some(TraitSolverLangItem::FnPtrTrait) => {
456446
G::consider_builtin_fn_ptr_trait_candidate(self, goal)
457447
}

compiler/rustc_next_trait_solver/src/solve/effect_goals.rs

-7
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,6 @@ where
210210
Err(NoSolution)
211211
}
212212

213-
fn consider_builtin_pointer_like_candidate(
214-
_ecx: &mut EvalCtxt<'_, D>,
215-
_goal: Goal<I, Self>,
216-
) -> Result<Candidate<I>, NoSolution> {
217-
unreachable!("PointerLike is not const")
218-
}
219-
220213
fn consider_builtin_fn_ptr_trait_candidate(
221214
_ecx: &mut EvalCtxt<'_, D>,
222215
_goal: Goal<I, Self>,

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,6 @@ where
363363
panic!("`Copy`/`Clone` does not have an associated type: {:?}", goal);
364364
}
365365

366-
fn consider_builtin_pointer_like_candidate(
367-
_ecx: &mut EvalCtxt<'_, D>,
368-
goal: Goal<I, Self>,
369-
) -> Result<Candidate<I>, NoSolution> {
370-
panic!("`PointerLike` does not have an associated type: {:?}", goal);
371-
}
372-
373366
fn consider_builtin_fn_ptr_trait_candidate(
374367
_ecx: &mut EvalCtxt<'_, D>,
375368
goal: Goal<I, Self>,

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

-26
Original file line numberDiff line numberDiff line change
@@ -248,32 +248,6 @@ where
248248
)
249249
}
250250

251-
fn consider_builtin_pointer_like_candidate(
252-
ecx: &mut EvalCtxt<'_, D>,
253-
goal: Goal<I, Self>,
254-
) -> Result<Candidate<I>, NoSolution> {
255-
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
256-
return Err(NoSolution);
257-
}
258-
259-
let cx = ecx.cx();
260-
// But if there are inference variables, we have to wait until it's resolved.
261-
if (goal.param_env, goal.predicate.self_ty()).has_non_region_infer() {
262-
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
263-
}
264-
265-
if cx.layout_is_pointer_like(
266-
ecx.typing_mode(goal.param_env),
267-
goal.param_env,
268-
goal.predicate.self_ty(),
269-
) {
270-
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc)
271-
.enter(|ecx| ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes))
272-
} else {
273-
Err(NoSolution)
274-
}
275-
}
276-
277251
fn consider_builtin_fn_ptr_trait_candidate(
278252
ecx: &mut EvalCtxt<'_, D>,
279253
goal: Goal<I, Self>,

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

-31
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
111111
self.assemble_candidates_for_transmutability(obligation, &mut candidates);
112112
} else if tcx.is_lang_item(def_id, LangItem::Tuple) {
113113
self.assemble_candidate_for_tuple(obligation, &mut candidates);
114-
} else if tcx.is_lang_item(def_id, LangItem::PointerLike) {
115-
self.assemble_candidate_for_pointer_like(obligation, &mut candidates);
116114
} else if tcx.is_lang_item(def_id, LangItem::FnPtrTrait) {
117115
self.assemble_candidates_for_fn_ptr_trait(obligation, &mut candidates);
118116
} else {
@@ -1216,35 +1214,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12161214
}
12171215
}
12181216

1219-
fn assemble_candidate_for_pointer_like(
1220-
&mut self,
1221-
obligation: &PolyTraitObligation<'tcx>,
1222-
candidates: &mut SelectionCandidateSet<'tcx>,
1223-
) {
1224-
// The regions of a type don't affect the size of the type
1225-
let tcx = self.tcx();
1226-
let self_ty = tcx.instantiate_bound_regions_with_erased(obligation.predicate.self_ty());
1227-
1228-
// But if there are inference variables, we have to wait until it's resolved.
1229-
if (obligation.param_env, self_ty).has_non_region_infer() {
1230-
candidates.ambiguous = true;
1231-
return;
1232-
}
1233-
1234-
// We should erase regions from both the param-env and type, since both
1235-
// may have infer regions. Specifically, after canonicalizing and instantiating,
1236-
// early bound regions turn into region vars in both the new and old solver.
1237-
let key = self.infcx.pseudo_canonicalize_query(
1238-
tcx.erase_regions(obligation.param_env),
1239-
tcx.erase_regions(self_ty),
1240-
);
1241-
if let Ok(layout) = tcx.layout_of(key)
1242-
&& layout.layout.is_pointer_like(&tcx.data_layout)
1243-
{
1244-
candidates.vec.push(BuiltinCandidate { has_nested: false });
1245-
}
1246-
}
1247-
12481217
fn assemble_candidates_for_fn_ptr_trait(
12491218
&mut self,
12501219
obligation: &PolyTraitObligation<'tcx>,

compiler/rustc_type_ir/src/interner.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::lang_items::TraitSolverLangItem;
1313
use crate::relate::Relate;
1414
use crate::solve::{CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult};
1515
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
16-
use crate::{self as ty, TypingMode, search_graph};
16+
use crate::{self as ty, search_graph};
1717

1818
pub trait Interner:
1919
Sized
@@ -278,13 +278,6 @@ pub trait Interner:
278278
fn coroutine_is_gen(self, coroutine_def_id: Self::DefId) -> bool;
279279
fn coroutine_is_async_gen(self, coroutine_def_id: Self::DefId) -> bool;
280280

281-
fn layout_is_pointer_like(
282-
self,
283-
typing_mode: TypingMode<Self>,
284-
param_env: Self::ParamEnv,
285-
ty: Self::Ty,
286-
) -> bool;
287-
288281
type UnsizingParams: Deref<Target = BitSet<u32>>;
289282
fn unsizing_params_for_adt(self, adt_def_id: Self::DefId) -> Self::UnsizingParams;
290283

compiler/rustc_type_ir/src/lang_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub enum TraitSolverLangItem {
3131
Metadata,
3232
Option,
3333
PointeeTrait,
34-
PointerLike,
3534
Poll,
3635
Sized,
3736
TransmuteTrait,

0 commit comments

Comments
 (0)