Skip to content

Commit e294333

Browse files
authored
Merge pull request #173 from nikomatsakis/type-alias-bounds
type alias bounds and other miscellany
2 parents 9345ac4 + 6c43ec8 commit e294333

15 files changed

+87
-92
lines changed

Cargo.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ena = "0.4"
1515
error-chain = "0.12.0"
1616
itertools = "0.7.8"
1717
lalrpop-intern = "0.14"
18-
petgraph = "0.4.5"
18+
petgraph = "0.4.13"
1919
rustyline = "1.0"
2020
serde = "1.0"
2121
serde_derive = "1.0"
@@ -30,7 +30,7 @@ version = "0.1.0"
3030
path = "chalk-macros"
3131

3232
[dependencies.chalk-engine]
33-
version = "0.7.0"
33+
version = "0.7.1"
3434
path = "chalk-engine"
3535

3636
[workspace]

chalk-engine/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chalk-engine"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
description = "Core trait engine from Chalk project"
55
license = "Apache-2.0/MIT"
66
authors = ["Rust Compiler Team", "Chalk developers"]

chalk-engine/src/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use crate::fallible::Fallible;
2-
use crate::hh::HhGoal;
3-
use crate::{DelayedLiteral, ExClause, SimplifiedAnswer};
1+
use fallible::Fallible;
2+
use hh::HhGoal;
3+
use {DelayedLiteral, ExClause, SimplifiedAnswer};
44
use std::fmt::Debug;
55
use std::hash::Hash;
66

7-
crate mod prelude;
7+
pub(crate) mod prelude;
88

99
/// The "context" in which the SLG solver operates. It defines all the
1010
/// types that the SLG solver may need to refer to, as well as a few

chalk-engine/src/context/prelude.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![allow(unused_imports)] // rustc bug
22

3-
crate use super::Context;
4-
crate use super::ContextOps;
5-
crate use super::AggregateOps;
6-
crate use super::ResolventOps;
7-
crate use super::TruncateOps;
8-
crate use super::InferenceTable;
3+
pub(crate) use super::Context;
4+
pub(crate) use super::ContextOps;
5+
pub(crate) use super::AggregateOps;
6+
pub(crate) use super::ResolventOps;
7+
pub(crate) use super::TruncateOps;
8+
pub(crate) use super::InferenceTable;

chalk-engine/src/forest.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
use crate::{DepthFirstNumber, SimplifiedAnswer, TableIndex};
2-
use crate::context::prelude::*;
3-
use crate::context::AnswerStream;
4-
use crate::logic::RootSearchFail;
5-
use crate::stack::{Stack, StackIndex};
6-
use crate::tables::Tables;
7-
use crate::table::{Answer, AnswerIndex};
1+
use {DepthFirstNumber, SimplifiedAnswer, TableIndex};
2+
use context::prelude::*;
3+
use context::AnswerStream;
4+
use logic::RootSearchFail;
5+
use stack::{Stack, StackIndex};
6+
use tables::Tables;
7+
use table::{Answer, AnswerIndex};
88

99
pub struct Forest<C: Context, CO: ContextOps<C>> {
1010
#[allow(dead_code)]
11-
crate context: CO,
12-
crate tables: Tables<C>,
13-
crate stack: Stack,
11+
pub(crate) context: CO,
12+
pub(crate) tables: Tables<C>,
13+
pub(crate) stack: Stack,
1414

1515
dfn: DepthFirstNumber,
1616
}

chalk-engine/src/hh.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::context::Context;
1+
use context::Context;
22

33
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
44
/// A general goal; this is the full range of questions you can pose to Chalk.

chalk-engine/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,9 @@
4949
//! - HH: Hereditary harrop predicates. What Chalk deals in.
5050
//! Popularized by Lambda Prolog.
5151
52-
#![feature(crate_in_paths)]
53-
#![feature(crate_visibility_modifier)]
5452
#![feature(in_band_lifetimes)]
55-
#![feature(macro_vis_matcher)]
5653
#![feature(step_trait)]
5754
#![feature(non_modrs_mods)]
58-
#![feature(rustc_private)]
5955

6056
#[macro_use]
6157
extern crate chalk_macros;
@@ -65,7 +61,7 @@ extern crate stacker;
6561

6662
extern crate rustc_hash;
6763

68-
use crate::context::Context;
64+
use context::Context;
6965
use rustc_hash::FxHashSet;
7066
use std::cmp::min;
7167
use std::usize;

chalk-engine/src/logic.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::{DelayedLiteral, DelayedLiteralSet, DepthFirstNumber, ExClause, Literal, Minimums,
1+
use {DelayedLiteral, DelayedLiteralSet, DepthFirstNumber, ExClause, Literal, Minimums,
22
TableIndex};
3-
use crate::fallible::NoSolution;
4-
use crate::context::{WithInstantiatedExClause, WithInstantiatedUCanonicalGoal, prelude::*};
5-
use crate::forest::Forest;
6-
use crate::hh::HhGoal;
7-
use crate::stack::StackIndex;
8-
use crate::strand::{CanonicalStrand, SelectedSubgoal, Strand};
9-
use crate::table::{Answer, AnswerIndex};
3+
use fallible::NoSolution;
4+
use context::{WithInstantiatedExClause, WithInstantiatedUCanonicalGoal, prelude::*};
5+
use forest::Forest;
6+
use hh::HhGoal;
7+
use stack::StackIndex;
8+
use strand::{CanonicalStrand, SelectedSubgoal, Strand};
9+
use table::{Answer, AnswerIndex};
1010
use rustc_hash::FxHashSet;
1111
use std::marker::PhantomData;
1212
use std::mem;
@@ -56,7 +56,8 @@ enum RecursiveSearchFail {
5656
QuantumExceeded,
5757
}
5858

59-
type StrandResult<C, T> = Result<T, StrandFail<C>>;
59+
#[allow(type_alias_bounds)]
60+
type StrandResult<C: Context, T> = Result<T, StrandFail<C>>;
6061

6162
/// Possible failures from pursuing a particular strand.
6263
#[derive(Debug)]
@@ -183,7 +184,7 @@ impl<C: Context, CO: ContextOps<C>> Forest<C, CO> {
183184
result.map(|()| EnsureSuccess::AnswerAvailable)
184185
}
185186

186-
crate fn answer(&self, table: TableIndex, answer: AnswerIndex) -> &Answer<C> {
187+
pub(crate) fn answer(&self, table: TableIndex, answer: AnswerIndex) -> &Answer<C> {
187188
self.tables[table].answer(answer).unwrap()
188189
}
189190

@@ -691,7 +692,7 @@ impl<C: Context, CO: ContextOps<C>> Forest<C, CO> {
691692
/// In terms of the NFTD paper, creating a new table corresponds
692693
/// to the *New Subgoal* step as well as the *Program Clause
693694
/// Resolution* steps.
694-
crate fn get_or_create_table_for_ucanonical_goal(
695+
pub(crate) fn get_or_create_table_for_ucanonical_goal(
695696
&mut self,
696697
goal: C::UCanonicalGoalInEnvironment,
697698
) -> TableIndex {
@@ -1166,7 +1167,7 @@ impl<C: Context, CO: ContextOps<C>> Forest<C, CO> {
11661167
depth: StackIndex,
11671168
strand: Strand<'_, C, impl Context>,
11681169
) -> StrandResult<C, ()> {
1169-
crate::maybe_grow_stack(|| self.pursue_strand(depth, strand))
1170+
::maybe_grow_stack(|| self.pursue_strand(depth, strand))
11701171
}
11711172

11721173
/// Invoked when we have found a successful answer to the given

chalk-engine/src/simplify.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::fallible::Fallible;
2-
use crate::{ExClause, Literal};
3-
use crate::forest::Forest;
4-
use crate::hh::HhGoal;
5-
use crate::context::prelude::*;
1+
use fallible::Fallible;
2+
use {ExClause, Literal};
3+
use forest::Forest;
4+
use hh::HhGoal;
5+
use context::prelude::*;
66

77
impl<C: Context, CO: ContextOps<C>> Forest<C, CO> {
88
/// Simplifies an HH goal into a series of positive domain goals

chalk-engine/src/stack.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::{DepthFirstNumber, TableIndex};
1+
use {DepthFirstNumber, TableIndex};
22
use std::ops::{Index, IndexMut, Range};
33

44
/// See `Forest`.
55
#[derive(Default)]
6-
crate struct Stack {
6+
pub(crate) struct Stack {
77
/// Stack: as described above, stores the in-progress goals.
88
stack: Vec<StackEntry>,
99
}
@@ -13,12 +13,12 @@ crate struct Stack {
1313
/// table is completely evaluated, it may be popped from the stack,
1414
/// and hence no longer have a stack index.
1515
index_struct! {
16-
crate struct StackIndex {
16+
pub(crate) struct StackIndex {
1717
value: usize,
1818
}
1919
}
2020

21-
crate struct StackEntry {
21+
pub(crate) struct StackEntry {
2222
/// The goal G from the stack entry `A :- G` represented here.
2323
pub(super) table: TableIndex,
2424

chalk-engine/src/strand.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
use std::fmt::{Debug, Error, Formatter};
2-
use crate::{ExClause, TableIndex};
3-
use crate::context::{Context, InferenceTable};
4-
use crate::table::AnswerIndex;
2+
use {ExClause, TableIndex};
3+
use context::{Context, InferenceTable};
4+
use table::AnswerIndex;
55

66
#[derive(Debug)]
7-
crate struct CanonicalStrand<C: Context> {
7+
pub(crate) struct CanonicalStrand<C: Context> {
88
pub(super) canonical_ex_clause: C::CanonicalExClause,
99

1010
/// Index into `ex_clause.subgoals`.
11-
crate selected_subgoal: Option<SelectedSubgoal<C>>,
11+
pub(crate) selected_subgoal: Option<SelectedSubgoal<C>>,
1212
}
1313

14-
crate struct Strand<'table, C: Context + 'table, I: Context + 'table> {
15-
crate infer: &'table mut dyn InferenceTable<C, I>,
14+
pub(crate) struct Strand<'table, C: Context + 'table, I: Context + 'table> {
15+
pub(crate) infer: &'table mut dyn InferenceTable<C, I>,
1616

1717
pub(super) ex_clause: ExClause<I>,
1818

1919
/// Index into `ex_clause.subgoals`.
20-
crate selected_subgoal: Option<SelectedSubgoal<C>>,
20+
pub(crate) selected_subgoal: Option<SelectedSubgoal<C>>,
2121
}
2222

2323
#[derive(Clone, Debug)]
24-
crate struct SelectedSubgoal<C: Context> {
24+
pub(crate) struct SelectedSubgoal<C: Context> {
2525
/// The index of the subgoal in `ex_clause.subgoals`
26-
crate subgoal_index: usize,
26+
pub(crate) subgoal_index: usize,
2727

2828
/// The index of the table that we created or found for this subgoal
2929
pub(super) subgoal_table: TableIndex,
3030

3131
/// Index of the answer we should request next from the table
32-
crate answer_index: AnswerIndex,
32+
pub(crate) answer_index: AnswerIndex,
3333

3434
/// Maps the universes of the subgoal to the canonical universes
3535
/// used in the table
36-
crate universe_map: C::UniverseMap,
36+
pub(crate) universe_map: C::UniverseMap,
3737
}
3838

3939
impl<'table, C: Context, I: Context> Debug for Strand<'table, C, I> {

0 commit comments

Comments
 (0)