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

Fix infinite recursion #59539

Merged
merged 1 commit into from
Mar 30, 2019
Merged
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
14 changes: 9 additions & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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);
}
Expand All @@ -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 {
Expand All @@ -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());
}
Expand Down