Skip to content

Commit f228c58

Browse files
committed
update a few fixmes, and one trivial improvement
1 parent a9450eb commit f228c58

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

crates/hir-ty/src/next_solver/interner.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use rustc_type_ir::inherent::{
2222
use rustc_type_ir::lang_items::TraitSolverLangItem;
2323
use rustc_type_ir::solve::SizedTraitKind;
2424
use rustc_type_ir::{
25-
AliasTerm, AliasTermKind, AliasTy, EarlyBinder, FlagComputation, Flags, ImplPolarity, InferTy,
26-
ProjectionPredicate, TraitPredicate, TraitRef, Upcast,
25+
AliasTerm, AliasTermKind, AliasTy, AliasTyKind, EarlyBinder, FlagComputation, Flags,
26+
ImplPolarity, InferTy, ProjectionPredicate, TraitPredicate, TraitRef, Upcast,
2727
};
2828
use salsa::plumbing::AsId;
2929
use smallvec::{SmallVec, smallvec};
@@ -1024,8 +1024,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
10241024
false
10251025
}
10261026

1027-
fn expand_abstract_consts<T: rustc_type_ir::TypeFoldable<Self>>(self, t: T) -> T {
1028-
t
1027+
fn expand_abstract_consts<T: rustc_type_ir::TypeFoldable<Self>>(self, _: T) -> T {
1028+
unreachable!("only used by the old trait solver in rustc");
10291029
}
10301030

10311031
fn generics_of(self, def_id: Self::DefId) -> Self::GenericsOf {
@@ -1054,6 +1054,9 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
10541054
),
10551055
SolverDefId::InternedOpaqueTyId(_def_id) => {
10561056
// FIXME(next-solver): track variances
1057+
//
1058+
// We compute them based on the only `Ty` level info in rustc,
1059+
// move `variances_of_opaque` into `rustc_next_trait_solver` for reuse.
10571060
VariancesOf::new_from_iter(
10581061
self,
10591062
(0..self.generics_of(def_id).count()).map(|_| Variance::Invariant),
@@ -1074,6 +1077,9 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
10741077
crate::TyDefId::TypeAliasId(id)
10751078
}
10761079
SolverDefId::AdtId(id) => crate::TyDefId::AdtId(id),
1080+
// FIXME(next-solver): need to support opaque types. This uses the types of
1081+
// `query mir_borrowck` in rustc. If we're ignoring regions, we could simply
1082+
// use the type inferred by general type inference here.
10771083
_ => panic!("Unexpected def_id `{def_id:?}` provided for `type_of`"),
10781084
};
10791085
self.db().ty_ns(def_id)
@@ -1087,9 +1093,12 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
10871093
AdtDef::new(def_id, self)
10881094
}
10891095

1090-
fn alias_ty_kind(self, alias: rustc_type_ir::AliasTy<Self>) -> rustc_type_ir::AliasTyKind {
1091-
// FIXME: not currently creating any others
1092-
rustc_type_ir::AliasTyKind::Projection
1096+
fn alias_ty_kind(self, alias: rustc_type_ir::AliasTy<Self>) -> AliasTyKind {
1097+
match alias.def_id {
1098+
SolverDefId::InternedOpaqueTyId(_) => AliasTyKind::Opaque,
1099+
SolverDefId::TypeAliasId(_) => AliasTyKind::Projection,
1100+
_ => unimplemented!("Unexpected alias: {:?}", alias.def_id),
1101+
}
10931102
}
10941103

10951104
fn alias_term_kind(
@@ -1100,7 +1109,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
11001109
SolverDefId::InternedOpaqueTyId(_) => AliasTermKind::OpaqueTy,
11011110
SolverDefId::TypeAliasId(_) => AliasTermKind::ProjectionTy,
11021111
SolverDefId::ConstId(_) => AliasTermKind::UnevaluatedConst,
1103-
_ => unreachable!("Unexpected alias: {:?}", alias.def_id),
1112+
_ => todo!("Unexpected alias: {:?}", alias.def_id),
11041113
}
11051114
}
11061115

@@ -1741,7 +1750,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
17411750
}
17421751

17431752
fn has_item_definition(self, def_id: Self::DefId) -> bool {
1744-
// FIXME: should check if has value
1753+
// FIXME(next-solver): should check if the associated item has a value.
17451754
true
17461755
}
17471756

@@ -1811,7 +1820,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
18111820
}
18121821

18131822
fn trait_may_be_implemented_via_object(self, trait_def_id: Self::DefId) -> bool {
1814-
// FIXME(next-solver)
1823+
// FIXME(next-solver): should check the `TraitFlags` for
1824+
// the `#[rustc_do_not_implement_via_object]` flag
18151825
true
18161826
}
18171827

@@ -1982,7 +1992,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
19821992
self,
19831993
def_id: Self::LocalDefId,
19841994
) -> rustc_type_ir::EarlyBinder<Self, Self::Ty> {
1985-
// FIXME(next-solver)
1995+
// FIXME(next-solver): This should look at the type computed for the
1996+
// opaque by HIR typeck.
19861997
unimplemented!()
19871998
}
19881999

0 commit comments

Comments
 (0)