Skip to content

Commit 8b7284b

Browse files
authored
Merge pull request #175 from nikomatsakis/partition-into-crates
extract `ir` and `solve` into their own crates
2 parents e490722 + c2ba2dd commit 8b7284b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5899
-1482
lines changed

Cargo.lock

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

Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ keywords = ["compiler", "traits", "prolog"]
1111
[dependencies]
1212
diff = "0.1.11"
1313
docopt = "1.0.0"
14-
ena = "0.4"
1514
error-chain = "0.12.0"
1615
itertools = "0.7.8"
1716
lalrpop-intern = "0.14"
@@ -25,6 +24,14 @@ stacker = "0.1.2"
2524
version = "0.1.0"
2625
path = "chalk-parse"
2726

27+
[dependencies.chalk-ir]
28+
version = "0.1.0"
29+
path = "chalk-ir"
30+
31+
[dependencies.chalk-solve]
32+
version = "0.1.0"
33+
path = "chalk-solve"
34+
2835
[dependencies.chalk-macros]
2936
version = "0.1.0"
3037
path = "chalk-macros"

chalk-engine/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
//! Popularized by Lambda Prolog.
5151
5252
#![feature(in_band_lifetimes)]
53-
#![feature(macro_vis_matcher)]
5453
#![feature(step_trait)]
5554
#![feature(non_modrs_mods)]
5655

chalk-ir/Cargo.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "chalk-ir"
3+
version = "0.1.0"
4+
description = "Chalk's internal representation of types, goals, and clauses"
5+
license = "Apache-2.0/MIT"
6+
authors = ["Rust Compiler Team", "Chalk developers"]
7+
repository = "https://github.com/rust-lang-nursery/chalk"
8+
readme = "README.md"
9+
keywords = ["compiler", "traits", "prolog"]
10+
11+
[dependencies]
12+
lalrpop-intern = "0.14"
13+
14+
[dependencies.chalk-macros]
15+
version = "0.1.0"
16+
path = "../chalk-macros"
17+
18+
[dependencies.chalk-engine]
19+
version = "0.7.2"
20+
path = "../chalk-engine"

src/cast.rs renamed to chalk-ir/src/cast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ir::*;
1+
use ::*;
22
use std::marker::PhantomData;
33

44
/// The `Cast` trait is used to make annoying upcasts between
@@ -26,7 +26,7 @@ use std::marker::PhantomData;
2626
/// as part of this, they should always use the same set of free
2727
/// variables (the `Canonical` implementation, for example, relies on
2828
/// that).
29-
crate trait Cast<T>: Sized {
29+
pub trait Cast<T>: Sized {
3030
fn cast(self) -> T;
3131
}
3232

@@ -224,7 +224,7 @@ where
224224
}
225225
}
226226

227-
crate struct Casted<I, U> {
227+
pub struct Casted<I, U> {
228228
iterator: I,
229229
_cast: PhantomData<U>,
230230
}
@@ -246,7 +246,7 @@ where
246246

247247
/// An iterator adapter that casts each element we are iterating over
248248
/// to some other type.
249-
crate trait Caster<U>: Sized {
249+
pub trait Caster<U>: Sized {
250250
fn casted(self) -> Casted<Self, U>;
251251
}
252252

src/ir/could_match.rs renamed to chalk-ir/src/could_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use ir::*;
1+
use ::*;
22
use zip::{Zip, Zipper};
33

44
/// A fast check to see whether two things could ever possibly match.
5-
crate trait CouldMatch<T> {
5+
pub trait CouldMatch<T> {
66
fn could_match(&self, other: &T) -> bool;
77
}
88

src/ir/debug.rs renamed to chalk-ir/src/debug.rs

+12-31
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@ use super::*;
55
impl Debug for ItemId {
66
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
77
tls::with_current_program(|p| match p {
8-
Some(prog) => if let Some(k) = prog.type_kinds.get(self) {
9-
write!(fmt, "{}", k.name)
10-
} else if let Some(k) = prog.associated_ty_data.get(self) {
11-
write!(fmt, "({:?}::{})", k.trait_id, k.name)
12-
} else {
13-
fmt.debug_struct("ItemId")
14-
.field("index", &self.index)
15-
.finish()
16-
},
17-
None => fmt.debug_struct("ItemId")
8+
Some(prog) => prog.debug_item_id(*self, fmt),
9+
None => fmt
10+
.debug_struct("ItemId")
1811
.field("index", &self.index)
1912
.finish(),
2013
})
@@ -58,10 +51,7 @@ impl Debug for Ty {
5851
impl Debug for QuantifiedTy {
5952
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
6053
// FIXME -- we should introduce some names or something here
61-
let QuantifiedTy {
62-
num_binders,
63-
ty,
64-
} = self;
54+
let QuantifiedTy { num_binders, ty } = self;
6555
write!(fmt, "for<{}> {:?}", num_binders, ty)
6656
}
6757
}
@@ -96,19 +86,7 @@ impl Debug for TraitRef {
9686
impl Debug for ProjectionTy {
9787
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
9888
tls::with_current_program(|p| match p {
99-
Some(program) => {
100-
let (associated_ty_data, trait_params, other_params) =
101-
program.split_projection(self);
102-
write!(
103-
fmt,
104-
"<{:?} as {:?}{:?}>::{}{:?}",
105-
&trait_params[0],
106-
associated_ty_data.trait_id,
107-
Angle(&trait_params[1..]),
108-
associated_ty_data.name,
109-
Angle(&other_params)
110-
)
111-
}
89+
Some(program) => program.debug_projection(self, fmt),
11290
None => write!(
11391
fmt,
11492
"({:?}){:?}",
@@ -132,7 +110,7 @@ impl Debug for UnselectedProjectionTy {
132110
}
133111
}
134112

135-
crate struct Angle<'a, T: 'a>(pub &'a [T]);
113+
pub struct Angle<'a, T: 'a>(pub &'a [T]);
136114

137115
impl<'a, T: Debug> Debug for Angle<'a, T> {
138116
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
@@ -165,7 +143,11 @@ impl Debug for ProjectionEq {
165143

166144
impl Debug for UnselectedNormalize {
167145
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
168-
write!(fmt, "UnselectedNormalize({:?} -> {:?})", self.projection, self.ty)
146+
write!(
147+
fmt,
148+
"UnselectedNormalize({:?} -> {:?})",
149+
self.projection, self.ty
150+
)
169151
}
170152
}
171153

@@ -379,8 +361,7 @@ impl Display for ConstrainedSubst {
379361
write!(
380362
f,
381363
"substitution {}, lifetime constraints {:?}",
382-
subst,
383-
constraints,
364+
subst, constraints,
384365
)
385366
}
386367
}
File renamed without changes.

0 commit comments

Comments
 (0)