Skip to content

Commit

Permalink
Rollup merge of rust-lang#59539 - GuillaumeGomez:rustdoc-infinite-rec…
Browse files Browse the repository at this point in the history
…ursion, r=eddyb

Fix infinite recursion

Temporary fix for rust-lang#59502.

r? @eddyb
  • Loading branch information
Centril authored Mar 30, 2019
2 parents c9dca36 + 29885ff commit 68d03c0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1769,9 +1769,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 {
Expand All @@ -1788,7 +1792,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() {
Expand All @@ -1806,7 +1810,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() {
Expand All @@ -1820,7 +1824,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);
}
Expand All @@ -1847,7 +1851,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 {
Expand All @@ -1857,7 +1861,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());
}
Expand Down

0 comments on commit 68d03c0

Please sign in to comment.