@@ -626,12 +626,8 @@ impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef {
626
626
fn struct_tail_ty (
627
627
self ,
628
628
interner : DbInterner < ' db > ,
629
- ) -> Option <
630
- rustc_type_ir:: EarlyBinder <
631
- DbInterner < ' db > ,
632
- <DbInterner < ' db > as rustc_type_ir:: Interner >:: Ty ,
633
- > ,
634
- > {
629
+ ) -> Option < EarlyBinder < DbInterner < ' db > , <DbInterner < ' db > as rustc_type_ir:: Interner >:: Ty > >
630
+ {
635
631
let db = interner. db ( ) ;
636
632
let hir_def:: AdtId :: StructId ( struct_id) = self . inner ( ) . id else {
637
633
return None ;
@@ -645,7 +641,7 @@ impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef {
645
641
fn all_field_tys (
646
642
self ,
647
643
interner : DbInterner < ' db > ,
648
- ) -> rustc_type_ir :: EarlyBinder <
644
+ ) -> EarlyBinder <
649
645
DbInterner < ' db > ,
650
646
impl IntoIterator < Item = <DbInterner < ' db > as rustc_type_ir:: Interner >:: Ty > ,
651
647
> {
@@ -679,19 +675,15 @@ impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef {
679
675
. collect ( ) ,
680
676
} ;
681
677
682
- rustc_type_ir :: EarlyBinder :: bind ( tys)
678
+ EarlyBinder :: bind ( tys)
683
679
}
684
680
685
681
fn sizedness_constraint (
686
682
self ,
687
683
interner : DbInterner < ' db > ,
688
684
sizedness : SizedTraitKind ,
689
- ) -> Option <
690
- rustc_type_ir:: EarlyBinder <
691
- DbInterner < ' db > ,
692
- <DbInterner < ' db > as rustc_type_ir:: Interner >:: Ty ,
693
- > ,
694
- > {
685
+ ) -> Option < EarlyBinder < DbInterner < ' db > , <DbInterner < ' db > as rustc_type_ir:: Interner >:: Ty > >
686
+ {
695
687
if self . is_struct ( ) {
696
688
let tail_ty = self . all_field_tys ( interner) . skip_binder ( ) . into_iter ( ) . last ( ) ?;
697
689
@@ -1066,7 +1058,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1066
1058
}
1067
1059
}
1068
1060
1069
- fn type_of ( self , def_id : Self :: DefId ) -> rustc_type_ir :: EarlyBinder < Self , Self :: Ty > {
1061
+ fn type_of ( self , def_id : Self :: DefId ) -> EarlyBinder < Self , Self :: Ty > {
1070
1062
let def_id = match def_id {
1071
1063
SolverDefId :: TypeAliasId ( id) => {
1072
1064
use hir_def:: Lookup ;
@@ -1077,9 +1069,13 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1077
1069
crate :: TyDefId :: TypeAliasId ( id)
1078
1070
}
1079
1071
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.
1072
+ // FIXME(next-solver): This uses the types of `query mir_borrowck` in rustc.
1073
+ //
1074
+ // We currently always use the type from HIR typeck which ignores regions. This
1075
+ // should be fine.
1076
+ SolverDefId :: InternedOpaqueTyId ( _) => {
1077
+ return self . type_of_opaque_hir_typeck ( def_id) ;
1078
+ }
1083
1079
_ => panic ! ( "Unexpected def_id `{def_id:?}` provided for `type_of`" ) ,
1084
1080
} ;
1085
1081
self . db ( ) . ty_ns ( def_id)
@@ -1109,7 +1105,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1109
1105
SolverDefId :: InternedOpaqueTyId ( _) => AliasTermKind :: OpaqueTy ,
1110
1106
SolverDefId :: TypeAliasId ( _) => AliasTermKind :: ProjectionTy ,
1111
1107
SolverDefId :: ConstId ( _) => AliasTermKind :: UnevaluatedConst ,
1112
- _ => todo ! ( "Unexpected alias: {:?}" , alias. def_id) ,
1108
+ _ => unimplemented ! ( "Unexpected alias: {:?}" , alias. def_id) ,
1113
1109
}
1114
1110
}
1115
1111
@@ -1204,8 +1200,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1204
1200
fn fn_sig (
1205
1201
self ,
1206
1202
def_id : Self :: DefId ,
1207
- ) -> rustc_type_ir:: EarlyBinder < Self , rustc_type_ir:: Binder < Self , rustc_type_ir:: FnSig < Self > > >
1208
- {
1203
+ ) -> EarlyBinder < Self , rustc_type_ir:: Binder < Self , rustc_type_ir:: FnSig < Self > > > {
1209
1204
let id = match def_id {
1210
1205
SolverDefId :: FunctionId ( id) => CallableDefId :: FunctionId ( id) ,
1211
1206
SolverDefId :: Ctor ( ctor) => match ctor {
@@ -1258,7 +1253,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1258
1253
fn item_bounds (
1259
1254
self ,
1260
1255
def_id : Self :: DefId ,
1261
- ) -> rustc_type_ir :: EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1256
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1262
1257
explicit_item_bounds ( self , def_id) . map_bound ( |bounds| {
1263
1258
Clauses :: new_from_iter ( self , elaborate ( self , bounds) . collect :: < Vec < _ > > ( ) )
1264
1259
} )
@@ -1268,7 +1263,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1268
1263
fn item_self_bounds (
1269
1264
self ,
1270
1265
def_id : Self :: DefId ,
1271
- ) -> rustc_type_ir :: EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1266
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1272
1267
explicit_item_bounds ( self , def_id) . map_bound ( |bounds| {
1273
1268
Clauses :: new_from_iter (
1274
1269
self ,
@@ -1280,7 +1275,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1280
1275
fn item_non_self_bounds (
1281
1276
self ,
1282
1277
def_id : Self :: DefId ,
1283
- ) -> rustc_type_ir :: EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1278
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1284
1279
let all_bounds: FxHashSet < _ > = self . item_bounds ( def_id) . skip_binder ( ) . into_iter ( ) . collect ( ) ;
1285
1280
let own_bounds: FxHashSet < _ > =
1286
1281
self . item_self_bounds ( def_id) . skip_binder ( ) . into_iter ( ) . collect ( ) ;
@@ -1298,7 +1293,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1298
1293
fn predicates_of (
1299
1294
self ,
1300
1295
def_id : Self :: DefId ,
1301
- ) -> rustc_type_ir :: EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1296
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1302
1297
let predicates = self . db ( ) . generic_predicates_ns ( def_id. try_into ( ) . unwrap ( ) ) ;
1303
1298
let predicates: Vec < _ > = predicates. iter ( ) . cloned ( ) . collect ( ) ;
1304
1299
EarlyBinder :: bind ( predicates. into_iter ( ) )
@@ -1308,7 +1303,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1308
1303
fn own_predicates_of (
1309
1304
self ,
1310
1305
def_id : Self :: DefId ,
1311
- ) -> rustc_type_ir :: EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1306
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1312
1307
let predicates = self . db ( ) . generic_predicates_without_parent_ns ( def_id. try_into ( ) . unwrap ( ) ) ;
1313
1308
let predicates: Vec < _ > = predicates. iter ( ) . cloned ( ) . collect ( ) ;
1314
1309
EarlyBinder :: bind ( predicates. into_iter ( ) )
@@ -1318,38 +1313,36 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1318
1313
fn explicit_super_predicates_of (
1319
1314
self ,
1320
1315
def_id : Self :: DefId ,
1321
- ) -> rustc_type_ir:: EarlyBinder < Self , impl IntoIterator < Item = ( Self :: Clause , Self :: Span ) > >
1322
- {
1316
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = ( Self :: Clause , Self :: Span ) > > {
1323
1317
let predicates: Vec < ( Clause < ' db > , Span ) > = self
1324
1318
. db ( )
1325
1319
. generic_predicates_ns ( def_id. try_into ( ) . unwrap ( ) )
1326
1320
. iter ( )
1327
1321
. cloned ( )
1328
1322
. map ( |p| ( p, Span :: dummy ( ) ) )
1329
1323
. collect ( ) ;
1330
- rustc_type_ir :: EarlyBinder :: bind ( predicates)
1324
+ EarlyBinder :: bind ( predicates)
1331
1325
}
1332
1326
1333
1327
#[ tracing:: instrument( skip( self ) , ret) ]
1334
1328
fn explicit_implied_predicates_of (
1335
1329
self ,
1336
1330
def_id : Self :: DefId ,
1337
- ) -> rustc_type_ir:: EarlyBinder < Self , impl IntoIterator < Item = ( Self :: Clause , Self :: Span ) > >
1338
- {
1331
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = ( Self :: Clause , Self :: Span ) > > {
1339
1332
let predicates: Vec < ( Clause < ' db > , Span ) > = self
1340
1333
. db ( )
1341
1334
. generic_predicates_ns ( def_id. try_into ( ) . unwrap ( ) )
1342
1335
. iter ( )
1343
1336
. cloned ( )
1344
1337
. map ( |p| ( p, Span :: dummy ( ) ) )
1345
1338
. collect ( ) ;
1346
- rustc_type_ir :: EarlyBinder :: bind ( predicates)
1339
+ EarlyBinder :: bind ( predicates)
1347
1340
}
1348
1341
1349
1342
fn impl_super_outlives (
1350
1343
self ,
1351
1344
impl_def_id : Self :: DefId ,
1352
- ) -> rustc_type_ir :: EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1345
+ ) -> EarlyBinder < Self , impl IntoIterator < Item = Self :: Clause > > {
1353
1346
let impl_id = match impl_def_id {
1354
1347
SolverDefId :: ImplId ( id) => id,
1355
1348
_ => unreachable ! ( ) ,
@@ -1372,11 +1365,11 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1372
1365
fn const_conditions (
1373
1366
self ,
1374
1367
def_id : Self :: DefId ,
1375
- ) -> rustc_type_ir :: EarlyBinder <
1368
+ ) -> EarlyBinder <
1376
1369
Self ,
1377
1370
impl IntoIterator < Item = rustc_type_ir:: Binder < Self , rustc_type_ir:: TraitRef < Self > > > ,
1378
1371
> {
1379
- rustc_type_ir :: EarlyBinder :: bind ( [ unimplemented ! ( ) ] )
1372
+ EarlyBinder :: bind ( [ unimplemented ! ( ) ] )
1380
1373
}
1381
1374
1382
1375
fn has_target_features ( self , def_id : Self :: DefId ) -> bool {
@@ -1763,7 +1756,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1763
1756
fn impl_trait_ref (
1764
1757
self ,
1765
1758
impl_def_id : Self :: DefId ,
1766
- ) -> rustc_type_ir :: EarlyBinder < Self , rustc_type_ir:: TraitRef < Self > > {
1759
+ ) -> EarlyBinder < Self , rustc_type_ir:: TraitRef < Self > > {
1767
1760
let impl_id = match impl_def_id {
1768
1761
SolverDefId :: ImplId ( id) => id,
1769
1762
_ => panic ! ( "Unexpected SolverDefId in impl_trait_ref" ) ,
@@ -1960,12 +1953,12 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1960
1953
fn explicit_implied_const_bounds (
1961
1954
self ,
1962
1955
def_id : Self :: DefId ,
1963
- ) -> rustc_type_ir :: EarlyBinder <
1956
+ ) -> EarlyBinder <
1964
1957
Self ,
1965
1958
impl IntoIterator < Item = rustc_type_ir:: Binder < Self , rustc_type_ir:: TraitRef < Self > > > ,
1966
1959
> {
1967
1960
// FIXME(next-solver)
1968
- rustc_type_ir :: EarlyBinder :: bind ( [ ] )
1961
+ EarlyBinder :: bind ( [ ] )
1969
1962
}
1970
1963
1971
1964
fn fn_is_const ( self , def_id : Self :: DefId ) -> bool {
@@ -1988,22 +1981,31 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
1988
1981
None
1989
1982
}
1990
1983
1991
- fn type_of_opaque_hir_typeck (
1992
- self ,
1993
- def_id : Self :: LocalDefId ,
1994
- ) -> rustc_type_ir:: EarlyBinder < Self , Self :: Ty > {
1995
- // FIXME(next-solver): This should look at the type computed for the
1996
- // opaque by HIR typeck.
1997
- unimplemented ! ( )
1984
+ fn type_of_opaque_hir_typeck ( self , def_id : Self :: LocalDefId ) -> EarlyBinder < Self , Self :: Ty > {
1985
+ match def_id {
1986
+ SolverDefId :: InternedOpaqueTyId ( opaque) => {
1987
+ let impl_trait_id = self . db ( ) . lookup_intern_impl_trait_id ( opaque) ;
1988
+ match impl_trait_id {
1989
+ crate :: ImplTraitId :: ReturnTypeImplTrait ( func, idx) => {
1990
+ let infer = self . db ( ) . infer ( func. into ( ) ) ;
1991
+ EarlyBinder :: bind ( infer. type_of_rpit [ idx] . to_nextsolver ( self ) )
1992
+ }
1993
+ crate :: ImplTraitId :: TypeAliasImplTrait ( ..)
1994
+ | crate :: ImplTraitId :: AsyncBlockTypeImplTrait ( _, _) => {
1995
+ // FIXME(next-solver)
1996
+ EarlyBinder :: bind ( Ty :: new_error ( self , ErrorGuaranteed ) )
1997
+ }
1998
+ }
1999
+ }
2000
+ _ => panic ! ( "Unexpected SolverDefId in type_of_opaque_hir_typeck" ) ,
2001
+ }
1998
2002
}
1999
2003
2000
2004
fn coroutine_hidden_types (
2001
2005
self ,
2002
2006
def_id : Self :: DefId ,
2003
- ) -> rustc_type_ir:: EarlyBinder <
2004
- Self ,
2005
- rustc_type_ir:: Binder < Self , rustc_type_ir:: CoroutineWitnessTypes < Self > > ,
2006
- > {
2007
+ ) -> EarlyBinder < Self , rustc_type_ir:: Binder < Self , rustc_type_ir:: CoroutineWitnessTypes < Self > > >
2008
+ {
2007
2009
// FIXME(next-solver)
2008
2010
unimplemented ! ( )
2009
2011
}
0 commit comments