diff options
| author | Jack Huey <jack.huey@umassmed.edu> | 2020-05-29 22:09:34 -0400 |
|---|---|---|
| committer | Jack Huey <jack.huey@umassmed.edu> | 2020-06-19 14:05:14 -0400 |
| commit | 64c486b6f43f79645c91a2f4a9b4494d7bbe3c9f (patch) | |
| tree | b6f20865d170c28e6e66095e09a4debe58019bb1 | |
| parent | 90e01ee2089700026fd3fbd68d1dc26f2540a648 (diff) | |
| download | rust-64c486b6f43f79645c91a2f4a9b4494d7bbe3c9f.tar.gz rust-64c486b6f43f79645c91a2f4a9b4494d7bbe3c9f.zip | |
Update chalk and add LifetimeOutlives and ObjectSafe lowering
| -rw-r--r-- | Cargo.lock | 20 | ||||
| -rw-r--r-- | src/librustc_middle/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/librustc_traits/Cargo.toml | 4 | ||||
| -rw-r--r-- | src/librustc_traits/chalk/lowering.rs | 65 | ||||
| -rw-r--r-- | src/librustc_traits/chalk/mod.rs | 2 |
5 files changed, 66 insertions, 27 deletions
diff --git a/Cargo.lock b/Cargo.lock index f3c139c32cb..0adb499a620 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,17 +433,9 @@ dependencies = [ ] [[package]] -name = "chalk-base" -version = "0.10.1-dev" -source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474" -dependencies = [ - "lazy_static", -] - -[[package]] name = "chalk-derive" version = "0.10.1-dev" -source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474" +source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18" dependencies = [ "proc-macro2 1.0.3", "quote 1.0.2", @@ -454,9 +446,8 @@ dependencies = [ [[package]] name = "chalk-engine" version = "0.10.1-dev" -source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474" +source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18" dependencies = [ - "chalk-base", "chalk-derive", "chalk-ir", "rustc-hash", @@ -465,18 +456,17 @@ dependencies = [ [[package]] name = "chalk-ir" version = "0.10.1-dev" -source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474" +source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18" dependencies = [ - "chalk-base", "chalk-derive", + "lazy_static 1.4.0", ] [[package]] name = "chalk-solve" version = "0.10.1-dev" -source = "git+https://github.com/jackh726/chalk.git?rev=c8f342bf5e48051333d0b2c7fab81347fc21c474#c8f342bf5e48051333d0b2c7fab81347fc21c474" +source = "git+https://github.com/rust-lang/chalk.git?rev=ea1ca4ddc43abcfed77420f294a3713fac714e18#ea1ca4ddc43abcfed77420f294a3713fac714e18" dependencies = [ - "chalk-base", "chalk-derive", "chalk-engine", "chalk-ir", diff --git a/src/librustc_middle/Cargo.toml b/src/librustc_middle/Cargo.toml index 121491c8cc4..9516d449671 100644 --- a/src/librustc_middle/Cargo.toml +++ b/src/librustc_middle/Cargo.toml @@ -30,7 +30,7 @@ rustc_serialize = { path = "../librustc_serialize" } rustc_ast = { path = "../librustc_ast" } rustc_span = { path = "../librustc_span" } byteorder = { version = "1.3" } -chalk-ir = { git = "https://github.com/jackh726/chalk.git", rev = "c8f342bf5e48051333d0b2c7fab81347fc21c474" } +chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1ca4ddc43abcfed77420f294a3713fac714e18" } #chalk-ir = "0.10.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "0.7.1" diff --git a/src/librustc_traits/Cargo.toml b/src/librustc_traits/Cargo.toml index 6bfebecf04c..f141daa9f93 100644 --- a/src/librustc_traits/Cargo.toml +++ b/src/librustc_traits/Cargo.toml @@ -19,8 +19,8 @@ rustc_span = { path = "../librustc_span" } #chalk-ir = "0.10.0" #chalk-rust-ir = "0.10.0" #chalk-solve = "0.10.0" -chalk-solve = { git = "https://github.com/jackh726/chalk.git", rev = "c8f342bf5e48051333d0b2c7fab81347fc21c474" } -chalk-ir = { git = "https://github.com/jackh726/chalk.git", rev = "c8f342bf5e48051333d0b2c7fab81347fc21c474" } +chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1ca4ddc43abcfed77420f294a3713fac714e18" } +chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ea1ca4ddc43abcfed77420f294a3713fac714e18" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../librustc_infer" } rustc_trait_selection = { path = "../librustc_trait_selection" } diff --git a/src/librustc_traits/chalk/lowering.rs b/src/librustc_traits/chalk/lowering.rs index 2d9b4247fd9..3cb5008f03d 100644 --- a/src/librustc_traits/chalk/lowering.rs +++ b/src/librustc_traits/chalk/lowering.rs @@ -97,8 +97,28 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<' .intern(interner), ) } - // FIXME(chalk): need to add RegionOutlives/TypeOutlives - ty::PredicateKind::RegionOutlives(_) => None, + ty::PredicateKind::RegionOutlives(predicate) => { + let (predicate, binders, _named_regions) = + collect_bound_vars(interner, interner.tcx, predicate); + + Some( + chalk_ir::ProgramClauseData::ForAll(chalk_ir::Binders::new( + binders, + chalk_ir::ProgramClauseImplication { + consequence: chalk_ir::DomainGoal::Holds( + chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives { + a: predicate.0.lower_into(interner), + b: predicate.1.lower_into(interner), + }) + ), + conditions: chalk_ir::Goals::new(interner), + priority: chalk_ir::ClausePriority::High, + }, + )) + .intern(interner), + ) + }, + // FIXME(chalk): need to add TypeOutlives ty::PredicateKind::TypeOutlives(_) => None, ty::PredicateKind::Projection(predicate) => { let (predicate, binders, _named_regions) = @@ -156,10 +176,24 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> { match self.kind() { ty::PredicateKind::Trait(predicate, _) => predicate.lower_into(interner), - // FIXME(chalk): we need to register constraints. - ty::PredicateKind::RegionOutlives(_predicate) => { - chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)) + ty::PredicateKind::RegionOutlives(predicate) => { + let (predicate, binders, _named_regions) = + collect_bound_vars(interner, interner.tcx, predicate); + + chalk_ir::GoalData::Quantified( + chalk_ir::QuantifierKind::ForAll, + chalk_ir::Binders::new( + binders, + chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds( + chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives { + a: predicate.0.lower_into(interner), + b: predicate.1.lower_into(interner), + }) + )).intern(interner) + ) + ) } + // FIXME(chalk): TypeOutlives ty::PredicateKind::TypeOutlives(_predicate) => { chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)) } @@ -182,12 +216,15 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi GenericArgKind::Lifetime(lt) => bug!("unexpect well formed predicate: {:?}", lt), }, + ty::PredicateKind::ObjectSafe(t) => { + chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::ObjectSafe(chalk_ir::TraitId(*t))) + } + // FIXME(chalk): other predicates // // We can defer this, but ultimately we'll want to express // some of these in terms of chalk operations. - ty::PredicateKind::ObjectSafe(..) - | ty::PredicateKind::ClosureKind(..) + ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::Subtype(..) | ty::PredicateKind::ConstEvaluatable(..) | ty::PredicateKind::ConstEquate(..) => { @@ -484,7 +521,19 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<' chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)), )) } - ty::PredicateKind::RegionOutlives(_predicate) => None, + ty::PredicateKind::RegionOutlives(predicate) => { + let (predicate, binders, _named_regions) = + collect_bound_vars(interner, interner.tcx, predicate); + + Some(chalk_ir::Binders::new( + binders, + chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives { + a: predicate.0.lower_into(interner), + b: predicate.1.lower_into(interner), + }), + )) + + }, ty::PredicateKind::TypeOutlives(_predicate) => None, ty::PredicateKind::Projection(_predicate) => None, ty::PredicateKind::WellFormed(_ty) => None, diff --git a/src/librustc_traits/chalk/mod.rs b/src/librustc_traits/chalk/mod.rs index 4d047d2107a..d8f9a40b943 100644 --- a/src/librustc_traits/chalk/mod.rs +++ b/src/librustc_traits/chalk/mod.rs @@ -199,7 +199,7 @@ crate fn evaluate_goal<'tcx>( .map(|s| match s { Solution::Unique(_subst) => { // FIXME(chalk): handle constraints - assert!(_subst.value.constraints.is_empty()); + // assert!(_subst.value.constraints.is_empty()); make_solution(_subst.value.subst) } Solution::Ambig(_guidance) => { |
