diff options
| author | csmoe <35686186+csmoe@users.noreply.github.com> | 2018-05-11 18:32:51 +0800 |
|---|---|---|
| committer | csmoe <35686186+csmoe@users.noreply.github.com> | 2018-07-05 18:49:02 +0800 |
| commit | ff83ef0c24f866ff1b07fd27bbce5b931b9dc065 (patch) | |
| tree | d76770e5edd70b32f6cff47c790e541cde1680f5 | |
| parent | dabd3f6935771ef26131b06c29f7937f9c561b38 (diff) | |
| download | rust-ff83ef0c24f866ff1b07fd27bbce5b931b9dc065.tar.gz rust-ff83ef0c24f866ff1b07fd27bbce5b931b9dc065.zip | |
merge wellformed(wc)s
| -rw-r--r-- | src/librustc_traits/lowering.rs | 42 | ||||
| -rw-r--r-- | src/test/ui/chalkify/lower_env1.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/chalkify/lower_trait.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/chalkify/lower_trait_higher_rank.stderr | 1 | ||||
| -rw-r--r-- | src/test/ui/chalkify/lower_trait_where_clause.stderr | 7 |
5 files changed, 24 insertions, 38 deletions
diff --git a/src/librustc_traits/lowering.rs b/src/librustc_traits/lowering.rs index c8192f21418..cc12a2e1dcd 100644 --- a/src/librustc_traits/lowering.rs +++ b/src/librustc_traits/lowering.rs @@ -13,10 +13,9 @@ use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::definitions::DefPathData; use rustc::hir::{self, ImplPolarity}; use rustc::traits::{ - Clause, Clauses, DomainGoal, FromEnv, Goal, PolyDomainGoal, ProgramClause, WellFormed, - WhereClause, + Clause, Clauses, DomainGoal, Goal, PolyDomainGoal, ProgramClause, WhereClauseAtom, }; -use rustc::ty::query::Providers; +use rustc::ty::subst::Substs; use rustc::ty::{self, Slice, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use std::mem; @@ -278,21 +277,15 @@ fn program_clauses_for_trait<'a, 'tcx>( hypotheses, })) .map(|wc| implied_bound_from_trait(tcx, trait_pred, wc)); - let wellformed_clauses = where_clauses[1..] - .into_iter() - .map(|wc| wellformed_from_bound(tcx, trait_pred, wc)); - tcx.mk_clauses( - clauses - .chain(implied_bound_clauses) - .chain(wellformed_clauses), - ) + let wellformed_clauses = wellformed_from_bound(tcx, trait_pred, &where_clauses[1..]); + tcx.mk_clauses(clauses.chain(implied_bound_clauses).chain(wellformed_clauses)) } fn wellformed_from_bound<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_pred: ty::TraitPredicate<'tcx>, - where_clause: &ty::Predicate<'tcx>, -) -> Clause<'tcx> { + where_clauses: &[ty::Predicate<'tcx>], +) -> iter::Once<Clause<'tcx>> { // Rule WellFormed-TraitRef // // For each where clause WC: @@ -309,18 +302,17 @@ fn wellformed_from_bound<'a, 'tcx>( .lower() .map_bound(|wc| wc.into_wellformed_goal()); // Implemented(Self: Trait<P1..Pn>) && WellFormed(WC) - let mut where_clauses = vec![impl_trait]; - where_clauses.push(wellformed_wc); - Clause::ForAll(where_clause.lower().map_bound(|_| { - ProgramClause { - goal: wellformed_trait, - hypotheses: tcx.mk_goals( - where_clauses - .into_iter() - .map(|wc| Goal::from_poly_domain_goal(wc, tcx)), - ), - } - })) + let mut wcs = vec![impl_trait]; + wcs.extend(wellformed_wcs); + + let clause = ProgramClause { + goal: wellformed_trait, + hypotheses: tcx.mk_goals( + wcs.into_iter() + .map(|wc| Goal::from_poly_domain_goal(wc, tcx)), + ), + }; + iter::once(Clause::ForAll(ty::Binder::dummy(clause))) } fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { diff --git a/src/test/ui/chalkify/lower_env1.stderr b/src/test/ui/chalkify/lower_env1.stderr index e32df036ef4..e688d9e8b49 100644 --- a/src/test/ui/chalkify/lower_env1.stderr +++ b/src/test/ui/chalkify/lower_env1.stderr @@ -7,8 +7,7 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump = note: FromEnv(Self: Foo) :- FromEnv(Self: Bar). = note: FromEnv(Self: Foo) :- FromEnv(Self: Bar). = note: Implemented(Self: Bar) :- FromEnv(Self: Bar). - = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Bar). - = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo). + = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Bar), WellFormed(Self: Foo). error: program clause dump --> $DIR/lower_env1.rs:19:1 @@ -21,8 +20,9 @@ LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump = note: Implemented(Self: Bar) :- FromEnv(Self: Bar). = note: Implemented(Self: Foo) :- FromEnv(Self: Foo). = note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized). - = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Bar). - = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo). + = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Bar), WellFormed(Self: Foo). + = note: WellFormed(Self: Foo) :- Implemented(Self: Foo). + = note: WellFormed(Self: std::marker::Sized) :- Implemented(Self: std::marker::Sized). error: aborting due to 2 previous errors diff --git a/src/test/ui/chalkify/lower_trait.stderr b/src/test/ui/chalkify/lower_trait.stderr index 4e03fc634cc..c4e768415d6 100644 --- a/src/test/ui/chalkify/lower_trait.stderr +++ b/src/test/ui/chalkify/lower_trait.stderr @@ -8,9 +8,7 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump = note: FromEnv(T: std::marker::Sized) :- FromEnv(Self: Foo<S, T, U>). = note: FromEnv(U: std::marker::Sized) :- FromEnv(Self: Foo<S, T, U>). = note: Implemented(Self: Foo<S, T, U>) :- FromEnv(Self: Foo<S, T, U>). - = note: WellFormed(Self: Foo<S, T, U>) :- Implemented(Self: Foo<S, T, U>), WellFormed(S: std::marker::Sized). - = note: WellFormed(Self: Foo<S, T, U>) :- Implemented(Self: Foo<S, T, U>), WellFormed(T: std::marker::Sized). - = note: WellFormed(Self: Foo<S, T, U>) :- Implemented(Self: Foo<S, T, U>), WellFormed(U: std::marker::Sized). + = note: WellFormed(Self: Foo<S, T, U>) :- Implemented(Self: Foo<S, T, U>), WellFormed(S: std::marker::Sized), WellFormed(T: std::marker::Sized), WellFormed(U: std::marker::Sized). error: aborting due to previous error diff --git a/src/test/ui/chalkify/lower_trait_higher_rank.stderr b/src/test/ui/chalkify/lower_trait_higher_rank.stderr index 891f0453561..ab86b6fdb25 100644 --- a/src/test/ui/chalkify/lower_trait_higher_rank.stderr +++ b/src/test/ui/chalkify/lower_trait_higher_rank.stderr @@ -11,6 +11,7 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump = note: WellFormed(Self: Foo<F>) :- Implemented(Self: Foo<F>), WellFormed(F: std::marker::Sized). = note: WellFormed(Self: Foo<F>) :- Implemented(Self: Foo<F>), forall<> { WellFormed(<F as std::ops::FnOnce<(&'a (u8, u16),)>>::Output == &'a u8) }. = note: WellFormed(Self: Foo<F>) :- Implemented(Self: Foo<F>), forall<> { WellFormed(F: std::ops::Fn<(&'a (u8, u16),)>) }. + = note: WellFormed(Self: Foo<F>) :- Implemented(Self: Foo<F>), WellFormed(F: std::marker::Sized), forall<> { WellFormed(F: std::ops::Fn<(&'a (u8, u16),)>) }, forall<> { WellFormed(<F as std::ops::FnOnce<(&'a (u8, u16),)>>::Output == &'a u8) }. error: aborting due to previous error diff --git a/src/test/ui/chalkify/lower_trait_where_clause.stderr b/src/test/ui/chalkify/lower_trait_where_clause.stderr index db5a795e301..5ea397d424b 100644 --- a/src/test/ui/chalkify/lower_trait_where_clause.stderr +++ b/src/test/ui/chalkify/lower_trait_where_clause.stderr @@ -11,12 +11,7 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump = note: Implemented(Self: Foo<'a, 'b, S, T, U>) :- FromEnv(Self: Foo<'a, 'b, S, T, U>). = note: RegionOutlives('a : 'b) :- FromEnv(Self: Foo<'a, 'b, S, T, U>). = note: TypeOutlives(U : 'b) :- FromEnv(Self: Foo<'a, 'b, S, T, U>). - = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), RegionOutlives('a : 'b). - = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), TypeOutlives(U : 'b). - = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), WellFormed(S: std::fmt::Debug). - = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), WellFormed(S: std::marker::Sized). - = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), WellFormed(T: std::borrow::Borrow<U>). - = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), WellFormed(T: std::marker::Sized). + = note: WellFormed(Self: Foo<'a, 'b, S, T, U>) :- Implemented(Self: Foo<'a, 'b, S, T, U>), WellFormed(S: std::marker::Sized), WellFormed(T: std::marker::Sized), WellFormed(S: std::fmt::Debug), WellFormed(T: std::borrow::Borrow<U>), RegionOutlives('a : 'b), TypeOutlives(U : 'b). error: aborting due to previous error |
