Skip to content

Commit

Permalink
rustdoc: rebase after changes to bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Nov 16, 2023
1 parent bed8bbc commit 673ab88
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
12 changes: 8 additions & 4 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,16 +1651,16 @@ impl Type {
}
}

pub(crate) fn generics(&self) -> Option<Vec<&Type>> {
pub(crate) fn generic_args(&self) -> Option<&GenericArgs> {
match self {
Type::Path { path, .. } => path.generics(),
Type::Path { path, .. } => path.generic_args(),
_ => None,
}
}

pub(crate) fn bindings(&self) -> Option<&[TypeBinding]> {
pub(crate) fn generics(&self) -> Option<Vec<&Type>> {
match self {
Type::Path { path, .. } => path.bindings(),
Type::Path { path, .. } => path.generics(),
_ => None,
}
}
Expand Down Expand Up @@ -2198,6 +2198,10 @@ impl Path {
}
}

pub(crate) fn generic_args(&self) -> Option<&GenericArgs> {
self.segments.last().map(|seg| &seg.args)
}

pub(crate) fn generics(&self) -> Option<Vec<&Type>> {
self.segments.last().and_then(|seg| {
if let GenericArgs::AngleBracketed { ref args, .. } = seg.args {
Expand Down
35 changes: 19 additions & 16 deletions src/librustdoc/html/render/search_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,25 +805,15 @@ fn simplify_fn_type<'tcx, 'a>(
// we will look for them but not for `T`).
let mut ty_generics = Vec::new();
let mut ty_bindings = Vec::new();
for binding in arg.bindings().unwrap_or_default() {
simplify_fn_binding(
self_,
generics,
binding,
tcx,
recurse + 1,
&mut ty_bindings,
rgen,
is_return,
cache,
);
}
if let Some(arg_generics) = arg.generics() {
for gen in arg_generics.iter() {
if let Some(arg_generics) = arg.generic_args() {
for ty in arg_generics.into_iter().filter_map(|gen| match gen {
clean::GenericArg::Type(ty) => Some(ty),
_ => None,
}) {
simplify_fn_type(
self_,
generics,
gen,
&ty,
tcx,
recurse + 1,
&mut ty_generics,
Expand All @@ -832,6 +822,19 @@ fn simplify_fn_type<'tcx, 'a>(
cache,
);
}
for binding in arg_generics.bindings() {
simplify_fn_binding(
self_,
generics,
&binding,
tcx,
recurse + 1,
&mut ty_bindings,
rgen,
is_return,
cache,
);
}
}
// Every trait associated type on self gets assigned to a type parameter index
// this same one is used later for any appearances of these types
Expand Down

0 comments on commit 673ab88

Please sign in to comment.