@@ -4,6 +4,7 @@ use std::sync::Arc;
4
4
use log:: debug;
5
5
6
6
use chalk_ir:: { fold:: shift:: Shift , GenericArg , TypeName } ;
7
+ use chalk_solve:: rust_ir:: { self , WellKnownTrait } ;
7
8
8
9
use hir_def:: {
9
10
lang_item:: { lang_attr, LangItemTarget } ,
@@ -16,7 +17,6 @@ use crate::{
16
17
db:: HirDatabase , display:: HirDisplay , method_resolution:: TyFingerprint , utils:: generics,
17
18
CallableDef , DebruijnIndex , GenericPredicate , Substs , Ty , TypeCtor ,
18
19
} ;
19
- use chalk_rust_ir:: WellKnownTrait ;
20
20
use mapping:: { convert_where_clauses, generic_predicate_to_inline_bound, make_binders} ;
21
21
22
22
pub use self :: interner:: * ;
@@ -55,7 +55,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
55
55
fn fn_def_datum (
56
56
& self ,
57
57
fn_def_id : chalk_ir:: FnDefId < Interner > ,
58
- ) -> Arc < chalk_rust_ir :: FnDefDatum < Interner > > {
58
+ ) -> Arc < rust_ir :: FnDefDatum < Interner > > {
59
59
self . db . fn_def_datum ( self . krate , fn_def_id)
60
60
}
61
61
@@ -112,7 +112,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
112
112
}
113
113
fn well_known_trait_id (
114
114
& self ,
115
- well_known_trait : chalk_rust_ir :: WellKnownTrait ,
115
+ well_known_trait : rust_ir :: WellKnownTrait ,
116
116
) -> Option < chalk_ir:: TraitId < Interner > > {
117
117
let lang_attr = lang_attr_from_well_known_trait ( well_known_trait) ;
118
118
let lang_items = self . db . crate_lang_items ( self . krate ) ;
@@ -133,13 +133,13 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
133
133
fn opaque_ty_data (
134
134
& self ,
135
135
_id : chalk_ir:: OpaqueTyId < Interner > ,
136
- ) -> Arc < chalk_rust_ir :: OpaqueTyDatum < Interner > > {
136
+ ) -> Arc < rust_ir :: OpaqueTyDatum < Interner > > {
137
137
unimplemented ! ( )
138
138
}
139
139
140
140
fn force_impl_for (
141
141
& self ,
142
- _well_known : chalk_rust_ir :: WellKnownTrait ,
142
+ _well_known : rust_ir :: WellKnownTrait ,
143
143
_ty : & chalk_ir:: TyData < Interner > ,
144
144
) -> Option < bool > {
145
145
// this method is mostly for rustc
@@ -150,6 +150,10 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
150
150
// FIXME: implement actual object safety
151
151
true
152
152
}
153
+
154
+ fn hidden_opaque_type ( & self , _id : chalk_ir:: OpaqueTyId < Interner > ) -> chalk_ir:: Ty < Interner > {
155
+ Ty :: Unknown . to_chalk ( self . db )
156
+ }
153
157
}
154
158
155
159
pub ( crate ) fn program_clauses_for_chalk_env_query (
@@ -188,7 +192,7 @@ pub(crate) fn associated_ty_data_query(
188
192
. collect ( ) ;
189
193
190
194
let where_clauses = convert_where_clauses ( db, type_alias. into ( ) , & bound_vars) ;
191
- let bound_data = chalk_rust_ir :: AssociatedTyDatumBound { bounds, where_clauses } ;
195
+ let bound_data = rust_ir :: AssociatedTyDatumBound { bounds, where_clauses } ;
192
196
let datum = AssociatedTyDatum {
193
197
trait_id : trait_. to_chalk ( db) ,
194
198
id,
@@ -209,7 +213,7 @@ pub(crate) fn trait_datum_query(
209
213
debug ! ( "trait {:?} = {:?}" , trait_id, trait_data. name) ;
210
214
let generic_params = generics ( db. upcast ( ) , trait_. into ( ) ) ;
211
215
let bound_vars = Substs :: bound_vars ( & generic_params, DebruijnIndex :: INNERMOST ) ;
212
- let flags = chalk_rust_ir :: TraitFlags {
216
+ let flags = rust_ir :: TraitFlags {
213
217
auto : trait_data. auto ,
214
218
upstream : trait_. lookup ( db. upcast ( ) ) . container . module ( db. upcast ( ) ) . krate != krate,
215
219
non_enumerable : true ,
@@ -221,7 +225,7 @@ pub(crate) fn trait_datum_query(
221
225
let where_clauses = convert_where_clauses ( db, trait_. into ( ) , & bound_vars) ;
222
226
let associated_ty_ids =
223
227
trait_data. associated_types ( ) . map ( |type_alias| type_alias. to_chalk ( db) ) . collect ( ) ;
224
- let trait_datum_bound = chalk_rust_ir :: TraitDatumBound { where_clauses } ;
228
+ let trait_datum_bound = rust_ir :: TraitDatumBound { where_clauses } ;
225
229
let well_known =
226
230
lang_attr ( db. upcast ( ) , trait_) . and_then ( |name| well_known_trait_from_lang_attr ( & name) ) ;
227
231
let trait_datum = TraitDatum {
@@ -271,12 +275,12 @@ pub(crate) fn struct_datum_query(
271
275
convert_where_clauses ( db, generic_def, & bound_vars)
272
276
} )
273
277
. unwrap_or_else ( Vec :: new) ;
274
- let flags = chalk_rust_ir :: AdtFlags {
278
+ let flags = rust_ir :: AdtFlags {
275
279
upstream,
276
280
// FIXME set fundamental flag correctly
277
281
fundamental : false ,
278
282
} ;
279
- let struct_datum_bound = chalk_rust_ir :: AdtDatumBound {
283
+ let struct_datum_bound = rust_ir :: AdtDatumBound {
280
284
fields : Vec :: new ( ) , // FIXME add fields (only relevant for auto traits)
281
285
where_clauses,
282
286
} ;
@@ -316,9 +320,9 @@ fn impl_def_datum(
316
320
let bound_vars = Substs :: bound_vars ( & generic_params, DebruijnIndex :: INNERMOST ) ;
317
321
let trait_ = trait_ref. trait_ ;
318
322
let impl_type = if impl_id. lookup ( db. upcast ( ) ) . container . module ( db. upcast ( ) ) . krate == krate {
319
- chalk_rust_ir :: ImplType :: Local
323
+ rust_ir :: ImplType :: Local
320
324
} else {
321
- chalk_rust_ir :: ImplType :: External
325
+ rust_ir :: ImplType :: External
322
326
} ;
323
327
let where_clauses = convert_where_clauses ( db, impl_id. into ( ) , & bound_vars) ;
324
328
let negative = impl_data. is_negative ;
@@ -331,13 +335,9 @@ fn impl_def_datum(
331
335
) ;
332
336
let trait_ref = trait_ref. to_chalk ( db) ;
333
337
334
- let polarity = if negative {
335
- chalk_rust_ir:: Polarity :: Negative
336
- } else {
337
- chalk_rust_ir:: Polarity :: Positive
338
- } ;
338
+ let polarity = if negative { rust_ir:: Polarity :: Negative } else { rust_ir:: Polarity :: Positive } ;
339
339
340
- let impl_datum_bound = chalk_rust_ir :: ImplDatumBound { trait_ref, where_clauses } ;
340
+ let impl_datum_bound = rust_ir :: ImplDatumBound { trait_ref, where_clauses } ;
341
341
let trait_data = db. trait_data ( trait_) ;
342
342
let associated_ty_value_ids = impl_data
343
343
. items
@@ -395,8 +395,8 @@ fn type_alias_associated_ty_value(
395
395
. associated_type_by_name ( & type_alias_data. name )
396
396
. expect ( "assoc ty value should not exist" ) ; // validated when building the impl data as well
397
397
let ty = db. ty ( type_alias. into ( ) ) ;
398
- let value_bound = chalk_rust_ir :: AssociatedTyValueBound { ty : ty. value . to_chalk ( db) } ;
399
- let value = chalk_rust_ir :: AssociatedTyValue {
398
+ let value_bound = rust_ir :: AssociatedTyValueBound { ty : ty. value . to_chalk ( db) } ;
399
+ let value = rust_ir :: AssociatedTyValue {
400
400
impl_id : Impl :: ImplDef ( impl_id) . to_chalk ( db) ,
401
401
associated_ty_id : assoc_ty. to_chalk ( db) ,
402
402
value : make_binders ( value_bound, ty. num_binders ) ,
@@ -414,7 +414,7 @@ pub(crate) fn fn_def_datum_query(
414
414
let sig = db. callable_item_signature ( callable_def) ;
415
415
let bound_vars = Substs :: bound_vars ( & generic_params, DebruijnIndex :: INNERMOST ) ;
416
416
let where_clauses = convert_where_clauses ( db, callable_def. into ( ) , & bound_vars) ;
417
- let bound = chalk_rust_ir :: FnDefDatumBound {
417
+ let bound = rust_ir :: FnDefDatumBound {
418
418
// Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
419
419
argument_types : sig. value . params ( ) . iter ( ) . map ( |ty| ty. clone ( ) . to_chalk ( db) ) . collect ( ) ,
420
420
return_type : sig. value . ret ( ) . clone ( ) . to_chalk ( db) ,
@@ -460,14 +460,14 @@ impl From<crate::traits::GlobalImplId> for ImplId {
460
460
}
461
461
}
462
462
463
- impl From < chalk_rust_ir :: AssociatedTyValueId < Interner > > for crate :: traits:: AssocTyValueId {
464
- fn from ( id : chalk_rust_ir :: AssociatedTyValueId < Interner > ) -> Self {
463
+ impl From < rust_ir :: AssociatedTyValueId < Interner > > for crate :: traits:: AssocTyValueId {
464
+ fn from ( id : rust_ir :: AssociatedTyValueId < Interner > ) -> Self {
465
465
Self :: from_intern_id ( id. 0 )
466
466
}
467
467
}
468
468
469
- impl From < crate :: traits:: AssocTyValueId > for chalk_rust_ir :: AssociatedTyValueId < Interner > {
469
+ impl From < crate :: traits:: AssocTyValueId > for rust_ir :: AssociatedTyValueId < Interner > {
470
470
fn from ( assoc_ty_value_id : crate :: traits:: AssocTyValueId ) -> Self {
471
- chalk_rust_ir :: AssociatedTyValueId ( assoc_ty_value_id. as_intern_id ( ) )
471
+ rust_ir :: AssociatedTyValueId ( assoc_ty_value_id. as_intern_id ( ) )
472
472
}
473
473
}
0 commit comments