Skip to content

Commit f3eac03

Browse files
authored
Merge pull request #106 from scalexm/master
Fix `InferenceTable::normalize_lifetime`
2 parents b97a08d + 611f063 commit f3eac03

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

chalk-engine/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,12 @@
4949
//! - HH: Hereditary harrop predicates. What Chalk deals in.
5050
//! Popularized by Lambda Prolog.
5151
52-
#![feature(conservative_impl_trait)]
5352
#![feature(crate_in_paths)]
5453
#![feature(crate_visibility_modifier)]
5554
#![feature(dyn_trait)]
5655
#![feature(in_band_lifetimes)]
57-
#![feature(match_default_bindings)]
5856
#![feature(macro_vis_matcher)]
5957
#![feature(step_trait)]
60-
#![feature(universal_impl_trait)]
6158
#![feature(underscore_lifetimes)]
6259

6360
#[macro_use] extern crate chalk_macros;

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
#![recursion_limit = "1024"]
22
#![cfg_attr(test, feature(test))]
3-
#![feature(conservative_impl_trait)]
43
#![feature(catch_expr)]
54
#![feature(crate_in_paths)]
65
#![feature(crate_visibility_modifier)]
76
#![feature(dyn_trait)]
87
#![feature(in_band_lifetimes)]
98
#![feature(macro_at_most_once_rep)]
109
#![feature(macro_vis_matcher)]
11-
#![feature(match_default_bindings)]
1210
#![feature(specialization)]
1311
#![feature(step_trait)]
1412
#![feature(underscore_lifetimes)]
15-
#![feature(universal_impl_trait)]
1613

1714
extern crate chalk_parse;
1815
#[macro_use]

src/solve/infer/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ impl InferenceTable {
164164
crate fn normalize_lifetime(&mut self, leaf: &Lifetime, binders: usize) -> Option<Lifetime> {
165165
match *leaf {
166166
Lifetime::Var(v) => {
167-
let v1 = self.probe_lifetime_var(InferenceVariable::from_depth(v))?;
167+
if v < binders {
168+
return None;
169+
}
170+
let v1 = self.probe_lifetime_var(InferenceVariable::from_depth(v - binders))?;
168171
Some(v1.up_shift(binders))
169172
}
170173
Lifetime::ForAll(_) => None,

src/solve/test/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,3 +1992,28 @@ fn clauses_in_if_goals() {
19921992
}
19931993
}
19941994
}
1995+
1996+
#[test]
1997+
fn quantified_types() {
1998+
test! {
1999+
program {
2000+
trait Foo { }
2001+
struct fn<'a> { }
2002+
impl Foo for for<'a> fn<'a> { }
2003+
}
2004+
2005+
goal {
2006+
for<'a> fn<'a>: Foo
2007+
} yields {
2008+
"Unique"
2009+
}
2010+
2011+
goal {
2012+
forall<'a> { fn<'a>: Foo }
2013+
} yields {
2014+
// Lifetime constraints are unsatisfiable
2015+
"Unique; substitution [], \
2016+
lifetime constraints [InEnvironment { environment: Env([]), goal: '!2 == '!1 }]"
2017+
}
2018+
}
2019+
}

0 commit comments

Comments
 (0)