Skip to content

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

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ShoyuVanilla:rustdoc-auto
Nov 27, 2026
Merged

rust-bors[bot] merged 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
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?

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.

yeah, recursion limit or have a separate hashmap for the adt def_ids

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.

I simply chose the former b/c I might not recurse into non-diverging nested adts with the later

/// 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

@rust-bors

This comment has been minimized.

@lcnr

lcnr commented Nov 24, 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 Nov 24, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

@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 Nov 24, 2026
let fresh_ty = if !ty.has_param() {
ty
} else {
let mut tys = FxHashMap::default();

@lcnr lcnr Nov 25, 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.

Suggested change
let mut tys = FxHashMap::default();
// We manually instantiate the generic args with inference variables
// here to also trivially handle builtin types.
let mut tys = FxHashMap::default();

View changes since the review

@lcnr lcnr left a comment •

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.

@ShoyuVanilla

Copy link
Copy Markdown
Member Author

@bors r=lcnr

@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1b0daf0 has been tentatively approved by lcnr

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
Rollup of 20 pull requests

Successful merges:

 - #164161 (`-Znext-solver` Support a bit more types for rustdoc auto traits)
 - #165572 (Run the `FatLtoCleanup` pass to lower `llvm.type.checked.load`)
 - #166235 (Keep opening '(' when suggesting to remove '&' from pattern)
 - #166335 (A few fixes in x86 std_detect)
 - #166516 (Fix ICE in iterator method suggestion when the receiver is a block)
 - #166586 (abby test dsl: one binder to rule them all)
 - #166604 (fix: embed-source-dwarf test with remapped debuginfo)
 - #166620 (Change wording of overwrite span in `unused_assignments` lint)
 - #166626 (Remove some outdated comments about None terminator)
 - #164289 (Add regression test for self-referential GAT with missing lifetime argument)
 - #165859 (Add codegen test for MaybeUninit array built in the return slot)
 - #166092 (add fake borrow tests for divergent match guards)
 - #166292 (Don't suggest closure braces for errors inside the body)
 - #166435 (Encode direct const mir)
 - #166447 (Document allocator behaviour of BTreeMap::append and BTreeSet::append)
 - #166558 (triagebot: Send "in progress" message when nomination is in progress pt. 2)
 - #166584 (Arg pos const mismatch ice)
 - #166599 (add alias-bound test)
 - #166606 (llvm-wrapper: Pass LibraryOptionsContext to computeDeadSymbolsWithConstProp etc.)
 - #166623 (Correct feature name for `is_cased()` method)

Failed merges:

 - #166583 (abby dsl tests: the passing test should check-pass)
@rust-bors
rust-bors Bot merged commit 9322306 into rust-lang:main Nov 27, 2026
14 checks passed
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
Rollup merge of #164161 - ShoyuVanilla:rustdoc-auto, r=lcnr

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

cc https://hackmd.io/ydc_nIbHQqG-ctMDapXYTg#rustdoc-html

`rustdoc-html` test drifts are addressed here: main...ShoyuVanilla:rust:rustdoc-auto-tests

r? lcnr
@rustbot rustbot added this to the 1.102.0 milestone Nov 27, 2026
@ShoyuVanilla
ShoyuVanilla deleted the rustdoc-auto branch November 27, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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