Unnamed repository; edit this file 'description' to name the repository.
Slim down AssociatedTypeBinding by one usize
Lukas Wirth 2023-02-14
parent 41db8c2 · commit 4c2aef6
-rw-r--r--crates/hir-def/src/item_tree/lower.rs2
-rw-r--r--crates/hir-def/src/path.rs2
-rw-r--r--crates/hir-def/src/path/lower.rs6
-rw-r--r--crates/hir-def/src/type_ref.rs2
-rw-r--r--crates/hir-ty/src/display.rs2
-rw-r--r--crates/hir-ty/src/lower.rs2
6 files changed, 8 insertions, 8 deletions
diff --git a/crates/hir-def/src/item_tree/lower.rs b/crates/hir-def/src/item_tree/lower.rs
index 27705cbbbd..e8653274cf 100644
--- a/crates/hir-def/src/item_tree/lower.rs
+++ b/crates/hir-def/src/item_tree/lower.rs
@@ -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)));
diff --git a/crates/hir-def/src/path.rs b/crates/hir-def/src/path.rs
index f53bd4f618..b9e79fd462 100644
--- a/crates/hir-def/src/path.rs
+++ b/crates/hir-def/src/path.rs
@@ -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.
diff --git a/crates/hir-def/src/path/lower.rs b/crates/hir-def/src/path/lower.rs
index 334750a591..51f1ba79a4 100644
--- a/crates/hir-def/src/path/lower.rs
+++ b/crates/hir-def/src/path/lower.rs
@@ -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 })
diff --git a/crates/hir-def/src/type_ref.rs b/crates/hir-def/src/type_ref.rs
index 8fa12c7aaf..51b6c4d10b 100644
--- a/crates/hir-def/src/type_ref.rs
+++ b/crates/hir-def/src/type_ref.rs
@@ -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)
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index 5fcbdf34f3..1f2e56f5bd 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -1445,7 +1445,7 @@ impl HirDisplay for Path {
}
None => {
write!(f, ": ")?;
- f.write_joined(&binding.bounds, " + ")?;
+ f.write_joined(binding.bounds.iter(), " + ")?;
}
}
}
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index 7cce13a793..f93d710e1a 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -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),