about summary refs log tree commit diff
path: root/src/librustc_metadata/decoder.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-07-02 10:35:30 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-07-02 11:33:24 -0400
commit90ea49b891937eb7f121c1ded01ceacb66074e74 (patch)
tree596160e12e8bad733f470b0c58f6a45d27eec80d /src/librustc_metadata/decoder.rs
parent327093007add511cdcca4032dda13f7a342f29ea (diff)
downloadrust-90ea49b891937eb7f121c1ded01ceacb66074e74.tar.gz
rust-90ea49b891937eb7f121c1ded01ceacb66074e74.zip
introduce `predicates_defined_on` for traits
This new query returns only the predicates *directly defined* on an
item (in contrast to the more common `predicates_of`, which returns
the predicates that must be proven to reference an item). These two
sets are almost always identical except for traits, where
`predicates_of` includes an artificial `Self: Trait<...>` predicate
(basically saying that you cannot use a trait item without proving
that the trait is implemented for the type parameters).

This new query is only used in chalk lowering, where this artificial
`Self: Trait` predicate is problematic. We encode it in metadata but
only where needed since it is kind of repetitive with existing
information.

Co-authored-by: Tyler Mandry <tmandry@gmail.com>
Diffstat (limited to 'src/librustc_metadata/decoder.rs')
-rw-r--r--src/librustc_metadata/decoder.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs
index 1985900b3e1..d604ac819b8 100644
--- a/src/librustc_metadata/decoder.rs
+++ b/src/librustc_metadata/decoder.rs
@@ -563,6 +563,13 @@ impl<'a, 'tcx> CrateMetadata {
         self.entry(item_id).predicates.unwrap().decode((self, tcx))
     }
 
+    pub fn get_predicates_defined_on(&self,
+                                   item_id: DefIndex,
+                                   tcx: TyCtxt<'a, 'tcx, 'tcx>)
+                                   -> ty::GenericPredicates<'tcx> {
+        self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx))
+    }
+
     pub fn get_super_predicates(&self,
                                 item_id: DefIndex,
                                 tcx: TyCtxt<'a, 'tcx, 'tcx>)