@@ -22,8 +22,8 @@ use rustc_type_ir::inherent::{
22
22
use rustc_type_ir:: lang_items:: TraitSolverLangItem ;
23
23
use rustc_type_ir:: solve:: SizedTraitKind ;
24
24
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 ,
27
27
} ;
28
28
use salsa:: plumbing:: AsId ;
29
29
use smallvec:: { SmallVec , smallvec} ;
@@ -1024,8 +1024,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1024
1024
false
1025
1025
}
1026
1026
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" ) ;
1029
1029
}
1030
1030
1031
1031
fn generics_of ( self , def_id : Self :: DefId ) -> Self :: GenericsOf {
@@ -1054,6 +1054,9 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1054
1054
) ,
1055
1055
SolverDefId :: InternedOpaqueTyId ( _def_id) => {
1056
1056
// 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.
1057
1060
VariancesOf :: new_from_iter (
1058
1061
self ,
1059
1062
( 0 ..self . generics_of ( def_id) . count ( ) ) . map ( |_| Variance :: Invariant ) ,
@@ -1074,6 +1077,9 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1074
1077
crate :: TyDefId :: TypeAliasId ( id)
1075
1078
}
1076
1079
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.
1077
1083
_ => panic ! ( "Unexpected def_id `{def_id:?}` provided for `type_of`" ) ,
1078
1084
} ;
1079
1085
self . db ( ) . ty_ns ( def_id)
@@ -1087,9 +1093,12 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1087
1093
AdtDef :: new ( def_id, self )
1088
1094
}
1089
1095
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
+ }
1093
1102
}
1094
1103
1095
1104
fn alias_term_kind (
@@ -1100,7 +1109,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1100
1109
SolverDefId :: InternedOpaqueTyId ( _) => AliasTermKind :: OpaqueTy ,
1101
1110
SolverDefId :: TypeAliasId ( _) => AliasTermKind :: ProjectionTy ,
1102
1111
SolverDefId :: ConstId ( _) => AliasTermKind :: UnevaluatedConst ,
1103
- _ => unreachable ! ( "Unexpected alias: {:?}" , alias. def_id) ,
1112
+ _ => todo ! ( "Unexpected alias: {:?}" , alias. def_id) ,
1104
1113
}
1105
1114
}
1106
1115
@@ -1741,7 +1750,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1741
1750
}
1742
1751
1743
1752
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.
1745
1754
true
1746
1755
}
1747
1756
@@ -1811,7 +1820,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1811
1820
}
1812
1821
1813
1822
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
1815
1825
true
1816
1826
}
1817
1827
@@ -1982,7 +1992,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1982
1992
self ,
1983
1993
def_id : Self :: LocalDefId ,
1984
1994
) -> 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.
1986
1997
unimplemented ! ( )
1987
1998
}
1988
1999
0 commit comments