Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Use ThinVec in GenericParamDefKind #117337

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ fn clean_generic_param_def<'tcx>(
) -> GenericParamDef {
let (name, kind) = match def.kind {
ty::GenericParamDefKind::Lifetime => {
(def.name, GenericParamDefKind::Lifetime { outlives: vec![] })
(def.name, GenericParamDefKind::Lifetime { outlives: ThinVec::new() })
}
ty::GenericParamDefKind::Type { has_default, synthetic, .. } => {
let default = if has_default {
Expand All @@ -515,7 +515,7 @@ fn clean_generic_param_def<'tcx>(
def.name,
GenericParamDefKind::Type {
did: def.def_id,
bounds: vec![], // These are filled in from the where-clauses.
bounds: ThinVec::new(), // These are filled in from the where-clauses.
default: default.map(Box::new),
synthetic,
},
Expand Down Expand Up @@ -567,7 +567,7 @@ fn clean_generic_param<'tcx>(
})
.collect()
} else {
Vec::new()
ThinVec::new()
};
(param.name.ident().name, GenericParamDefKind::Lifetime { outlives })
}
Expand All @@ -580,7 +580,7 @@ fn clean_generic_param<'tcx>(
.filter_map(|x| clean_generic_bound(x, cx))
.collect()
} else {
Vec::new()
ThinVec::new()
};
(
param.name.ident().name,
Expand Down Expand Up @@ -636,7 +636,7 @@ pub(crate) fn clean_generics<'tcx>(
match param.kind {
GenericParamDefKind::Lifetime { .. } => unreachable!(),
GenericParamDefKind::Type { did, ref bounds, .. } => {
cx.impl_trait_bounds.insert(did.into(), bounds.clone());
cx.impl_trait_bounds.insert(did.into(), bounds.to_vec());
}
GenericParamDefKind::Const { .. } => unreachable!(),
}
Expand Down Expand Up @@ -3146,7 +3146,7 @@ fn clean_bound_vars<'tcx>(
name,
kind: GenericParamDefKind::Type {
did,
bounds: Vec::new(),
bounds: ThinVec::new(),
default: None,
synthetic: false,
},
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub(crate) fn move_bounds_to_generic_parameters(generics: &mut clean::Generics)
..
}) = generics.params.iter_mut().find(|param| &param.name == arg)
{
param_bounds.append(bounds);
param_bounds.extend(bounds.drain(..));
} else if let WherePredicate::RegionPredicate { lifetime: Lifetime(arg), bounds } = &mut pred
&& let Some(GenericParamDef {
kind: GenericParamDefKind::Lifetime { outlives: param_bounds },
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,8 +1325,8 @@ impl WherePredicate {

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub(crate) enum GenericParamDefKind {
Lifetime { outlives: Vec<Lifetime> },
Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
Lifetime { outlives: ThinVec<Lifetime> },
Type { did: DefId, bounds: ThinVec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
Const { ty: Box<Type>, default: Option<Box<String>>, is_host_effect: bool },
}

Expand All @@ -1344,7 +1344,7 @@ pub(crate) struct GenericParamDef {

impl GenericParamDef {
pub(crate) fn lifetime(name: Symbol) -> Self {
Self { name, kind: GenericParamDefKind::Lifetime { outlives: Vec::new() } }
Self { name, kind: GenericParamDefKind::Lifetime { outlives: ThinVec::new() } }
}

pub(crate) fn is_synthetic_param(&self) -> bool {
Expand Down Expand Up @@ -2521,7 +2521,7 @@ mod size_asserts {
static_assert_size!(DocFragment, 32);
static_assert_size!(GenericArg, 32);
static_assert_size!(GenericArgs, 32);
static_assert_size!(GenericParamDef, 56);
static_assert_size!(GenericParamDef, 40);
static_assert_size!(Generics, 16);
static_assert_size!(Item, 56);
static_assert_size!(ItemKind, 56);
Expand Down
Loading