-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
remove some const arg in ty dep path boilerplate #74404
Conversation
@@ -1615,12 +1615,33 @@ pub struct WithOptConstParam<T> { | |||
|
|||
impl<T> WithOptConstParam<T> { | |||
/// Creates a new `WithOptConstParam` setting `const_param_did` to `None`. | |||
#[inline(always)] | |||
pub fn unknown(did: T) -> WithOptConstParam<T> { |
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 think the general guideline is not to inline for generic function.
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.
hm... this function is only instantiated for WithOptConstParam<DefId>
and WithOptConstParam<LocalDefId>
.
Would be kind of sad if this is a problem :/
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.
Wait, isn't this only for code in the standard library as inline causes that to get included in every CGU? I don't think that policy counts for compiler internals afaik 🤔
Might be misremembering something here though
src/librustc_middle/ty/mod.rs
Outdated
/// Returns `Some((did, param_did))` if `def_id` is a const argument, | ||
/// `None` otherwise. | ||
#[inline(always)] | ||
pub fn try_fetch(did: LocalDefId, tcx: TyCtxt<'_>) -> Option<(LocalDefId, DefId)> { |
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 think it's clearer if you start with unknown
and then use the other method. Bonus: the other case likely takes the unknown
anyway, so it would only be created once.
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 don't think so. The other method creates a WithOptConstParam
, requiring us to write query_name((def.did, def.const_param_did.unwrap()))
which seems really noisy.
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.
We might also change the return value of try_upgrade
to Option<(LocalDefId, DefId)>
but that makes the other use case less clear.
The problem at its core is that we have two different kinds of queries.
- split queries with
query_name
andquery_name_of_const_arg
wheretry_fetch
is used at the start ofquery_name
- shared queries taking
ty::WithOptConstParam
, these calltry_upgrade
at their start and call itself if that returns some.
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.
We may try and split the remaining shared queries at which point try_upgrade
won't be used anymore.
☔ The latest upstream changes (presumably #72983) made this pull request unmergeable. Please resolve the merge conflicts. |
/// In case `self` is unknown but `self.did` is a const argument, this returns | ||
/// a `WithOptConstParam` with the correct `const_param_did`. | ||
#[inline(always)] | ||
pub fn try_upgrade(self, tcx: TyCtxt<'_>) -> Option<WithOptConstParam<LocalDefId>> { |
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.
Hmm, so if we wanted this name to be more explicit, it could be try_upgrade_to_const_arg
, right?
Then the other one could be try_lookup_as_const_arg
.
Alternatively, try_upgrade_with_const_param
and try_lookup_const_param_for
.
12bcb56
to
ddf2c70
Compare
ddf2c70
to
4bffe8f
Compare
@bors rollup=never (just in case there's a perf impact, even if small) |
@bors r+ |
📌 Commit 4bffe8f has been approved by |
⌛ Testing commit 4bffe8f with merge a02f4b3b2949898ae25f68f01203574f21127307... |
💔 Test failed - checks-actions |
looks like a network failure @bors retry |
⌛ Testing commit 4bffe8f with merge 300a3672c74c560ff7d962d52a2c47ec2b55dd90... |
💔 Test failed - checks-actions |
Again |
⌛ Testing commit 4bffe8f with merge e3cea76f3d3b1c5aba3975f5ecebb67c246b89f4... |
@bors retry yield |
⌛ Testing commit 4bffe8f with merge a385482389198bd17c8883c3f37b89185d24515d... |
💔 Test failed - checks-azure |
@bors retry
|
@bors treeclosed- |
☀️ Test successful - checks-actions, checks-azure |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
followup to #74113, together with #74376, this closes #74360.
r? @eddyb