mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 15:32:06 +00:00
Auto merge of #88574 - camelid:box-genericarg-const, r=GuillaumeGomez
rustdoc: Box `GenericArg::Const` to reduce enum size This should reduce the amount of memory allocated in the common cases where the `GenericArg` is a lifetime or type.
This commit is contained in:
commit
b89e01cd8e
@ -1789,7 +1789,7 @@ impl Clean<GenericArgs> for hir::GenericArgs<'_> {
|
||||
}
|
||||
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
|
||||
hir::GenericArg::Type(ty) => GenericArg::Type(ty.clean(cx)),
|
||||
hir::GenericArg::Const(ct) => GenericArg::Const(ct.clean(cx)),
|
||||
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(ct.clean(cx))),
|
||||
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
|
||||
})
|
||||
.collect(),
|
||||
|
@ -2012,10 +2012,15 @@ impl Path {
|
||||
crate enum GenericArg {
|
||||
Lifetime(Lifetime),
|
||||
Type(Type),
|
||||
Const(Constant),
|
||||
Const(Box<Constant>),
|
||||
Infer,
|
||||
}
|
||||
|
||||
// `GenericArg` can occur many times in a single `Path`, so make sure it
|
||||
// doesn't increase in size unexpectedly.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
rustc_data_structures::static_assert_size!(GenericArg, 80);
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
crate enum GenericArgs {
|
||||
AngleBracketed { args: Vec<GenericArg>, bindings: Vec<TypeBinding> },
|
||||
|
@ -121,7 +121,7 @@ fn external_generic_args(
|
||||
ty_kind = Some(ty.kind());
|
||||
Some(GenericArg::Type(ty.clean(cx)))
|
||||
}
|
||||
GenericArgKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))),
|
||||
GenericArgKind::Const(ct) => Some(GenericArg::Const(Box::new(ct.clean(cx)))),
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -139,7 +139,7 @@ impl FromWithTcx<clean::GenericArg> for GenericArg {
|
||||
match arg {
|
||||
Lifetime(l) => GenericArg::Lifetime(l.0.to_string()),
|
||||
Type(t) => GenericArg::Type(t.into_tcx(tcx)),
|
||||
Const(c) => GenericArg::Const(c.into_tcx(tcx)),
|
||||
Const(box c) => GenericArg::Const(c.into_tcx(tcx)),
|
||||
Infer => GenericArg::Infer,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user