about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-07-12 06:29:27 -0400
committerAlexander Regueiro <alexreg@me.com>2019-08-05 15:16:27 +0100
commit63a67a076f134347d9941bb46bdac9bacebe2431 (patch)
tree96b40571feb94e816e4fbd65b56baa35a38c5e95
parent709b9246434944f5eb7c626d43dbaf6cea00e531 (diff)
downloadrust-63a67a076f134347d9941bb46bdac9bacebe2431.tar.gz
rust-63a67a076f134347d9941bb46bdac9bacebe2431.zip
useful comments
-rw-r--r--src/librustc_typeck/astconv.rs13
-rw-r--r--src/librustc_typeck/collect.rs2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 881f66afc91..7d275e48a29 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -42,8 +42,17 @@ pub struct PathSeg(pub DefId, pub usize);
 pub trait AstConv<'tcx> {
     fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
 
-    /// Returns the set of bounds in scope for the type parameter with
-    /// the given id.
+    /// Returns predicates in scope of the form `X: Foo`, where `X` is
+    /// a type parameter `X` with the given id `def_id`. This is a
+    /// subset of the full set of predicates.
+    ///
+    /// This is used for one specific purpose: resolving "short-hand"
+    /// associated type references like `T::Item`. In principle, we
+    /// would do that by first getting the full set of predicates in
+    /// scope and then filtering down to find those that apply to `T`,
+    /// but this can lead to cycle errors. The problem is that we have
+    /// to do this resolution *in order to create the predicates in
+    /// the first place*. Hence, we have this "special pass".
     fn get_type_parameter_bounds(&self, span: Span, def_id: DefId)
                                  -> &'tcx ty::GenericPredicates<'tcx>;
 
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 357dcd878f5..0f0568907c6 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -250,6 +250,8 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
     }
 }
 
+/// Returns the predicates defined on `item_def_id` of the form
+/// `X: Foo` where `X` is the type parameter `def_id`.
 fn type_param_predicates(
     tcx: TyCtxt<'_>,
     (item_def_id, def_id): (DefId, DefId),