Skip to content

Commit 63a67a0

Browse files
nikomatsakisAlexander Regueiro
authored andcommitted
useful comments
1 parent 709b924 commit 63a67a0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,17 @@ pub struct PathSeg(pub DefId, pub usize);
4242
pub trait AstConv<'tcx> {
4343
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
4444

45-
/// Returns the set of bounds in scope for the type parameter with
46-
/// the given id.
45+
/// Returns predicates in scope of the form `X: Foo`, where `X` is
46+
/// a type parameter `X` with the given id `def_id`. This is a
47+
/// subset of the full set of predicates.
48+
///
49+
/// This is used for one specific purpose: resolving "short-hand"
50+
/// associated type references like `T::Item`. In principle, we
51+
/// would do that by first getting the full set of predicates in
52+
/// scope and then filtering down to find those that apply to `T`,
53+
/// but this can lead to cycle errors. The problem is that we have
54+
/// to do this resolution *in order to create the predicates in
55+
/// the first place*. Hence, we have this "special pass".
4756
fn get_type_parameter_bounds(&self, span: Span, def_id: DefId)
4857
-> &'tcx ty::GenericPredicates<'tcx>;
4958

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
250250
}
251251
}
252252

253+
/// Returns the predicates defined on `item_def_id` of the form
254+
/// `X: Foo` where `X` is the type parameter `def_id`.
253255
fn type_param_predicates(
254256
tcx: TyCtxt<'_>,
255257
(item_def_id, def_id): (DefId, DefId),

0 commit comments

Comments
 (0)