aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/traits
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-05-07 17:53:16 +0100
committerFlorian Diebold <[email protected]>2019-05-11 15:21:20 +0100
commitd6dc75f9f22b73faf8c526be69ca43e52d6db1bf (patch)
treef17b35ab78b5dc123e55a69f065dc47d08ef3ff8 /crates/ra_hir/src/ty/traits
parent7744cd41e2ad79c1b36d3d9fccd3bc0dbfd9e2d9 (diff)
Handle auto traits & negative impls
We don't pass field types to Chalk yet though, so the auto trait inference won't be correct.
Diffstat (limited to 'crates/ra_hir/src/ty/traits')
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 8fa0ba7a5..027c5ec4c 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -12,7 +12,9 @@ use ra_db::salsa::{InternId, InternKey};
12use crate::{ 12use crate::{
13 Trait, HasGenericParams, ImplBlock, 13 Trait, HasGenericParams, ImplBlock,
14 db::HirDatabase, 14 db::HirDatabase,
15 ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate}, generics::GenericDef, ty::CallableDef, 15 ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef},
16 ty::display::HirDisplay,
17 generics::GenericDef,
16}; 18};
17use super::ChalkContext; 19use super::ChalkContext;
18 20
@@ -232,10 +234,10 @@ where
232 let bound_vars = Substs::bound_vars(&generic_params); 234 let bound_vars = Substs::bound_vars(&generic_params);
233 let trait_ref = trait_.trait_ref(self.db).subst(&bound_vars).to_chalk(self.db); 235 let trait_ref = trait_.trait_ref(self.db).subst(&bound_vars).to_chalk(self.db);
234 let flags = chalk_rust_ir::TraitFlags { 236 let flags = chalk_rust_ir::TraitFlags {
237 auto: trait_.is_auto(self.db),
238 upstream: trait_.module(self.db).krate(self.db) != Some(self.krate),
235 // FIXME set these flags correctly 239 // FIXME set these flags correctly
236 auto: false,
237 marker: false, 240 marker: false,
238 upstream: trait_.module(self.db).krate(self.db) != Some(self.krate),
239 fundamental: false, 241 fundamental: false,
240 }; 242 };
241 let where_clauses = convert_where_clauses(self.db, trait_.into(), &bound_vars); 243 let where_clauses = convert_where_clauses(self.db, trait_.into(), &bound_vars);
@@ -329,9 +331,21 @@ where
329 chalk_rust_ir::ImplType::External 331 chalk_rust_ir::ImplType::External
330 }; 332 };
331 let where_clauses = convert_where_clauses(self.db, impl_block.into(), &bound_vars); 333 let where_clauses = convert_where_clauses(self.db, impl_block.into(), &bound_vars);
334 let negative = impl_block.is_negative(self.db);
335 debug!(
336 "impl {:?}: {}{} where {:?}",
337 impl_id,
338 if negative { "!" } else { "" },
339 trait_ref.display(self.db),
340 where_clauses
341 );
342 let trait_ref = trait_ref.to_chalk(self.db);
332 let impl_datum_bound = chalk_rust_ir::ImplDatumBound { 343 let impl_datum_bound = chalk_rust_ir::ImplDatumBound {
333 // FIXME handle negative impls (impl !Sync for Foo) 344 trait_ref: if negative {
334 trait_ref: chalk_rust_ir::PolarizedTraitRef::Positive(trait_ref.to_chalk(self.db)), 345 chalk_rust_ir::PolarizedTraitRef::Negative(trait_ref)
346 } else {
347 chalk_rust_ir::PolarizedTraitRef::Positive(trait_ref)
348 },
335 where_clauses, 349 where_clauses,
336 associated_ty_values: Vec::new(), // FIXME add associated type values 350 associated_ty_values: Vec::new(), // FIXME add associated type values
337 impl_type, 351 impl_type,