Skip to content

Commit 64c486b

Browse files
committed
Update chalk and add LifetimeOutlives and ObjectSafe lowering
1 parent 90e01ee commit 64c486b

File tree

5 files changed

+66
-27
lines changed

5 files changed

+66
-27
lines changed

Cargo.lock

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,10 @@ dependencies = [
432432
"rustc-std-workspace-core",
433433
]
434434

435-
[[package]]
436-
name = "chalk-base"
437-
version = "0.10.1-dev"
438-
source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474"
439-
dependencies = [
440-
"lazy_static",
441-
]
442-
443435
[[package]]
444436
name = "chalk-derive"
445437
version = "0.10.1-dev"
446-
source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474"
438+
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18"
447439
dependencies = [
448440
"proc-macro2 1.0.3",
449441
"quote 1.0.2",
@@ -454,9 +446,8 @@ dependencies = [
454446
[[package]]
455447
name = "chalk-engine"
456448
version = "0.10.1-dev"
457-
source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474"
449+
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18"
458450
dependencies = [
459-
"chalk-base",
460451
"chalk-derive",
461452
"chalk-ir",
462453
"rustc-hash",
@@ -465,18 +456,17 @@ dependencies = [
465456
[[package]]
466457
name = "chalk-ir"
467458
version = "0.10.1-dev"
468-
source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474"
459+
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18"
469460
dependencies = [
470-
"chalk-base",
471461
"chalk-derive",
462+
"lazy_static 1.4.0",
472463
]
473464

474465
[[package]]
475466
name = "chalk-solve"
476467
version = "0.10.1-dev"
477-
source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474"
468+
source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18"
478469
dependencies = [
479-
"chalk-base",
480470
"chalk-derive",
481471
"chalk-engine",
482472
"chalk-ir",

src/librustc_middle/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rustc_serialize = { path = "../librustc_serialize" }
3030
rustc_ast = { path = "../librustc_ast" }
3131
rustc_span = { path = "../librustc_span" }
3232
byteorder = { version = "1.3" }
33-
chalk-ir = { git = "https://github.com/jackh726/chalk.git", rev = "c8f342bf5e48051333d0b2c7fab81347fc21c474" }
33+
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1ca4ddc43abcfed77420f294a3713fac714e18" }
3434
#chalk-ir = "0.10.0"
3535
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3636
measureme = "0.7.1"

src/librustc_traits/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ rustc_span = { path = "../librustc_span" }
1919
#chalk-ir = "0.10.0"
2020
#chalk-rust-ir = "0.10.0"
2121
#chalk-solve = "0.10.0"
22-
chalk-solve = { git = "https://github.com/jackh726/chalk.git", rev = "c8f342bf5e48051333d0b2c7fab81347fc21c474" }
23-
chalk-ir = { git = "https://github.com/jackh726/chalk.git", rev = "c8f342bf5e48051333d0b2c7fab81347fc21c474" }
22+
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1ca4ddc43abcfed77420f294a3713fac714e18" }
23+
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1ca4ddc43abcfed77420f294a3713fac714e18" }
2424
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
2525
rustc_infer = { path = "../librustc_infer" }
2626
rustc_trait_selection = { path = "../librustc_trait_selection" }

src/librustc_traits/chalk/lowering.rs

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,28 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
9797
.intern(interner),
9898
)
9999
}
100-
// FIXME(chalk): need to add RegionOutlives/TypeOutlives
101-
ty::PredicateKind::RegionOutlives(_) => None,
100+
ty::PredicateKind::RegionOutlives(predicate) => {
101+
let (predicate, binders, _named_regions) =
102+
collect_bound_vars(interner, interner.tcx, predicate);
103+
104+
Some(
105+
chalk_ir::ProgramClauseData::ForAll(chalk_ir::Binders::new(
106+
binders,
107+
chalk_ir::ProgramClauseImplication {
108+
consequence: chalk_ir::DomainGoal::Holds(
109+
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
110+
a: predicate.0.lower_into(interner),
111+
b: predicate.1.lower_into(interner),
112+
})
113+
),
114+
conditions: chalk_ir::Goals::new(interner),
115+
priority: chalk_ir::ClausePriority::High,
116+
},
117+
))
118+
.intern(interner),
119+
)
120+
},
121+
// FIXME(chalk): need to add TypeOutlives
102122
ty::PredicateKind::TypeOutlives(_) => None,
103123
ty::PredicateKind::Projection(predicate) => {
104124
let (predicate, binders, _named_regions) =
@@ -156,10 +176,24 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
156176
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
157177
match self.kind() {
158178
ty::PredicateKind::Trait(predicate, _) => predicate.lower_into(interner),
159-
// FIXME(chalk): we need to register constraints.
160-
ty::PredicateKind::RegionOutlives(_predicate) => {
161-
chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
179+
ty::PredicateKind::RegionOutlives(predicate) => {
180+
let (predicate, binders, _named_regions) =
181+
collect_bound_vars(interner, interner.tcx, predicate);
182+
183+
chalk_ir::GoalData::Quantified(
184+
chalk_ir::QuantifierKind::ForAll,
185+
chalk_ir::Binders::new(
186+
binders,
187+
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
188+
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
189+
a: predicate.0.lower_into(interner),
190+
b: predicate.1.lower_into(interner),
191+
})
192+
)).intern(interner)
193+
)
194+
)
162195
}
196+
// FIXME(chalk): TypeOutlives
163197
ty::PredicateKind::TypeOutlives(_predicate) => {
164198
chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
165199
}
@@ -182,12 +216,15 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
182216
GenericArgKind::Lifetime(lt) => bug!("unexpect well formed predicate: {:?}", lt),
183217
},
184218

219+
ty::PredicateKind::ObjectSafe(t) => {
220+
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::ObjectSafe(chalk_ir::TraitId(*t)))
221+
}
222+
185223
// FIXME(chalk): other predicates
186224
//
187225
// We can defer this, but ultimately we'll want to express
188226
// some of these in terms of chalk operations.
189-
ty::PredicateKind::ObjectSafe(..)
190-
| ty::PredicateKind::ClosureKind(..)
227+
ty::PredicateKind::ClosureKind(..)
191228
| ty::PredicateKind::Subtype(..)
192229
| ty::PredicateKind::ConstEvaluatable(..)
193230
| ty::PredicateKind::ConstEquate(..) => {
@@ -484,7 +521,19 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
484521
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
485522
))
486523
}
487-
ty::PredicateKind::RegionOutlives(_predicate) => None,
524+
ty::PredicateKind::RegionOutlives(predicate) => {
525+
let (predicate, binders, _named_regions) =
526+
collect_bound_vars(interner, interner.tcx, predicate);
527+
528+
Some(chalk_ir::Binders::new(
529+
binders,
530+
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
531+
a: predicate.0.lower_into(interner),
532+
b: predicate.1.lower_into(interner),
533+
}),
534+
))
535+
536+
},
488537
ty::PredicateKind::TypeOutlives(_predicate) => None,
489538
ty::PredicateKind::Projection(_predicate) => None,
490539
ty::PredicateKind::WellFormed(_ty) => None,

src/librustc_traits/chalk/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ crate fn evaluate_goal<'tcx>(
199199
.map(|s| match s {
200200
Solution::Unique(_subst) => {
201201
// FIXME(chalk): handle constraints
202-
assert!(_subst.value.constraints.is_empty());
202+
// assert!(_subst.value.constraints.is_empty());
203203
make_solution(_subst.value.subst)
204204
}
205205
Solution::Ambig(_guidance) => {

0 commit comments

Comments
 (0)