Do not discard ?Sized
type params and suggest their removal
This commit is contained in:
parent
5fb3394cbd
commit
15a40c7ee8
32 changed files with 615 additions and 19 deletions
|
@ -1443,16 +1443,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
ImplTraitContext::disallowed(),
|
||||
),
|
||||
bounded_ty: this.lower_ty(bounded_ty, ImplTraitContext::disallowed()),
|
||||
bounds: this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| {
|
||||
match *bound {
|
||||
// Ignore `?Trait` bounds.
|
||||
// They were copied into type parameters already.
|
||||
GenericBound::Trait(_, TraitBoundModifier::Maybe) => None,
|
||||
_ => Some(
|
||||
this.lower_param_bound(bound, ImplTraitContext::disallowed()),
|
||||
),
|
||||
}
|
||||
})),
|
||||
bounds: this.arena.alloc_from_iter(bounds.iter().map(
|
||||
|bound| match bound {
|
||||
// We used to ignore `?Trait` bounds, as they were copied into type
|
||||
// parameters already, but we need to keep them around only for
|
||||
// diagnostics when we suggest removal of `?Sized` bounds. See
|
||||
// `suggest_constraining_type_param`. This will need to change if
|
||||
// we ever allow something *other* than `?Sized`.
|
||||
GenericBound::Trait(p, TraitBoundModifier::Maybe) => {
|
||||
hir::GenericBound::Unsized(p.span)
|
||||
}
|
||||
_ => this.lower_param_bound(bound, ImplTraitContext::disallowed()),
|
||||
},
|
||||
)),
|
||||
span,
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2160,12 +2160,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
tpb: &GenericBound,
|
||||
itctx: ImplTraitContext<'_, 'hir>,
|
||||
) -> hir::GenericBound<'hir> {
|
||||
match *tpb {
|
||||
GenericBound::Trait(ref ty, modifier) => hir::GenericBound::Trait(
|
||||
self.lower_poly_trait_ref(ty, itctx),
|
||||
self.lower_trait_bound_modifier(modifier),
|
||||
match tpb {
|
||||
GenericBound::Trait(p, modifier) => hir::GenericBound::Trait(
|
||||
self.lower_poly_trait_ref(p, itctx),
|
||||
self.lower_trait_bound_modifier(*modifier),
|
||||
),
|
||||
GenericBound::Outlives(ref lifetime) => {
|
||||
GenericBound::Outlives(lifetime) => {
|
||||
hir::GenericBound::Outlives(self.lower_lifetime(lifetime))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue