Skip to content

Commit

Permalink
Implement is_coinductive
Browse files Browse the repository at this point in the history
Fixes #55096.
  • Loading branch information
scalexm committed Dec 27, 2018
1 parent f2b9217 commit 9b87f59
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/librustc_traits/chalk_context/mod.rs
Expand Up @@ -155,12 +155,29 @@ impl context::AggregateOps<ChalkArenas<'gcx>> for ChalkContext<'cx, 'gcx> {
}

impl context::ContextOps<ChalkArenas<'gcx>> for ChalkContext<'cx, 'gcx> {
/// True if this is a coinductive goal -- e.g., proving an auto trait.
/// True if this is a coinductive goal: basically proving that an auto trait
/// is implemented or proving that a trait reference is well-formed.
fn is_coinductive(
&self,
_goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>
goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>
) -> bool {
unimplemented!()
use rustc::traits::{WellFormed, WhereClause};

let mut goal = goal.value.goal;
loop {
match goal {
GoalKind::DomainGoal(domain_goal) => match domain_goal {
DomainGoal::WellFormed(WellFormed::Trait(..)) => return true,
DomainGoal::Holds(WhereClause::Implemented(trait_predicate)) => {
return self.tcx.trait_is_auto(trait_predicate.def_id());
}
_ => return false,
}

GoalKind::Quantified(_, bound_goal) => goal = *bound_goal.skip_binder(),
_ => return false,
}
}
}

/// Create an inference table for processing a new goal and instantiate that goal
Expand Down

0 comments on commit 9b87f59

Please sign in to comment.