Skip to content

Commit 6222e41

Browse files
authored
Merge pull request #390 from jackh726/force_impl
Change force_impl_for to return Option<bool>
2 parents 5b36472 + 98ab8ee commit 6222e41

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

chalk-solve/src/clauses/builtin_traits.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ pub fn add_builtin_program_clauses<I: Interner>(
1313
trait_ref: &TraitRef<I>,
1414
ty: &TyData<I>,
1515
) {
16-
if db.force_impl_for(well_known, ty) {
17-
builder.push_fact(trait_ref.clone());
16+
if let Some(force_impl) = db.force_impl_for(well_known, ty) {
17+
if force_impl {
18+
builder.push_fact(trait_ref.clone());
19+
}
20+
return;
1821
}
1922

2023
match well_known {

chalk-solve/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ pub trait RustIrDatabase<I: Interner>: Debug {
7171

7272
/// A stop-gap solution to force an impl for a given well-known trait.
7373
/// Useful when the logic for a given trait is absent or incomplete.
74+
/// A value of `Some(true)` means that the the clause for the impl will be
75+
/// added. A value of `Some(false)` means that the clause for the impl will
76+
/// not be added, and fallback logic will not be checked. A value of `None`
77+
/// means that the clause will not be added, but fallback logic may add logic.
7478
#[allow(unused_variables)]
75-
fn force_impl_for(&self, well_known: WellKnownTrait, ty: &TyData<I>) -> bool {
76-
false
79+
fn force_impl_for(&self, well_known: WellKnownTrait, ty: &TyData<I>) -> Option<bool> {
80+
None
7781
}
7882

7983
/// Returns id of a trait lang item, if found

chalk-solve/src/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'i, I: Interner> InputTypeCollector<'i, I> {
6262
}
6363
}
6464

65-
impl<'i, 't, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> {
65+
impl<'i, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> {
6666
type Result = ();
6767

6868
fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, Result = Self::Result> {

0 commit comments

Comments
 (0)