Skip to content

hir_typeck: Don't ICE on closures without drop location in closure capture lint - #161548

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
malezjaa:fix-drop-location-span-ice
Sep 15, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
malezjaa:fix-drop-location-span-ice

Conversation

@malezjaa

@malezjaa malezjaa commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Resolves #156288.

drop_location_span assumed that every closure had a valid drop location, which could cause an ICE for closures in unsupported contexts. This changes drop_location_span to return Option<Span>. If there is no valid drop location, the migration lint is not emitted because its drop-order diagnostic would be misleading. The span is computed before creating MigrationLint and stored there so it can be reused for the drop-order labels.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 22, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 22, 2026
@rustbot

rustbot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

r? @Enselic

rustbot has assigned @Enselic.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 20 candidates

Comment thread compiler/rustc_hir_typeck/src/upvar.rs Outdated
@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 Aug 25, 2026
@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@malezjaa
malezjaa force-pushed the fix-drop-location-span-ice branch 2 times, most recently from d1439d4 to 21060d4 Compare August 26, 2026 21:32
@malezjaa

Copy link
Copy Markdown
Contributor Author

@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 Aug 26, 2026
@rust-log-analyzer

This comment has been minimized.

@malezjaa
malezjaa force-pushed the fix-drop-location-span-ice branch from 21060d4 to 5280e63 Compare August 26, 2026 22:33
@rustbot

rustbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rustbot

rustbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@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 Aug 27, 2026
@malezjaa
malezjaa force-pushed the fix-drop-location-span-ice branch from 5280e63 to 623f6f7 Compare August 27, 2026 09:19
@malezjaa

Copy link
Copy Markdown
Contributor Author

@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 Aug 27, 2026

@Enselic Enselic left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some more comments. I'd also like to ask you to have a more descriptive commit title. My suggestion is something along the lines of:

hir_typeck: Don't ICE on closures without drop location in closure capture lint

View changes since this review

Comment thread compiler/rustc_hir_typeck/src/upvar.rs Outdated
Comment thread compiler/rustc_hir_typeck/src/upvar.rs Outdated
Comment thread compiler/rustc_hir_typeck/src/upvar.rs
@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 Aug 31, 2026
@malezjaa
malezjaa force-pushed the fix-drop-location-span-ice branch from 623f6f7 to 158a310 Compare August 31, 2026 21:07
@malezjaa

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 31, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 31, 2026

@Enselic Enselic left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a quick comment. (I didn't have time for a full and detailed review, but figured you might want to look into this one already now. Feel free to wait for more review comments before you push new code, if you prefer.)

View changes since this review

Comment thread compiler/rustc_hir_typeck/src/upvar.rs Outdated
@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 Sep 3, 2026
@malezjaa
malezjaa force-pushed the fix-drop-location-span-ice branch from 158a310 to 20cbc85 Compare September 3, 2026 19:38
Comment thread compiler/rustc_hir_typeck/src/upvar.rs Outdated
@Enselic Enselic changed the title fix drop_location_span ICE hir_typeck: Don't ICE on closures without drop location in closure capture lint Sep 9, 2026
…pture lint

`drop_location_span` assumed that every closure had a valid drop location, which could cause an ICE for closures in unsupported contexts. This changes `drop_location_span` to return `Option<Span>`. If there is no valid drop location, the migration lint is not emitted because its drop-order diagnostic would be misleading. The span is computed before creating `MigrationLint` and stored there so it can be reused for the drop-order labels.
@malezjaa
malezjaa force-pushed the fix-drop-location-span-ice branch from 20cbc85 to 1699fba Compare September 11, 2026 05:59
@malezjaa

Copy link
Copy Markdown
Contributor Author

@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 13, 2026

@Enselic Enselic left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good now, thanks!

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1699fba has been approved by Enselic

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 15, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 15, 2026
…e, r=Enselic

hir_typeck: Don't ICE on closures without drop location in closure capture lint

Resolves rust-lang#156288.

`drop_location_span` assumed that every closure had a valid drop location, which could cause an ICE for closures in unsupported contexts. This changes `drop_location_span` to return `Option<Span>`. If there is no valid drop location, the migration lint is not emitted because its drop-order diagnostic would be misleading. The span is computed before creating `MigrationLint` and stored there so it can be reused for the drop-order labels.
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup of 10 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - #161612 (std: make a lot of items crate private)
 - #162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup of 10 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - #161612 (std: make a lot of items crate private)
 - #162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #160911 (Remove d32 feature from 32-bit Arm targets)
 - #161868 (libtest: never iterate over all tests in `--exact` mode)
 - #162771 (Filter do_not_recommend impls before handling a single candidate)
 - #162779 (rustdoc: Revert "fix bare urls split text")
 - #161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - #161612 (std: make a lot of items crate private)
 - #162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - #162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - #162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - #162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - #162654 (Improve Armv7-R documentation)
 - #162784 (AGENTS.md: Permit local experimentation, per the online policy.)
@rust-bors
rust-bors Bot merged commit 0f31e2c into rust-lang:main Sep 15, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 15, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Rollup merge of #161548 - malezjaa:fix-drop-location-span-ice, r=Enselic

hir_typeck: Don't ICE on closures without drop location in closure capture lint

Resolves #156288.

`drop_location_span` assumed that every closure had a valid drop location, which could cause an ICE for closures in unsupported contexts. This changes `drop_location_span` to return `Option<Span>`. If there is no valid drop location, the migration lint is not emitted because its drop-order diagnostic would be misleading. The span is computed before creating `MigrationLint` and stored there so it can be reused for the drop-order labels.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 17, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#160911 (Remove d32 feature from 32-bit Arm targets)
 - rust-lang/rust#161868 (libtest: never iterate over all tests in `--exact` mode)
 - rust-lang/rust#162771 (Filter do_not_recommend impls before handling a single candidate)
 - rust-lang/rust#162779 (rustdoc: Revert "fix bare urls split text")
 - rust-lang/rust#161548 (hir_typeck: Don't ICE on closures without drop location in closure capture lint)
 - rust-lang/rust#161612 (std: make a lot of items crate private)
 - rust-lang/rust#162204 (Suggest keyword order for `extern "C" const unsafe fn`)
 - rust-lang/rust#162372 (Clean up `test/rustdoc-html` folder by moving tests where appropriate)
 - rust-lang/rust#162638 (dont suggest changing the mutability of a borrow that comes from a macro)
 - rust-lang/rust#162643 (Fix `path_trailing_sep` methods for Windows verbatim paths)
 - rust-lang/rust#162654 (Improve Armv7-R documentation)
 - rust-lang/rust#162784 (AGENTS.md: Permit local experimentation, per the online policy.)
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-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]: Drop location span error: need to handle more ItemKind

4 participants