Skip to content
Permalink
Browse files

Fix infinite recursion

  • Loading branch information...
GuillaumeGomez committed Mar 29, 2019
1 parent 2002b4b commit 29885ff2915665f1e5b53c6c21609a12812bf29e
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/librustdoc/clean/mod.rs
@@ -1766,9 +1766,13 @@ fn get_real_types(
generics: &Generics,
arg: &Type,
cx: &DocContext<'_>,
recurse: i32,
) -> FxHashSet<Type> {
let arg_s = arg.to_string();
let mut res = FxHashSet::default();
if recurse >= 10 { // FIXME: remove this whole recurse thing when the recursion bug is fixed
return res;
}
if arg.is_full_generic() {
if let Some(where_pred) = generics.where_predicates.iter().find(|g| {
match g {
@@ -1785,7 +1789,7 @@ fn get_real_types(
continue
}
if let Some(ty) = x.get_type(cx) {
let adds = get_real_types(generics, &ty, cx);
let adds = get_real_types(generics, &ty, cx, recurse + 1);
if !adds.is_empty() {
res.extend(adds);
} else if !ty.is_full_generic() {
@@ -1803,7 +1807,7 @@ fn get_real_types(
}) {
for bound in bound.get_bounds().unwrap_or_else(|| &[]) {
if let Some(ty) = bound.get_trait_type() {
let adds = get_real_types(generics, &ty, cx);
let adds = get_real_types(generics, &ty, cx, recurse + 1);
if !adds.is_empty() {
res.extend(adds);
} else if !ty.is_full_generic() {
@@ -1817,7 +1821,7 @@ fn get_real_types(
if let Some(gens) = arg.generics() {
for gen in gens.iter() {
if gen.is_full_generic() {
let adds = get_real_types(generics, gen, cx);
let adds = get_real_types(generics, gen, cx, recurse + 1);
if !adds.is_empty() {
res.extend(adds);
}
@@ -1844,7 +1848,7 @@ pub fn get_all_types(
if arg.type_.is_self_type() {
continue;
}
let args = get_real_types(generics, &arg.type_, cx);
let args = get_real_types(generics, &arg.type_, cx, 0);
if !args.is_empty() {
all_types.extend(args);
} else {
@@ -1854,7 +1858,7 @@ pub fn get_all_types(

let ret_types = match decl.output {
FunctionRetTy::Return(ref return_type) => {
let mut ret = get_real_types(generics, &return_type, cx);
let mut ret = get_real_types(generics, &return_type, cx, 0);
if ret.is_empty() {
ret.insert(return_type.clone());
}

0 comments on commit 29885ff

Please sign in to comment.
You can’t perform that action at this time.