Skip to content

Commit 65942d1

Browse files
committed
Avoid using kw::Empty for param names in rustdoc.
1 parent 4097858 commit 65942d1

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Diff for: src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub(crate) struct IndexItemFunctionType {
208208
inputs: Vec<RenderType>,
209209
output: Vec<RenderType>,
210210
where_clause: Vec<Vec<RenderType>>,
211-
param_names: Vec<Symbol>,
211+
param_names: Vec<Option<Symbol>>,
212212
}
213213

214214
impl IndexItemFunctionType {

Diff for: src/librustdoc/html/render/search_index.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,11 @@ pub(crate) fn build_index(
709709
let mut result = Vec::new();
710710
for (index, item) in self.items.iter().enumerate() {
711711
if let Some(ty) = &item.search_type
712-
&& let my =
713-
ty.param_names.iter().map(|sym| sym.as_str()).collect::<Vec<_>>()
712+
&& let my = ty
713+
.param_names
714+
.iter()
715+
.filter_map(|sym| sym.map(|sym| sym.to_string()))
716+
.collect::<Vec<_>>()
714717
&& my != prev
715718
{
716719
result.push((index, my.join(",")));
@@ -1372,7 +1375,7 @@ fn simplify_fn_constraint<'a>(
13721375
/// Used to allow type-based search on constants and statics.
13731376
fn make_nullary_fn(
13741377
clean_type: &clean::Type,
1375-
) -> (Vec<RenderType>, Vec<RenderType>, Vec<Symbol>, Vec<Vec<RenderType>>) {
1378+
) -> (Vec<RenderType>, Vec<RenderType>, Vec<Option<Symbol>>, Vec<Vec<RenderType>>) {
13761379
let mut rgen: FxIndexMap<SimplifiedParam, (isize, Vec<RenderType>)> = Default::default();
13771380
let output = get_index_type(clean_type, vec![], &mut rgen);
13781381
(vec![], vec![output], vec![], vec![])
@@ -1387,7 +1390,7 @@ fn get_fn_inputs_and_outputs(
13871390
tcx: TyCtxt<'_>,
13881391
impl_or_trait_generics: Option<&(clean::Type, clean::Generics)>,
13891392
cache: &Cache,
1390-
) -> (Vec<RenderType>, Vec<RenderType>, Vec<Symbol>, Vec<Vec<RenderType>>) {
1393+
) -> (Vec<RenderType>, Vec<RenderType>, Vec<Option<Symbol>>, Vec<Vec<RenderType>>) {
13911394
let decl = &func.decl;
13921395

13931396
let mut rgen: FxIndexMap<SimplifiedParam, (isize, Vec<RenderType>)> = Default::default();
@@ -1441,10 +1444,10 @@ fn get_fn_inputs_and_outputs(
14411444
simplified_params
14421445
.iter()
14431446
.map(|(name, (_idx, _traits))| match name {
1444-
SimplifiedParam::Symbol(name) => *name,
1445-
SimplifiedParam::Anonymous(_) => kw::Empty,
1447+
SimplifiedParam::Symbol(name) => Some(*name),
1448+
SimplifiedParam::Anonymous(_) => None,
14461449
SimplifiedParam::AssociatedType(def_id, name) => {
1447-
Symbol::intern(&format!("{}::{}", tcx.item_name(*def_id), name))
1450+
Some(Symbol::intern(&format!("{}::{}", tcx.item_name(*def_id), name)))
14481451
}
14491452
})
14501453
.collect(),

0 commit comments

Comments
 (0)