mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 14:23:45 +00:00
Rip out built-in PointerLike impl
This commit is contained in:
parent
bfe809d93c
commit
06e66d78c3
@ -602,19 +602,6 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||||||
self.coroutine_is_async_gen(coroutine_def_id)
|
self.coroutine_is_async_gen(coroutine_def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't use `TypingEnv` here as it's only defined in `rustc_middle` and
|
|
||||||
// `rustc_next_trait_solver` shouldn't have to know about it.
|
|
||||||
fn layout_is_pointer_like(
|
|
||||||
self,
|
|
||||||
typing_mode: ty::TypingMode<'tcx>,
|
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
|
||||||
ty: Ty<'tcx>,
|
|
||||||
) -> bool {
|
|
||||||
let typing_env = ty::TypingEnv { typing_mode, param_env };
|
|
||||||
self.layout_of(self.erase_regions(typing_env).as_query_input(self.erase_regions(ty)))
|
|
||||||
.is_ok_and(|layout| layout.layout.is_pointer_like(&self.data_layout))
|
|
||||||
}
|
|
||||||
|
|
||||||
type UnsizingParams = &'tcx rustc_index::bit_set::BitSet<u32>;
|
type UnsizingParams = &'tcx rustc_index::bit_set::BitSet<u32>;
|
||||||
fn unsizing_params_for_adt(self, adt_def_id: DefId) -> Self::UnsizingParams {
|
fn unsizing_params_for_adt(self, adt_def_id: DefId) -> Self::UnsizingParams {
|
||||||
self.unsizing_params_for_adt(adt_def_id)
|
self.unsizing_params_for_adt(adt_def_id)
|
||||||
@ -688,7 +675,6 @@ bidirectional_lang_item_map! {
|
|||||||
Metadata,
|
Metadata,
|
||||||
Option,
|
Option,
|
||||||
PointeeTrait,
|
PointeeTrait,
|
||||||
PointerLike,
|
|
||||||
Poll,
|
Poll,
|
||||||
Sized,
|
Sized,
|
||||||
TransmuteTrait,
|
TransmuteTrait,
|
||||||
|
@ -159,13 +159,6 @@ where
|
|||||||
goal: Goal<I, Self>,
|
goal: Goal<I, Self>,
|
||||||
) -> Result<Candidate<I>, NoSolution>;
|
) -> Result<Candidate<I>, NoSolution>;
|
||||||
|
|
||||||
/// A type is `PointerLike` if we can compute its layout, and that layout
|
|
||||||
/// matches the layout of `usize`.
|
|
||||||
fn consider_builtin_pointer_like_candidate(
|
|
||||||
ecx: &mut EvalCtxt<'_, D>,
|
|
||||||
goal: Goal<I, Self>,
|
|
||||||
) -> Result<Candidate<I>, NoSolution>;
|
|
||||||
|
|
||||||
/// A type is a `FnPtr` if it is of `FnPtr` type.
|
/// A type is a `FnPtr` if it is of `FnPtr` type.
|
||||||
fn consider_builtin_fn_ptr_trait_candidate(
|
fn consider_builtin_fn_ptr_trait_candidate(
|
||||||
ecx: &mut EvalCtxt<'_, D>,
|
ecx: &mut EvalCtxt<'_, D>,
|
||||||
@ -449,9 +442,6 @@ where
|
|||||||
ty::ClosureKind::FnOnce,
|
ty::ClosureKind::FnOnce,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Some(TraitSolverLangItem::PointerLike) => {
|
|
||||||
G::consider_builtin_pointer_like_candidate(self, goal)
|
|
||||||
}
|
|
||||||
Some(TraitSolverLangItem::FnPtrTrait) => {
|
Some(TraitSolverLangItem::FnPtrTrait) => {
|
||||||
G::consider_builtin_fn_ptr_trait_candidate(self, goal)
|
G::consider_builtin_fn_ptr_trait_candidate(self, goal)
|
||||||
}
|
}
|
||||||
|
@ -210,13 +210,6 @@ where
|
|||||||
Err(NoSolution)
|
Err(NoSolution)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consider_builtin_pointer_like_candidate(
|
|
||||||
_ecx: &mut EvalCtxt<'_, D>,
|
|
||||||
_goal: Goal<I, Self>,
|
|
||||||
) -> Result<Candidate<I>, NoSolution> {
|
|
||||||
unreachable!("PointerLike is not const")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn consider_builtin_fn_ptr_trait_candidate(
|
fn consider_builtin_fn_ptr_trait_candidate(
|
||||||
_ecx: &mut EvalCtxt<'_, D>,
|
_ecx: &mut EvalCtxt<'_, D>,
|
||||||
_goal: Goal<I, Self>,
|
_goal: Goal<I, Self>,
|
||||||
|
@ -363,13 +363,6 @@ where
|
|||||||
panic!("`Copy`/`Clone` does not have an associated type: {:?}", goal);
|
panic!("`Copy`/`Clone` does not have an associated type: {:?}", goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consider_builtin_pointer_like_candidate(
|
|
||||||
_ecx: &mut EvalCtxt<'_, D>,
|
|
||||||
goal: Goal<I, Self>,
|
|
||||||
) -> Result<Candidate<I>, NoSolution> {
|
|
||||||
panic!("`PointerLike` does not have an associated type: {:?}", goal);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn consider_builtin_fn_ptr_trait_candidate(
|
fn consider_builtin_fn_ptr_trait_candidate(
|
||||||
_ecx: &mut EvalCtxt<'_, D>,
|
_ecx: &mut EvalCtxt<'_, D>,
|
||||||
goal: Goal<I, Self>,
|
goal: Goal<I, Self>,
|
||||||
|
@ -248,32 +248,6 @@ where
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consider_builtin_pointer_like_candidate(
|
|
||||||
ecx: &mut EvalCtxt<'_, D>,
|
|
||||||
goal: Goal<I, Self>,
|
|
||||||
) -> Result<Candidate<I>, NoSolution> {
|
|
||||||
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
|
|
||||||
return Err(NoSolution);
|
|
||||||
}
|
|
||||||
|
|
||||||
let cx = ecx.cx();
|
|
||||||
// But if there are inference variables, we have to wait until it's resolved.
|
|
||||||
if (goal.param_env, goal.predicate.self_ty()).has_non_region_infer() {
|
|
||||||
return ecx.forced_ambiguity(MaybeCause::Ambiguity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if cx.layout_is_pointer_like(
|
|
||||||
ecx.typing_mode(goal.param_env),
|
|
||||||
goal.param_env,
|
|
||||||
goal.predicate.self_ty(),
|
|
||||||
) {
|
|
||||||
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc)
|
|
||||||
.enter(|ecx| ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes))
|
|
||||||
} else {
|
|
||||||
Err(NoSolution)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn consider_builtin_fn_ptr_trait_candidate(
|
fn consider_builtin_fn_ptr_trait_candidate(
|
||||||
ecx: &mut EvalCtxt<'_, D>,
|
ecx: &mut EvalCtxt<'_, D>,
|
||||||
goal: Goal<I, Self>,
|
goal: Goal<I, Self>,
|
||||||
|
@ -111,8 +111,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
self.assemble_candidates_for_transmutability(obligation, &mut candidates);
|
self.assemble_candidates_for_transmutability(obligation, &mut candidates);
|
||||||
} else if tcx.is_lang_item(def_id, LangItem::Tuple) {
|
} else if tcx.is_lang_item(def_id, LangItem::Tuple) {
|
||||||
self.assemble_candidate_for_tuple(obligation, &mut candidates);
|
self.assemble_candidate_for_tuple(obligation, &mut candidates);
|
||||||
} else if tcx.is_lang_item(def_id, LangItem::PointerLike) {
|
|
||||||
self.assemble_candidate_for_pointer_like(obligation, &mut candidates);
|
|
||||||
} else if tcx.is_lang_item(def_id, LangItem::FnPtrTrait) {
|
} else if tcx.is_lang_item(def_id, LangItem::FnPtrTrait) {
|
||||||
self.assemble_candidates_for_fn_ptr_trait(obligation, &mut candidates);
|
self.assemble_candidates_for_fn_ptr_trait(obligation, &mut candidates);
|
||||||
} else {
|
} else {
|
||||||
@ -1216,35 +1214,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assemble_candidate_for_pointer_like(
|
|
||||||
&mut self,
|
|
||||||
obligation: &PolyTraitObligation<'tcx>,
|
|
||||||
candidates: &mut SelectionCandidateSet<'tcx>,
|
|
||||||
) {
|
|
||||||
// The regions of a type don't affect the size of the type
|
|
||||||
let tcx = self.tcx();
|
|
||||||
let self_ty = tcx.instantiate_bound_regions_with_erased(obligation.predicate.self_ty());
|
|
||||||
|
|
||||||
// But if there are inference variables, we have to wait until it's resolved.
|
|
||||||
if (obligation.param_env, self_ty).has_non_region_infer() {
|
|
||||||
candidates.ambiguous = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We should erase regions from both the param-env and type, since both
|
|
||||||
// may have infer regions. Specifically, after canonicalizing and instantiating,
|
|
||||||
// early bound regions turn into region vars in both the new and old solver.
|
|
||||||
let key = self.infcx.pseudo_canonicalize_query(
|
|
||||||
tcx.erase_regions(obligation.param_env),
|
|
||||||
tcx.erase_regions(self_ty),
|
|
||||||
);
|
|
||||||
if let Ok(layout) = tcx.layout_of(key)
|
|
||||||
&& layout.layout.is_pointer_like(&tcx.data_layout)
|
|
||||||
{
|
|
||||||
candidates.vec.push(BuiltinCandidate { has_nested: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn assemble_candidates_for_fn_ptr_trait(
|
fn assemble_candidates_for_fn_ptr_trait(
|
||||||
&mut self,
|
&mut self,
|
||||||
obligation: &PolyTraitObligation<'tcx>,
|
obligation: &PolyTraitObligation<'tcx>,
|
||||||
|
@ -13,7 +13,7 @@ use crate::lang_items::TraitSolverLangItem;
|
|||||||
use crate::relate::Relate;
|
use crate::relate::Relate;
|
||||||
use crate::solve::{CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult};
|
use crate::solve::{CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult};
|
||||||
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
|
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
|
||||||
use crate::{self as ty, TypingMode, search_graph};
|
use crate::{self as ty, search_graph};
|
||||||
|
|
||||||
pub trait Interner:
|
pub trait Interner:
|
||||||
Sized
|
Sized
|
||||||
@ -278,13 +278,6 @@ pub trait Interner:
|
|||||||
fn coroutine_is_gen(self, coroutine_def_id: Self::DefId) -> bool;
|
fn coroutine_is_gen(self, coroutine_def_id: Self::DefId) -> bool;
|
||||||
fn coroutine_is_async_gen(self, coroutine_def_id: Self::DefId) -> bool;
|
fn coroutine_is_async_gen(self, coroutine_def_id: Self::DefId) -> bool;
|
||||||
|
|
||||||
fn layout_is_pointer_like(
|
|
||||||
self,
|
|
||||||
typing_mode: TypingMode<Self>,
|
|
||||||
param_env: Self::ParamEnv,
|
|
||||||
ty: Self::Ty,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
type UnsizingParams: Deref<Target = BitSet<u32>>;
|
type UnsizingParams: Deref<Target = BitSet<u32>>;
|
||||||
fn unsizing_params_for_adt(self, adt_def_id: Self::DefId) -> Self::UnsizingParams;
|
fn unsizing_params_for_adt(self, adt_def_id: Self::DefId) -> Self::UnsizingParams;
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ pub enum TraitSolverLangItem {
|
|||||||
Metadata,
|
Metadata,
|
||||||
Option,
|
Option,
|
||||||
PointeeTrait,
|
PointeeTrait,
|
||||||
PointerLike,
|
|
||||||
Poll,
|
Poll,
|
||||||
Sized,
|
Sized,
|
||||||
TransmuteTrait,
|
TransmuteTrait,
|
||||||
|
Loading…
Reference in New Issue
Block a user