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

remove some const arg in ty dep path boilerplate #74404

Merged
merged 3 commits into from
Jul 23, 2020

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jul 16, 2020

followup to #74113, together with #74376, this closes #74360.

r? @eddyb

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 16, 2020
@@ -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> {
Copy link
Contributor

@tesuji tesuji Jul 16, 2020

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

/// 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)> {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 and query_name_of_const_arg where try_fetch is used at the start of query_name
  • shared queries taking ty::WithOptConstParam, these call try_upgrade at their start and call itself if that returns some.

Copy link
Contributor Author

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.

@bors
Copy link
Contributor

bors commented Jul 17, 2020

☔ 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>> {
Copy link
Member

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.

@lcnr lcnr force-pushed the ty-dep-path-cleanup-aaaaa branch from 12bcb56 to ddf2c70 Compare July 21, 2020 21:06
@lcnr lcnr force-pushed the ty-dep-path-cleanup-aaaaa branch from ddf2c70 to 4bffe8f Compare July 21, 2020 21:12
@eddyb
Copy link
Member

eddyb commented Jul 21, 2020

@bors rollup=never (just in case there's a perf impact, even if small)

@eddyb
Copy link
Member

eddyb commented Jul 21, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jul 21, 2020

📌 Commit 4bffe8f has been approved by eddyb

@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 Jul 21, 2020
@bors
Copy link
Contributor

bors commented Jul 22, 2020

⌛ Testing commit 4bffe8f with merge a02f4b3b2949898ae25f68f01203574f21127307...

@bors
Copy link
Contributor

bors commented Jul 22, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 22, 2020
@lcnr
Copy link
Contributor Author

lcnr commented Jul 22, 2020

looks like a network failure

@bors retry

@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 Jul 22, 2020
@bors
Copy link
Contributor

bors commented Jul 22, 2020

⌛ Testing commit 4bffe8f with merge 300a3672c74c560ff7d962d52a2c47ec2b55dd90...

@bors
Copy link
Contributor

bors commented Jul 22, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 22, 2020
@lcnr
Copy link
Contributor Author

lcnr commented Jul 22, 2020

Again
@bors retry

@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 Jul 22, 2020
@bors
Copy link
Contributor

bors commented Jul 22, 2020

⌛ Testing commit 4bffe8f with merge e3cea76f3d3b1c5aba3975f5ecebb67c246b89f4...

@Manishearth
Copy link
Member

@bors retry yield

@bors
Copy link
Contributor

bors commented Jul 22, 2020

⌛ Testing commit 4bffe8f with merge a385482389198bd17c8883c3f37b89185d24515d...

@bors
Copy link
Contributor

bors commented Jul 22, 2020

💔 Test failed - checks-azure

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 22, 2020
@Manishearth
Copy link
Member

@bors retry

  • network problems

@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 Jul 22, 2020
@Mark-Simulacrum
Copy link
Member

@bors treeclosed-

@bors
Copy link
Contributor

bors commented Jul 22, 2020

⌛ Testing commit 4bffe8f with merge 4a86573...

@bors
Copy link
Contributor

bors commented Jul 23, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: eddyb
Pushing 4a86573 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 23, 2020
@bors bors merged commit 4a86573 into rust-lang:master Jul 23, 2020
@lcnr lcnr deleted the ty-dep-path-cleanup-aaaaa branch July 23, 2020 06:07
@rust-log-analyzer
Copy link
Collaborator

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.
##[group]Run exit 1
exit 1
shell: /bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
##[error]Process completed with exit code 1.

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 @rust-lang/infra. (Feature Requests)

@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

post const args in type dependent paths cleanup
9 participants