Slim down AssociatedTypeBinding by one usize

This commit is contained in:
Lukas Wirth 2023-02-14 17:18:46 +01:00
parent 41db8c2b59
commit 4c2aef650a
6 changed files with 8 additions and 8 deletions

View file

@ -664,7 +664,7 @@ fn desugar_future_path(orig: TypeRef) -> Path {
name: name![Output], name: name![Output],
args: None, args: None,
type_ref: Some(orig), type_ref: Some(orig),
bounds: Vec::new(), bounds: Box::default(),
}; };
last.bindings.push(binding); last.bindings.push(binding);
generic_args.push(Some(Interned::new(last))); generic_args.push(Some(Interned::new(last)));

View file

@ -77,7 +77,7 @@ pub struct AssociatedTypeBinding {
/// Bounds for the associated type, like in `Iterator<Item: /// Bounds for the associated type, like in `Iterator<Item:
/// SomeOtherTrait>`. (This is the unstable `associated_type_bounds` /// SomeOtherTrait>`. (This is the unstable `associated_type_bounds`
/// feature.) /// feature.)
pub bounds: Vec<Interned<TypeBound>>, pub bounds: Box<[Interned<TypeBound>]>,
} }
/// A single generic argument. /// A single generic argument.

View file

@ -187,7 +187,7 @@ pub(super) fn lower_generic_args(
.map(|it| Interned::new(TypeBound::from_ast(lower_ctx, it))) .map(|it| Interned::new(TypeBound::from_ast(lower_ctx, it)))
.collect() .collect()
} else { } else {
Vec::new() Box::default()
}; };
bindings.push(AssociatedTypeBinding { name, args, type_ref, bounds }); bindings.push(AssociatedTypeBinding { name, args, type_ref, bounds });
} }
@ -234,7 +234,7 @@ fn lower_generic_args_from_fn_path(
name: name![Output], name: name![Output],
args: None, args: None,
type_ref: Some(type_ref), type_ref: Some(type_ref),
bounds: Vec::new(), bounds: Box::default(),
}); });
} else { } else {
// -> () // -> ()
@ -243,7 +243,7 @@ fn lower_generic_args_from_fn_path(
name: name![Output], name: name![Output],
args: None, args: None,
type_ref: Some(type_ref), type_ref: Some(type_ref),
bounds: Vec::new(), bounds: Box::default(),
}); });
} }
Some(GenericArgs { args, has_self_type: false, bindings, desugared_from_fn: true }) Some(GenericArgs { args, has_self_type: false, bindings, desugared_from_fn: true })

View file

@ -305,7 +305,7 @@ impl TypeRef {
if let Some(type_ref) = &binding.type_ref { if let Some(type_ref) = &binding.type_ref {
go(type_ref, f); go(type_ref, f);
} }
for bound in &binding.bounds { for bound in binding.bounds.iter() {
match bound.as_ref() { match bound.as_ref() {
TypeBound::Path(path, _) | TypeBound::ForLifetime(_, path) => { TypeBound::Path(path, _) | TypeBound::ForLifetime(_, path) => {
go_path(path, f) go_path(path, f)

View file

@ -1445,7 +1445,7 @@ impl HirDisplay for Path {
} }
None => { None => {
write!(f, ": ")?; write!(f, ": ")?;
f.write_joined(&binding.bounds, " + ")?; f.write_joined(binding.bounds.iter(), " + ")?;
} }
} }
} }

View file

@ -1068,7 +1068,7 @@ impl<'a> TyLoweringContext<'a> {
AliasEq { alias: AliasTy::Projection(projection_ty.clone()), ty }; AliasEq { alias: AliasTy::Projection(projection_ty.clone()), ty };
preds.push(crate::wrap_empty_binders(WhereClause::AliasEq(alias_eq))); preds.push(crate::wrap_empty_binders(WhereClause::AliasEq(alias_eq)));
} }
for bound in &binding.bounds { for bound in binding.bounds.iter() {
preds.extend(self.lower_type_bound( preds.extend(self.lower_type_bound(
bound, bound,
TyKind::Alias(AliasTy::Projection(projection_ty.clone())).intern(Interner), TyKind::Alias(AliasTy::Projection(projection_ty.clone())).intern(Interner),