Skip to content

Fix avoid cycle for self referential return type notation - #159958

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
amirHdev:fix-rtn-cycle
Jul 31, 2026
Merged

Fix avoid cycle for self referential return type notation#159958
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
amirHdev:fix-rtn-cycle

Conversation

@amirHdev

@amirHdev amirHdev commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

View all comments

Fixes #159892 and #133613
we had to preserve and restore shadowed parameters in the impl trait overcapture lint and convert the resolved crash regression into a normal UI test which is applied to this patch

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 26, 2026
@amirHdev
amirHdev force-pushed the fix-rtn-cycle branch 2 times, most recently from 037d040 to 6e1755a Compare July 26, 2026 12:10
@amirHdev
amirHdev marked this pull request as ready for review July 26, 2026 13:15
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 26, 2026
@rustbot

rustbot commented Jul 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 removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 26, 2026
@rustbot

rustbot commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 74 candidates
  • Random selection from 16 candidates

@jieyouxu

Copy link
Copy Markdown
Member

r? types (bandwidth)

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jul 29, 2026
@rustbot rustbot assigned oli-obk and unassigned jieyouxu Jul 29, 2026

@oli-obk oli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand the immediate-self-cycle solution in resolve_bound_vars, but not yet the entire picture here. I'm worried 133613 is only "fixed" accidentally and is now referencing the wrong bound vars, but thus not ICEing anymore

View changes since this review

//@ dont-check-compiler-stderr
//@ dont-require-annotations: ERROR

struct Wrapper<'a>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why was this unrelated type ever part of the logic that caused the ICE?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one thing to try is to add more lifetime params here until they are more than the anonymous ones on the function, maybe then the ICE reoccurs?

@amirHdev amirHdev Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wrapper is only there to force error recovery. it is a separate HIR owner and is not the source of the bound variable list used for IntFactory::stream
I increased it to four unrelated lifetime parameters as you suggested. on the this patch base commit the compiler still panics with
Not enough bound vars: ... IntFactory::stream ... not found in []
and exits with status 101
With the patch applied the exact same test only reports the four expected E0392 diagnostics. this shows that the fix is addressing the underlying problem

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I see now. the query cycle happens during fn_sig, which, when part of a cycle returns a dummy value instead of causing a fatal error. Thus the entire output of resolve_bound_vars query is now bogus, as invoking it again will not cause a cycle now, but use the dummy value from the cached failed fn_sig query. This produces an empty list of bound vars.

Your fix avoids the cycle entirely and everything is good.

Comment thread compiler/rustc_lint/src/impl_trait_overcaptures.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 Jul 29, 2026
@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

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

@amirHdev

amirHdev commented Jul 29, 2026

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 Jul 29, 2026
@amirHdev
amirHdev requested a review from oli-obk July 29, 2026 17:09
@oli-obk

oli-obk commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@bors squash avoid cycle for self referential return type notation

@rust-bors

rust-bors Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Unknown argument "avoid". Did you mean to use @bors squash [msg|message="<commit-msg>"|description]? Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@oli-obk

oli-obk commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@bors squash msg="avoid cycle for self referential return type notation"

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🔨 2 commits were squashed into af64640.

@rust-bors
rust-bors Bot force-pushed the fix-rtn-cycle branch from f4caf4f to af64640 Compare July 30, 2026 16:04
@oli-obk

oli-obk commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit af64640 has been approved by oli-obk

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 Jul 30, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #160204 (Sync from portable simd 2026 07 30)
 - #138230 (Add `raw_borrows_via_references` lint)
 - #158057 (Don't escape U+FF9E and U+FF9F in `escape_debug_ext`)
 - #160015 (refactor(mir-transform): Merge `can_be_overridden`, `is_required` and `is_enabled` into one)
 - #160031 (std: make positioned I/O unsupported on VxWorks)
 - #160125 (Fix typing mode handling in transmute checks and rustc_dump_layout)
 - #160152 (Create on-demand CI job for testing EC2 instances)
 - #160232 (rustdoc: fix ICE when a grapheme cluster joins a Prepend-class character to `_` or `:`)
 - #159214 (std: improve the documentation of the random feature)
 - #159818 (Resolve vars before calling `unnormalized_obligations`)
 - #159955 (Stop using higher-order macros to declare arenas)
 - #159958 (Fix avoid cycle for self referential return type notation)
 - #160040 (Split function parsing out of `item.rs` to a new module.)
 - #160044 (Add regression tests for fixed dead-code issues)
 - #160144 (renovate: group lockfiles PRs)
 - #160149 (Fix Windows on Arm PAC default)
 - #160164 (Derive `GenericTypeVisitable` for `RegionConstraint`)
 - #160175 (Try to recover less from incorrectly parsed const arg)
 - #160177 (A few more "predicate"-to-"clause" renamings)
 - #160181 (Mark `Tuple` and `FnPtr` traits `#[fundamental]`)
 - #160192 (Fix ICE for parsing issue with a closing brace)
 - #160209 (bootstrap: Remove method `Subcommand::kind`)
 - #160221 (Remove `Copy` supertrait from `VaList`)
 - #160223 (interpret: rename validate_operand → validate_place)
 - #160234 (Always use short ty path for call with missing arguments suggestion)
rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #160204 (Sync from portable simd 2026 07 30)
 - #138230 (Add `raw_borrows_via_references` lint)
 - #158057 (Don't escape U+FF9E and U+FF9F in `escape_debug_ext`)
 - #160015 (refactor(mir-transform): Merge `can_be_overridden`, `is_required` and `is_enabled` into one)
 - #160031 (std: make positioned I/O unsupported on VxWorks)
 - #160125 (Fix typing mode handling in transmute checks and rustc_dump_layout)
 - #160152 (Create on-demand CI job for testing EC2 instances)
 - #160232 (rustdoc: fix ICE when a grapheme cluster joins a Prepend-class character to `_` or `:`)
 - #159214 (std: improve the documentation of the random feature)
 - #159818 (Resolve vars before calling `unnormalized_obligations`)
 - #159955 (Stop using higher-order macros to declare arenas)
 - #159958 (Fix avoid cycle for self referential return type notation)
 - #160040 (Split function parsing out of `item.rs` to a new module.)
 - #160044 (Add regression tests for fixed dead-code issues)
 - #160144 (renovate: group lockfiles PRs)
 - #160149 (Fix Windows on Arm PAC default)
 - #160164 (Derive `GenericTypeVisitable` for `RegionConstraint`)
 - #160175 (Try to recover less from incorrectly parsed const arg)
 - #160177 (A few more "predicate"-to-"clause" renamings)
 - #160181 (Mark `Tuple` and `FnPtr` traits `#[fundamental]`)
 - #160192 (Fix ICE for parsing issue with a closing brace)
 - #160209 (bootstrap: Remove method `Subcommand::kind`)
 - #160221 (Remove `Copy` supertrait from `VaList`)
 - #160223 (interpret: rename validate_operand → validate_place)
 - #160234 (Always use short ty path for call with missing arguments suggestion)
@rust-bors
rust-bors Bot merged commit 8384a31 into rust-lang:main Jul 31, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 31, 2026
rust-timer added a commit that referenced this pull request Jul 31, 2026
Rollup merge of #159958 - amirHdev:fix-rtn-cycle, r=oli-obk

Fix avoid cycle for self referential return type notation

Fixes #159892 and #133613
we had to preserve and restore shadowed parameters in the impl trait overcapture lint and convert the resolved crash regression into a normal UI test which is applied to this patch
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Jul 31, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - rust-lang/rust#160204 (Sync from portable simd 2026 07 30)
 - rust-lang/rust#138230 (Add `raw_borrows_via_references` lint)
 - rust-lang/rust#158057 (Don't escape U+FF9E and U+FF9F in `escape_debug_ext`)
 - rust-lang/rust#160015 (refactor(mir-transform): Merge `can_be_overridden`, `is_required` and `is_enabled` into one)
 - rust-lang/rust#160031 (std: make positioned I/O unsupported on VxWorks)
 - rust-lang/rust#160125 (Fix typing mode handling in transmute checks and rustc_dump_layout)
 - rust-lang/rust#160152 (Create on-demand CI job for testing EC2 instances)
 - rust-lang/rust#160232 (rustdoc: fix ICE when a grapheme cluster joins a Prepend-class character to `_` or `:`)
 - rust-lang/rust#159214 (std: improve the documentation of the random feature)
 - rust-lang/rust#159818 (Resolve vars before calling `unnormalized_obligations`)
 - rust-lang/rust#159955 (Stop using higher-order macros to declare arenas)
 - rust-lang/rust#159958 (Fix avoid cycle for self referential return type notation)
 - rust-lang/rust#160040 (Split function parsing out of `item.rs` to a new module.)
 - rust-lang/rust#160044 (Add regression tests for fixed dead-code issues)
 - rust-lang/rust#160144 (renovate: group lockfiles PRs)
 - rust-lang/rust#160149 (Fix Windows on Arm PAC default)
 - rust-lang/rust#160164 (Derive `GenericTypeVisitable` for `RegionConstraint`)
 - rust-lang/rust#160175 (Try to recover less from incorrectly parsed const arg)
 - rust-lang/rust#160177 (A few more "predicate"-to-"clause" renamings)
 - rust-lang/rust#160181 (Mark `Tuple` and `FnPtr` traits `#[fundamental]`)
 - rust-lang/rust#160192 (Fix ICE for parsing issue with a closing brace)
 - rust-lang/rust#160209 (bootstrap: Remove method `Subcommand::kind`)
 - rust-lang/rust#160221 (Remove `Copy` supertrait from `VaList`)
 - rust-lang/rust#160223 (interpret: rename validate_operand → validate_place)
 - rust-lang/rust#160234 (Always use short ty path for call with missing arguments suggestion)
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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: cycle detected when computing function signature / Not enough bound vars:

4 participants