]> git.lizzy.rs Git - rust.git/commitdiff
useful comments
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 12 Jul 2019 10:29:27 +0000 (06:29 -0400)
committerAlexander Regueiro <alexreg@me.com>
Mon, 5 Aug 2019 14:16:27 +0000 (15:16 +0100)
src/librustc_typeck/astconv.rs
src/librustc_typeck/collect.rs

index 881f66afc91dfcbb56b964c3e1156d01b317f1d6..7d275e48a294aecbe9eaa4c8e16458a5b3c51db2 100644 (file)
 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>;
 
index 357dcd878f51521bdb9822b2533c1589d4c1c37e..0f0568907c64679e4b3dcd3f295cb63b746cf108 100644 (file)
@@ -250,6 +250,8 @@ fn record_ty(&self, _hir_id: hir::HirId, _ty: Ty<'tcx>, _span: Span) {
     }
 }
 
+/// 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),