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

rustdoc: properly elide cross-crate host effect args #117531

Conversation

fmease
Copy link
Member

@fmease fmease commented Nov 3, 2023

Fixes FIXMEs introduced in #116670.

@rustbot
Copy link
Collaborator

rustbot commented Nov 3, 2023

r? @GuillaumeGomez

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 3, 2023
@@ -2534,7 +2534,6 @@ fn clean_generic_args<'tcx>(
}
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
// FIXME(effects): This will still emit `<true>` for non-const impls of const traits
Copy link
Member Author

@fmease fmease Nov 3, 2023

Choose a reason for hiding this comment

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

In #116670 (https://github.com/rust-lang/rust/pull/116670/files#r1357977394) I blamed this code path for /*host*/ true getting leaked in impls which isn't correct 😅. Now I fully understand the relevant parts of the effects lowering code and can confirm that this piece of code is correct. #112463 (sic!) fixed the specific impl issue.

Checking for the presence of #[rustc_host] on the AnonConst is correct and works not just for /*host*/ host but also for the hypothetical /*host*/ true (unreachable atm since true args never get synthesized in the first place) /*host*/ false (always const) (unreachable atm, #117530 would change that).

Copy link
Member

Choose a reason for hiding this comment

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

I'm very tempted to ask you to add this as a code comment. So I'll succumb to the temptation: please add this as a code comment. :D

// FIXME(effects): this causes `host = true` and `host = false` generics to also be emitted.
if let ty::ConstKind::Param(p) = ct.kind()
&& p.name == sym::host
if let ty::GenericParamDefKind::Const { is_host_effect: true, .. } = params[index].kind
Copy link
Member Author

@fmease fmease Nov 3, 2023

Choose a reason for hiding this comment

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

I could add a test for the fixed issue “impl Trait<true>”. However, it was actually fixed by #112463 (sic!). The /*host*/ false case is unreachable atm, #117530 would change that).

Re. testing host vs #[rustc_host], I don't think it's worth it.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to have a test, even if pointless. If everything is covered, regressions will be easier to track down.

@fmease fmease force-pushed the rustdoc-effects-properly-elide-x-crate-host-args branch from 1f74e13 to ee0cdfd Compare November 4, 2023 21:34
@fmease fmease force-pushed the rustdoc-effects-properly-elide-x-crate-host-args branch 2 times, most recently from 37c8feb to 217153b Compare November 4, 2023 23:07
@fmease fmease force-pushed the rustdoc-effects-properly-elide-x-crate-host-args branch from 217153b to 1dcdf83 Compare November 4, 2023 23:57
// edition: 2021
#![crate_name = "user"]

// Don't render the host param on `load` and the host arg `host` passed to `Resource`.
Copy link
Member Author

Choose a reason for hiding this comment

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

This one was already fixed by oli's PR but there was no cross-crate test for it yet, only a local crate one.

// R: Resource"
pub use const_effect_param::load;

// Don't render the host arg `true` passed to `Resource`.
Copy link
Member Author

@fmease fmease Nov 5, 2023

Choose a reason for hiding this comment

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

This one was fixed by my “elide cross-crate default generic args” PR which ofc predates oli's PR, hence no test until now. Feature effects synthesizes the param #[rustc_host_param] const host: bool = true for const fn etc, therefore since my PR was merged true gets elided.

This PR introduces a more principled approach and not only elides host and true but arbitrary const values like false. I can't add a test for false since effects doesn't synthesize such code yet. My "generic const items: support effects" PR (#117530) would change that and rustdoc would handle it correctly (I've double-checked that).

// R: Resource"
pub use const_effect_param::lock;

// Regression test for an issue introduced in PR #116670.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed by this PR.

@@ -0,0 +1,16 @@
#![feature(effects, const_trait_impl)]
Copy link
Member Author

Choose a reason for hiding this comment

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

I've renamed the test const-fn.rs to const-effect-param.rs since it's more accurate but git / GitHub doesn't display it as such due to the large number of additional changes in this file.

@GuillaumeGomez
Copy link
Member

Thanks for the fix!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 8, 2023

📌 Commit 1dcdf83 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors bors 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 8, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#114316 (Add AIX platform support document)
 - rust-lang#117531 (rustdoc: properly elide cross-crate host effect args)
 - rust-lang#117650 (Add -Zcross-crate-inline-threshold=yes)
 - rust-lang#117663 (bump some deps)
 - rust-lang#117667 (Document clippy_config in nightly-rustc docs)
 - rust-lang#117698 (Clarify `space_between`)
 - rust-lang#117700 (coverage: Rename the `run-coverage` test mode to `coverage-run`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ba7ec56 into rust-lang:master Nov 8, 2023
11 checks passed
@rustbot rustbot added this to the 1.75.0 milestone Nov 8, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2023
Rollup merge of rust-lang#117531 - fmease:rustdoc-effects-properly-elide-x-crate-host-args, r=GuillaumeGomez

rustdoc: properly elide cross-crate host effect args

Fixes FIXMEs introduced in rust-lang#116670.
@fmease fmease deleted the rustdoc-effects-properly-elide-x-crate-host-args branch November 8, 2023 14:51
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 18, 2023
…nkov

Reenable effects in libcore

With rust-lang#116670, rust-lang#117531, and rust-lang#117171, I think we would be comfortable with re-enabling the effects feature for more testing in libcore.

r? `@oli-obk`
cc `@fmease`
cc rust-lang#110395
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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants