Skip to content

Commit 130a0ff

Browse files
Fix some TODOs
1 parent 47974c6 commit 130a0ff

File tree

7 files changed

+44
-10
lines changed

7 files changed

+44
-10
lines changed

Diff for: compiler/rustc_infer/src/infer/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@ impl<'tcx> ty::InferCtxtLike for InferCtxt<'tcx> {
368368
}
369369
}
370370

371+
fn root_ty_var(&self, var: TyVid) -> TyVid {
372+
self.root_var(var)
373+
}
374+
375+
fn root_const_var(&self, var: ConstVid) -> ConstVid {
376+
self.root_const_var(var)
377+
}
378+
371379
fn opportunistic_resolve_ty_var(&self, vid: TyVid) -> Ty<'tcx> {
372380
match self.probe_ty_var(vid) {
373381
Ok(ty) => ty,

Diff for: compiler/rustc_middle/src/ty/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,20 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
324324
}
325325

326326
impl<'tcx> rustc_type_ir::inherent::Abi<TyCtxt<'tcx>> for abi::Abi {
327+
fn rust() -> Self {
328+
abi::Abi::Rust
329+
}
330+
327331
fn is_rust(self) -> bool {
328332
matches!(self, abi::Abi::Rust)
329333
}
330334
}
331335

332336
impl<'tcx> rustc_type_ir::inherent::Safety<TyCtxt<'tcx>> for hir::Safety {
337+
fn safe() -> Self {
338+
hir::Safety::Safe
339+
}
340+
333341
fn is_safe(self) -> bool {
334342
matches!(self, hir::Safety::Safe)
335343
}

Diff for: compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_span::DUMMY_SP;
1818
use rustc_type_ir::fold::TypeSuperFoldable;
1919
use rustc_type_ir::inherent::*;
2020
use rustc_type_ir::relate::Relate;
21+
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
2122
use rustc_type_ir::{self as ir, CanonicalVarValues, Interner};
2223
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
2324
use std::ops::ControlFlow;
@@ -634,7 +635,6 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> EvalCtxt<'_, Infcx> {
634635
}
635636
}
636637

637-
/* TODO:
638638
/// Is the projection predicate is of the form `exists<T> <Ty as Trait>::Assoc = T`.
639639
///
640640
/// 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> {
685685
match t.kind() {
686686
ir::Infer(ir::TyVar(vid)) => {
687687
if let ir::TermKind::Ty(term) = self.term.kind()
688-
&& let Some(term_vid) = term.ty_vid()
689-
&& self.infcx.root_var(vid) == self.infcx.root_var(term_vid)
688+
&& let ir::Infer(ir::TyVar(term_vid)) = term.kind()
689+
&& self.infcx.root_ty_var(vid) == self.infcx.root_ty_var(term_vid)
690690
{
691691
ControlFlow::Break(())
692692
} else {
@@ -736,7 +736,6 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> EvalCtxt<'_, Infcx> {
736736
goal.predicate.alias.visit_with(&mut visitor).is_continue()
737737
&& goal.param_env.visit_with(&mut visitor).is_continue()
738738
}
739-
*/
740739

741740
#[instrument(level = "trace", skip(self, param_env), ret)]
742741
pub(super) fn eq<T: Relate<I>>(

Diff for: compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
3131
goal: Goal<'tcx, NormalizesTo<'tcx>>,
3232
) -> QueryResult<'tcx> {
3333
self.set_is_normalizes_to_goal();
34-
// debug_assert!(self.term_is_fully_unconstrained(goal)); TODO:
34+
debug_assert!(self.term_is_fully_unconstrained(goal));
3535
let normalize_result = self
3636
.probe(|&result| ProbeKind::TryNormalizeNonRigid { result })
3737
.enter(|this| this.normalize_at_least_one_step(goal));

Diff for: compiler/rustc_type_ir/src/infcx.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ pub trait InferCtxtLike: Sized {
1212
fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex>;
1313
fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex>;
1414

15+
fn root_ty_var(&self, var: ty::TyVid) -> ty::TyVid;
16+
fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid;
17+
1518
fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> <Self::Interner as Interner>::Ty;
1619
fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> <Self::Interner as Interner>::Ty;
1720
fn opportunistic_resolve_float_var(

Diff for: compiler/rustc_type_ir/src/inherent.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,19 @@ pub trait Ty<I: Interner<Ty = Self>>:
111111
match self.kind() {
112112
ty::FnPtr(sig) => sig,
113113
ty::FnDef(def_id, args) => interner.fn_sig(def_id).instantiate(interner, &args),
114-
_ => todo!("TODO:"),
114+
ty::Error(_) => {
115+
// ignore errors (#54954)
116+
ty::Binder::dummy(ty::FnSig {
117+
inputs_and_output: Default::default(),
118+
c_variadic: false,
119+
safety: I::Safety::safe(),
120+
abi: I::Abi::rust(),
121+
})
122+
}
123+
ty::Closure(..) => panic!(
124+
"to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
125+
),
126+
_ => panic!("Ty::fn_sig() called on non-fn type: {:?}", self),
115127
}
116128
}
117129
}
@@ -129,12 +141,16 @@ pub trait Tys<I: Interner<Tys = Self>>:
129141
fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty);
130142
}
131143

132-
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq + TypeVisitable<I> {
144+
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
145+
fn rust() -> Self;
146+
133147
/// Whether this ABI is `extern "Rust"`.
134148
fn is_rust(self) -> bool;
135149
}
136150

137-
pub trait Safety<I: Interner<Safety = Self>>: Copy + Debug + Hash + Eq + TypeVisitable<I> {
151+
pub trait Safety<I: Interner<Safety = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
152+
fn safe() -> Self;
153+
138154
fn is_safe(self) -> bool;
139155

140156
fn prefix_str(self) -> &'static str;

Diff for: compiler/rustc_type_ir/src/interner.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub trait Interner:
7272
+ IntoIterator<Item = ty::Binder<Self, ty::ExistentialPredicate<Self>>>;
7373
type AllocId: Copy + Debug + Hash + Eq;
7474
type Pat: Copy + Debug + Hash + Eq + Debug + Relate<Self>;
75-
type Safety: Safety<Self> + TypeFoldable<Self> + Relate<Self>;
76-
type Abi: Abi<Self> + TypeFoldable<Self> + Relate<Self>;
75+
type Safety: Safety<Self>;
76+
type Abi: Abi<Self>;
7777

7878
// Kinds of consts
7979
type Const: Const<Self>;

0 commit comments

Comments
 (0)