@@ -4,6 +4,7 @@ use std::sync::Arc;
44use log:: debug;
55
66use chalk_ir:: { fold:: shift:: Shift , GenericArg , TypeName } ;
7+ use chalk_solve:: rust_ir:: { self , WellKnownTrait } ;
78
89use hir_def:: {
910 lang_item:: { lang_attr, LangItemTarget } ,
@@ -16,7 +17,6 @@ use crate::{
1617 db:: HirDatabase , display:: HirDisplay , method_resolution:: TyFingerprint , utils:: generics,
1718 CallableDef , DebruijnIndex , GenericPredicate , Substs , Ty , TypeCtor ,
1819} ;
19- use chalk_rust_ir:: WellKnownTrait ;
2020use mapping:: { convert_where_clauses, generic_predicate_to_inline_bound, make_binders} ;
2121
2222pub use self :: interner:: * ;
@@ -55,7 +55,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
5555 fn fn_def_datum (
5656 & self ,
5757 fn_def_id : chalk_ir:: FnDefId < Interner > ,
58- ) -> Arc < chalk_rust_ir :: FnDefDatum < Interner > > {
58+ ) -> Arc < rust_ir :: FnDefDatum < Interner > > {
5959 self . db . fn_def_datum ( self . krate , fn_def_id)
6060 }
6161
@@ -112,7 +112,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
112112 }
113113 fn well_known_trait_id (
114114 & self ,
115- well_known_trait : chalk_rust_ir :: WellKnownTrait ,
115+ well_known_trait : rust_ir :: WellKnownTrait ,
116116 ) -> Option < chalk_ir:: TraitId < Interner > > {
117117 let lang_attr = lang_attr_from_well_known_trait ( well_known_trait) ;
118118 let lang_items = self . db . crate_lang_items ( self . krate ) ;
@@ -133,13 +133,13 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
133133 fn opaque_ty_data (
134134 & self ,
135135 _id : chalk_ir:: OpaqueTyId < Interner > ,
136- ) -> Arc < chalk_rust_ir :: OpaqueTyDatum < Interner > > {
136+ ) -> Arc < rust_ir :: OpaqueTyDatum < Interner > > {
137137 unimplemented ! ( )
138138 }
139139
140140 fn force_impl_for (
141141 & self ,
142- _well_known : chalk_rust_ir :: WellKnownTrait ,
142+ _well_known : rust_ir :: WellKnownTrait ,
143143 _ty : & chalk_ir:: TyData < Interner > ,
144144 ) -> Option < bool > {
145145 // this method is mostly for rustc
@@ -150,6 +150,10 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
150150 // FIXME: implement actual object safety
151151 true
152152 }
153+
154+ fn hidden_opaque_type ( & self , _id : chalk_ir:: OpaqueTyId < Interner > ) -> chalk_ir:: Ty < Interner > {
155+ Ty :: Unknown . to_chalk ( self . db )
156+ }
153157}
154158
155159pub ( crate ) fn program_clauses_for_chalk_env_query (
@@ -188,7 +192,7 @@ pub(crate) fn associated_ty_data_query(
188192 . collect ( ) ;
189193
190194 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 } ;
192196 let datum = AssociatedTyDatum {
193197 trait_id : trait_. to_chalk ( db) ,
194198 id,
@@ -209,7 +213,7 @@ pub(crate) fn trait_datum_query(
209213 debug ! ( "trait {:?} = {:?}" , trait_id, trait_data. name) ;
210214 let generic_params = generics ( db. upcast ( ) , trait_. into ( ) ) ;
211215 let bound_vars = Substs :: bound_vars ( & generic_params, DebruijnIndex :: INNERMOST ) ;
212- let flags = chalk_rust_ir :: TraitFlags {
216+ let flags = rust_ir :: TraitFlags {
213217 auto : trait_data. auto ,
214218 upstream : trait_. lookup ( db. upcast ( ) ) . container . module ( db. upcast ( ) ) . krate != krate,
215219 non_enumerable : true ,
@@ -221,7 +225,7 @@ pub(crate) fn trait_datum_query(
221225 let where_clauses = convert_where_clauses ( db, trait_. into ( ) , & bound_vars) ;
222226 let associated_ty_ids =
223227 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 } ;
225229 let well_known =
226230 lang_attr ( db. upcast ( ) , trait_) . and_then ( |name| well_known_trait_from_lang_attr ( & name) ) ;
227231 let trait_datum = TraitDatum {
@@ -271,12 +275,12 @@ pub(crate) fn struct_datum_query(
271275 convert_where_clauses ( db, generic_def, & bound_vars)
272276 } )
273277 . unwrap_or_else ( Vec :: new) ;
274- let flags = chalk_rust_ir :: AdtFlags {
278+ let flags = rust_ir :: AdtFlags {
275279 upstream,
276280 // FIXME set fundamental flag correctly
277281 fundamental : false ,
278282 } ;
279- let struct_datum_bound = chalk_rust_ir :: AdtDatumBound {
283+ let struct_datum_bound = rust_ir :: AdtDatumBound {
280284 fields : Vec :: new ( ) , // FIXME add fields (only relevant for auto traits)
281285 where_clauses,
282286 } ;
@@ -316,9 +320,9 @@ fn impl_def_datum(
316320 let bound_vars = Substs :: bound_vars ( & generic_params, DebruijnIndex :: INNERMOST ) ;
317321 let trait_ = trait_ref. trait_ ;
318322 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
320324 } else {
321- chalk_rust_ir :: ImplType :: External
325+ rust_ir :: ImplType :: External
322326 } ;
323327 let where_clauses = convert_where_clauses ( db, impl_id. into ( ) , & bound_vars) ;
324328 let negative = impl_data. is_negative ;
@@ -331,13 +335,9 @@ fn impl_def_datum(
331335 ) ;
332336 let trait_ref = trait_ref. to_chalk ( db) ;
333337
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 } ;
339339
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 } ;
341341 let trait_data = db. trait_data ( trait_) ;
342342 let associated_ty_value_ids = impl_data
343343 . items
@@ -395,8 +395,8 @@ fn type_alias_associated_ty_value(
395395 . associated_type_by_name ( & type_alias_data. name )
396396 . expect ( "assoc ty value should not exist" ) ; // validated when building the impl data as well
397397 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 {
400400 impl_id : Impl :: ImplDef ( impl_id) . to_chalk ( db) ,
401401 associated_ty_id : assoc_ty. to_chalk ( db) ,
402402 value : make_binders ( value_bound, ty. num_binders ) ,
@@ -414,7 +414,7 @@ pub(crate) fn fn_def_datum_query(
414414 let sig = db. callable_item_signature ( callable_def) ;
415415 let bound_vars = Substs :: bound_vars ( & generic_params, DebruijnIndex :: INNERMOST ) ;
416416 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 {
418418 // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
419419 argument_types : sig. value . params ( ) . iter ( ) . map ( |ty| ty. clone ( ) . to_chalk ( db) ) . collect ( ) ,
420420 return_type : sig. value . ret ( ) . clone ( ) . to_chalk ( db) ,
@@ -460,14 +460,14 @@ impl From<crate::traits::GlobalImplId> for ImplId {
460460 }
461461}
462462
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 {
465465 Self :: from_intern_id ( id. 0 )
466466 }
467467}
468468
469- impl From < crate :: traits:: AssocTyValueId > for chalk_rust_ir :: AssociatedTyValueId < Interner > {
469+ impl From < crate :: traits:: AssocTyValueId > for rust_ir :: AssociatedTyValueId < Interner > {
470470 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 ( ) )
472472 }
473473}
0 commit comments