Skip to content

Commit 99ea62d

Browse files
authored
Merge pull request #602 from detrumi/simplify-lowering
Simplify lowering
2 parents cf7bc67 + db471f1 commit 99ea62d

File tree

8 files changed

+538
-872
lines changed

8 files changed

+538
-872
lines changed

chalk-integration/src/db.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
error::ChalkError,
33
interner::ChalkIr,
4-
lowering::LowerGoal,
4+
lowering::lower_goal,
55
program::Program,
66
query::{Lowering, LoweringDatabase},
77
tls, SolverChoice,
@@ -43,7 +43,7 @@ impl ChalkDatabase {
4343

4444
pub fn parse_and_lower_goal(&self, text: &str) -> Result<Goal<ChalkIr>, ChalkError> {
4545
let program = self.checked_program()?;
46-
Ok(chalk_parse::parse_goal(text)?.lower(&*program)?)
46+
Ok(lower_goal(&*chalk_parse::parse_goal(text)?, &*program)?)
4747
}
4848

4949
pub fn solve(

chalk-integration/src/lowering.rs

+513-851
Large diffs are not rendered by default.

chalk-integration/src/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use crate::error::ChalkError;
55
use crate::interner::ChalkIr;
6-
use crate::lowering::LowerProgram;
6+
use crate::lowering::Lower;
77
use crate::program::Program;
88
use crate::program_environment::ProgramEnvironment;
99
use crate::tls;

chalk-parse/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub struct AssocTyDefn {
151151
pub struct OpaqueTyDefn {
152152
pub ty: Ty,
153153
pub variable_kinds: Vec<VariableKind>,
154-
pub identifier: Identifier,
154+
pub name: Identifier,
155155
pub bounds: Vec<QuantifiedInlineBound>,
156156
pub where_clauses: Vec<QuantifiedWhereClause>,
157157
}

chalk-parse/src/parser.lalrpop

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ AssocTyDefn: AssocTyDefn = {
231231
};
232232

233233
OpaqueTyDefn: OpaqueTyDefn = {
234-
"opaque" "type" <identifier:Id> <p:Angle<VariableKind>> ":" <b:Plus<QuantifiedInlineBound>>
234+
"opaque" "type" <name:Id> <p:Angle<VariableKind>> ":" <b:Plus<QuantifiedInlineBound>>
235235
<w:QuantifiedWhereClauses> "=" <ty:Ty> ";" => {
236236
OpaqueTyDefn {
237237
ty,
238238
variable_kinds: p,
239-
identifier,
239+
name,
240240
bounds: b,
241241
where_clauses: w,
242242
}

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl LoadedProgram {
6666
multiple_answers: bool,
6767
) -> Result<()> {
6868
let program = self.db.checked_program()?;
69-
let goal = chalk_parse::parse_goal(text)?.lower(&*program)?;
69+
let goal = lower_goal(&*chalk_parse::parse_goal(text)?, &*program)?;
7070
let peeled_goal = goal.into_peeled_goal(self.db.interner());
7171
if multiple_answers {
7272
if self.db.solve_multiple(&peeled_goal, &mut |v, has_next| {

tests/logging_db/util.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
//! to `test/`. We can't compile without access to `test/`, so we can't be under
66
//! of `test_util.rs`.
77
use chalk_integration::{
8-
db::ChalkDatabase, lowering::LowerGoal, program::Program, query::LoweringDatabase, SolverChoice,
8+
db::ChalkDatabase, lowering::lower_goal, program::Program, query::LoweringDatabase,
9+
SolverChoice,
910
};
1011
use chalk_solve::ext::*;
1112
use chalk_solve::logging_db::LoggingRustIrDatabase;
@@ -47,10 +48,11 @@ pub fn logging_db_output_sufficient(
4748
println!("goal {}", goal_text);
4849
assert!(goal_text.starts_with("{"));
4950
assert!(goal_text.ends_with("}"));
50-
let goal = chalk_parse::parse_goal(&goal_text[1..goal_text.len() - 1])
51-
.unwrap()
52-
.lower(&*program)
53-
.unwrap();
51+
let goal = lower_goal(
52+
&*chalk_parse::parse_goal(&goal_text[1..goal_text.len() - 1]).unwrap(),
53+
&*program,
54+
)
55+
.unwrap();
5456

5557
println!("using solver: {:?}", solver_choice);
5658
let peeled_goal = goal.into_peeled_goal(db.interner());
@@ -88,10 +90,11 @@ pub fn logging_db_output_sufficient(
8890
println!("goal {}", goal_text);
8991
assert!(goal_text.starts_with("{"));
9092
assert!(goal_text.ends_with("}"));
91-
let goal = chalk_parse::parse_goal(&goal_text[1..goal_text.len() - 1])
92-
.unwrap()
93-
.lower(&*new_program)
94-
.unwrap();
93+
let goal = lower_goal(
94+
&*chalk_parse::parse_goal(&goal_text[1..goal_text.len() - 1]).unwrap(),
95+
&*new_program,
96+
)
97+
.unwrap();
9598

9699
println!("using solver: {:?}", solver_choice);
97100
let peeled_goal = goal.into_peeled_goal(db.interner());

tests/test/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::test_util::assert_same;
44
use chalk_integration::db::ChalkDatabase;
55
use chalk_integration::interner::ChalkIr;
6-
use chalk_integration::lowering::LowerGoal;
6+
use chalk_integration::lowering::lower_goal;
77
use chalk_integration::query::LoweringDatabase;
88
use chalk_integration::SolverChoice;
99
use chalk_ir::Constraints;
@@ -254,10 +254,11 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
254254
println!("goal {}", goal_text);
255255
assert!(goal_text.starts_with("{"));
256256
assert!(goal_text.ends_with("}"));
257-
let goal = chalk_parse::parse_goal(&goal_text[1..goal_text.len() - 1])
258-
.unwrap()
259-
.lower(&*program)
260-
.unwrap();
257+
let goal = lower_goal(
258+
&*chalk_parse::parse_goal(&goal_text[1..goal_text.len() - 1]).unwrap(),
259+
&*program,
260+
)
261+
.unwrap();
261262

262263
println!("using solver: {:?}", solver_choice);
263264
let peeled_goal = goal.into_peeled_goal(db.interner());

0 commit comments

Comments
 (0)