Skip to content

Commit

Permalink
Improve comments for Rule Implemented-From-Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Mar 20, 2018
1 parent 75af15e commit de9e665
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/librustc_traits/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,24 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
return Lrc::new(vec![]);
}

// Rule Implemented-From-Impl
// Rule Implemented-From-Impl (see rustc guide)
//
// (see rustc guide)
// `impl<P0..Pn> Trait<A1..An> for A0 where WC { .. }`
//
// ```
// forall<P0..Pn> {
// Implemented(A0: Trait<A1..An>) :- WC
// }
// ```

let trait_ref = tcx.impl_trait_ref(def_id).unwrap();
let trait_ref = ty::TraitPredicate { trait_ref }.lower();
// `Implemented(A0: Trait<A1..An>)`
let trait_pred = ty::TraitPredicate { trait_ref }.lower();
// `WC`
let where_clauses = tcx.predicates_of(def_id).predicates.lower();

let clause = Clause::Implies(where_clauses, trait_ref);
// `Implemented(A0: Trait<A1..An>) :- WC`
let clause = Clause::Implies(where_clauses, trait_pred);
Lrc::new(vec![clause])
}

Expand Down

0 comments on commit de9e665

Please sign in to comment.