Skip to content

Commit 18d5085

Browse files
nikomatsakisAlexander Regueiro
authored and
Alexander Regueiro
committed
more comments
1 parent 83078f0 commit 18d5085

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/librustc_typeck/astconv.rs

+31-3
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,21 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
929929
true
930930
}
931931

932+
/// This helper takes a *converted* parameter type (`param_ty`)
933+
/// and an *unconverted* list of bounds:
934+
///
935+
/// ```
936+
/// fn foo<T: Debug>
937+
/// ^ ^^^^^ `ast_bounds` parameter, in HIR form
938+
/// |
939+
/// `param_ty`, in ty form
940+
/// ```
941+
///
942+
/// It adds these `ast_bounds` into the `bounds` structure.
943+
///
944+
/// **A note on binders:** There is an implied binder around
945+
/// `param_ty` and `ast_bounds`. See `instantiate_poly_trait_ref`
946+
/// for more details.
932947
fn add_bounds(&self,
933948
param_ty: Ty<'tcx>,
934949
ast_bounds: &[hir::GenericBound],
@@ -962,9 +977,22 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
962977
);
963978
}
964979

965-
/// Translates the AST's notion of ty param bounds (which are an enum consisting of a newtyped
966-
/// `Ty` or a region) to ty's notion of ty param bounds (which can either be user-defined traits
967-
/// or the built-in trait `Sized`).
980+
/// Translates a list of bounds from the HIR into the `Bounds` data structure.
981+
/// The self-type for the bounds is given by `param_ty`.
982+
///
983+
/// Example:
984+
///
985+
/// ```
986+
/// fn foo<T: Bar + Baz>() { }
987+
/// ^ ^^^^^^^^^ ast_bounds
988+
/// param_ty
989+
/// ```
990+
///
991+
/// The `sized_by_default` parameter indicates if, in this context, the `param_ty` should be
992+
/// considered `Sized` unless there is an explicit `?Sized` bound. This would be true in the
993+
/// example above, but is not true in supertrait listings like `trait Foo: Bar + Baz`.
994+
///
995+
/// `span` should be the declaration size of the parameter.
968996
pub fn compute_bounds(&self,
969997
param_ty: Ty<'tcx>,
970998
ast_bounds: &[hir::GenericBound],

0 commit comments

Comments
 (0)