-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,11 +124,7 @@ pub(crate) fn ty_args_to_args<'tcx>( | |
))) | ||
} | ||
GenericArgKind::Const(ct) => { | ||
// FIXME(effects): this relies on the host effect being called `host`, which users could also name | ||
// their const generics. | ||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
return None; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![feature(effects, const_trait_impl)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've renamed the test |
||
|
||
#[const_trait] | ||
pub trait Resource {} | ||
|
||
pub const fn load<R: ~const Resource>() -> i32 { | ||
0 | ||
} | ||
|
||
pub const fn lock<R: Resource>() {} | ||
|
||
#[allow(non_upper_case_globals)] | ||
pub trait Clash<const host: u64> {} | ||
|
||
#[allow(non_upper_case_globals)] | ||
pub const fn clash<T: Clash<host>, const host: u64>() {} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Regression test for issue #116629. | ||
// Check that we don't render host effect parameters & arguments. | ||
|
||
// aux-crate:const_effect_param=const-effect-param.rs | ||
// edition: 2021 | ||
#![crate_name = "user"] | ||
|
||
// Don't render the host param on `load` and the host arg `host` passed to `Resource`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
// @has user/fn.load.html | ||
// @has - '//pre[@class="rust item-decl"]' "pub const fn load<R>() -> i32\ | ||
// where \ | ||
// R: Resource" | ||
pub use const_effect_param::load; | ||
|
||
// Don't render the host arg `true` passed to `Resource`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 This PR introduces a more principled approach and not only elides |
||
// @has user/fn.lock.html | ||
// @has - '//pre[@class="rust item-decl"]' "pub const fn lock<R>()\ | ||
// where \ | ||
// R: Resource" | ||
pub use const_effect_param::lock; | ||
|
||
// Regression test for an issue introduced in PR #116670. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by this PR. |
||
// Don't hide the const param `host` since it actually isn't the host effect param. | ||
// @has user/fn.clash.html | ||
// @has - '//pre[@class="rust item-decl"]' \ | ||
// "pub const fn clash<T, const host: u64>()\ | ||
// where \ | ||
// T: Clash<host>" | ||
pub use const_effect_param::clash; |
This file was deleted.
There was a problem hiding this comment.
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 inimpl
s which isn't correct 😅. Now I fully understand the relevant parts of theeffects
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 theAnonConst
is correct and works not just for/*host*/ host
but also for the hypothetical/*host*/ true
(unreachable atm sincetrue
args never get synthesized in the first place)/*host*/ false
(always const) (unreachable atm, #117530 would change that).There was a problem hiding this comment.
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