mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Added some comments, made add_bounds
private.
This commit is contained in:
parent
0f4a5ca33c
commit
538ebd197c
@ -699,6 +699,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Convert associated-type bindings or constraints into a separate vector.
|
||||||
|
// Example: Given this:
|
||||||
|
//
|
||||||
|
// T: Iterator<Item = u32>
|
||||||
|
//
|
||||||
|
// The `T` is passed in as a self-type; the `Item = u32` is
|
||||||
|
// not a "type parameter" of the `Iterator` trait, but rather
|
||||||
|
// a restriction on `<T as Iterator>::Item`, so it is passed
|
||||||
|
// back separately.
|
||||||
let assoc_bindings = generic_args.bindings.iter()
|
let assoc_bindings = generic_args.bindings.iter()
|
||||||
.map(|binding| {
|
.map(|binding| {
|
||||||
let kind = if let hir::TyKind::AssocTyExistential(ref bounds) = binding.ty.node {
|
let kind = if let hir::TyKind::AssocTyExistential(ref bounds) = binding.ty.node {
|
||||||
@ -899,7 +908,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_bounds(&self,
|
fn add_bounds(&self,
|
||||||
param_ty: Ty<'tcx>,
|
param_ty: Ty<'tcx>,
|
||||||
ast_bounds: &[hir::GenericBound],
|
ast_bounds: &[hir::GenericBound],
|
||||||
bounds: &mut Bounds<'tcx>,
|
bounds: &mut Bounds<'tcx>,
|
||||||
@ -1065,6 +1074,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
|||||||
|
|
||||||
match binding.kind {
|
match binding.kind {
|
||||||
ConvertedBindingKind::Equality(ref ty) => {
|
ConvertedBindingKind::Equality(ref ty) => {
|
||||||
|
// "Desugar" a constraint like `T: Iterator<Item = u32>` this to
|
||||||
|
// the "projection predicate" for:
|
||||||
|
//
|
||||||
|
// `<T as Iterator>::Item = u32`
|
||||||
bounds.projection_bounds.push((candidate.map_bound(|trait_ref| {
|
bounds.projection_bounds.push((candidate.map_bound(|trait_ref| {
|
||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty: ty::ProjectionTy::from_ref_and_name(
|
projection_ty: ty::ProjectionTy::from_ref_and_name(
|
||||||
|
Loading…
Reference in New Issue
Block a user