Skip to content

-Znext-solver Support a bit more types for rustdoc auto traits - #164161

Open
ShoyuVanilla wants to merge 1 commit into
rust-lang:mainfrom
ShoyuVanilla:rustdoc-auto
Open

ShoyuVanilla wants to merge 1 commit into
rust-lang:mainfrom
ShoyuVanilla:rustdoc-auto

Conversation

@ShoyuVanilla

Copy link
Copy Markdown
Member

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 11, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 11, 2026
@ShoyuVanilla ShoyuVanilla changed the title Support a bit more types on rustdoc auto traits -Znext-solver Support a bit more types for rustdoc auto traits Oct 11, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

ty
} else if let ty::Adt(adt_def, _) = *ty.kind() {
let fresh_args = infcx.fresh_args_for_item(DUMMY_SP, adt_def.did());
ty::EarlyBinder::bind(tcx, ty).instantiate(tcx, fresh_args).skip_norm_wip()

@lcnr lcnr Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider just yeeting the Adt special case, it doesn't change the behavior and it feels nicer to stay consistent

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, feels nicer to first check "does this type implement the autotrait for litreally any generic args, and only then collect the constituent types

})
.collect::<Vec<ty::Clause<'tcx>>>();
let full_user_env = ty::ParamEnv::new(tcx, orig_env.caller_bounds().chain(field_clauses));
let full_user_env =

@lcnr lcnr Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should prolly normalize the ParamEnv here

View changes since the review

/// Gather types that needs to be the RHS of the where bounds for auto trait impls,
/// by recursing into each field type. This is a recursive function rather than a
/// `TypeVisitor` because we have to look into nested fields.
fn gather_constituent_tys<'tcx>(

@lcnr lcnr Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is confusing 🤔 the NeedsAutoTraitEvaluation is only used when calling gather_constituent_tys in the root. Feels easier to have one match to check whether a type is interesting, and then have this function return ()

View changes since the review

@lcnr

lcnr commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 28, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

Updated test diff as well main...ShoyuVanilla:rust:rustdoc-auto-tests
(Small improvement due to the param env normalization)
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 28, 2026
}

for field_ty in
adt_def.all_fields().map(|field| field.ty(tcx, args).skip_norm_wip())

@lcnr lcnr Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can diverge, can it not?

i would assume this causes a stack overflow for struct Foo<T>(Box<Foo<(T,)>>);

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this goes into Foo<T> -> Foo<(T, )> -> Foo<((T, ), )> -> .. in such cases and it doesn't feel so clear to me how to avoid that 🤔 Would it make sense to just use the recursion limit as it would fail with the similar problem with the solver as well?

/// Gather types that needs to be the RHS of the where bounds for auto trait impls,
/// by recursing into each field type. This is a recursive function rather than a
/// `TypeVisitor` because we have to look into nested fields.
fn gather_constituent_tys<'tcx>(

@lcnr lcnr Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this function to where it's used?

View changes since the review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants