compute_bounds takes &[GenericBound]
This commit is contained in:
parent
c0007a2d7e
commit
dd267fecd6
|
@ -878,22 +878,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
pub fn compute_bounds(
|
pub fn compute_bounds(
|
||||||
&self,
|
&self,
|
||||||
param_ty: Ty<'tcx>,
|
param_ty: Ty<'tcx>,
|
||||||
ast_bounds: &[&hir::GenericBound<'_>],
|
ast_bounds: &[hir::GenericBound<'_>],
|
||||||
sized_by_default: SizedByDefault,
|
sized_by_default: SizedByDefault,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> Bounds<'tcx> {
|
) -> Bounds<'tcx> {
|
||||||
let mut bounds = Bounds::default();
|
let ast_bounds: Vec<_> = ast_bounds.iter().collect();
|
||||||
|
self.compute_bounds_inner(param_ty, &ast_bounds, sized_by_default, span)
|
||||||
self.add_bounds(param_ty, ast_bounds, &mut bounds);
|
|
||||||
bounds.trait_bounds.sort_by_key(|(t, _, _)| t.def_id());
|
|
||||||
|
|
||||||
bounds.implicitly_sized = if let SizedByDefault::Yes = sized_by_default {
|
|
||||||
if !self.is_unsized(ast_bounds, span) { Some(span) } else { None }
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
bounds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compute_bounds_that_match_assoc_type(
|
pub fn compute_bounds_that_match_assoc_type(
|
||||||
|
@ -916,7 +906,28 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.compute_bounds(param_ty, &result, sized_by_default, span)
|
self.compute_bounds_inner(param_ty, &result, sized_by_default, span)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn compute_bounds_inner(
|
||||||
|
&self,
|
||||||
|
param_ty: Ty<'tcx>,
|
||||||
|
ast_bounds: &[&hir::GenericBound<'_>],
|
||||||
|
sized_by_default: SizedByDefault,
|
||||||
|
span: Span,
|
||||||
|
) -> Bounds<'tcx> {
|
||||||
|
let mut bounds = Bounds::default();
|
||||||
|
|
||||||
|
self.add_bounds(param_ty, ast_bounds, &mut bounds);
|
||||||
|
bounds.trait_bounds.sort_by_key(|(t, _, _)| t.def_id());
|
||||||
|
|
||||||
|
bounds.implicitly_sized = if let SizedByDefault::Yes = sized_by_default {
|
||||||
|
if !self.is_unsized(ast_bounds, span) { Some(span) } else { None }
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given an HIR binding like `Item = Foo` or `Item: Foo`, pushes the corresponding predicates
|
/// Given an HIR binding like `Item = Foo` or `Item: Foo`, pushes the corresponding predicates
|
||||||
|
|
|
@ -1072,7 +1072,6 @@ fn super_predicates_that_define_assoc_type(
|
||||||
assoc_name,
|
assoc_name,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let bounds: Vec<_> = bounds.iter().collect();
|
|
||||||
AstConv::compute_bounds(&icx, self_param_ty, &bounds, SizedByDefault::No, item.span)
|
AstConv::compute_bounds(&icx, self_param_ty, &bounds, SizedByDefault::No, item.span)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2030,8 +2029,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||||
index += 1;
|
index += 1;
|
||||||
|
|
||||||
let sized = SizedByDefault::Yes;
|
let sized = SizedByDefault::Yes;
|
||||||
let bounds: Vec<_> = param.bounds.iter().collect();
|
let bounds =
|
||||||
let bounds = AstConv::compute_bounds(&icx, param_ty, &bounds, sized, param.span);
|
AstConv::compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span);
|
||||||
predicates.extend(bounds.predicates(tcx, param_ty));
|
predicates.extend(bounds.predicates(tcx, param_ty));
|
||||||
}
|
}
|
||||||
GenericParamKind::Const { .. } => {
|
GenericParamKind::Const { .. } => {
|
||||||
|
|
|
@ -25,7 +25,6 @@ fn associated_type_bounds<'tcx>(
|
||||||
InternalSubsts::identity_for_item(tcx, assoc_item_def_id),
|
InternalSubsts::identity_for_item(tcx, assoc_item_def_id),
|
||||||
);
|
);
|
||||||
|
|
||||||
let bounds: Vec<_> = bounds.iter().collect();
|
|
||||||
let bounds = AstConv::compute_bounds(
|
let bounds = AstConv::compute_bounds(
|
||||||
&ItemCtxt::new(tcx, assoc_item_def_id),
|
&ItemCtxt::new(tcx, assoc_item_def_id),
|
||||||
item_ty,
|
item_ty,
|
||||||
|
@ -66,7 +65,6 @@ fn opaque_type_bounds<'tcx>(
|
||||||
let item_ty =
|
let item_ty =
|
||||||
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
|
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
|
||||||
|
|
||||||
let bounds: Vec<_> = bounds.iter().collect();
|
|
||||||
let bounds = AstConv::compute_bounds(
|
let bounds = AstConv::compute_bounds(
|
||||||
&ItemCtxt::new(tcx, opaque_def_id),
|
&ItemCtxt::new(tcx, opaque_def_id),
|
||||||
item_ty,
|
item_ty,
|
||||||
|
|
Loading…
Reference in a new issue