Skip to content

Commit eb1ed91

Browse files
authored
Merge pull request #213 from detrumi/simplify-coinductive-trait-check
Remove coinductive_traits from ProgramEnvironment
2 parents 65de8b8 + 8cfd490 commit eb1ed91

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

src/db.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ impl ChalkSolveDatabase for ChalkDatabase {
7676
}
7777

7878
fn is_coinductive_trait(&self, trait_id: TraitId) -> bool {
79-
if let Ok(env) = self.environment() {
80-
env.coinductive_traits.contains(&trait_id)
79+
if let Ok(program) = self.program_ir() {
80+
// Currently, only auto traits are coinductive
81+
program.trait_data[&trait_id].binders.value.flags.auto
8182
} else {
8283
false
8384
}

src/program_environment.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
use chalk_ir::ProgramClause;
2-
use chalk_ir::TraitId;
3-
use std::collections::BTreeSet;
42

53
#[derive(Clone, Debug, PartialEq, Eq)]
64
pub struct ProgramEnvironment {
7-
/// Indicates whether a given trait has coinductive semantics --
8-
/// at present, this is true only for auto traits.
9-
pub coinductive_traits: BTreeSet<TraitId>,
10-
115
/// Compiled forms of the above:
126
pub program_clauses: Vec<ProgramClause>,
137
}
148

159
impl ProgramEnvironment {
16-
pub fn new(coinductive_traits: BTreeSet<TraitId>, program_clauses: Vec<ProgramClause>) -> Self {
17-
Self {
18-
coinductive_traits,
19-
program_clauses,
20-
}
10+
pub fn new(program_clauses: Vec<ProgramClause>) -> Self {
11+
Self { program_clauses }
2112
}
2213
}

src/query.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,7 @@ fn environment(db: &impl LoweringDatabase) -> Result<Arc<ProgramEnvironment>, Ch
167167
}
168168
}
169169

170-
let coinductive_traits = program
171-
.trait_data
172-
.iter()
173-
.filter_map(|(&trait_id, trait_datum)| {
174-
if trait_datum.binders.value.flags.auto {
175-
Some(trait_id)
176-
} else {
177-
None
178-
}
179-
})
180-
.collect();
181-
182-
Ok(Arc::new(ProgramEnvironment::new(
183-
coinductive_traits,
184-
program_clauses,
185-
)))
170+
Ok(Arc::new(ProgramEnvironment::new(program_clauses)))
186171
}
187172

188173
fn solver(db: &impl LoweringDatabase) -> Arc<Mutex<Solver>> {

0 commit comments

Comments
 (0)