mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Fix some TODOs
This commit is contained in:
parent
e82db89b4d
commit
a2fb2ebc17
@ -368,6 +368,14 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn root_ty_var(&self, var: TyVid) -> TyVid {
|
||||
self.root_var(var)
|
||||
}
|
||||
|
||||
fn root_const_var(&self, var: ConstVid) -> ConstVid {
|
||||
self.root_const_var(var)
|
||||
}
|
||||
|
||||
fn opportunistic_resolve_ty_var(&self, vid: TyVid) -> Ty<'tcx> {
|
||||
match self.probe_ty_var(vid) {
|
||||
Ok(ty) => ty,
|
||||
|
@ -324,12 +324,20 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Abi<TyCtxt<'tcx>> for abi::Abi {
|
||||
fn rust() -> Self {
|
||||
abi::Abi::Rust
|
||||
}
|
||||
|
||||
fn is_rust(self) -> bool {
|
||||
matches!(self, abi::Abi::Rust)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Safety<TyCtxt<'tcx>> for hir::Safety {
|
||||
fn safe() -> Self {
|
||||
hir::Safety::Safe
|
||||
}
|
||||
|
||||
fn is_safe(self) -> bool {
|
||||
matches!(self, hir::Safety::Safe)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ use rustc_span::DUMMY_SP;
|
||||
use rustc_type_ir::fold::TypeSuperFoldable;
|
||||
use rustc_type_ir::inherent::*;
|
||||
use rustc_type_ir::relate::Relate;
|
||||
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
||||
use rustc_type_ir::{self as ir, CanonicalVarValues, Interner};
|
||||
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
|
||||
use std::ops::ControlFlow;
|
||||
@ -634,7 +635,6 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> EvalCtxt<'_, Infcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO:
|
||||
/// Is the projection predicate is of the form `exists<T> <Ty as Trait>::Assoc = T`.
|
||||
///
|
||||
/// This is the case if the `term` does not occur in any other part of the predicate
|
||||
@ -685,8 +685,8 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> EvalCtxt<'_, Infcx> {
|
||||
match t.kind() {
|
||||
ir::Infer(ir::TyVar(vid)) => {
|
||||
if let ir::TermKind::Ty(term) = self.term.kind()
|
||||
&& let Some(term_vid) = term.ty_vid()
|
||||
&& self.infcx.root_var(vid) == self.infcx.root_var(term_vid)
|
||||
&& let ir::Infer(ir::TyVar(term_vid)) = term.kind()
|
||||
&& self.infcx.root_ty_var(vid) == self.infcx.root_ty_var(term_vid)
|
||||
{
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
@ -736,7 +736,6 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> EvalCtxt<'_, Infcx> {
|
||||
goal.predicate.alias.visit_with(&mut visitor).is_continue()
|
||||
&& goal.param_env.visit_with(&mut visitor).is_continue()
|
||||
}
|
||||
*/
|
||||
|
||||
#[instrument(level = "trace", skip(self, param_env), ret)]
|
||||
pub(super) fn eq<T: Relate<I>>(
|
||||
|
@ -31,7 +31,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
||||
goal: Goal<'tcx, NormalizesTo<'tcx>>,
|
||||
) -> QueryResult<'tcx> {
|
||||
self.set_is_normalizes_to_goal();
|
||||
// debug_assert!(self.term_is_fully_unconstrained(goal)); TODO:
|
||||
debug_assert!(self.term_is_fully_unconstrained(goal));
|
||||
let normalize_result = self
|
||||
.probe(|&result| ProbeKind::TryNormalizeNonRigid { result })
|
||||
.enter(|this| this.normalize_at_least_one_step(goal));
|
||||
|
@ -12,6 +12,9 @@ pub trait InferCtxtLike: Sized {
|
||||
fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex>;
|
||||
fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex>;
|
||||
|
||||
fn root_ty_var(&self, var: ty::TyVid) -> ty::TyVid;
|
||||
fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid;
|
||||
|
||||
fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> <Self::Interner as Interner>::Ty;
|
||||
fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> <Self::Interner as Interner>::Ty;
|
||||
fn opportunistic_resolve_float_var(
|
||||
|
@ -111,7 +111,19 @@ pub trait Ty<I: Interner<Ty = Self>>:
|
||||
match self.kind() {
|
||||
ty::FnPtr(sig) => sig,
|
||||
ty::FnDef(def_id, args) => interner.fn_sig(def_id).instantiate(interner, &args),
|
||||
_ => todo!("TODO:"),
|
||||
ty::Error(_) => {
|
||||
// ignore errors (#54954)
|
||||
ty::Binder::dummy(ty::FnSig {
|
||||
inputs_and_output: Default::default(),
|
||||
c_variadic: false,
|
||||
safety: I::Safety::safe(),
|
||||
abi: I::Abi::rust(),
|
||||
})
|
||||
}
|
||||
ty::Closure(..) => panic!(
|
||||
"to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
|
||||
),
|
||||
_ => panic!("Ty::fn_sig() called on non-fn type: {:?}", self),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,12 +141,16 @@ pub trait Tys<I: Interner<Tys = Self>>:
|
||||
fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty);
|
||||
}
|
||||
|
||||
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq + TypeVisitable<I> {
|
||||
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
|
||||
fn rust() -> Self;
|
||||
|
||||
/// Whether this ABI is `extern "Rust"`.
|
||||
fn is_rust(self) -> bool;
|
||||
}
|
||||
|
||||
pub trait Safety<I: Interner<Safety = Self>>: Copy + Debug + Hash + Eq + TypeVisitable<I> {
|
||||
pub trait Safety<I: Interner<Safety = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
|
||||
fn safe() -> Self;
|
||||
|
||||
fn is_safe(self) -> bool;
|
||||
|
||||
fn prefix_str(self) -> &'static str;
|
||||
|
@ -72,8 +72,8 @@ pub trait Interner:
|
||||
+ IntoIterator<Item = ty::Binder<Self, ty::ExistentialPredicate<Self>>>;
|
||||
type AllocId: Copy + Debug + Hash + Eq;
|
||||
type Pat: Copy + Debug + Hash + Eq + Debug + Relate<Self>;
|
||||
type Safety: Safety<Self> + TypeFoldable<Self> + Relate<Self>;
|
||||
type Abi: Abi<Self> + TypeFoldable<Self> + Relate<Self>;
|
||||
type Safety: Safety<Self>;
|
||||
type Abi: Abi<Self>;
|
||||
|
||||
// Kinds of consts
|
||||
type Const: Const<Self>;
|
||||
|
Loading…
Reference in New Issue
Block a user