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],
args: None,
type_ref: Some(orig),
bounds: Vec::new(),
bounds: Box::default(),
};
last.bindings.push(binding);
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:
/// SomeOtherTrait>`. (This is the unstable `associated_type_bounds`
/// feature.)
pub bounds: Vec<Interned<TypeBound>>,
pub bounds: Box<[Interned<TypeBound>]>,
}
/// 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)))
.collect()
} else {
Vec::new()
Box::default()
};
bindings.push(AssociatedTypeBinding { name, args, type_ref, bounds });
}
@ -234,7 +234,7 @@ fn lower_generic_args_from_fn_path(
name: name![Output],
args: None,
type_ref: Some(type_ref),
bounds: Vec::new(),
bounds: Box::default(),
});
} else {
// -> ()
@ -243,7 +243,7 @@ fn lower_generic_args_from_fn_path(
name: name![Output],
args: None,
type_ref: Some(type_ref),
bounds: Vec::new(),
bounds: Box::default(),
});
}
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 {
go(type_ref, f);
}
for bound in &binding.bounds {
for bound in binding.bounds.iter() {
match bound.as_ref() {
TypeBound::Path(path, _) | TypeBound::ForLifetime(_, path) => {
go_path(path, f)

View file

@ -1445,7 +1445,7 @@ impl HirDisplay for Path {
}
None => {
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 };
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(
bound,
TyKind::Alias(AliasTy::Projection(projection_ty.clone())).intern(Interner),