Skip to content

Commit 0e30fab

Browse files
authored
Merge pull request #196 from rust-lang-nursery/better-context-docs
Better context docs
2 parents 1db0e9a + 9dfe96d commit 0e30fab

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

chalk-engine/src/context.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
//! Defines traits used to embed the chalk-engine in another crate.
2+
//!
3+
//! chalk and rustc both define types which implement the traits in this
4+
//! module. This allows each user of chalk-engine to define their own
5+
//! `DomainGoal` type, add arena lifetime parameters, and more. See
6+
//! [`Context`] trait for a list of types.
7+
18
use crate::fallible::Fallible;
29
use crate::hh::HhGoal;
310
use crate::{DelayedLiteral, ExClause, SimplifiedAnswer};
@@ -163,8 +170,10 @@ pub trait ContextOps<C: Context>: Sized + Clone + Debug + AggregateOps<C> {
163170
fn empty_constraints(ccs: &C::CanonicalConstrainedSubst) -> bool;
164171

165172
fn canonical(u_canon: &C::UCanonicalGoalInEnvironment) -> &C::CanonicalGoalInEnvironment;
166-
fn is_trivial_substitution(u_canon: &C::UCanonicalGoalInEnvironment,
167-
canonical_subst: &C::CanonicalConstrainedSubst) -> bool;
173+
fn is_trivial_substitution(
174+
u_canon: &C::UCanonicalGoalInEnvironment,
175+
canonical_subst: &C::CanonicalConstrainedSubst,
176+
) -> bool;
168177
fn num_universes(_: &C::UCanonicalGoalInEnvironment) -> usize;
169178

170179
/// Convert a goal G *from* the canonical universes *into* our
@@ -244,11 +253,7 @@ pub trait InferenceTable<C: Context, I: Context>:
244253
fn into_hh_goal(&mut self, goal: I::Goal) -> HhGoal<I>;
245254

246255
// Used by: simplify
247-
fn add_clauses(
248-
&mut self,
249-
env: &I::Environment,
250-
clauses: I::ProgramClauses,
251-
) -> I::Environment;
256+
fn add_clauses(&mut self, env: &I::Environment, clauses: I::ProgramClauses) -> I::Environment;
252257

253258
/// Upcast this domain goal into a more general goal.
254259
fn into_goal(&self, domain_goal: I::DomainGoal) -> I::Goal;
@@ -300,10 +305,7 @@ pub trait UnificationOps<C: Context, I: Context> {
300305
value: &C::CanonicalConstrainedSubst,
301306
) -> I::CanonicalConstrainedSubst;
302307

303-
fn lift_delayed_literal(
304-
&self,
305-
value: DelayedLiteral<I>,
306-
) -> DelayedLiteral<C>;
308+
fn lift_delayed_literal(&self, value: DelayedLiteral<I>) -> DelayedLiteral<C>;
307309

308310
// Used by: logic
309311
fn invert_goal(&mut self, value: &I::GoalInEnvironment) -> Option<I::GoalInEnvironment>;
@@ -324,9 +326,10 @@ pub trait UnificationOps<C: Context, I: Context> {
324326

325327
/// "Truncation" (called "abstraction" in the papers referenced below)
326328
/// refers to the act of modifying a goal or answer that has become
327-
/// too large in order to guarantee termination. The SLG solver
328-
/// doesn't care about the precise truncation function, so long as
329-
/// it's deterministic and so forth.
329+
/// too large in order to guarantee termination.
330+
///
331+
/// The SLG solver doesn't care about the precise truncation function,
332+
/// so long as it's deterministic and so forth.
330333
///
331334
/// Citations:
332335
///

chalk-engine/src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
//! An alternative solver based around the SLG algorithm, which
2-
//! implements the well-formed semantics. This algorithm is very
3-
//! closed based on the description found in the following paper,
4-
//! which I will refer to in the comments as EWFS:
2+
//! implements the well-formed semantics. For an overview of how the solver
3+
//! works, see [The On-Demand SLG Solver][guide] in the rustc guide.
4+
//!
5+
//! [guide]: https://rust-lang.github.io/rustc-guide/traits/slg.html
6+
//!
7+
//! This algorithm is very closed based on the description found in the
8+
//! following paper, which I will refer to in the comments as EWFS:
59
//!
610
//! > Efficient Top-Down Computation of Queries Under the Well-formed Semantics
711
//! > (Chen, Swift, and Warren; Journal of Logic Programming '95)
@@ -51,7 +55,6 @@
5155
5256
#![feature(in_band_lifetimes)]
5357
#![feature(step_trait)]
54-
#![feature(non_modrs_mods)]
5558

5659
#[macro_use]
5760
extern crate chalk_macros;
@@ -189,7 +192,8 @@ pub enum DelayedLiteral<C: Context> {
189192

190193
/// Either `A` or `~A`, where `A` is a `Env |- Goal`.
191194
#[derive(Clone, Debug)]
192-
pub enum Literal<C: Context> { // FIXME: pub b/c fold
195+
pub enum Literal<C: Context> {
196+
// FIXME: pub b/c fold
193197
Positive(C::GoalInEnvironment),
194198
Negative(C::GoalInEnvironment),
195199
}

chalk-engine/src/logic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<C: Context, CO: ContextOps<C>> Forest<C, CO> {
562562
debug!("answer: table={:?}, answer_subst={:?}", table, answer_subst);
563563

564564
let delayed_literals = {
565-
let mut delayed_literals: FxHashSet<_> = delayed_literals.into_iter()
565+
let delayed_literals: FxHashSet<_> = delayed_literals.into_iter()
566566
.map(|dl| infer.lift_delayed_literal(dl))
567567
.collect();
568568
DelayedLiteralSet { delayed_literals }

chalk-ir/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(crate_visibility_modifier)]
22
#![feature(specialization)]
3-
#![feature(non_modrs_mods)]
43

54
use crate::cast::Cast;
65
use chalk_engine::fallible::*;

0 commit comments

Comments
 (0)