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

Don't ICE when no bound vars found while doing closure hir type check #113396

Conversation

lenko-d
Copy link
Contributor

@lenko-d lenko-d commented Jul 6, 2023

The problem was that we were not visiting the const generic default argument in a bound where predicate when the HIR gets traversed in hir_analysis -> collect -> resolve_bound_vars.

Fixes 112574

@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2023

r? @WaffleLapkin

(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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 6, 2023
Copy link
Member

@compiler-errors compiler-errors left a 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 is the correct solution. Rust will still ICE if the closure has >0 inputs.

This PR also needs more description. It should at least briefly explain why this fixes the issue and/or why it's correct.

compiler/rustc_hir_typeck/src/closure.rs Outdated Show resolved Hide resolved
@WaffleLapkin
Copy link
Member

r? @compiler-errors

@oli-obk
Copy link
Contributor

oli-obk commented Jul 7, 2023

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

bors commented Jul 14, 2023

☔ The latest upstream changes (presumably #113591) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC
Copy link
Member

@lenko-d any updates on this? thanks

@lenko-d
Copy link
Contributor Author

lenko-d commented Sep 22, 2023

@Dylan-DPC I'm still working on this occasionally. I believe that I have some understanding of what the problem is.

I believe that the problem is that the closure is not visited when the HIR gets traversed in hir_analysis -> collect -> resolve_bound_vars. Not sure yet why it is not visited and how to fix it.

@lenko-d lenko-d force-pushed the dont_ICE_when_no_bound_vars_for_lifetime_binders branch from 6920064 to 241c75f Compare September 25, 2023 02:15
Comment on lines 901 to 916
for param in bound_generic_params {
match param.kind {
GenericParamKind::Lifetime { .. } => {}
GenericParamKind::Type { default, .. } => {
if let Some(ty) = default {
self.visit_ty(ty);
}
}
GenericParamKind::Const { ty, default } => {
self.visit_ty(ty);
if let Some(default) = default {
self.visit_body(self.tcx.hir().body(default.body));
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This is generally the correct fix.

Though I feel like this could be merged with the same logic for handling lifetimes in const defaults in item generics (#93669). Maybe you could move the visit_ty and visit_body calls into visit_generic_param, and then this can be replaced with:

Suggested change
for param in bound_generic_params {
match param.kind {
GenericParamKind::Lifetime { .. } => {}
GenericParamKind::Type { default, .. } => {
if let Some(ty) = default {
self.visit_ty(ty);
}
}
GenericParamKind::Const { ty, default } => {
self.visit_ty(ty);
if let Some(default) = default {
self.visit_body(self.tcx.hir().body(default.body));
}
}
}
}
walk_list!(self, visit_generic_param, bound_generic_params);

@lenko-d lenko-d force-pushed the dont_ICE_when_no_bound_vars_for_lifetime_binders branch from 241c75f to a1d181d Compare September 25, 2023 04:41
@lenko-d
Copy link
Contributor Author

lenko-d commented Sep 25, 2023

@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 Sep 25, 2023
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 25, 2023

📌 Commit a1d181d has been approved by compiler-errors

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 Sep 25, 2023
@bors
Copy link
Contributor

bors commented Sep 25, 2023

⌛ Testing commit a1d181d with merge a1454e7...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 25, 2023
…for_lifetime_binders, r=compiler-errors

Don't ICE when no bound vars found while doing closure hir type check

The problem was that we were not visiting the const generic default argument in a bound where predicate when the HIR gets traversed in hir_analysis -> collect -> resolve_bound_vars.

Fixes [112574](rust-lang#112574)
@bors
Copy link
Contributor

bors commented Sep 25, 2023

💔 Test failed - checks-actions

@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 25, 2023
@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2023
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 "NO_DEBUG_ASSERTIONS": 1,
 "NO_OVERFLOW_CHECKS": 1
}
##[endgroup]
jq: error: Top-level program not given (try ".")
jq: 1 compile error
##[error]Process completed with exit code 3.
[command]/usr/local/bin/git version
git version 2.42.0
Copying '/Users/runner/.gitconfig' to '/Users/runner/work/_temp/81184fea-3da0-4d74-8c84-b453e02a17f9/.gitconfig'
Temporarily overriding HOME='/Users/runner/work/_temp/81184fea-3da0-4d74-8c84-b453e02a17f9' before making global git config changes

@compiler-errors
Copy link
Member

@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 Sep 25, 2023
@bors
Copy link
Contributor

bors commented Sep 25, 2023

⌛ Testing commit a1d181d with merge 1cbfeab...

@bors
Copy link
Contributor

bors commented Sep 25, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 1cbfeab to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Sep 25, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 1cbfeab to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 25, 2023
@bors bors merged commit 1cbfeab into rust-lang:master Sep 25, 2023
12 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 25, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1cbfeab): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
-2.9% [-3.8%, -1.3%] 3
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 2
All ❌✅ (primary) -2.9% [-3.8%, -1.3%] 3

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 632.116s -> 631.251s (-0.14%)
Artifact size: 317.31 MiB -> 317.22 MiB (-0.03%)

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

ICE: No bound vars found for HirId
9 participants