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 reporting borrowck errors involving regions from anonymous_lifetime_in_impl_trait #103382

Merged
merged 1 commit into from
Oct 25, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Oct 22, 2022

The issue here is that when we have:

trait Trait<'a> { .. }

fn foo(arg: impl Trait) { .. }

The anonymous lifetime '_ that we generate for arg: impl Trait doesn't end up in the argument type (which is a param) but in a where-clause of the function, in a predicate whose self type is that param ty.

Fixes #101660

r? @cjgillot

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 22, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 22, 2022
@compiler-errors compiler-errors changed the title Don't ICE on regions from anonymous_lifetime_in_impl_trait Don't ICE when reporting borrowck errors involving regions from anonymous_lifetime_in_impl_trait Oct 22, 2022
@compiler-errors compiler-errors force-pushed the anon-apit-lt-region-ice branch from ecbff72 to e025306 Compare October 22, 2022 03:01
error[E0521]: borrowed data escapes outside of closure
--> $DIR/anonymous-region-in-apit.rs:8:17
|
LL | fn qux(foo: impl Foo<&str>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any easy way to get the def_id of the lifetime itself and point to it?
r=me if not.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, as far as I understand it, the way that borrowck does it requires walking through HIR, and I didn't want to reinvent that for just this case.

@compiler-errors
Copy link
Member Author

@bors r=cjgillot rollup

@bors
Copy link
Contributor

bors commented Oct 24, 2022

📌 Commit e025306 has been approved by cjgillot

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 Oct 24, 2022
JohnTitor pushed a commit to JohnTitor/rust that referenced this pull request Oct 24, 2022
…n-ice, r=cjgillot

Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait`

The issue here is that when we have:

```
trait Trait<'a> { .. }

fn foo(arg: impl Trait) { .. }
```

The anonymous lifetime `'_` that we generate for `arg: impl Trait` doesn't end up in the argument type (which is a param) but in a where-clause of the function, in a predicate whose self type is that param ty.

Fixes rust-lang#101660

r? `@cjgillot`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 25, 2022
Rollup of 11 pull requests

Successful merges:

 - rust-lang#103333 (Fix assertion failed for break_last_token and trailing token)
 - rust-lang#103350 (Change terminology for assoc method suggestions when they are not called)
 - rust-lang#103382 (Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait`)
 - rust-lang#103409 (Delay span bug when we can't map lifetimes back in `collect_trait_impl_trait_tys`)
 - rust-lang#103410 (-Z docs: Add link to unstable book)
 - rust-lang#103462 (rustdoc: remove no-op CSS `.source pre.rust { white-space: pre }`)
 - rust-lang#103465 (E0210 explanation: remove redundant sentence)
 - rust-lang#103486 (Use functions in highlight-colors rustdoc GUI test)
 - rust-lang#103493 (rustdoc: remove unused `.sidebar-logo` DOM on source pages)
 - rust-lang#103494 (rustdoc: remove redundant CSS `a.test-arrow:hover`)
 - rust-lang#103495 (rustdoc: Use `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6383540 into rust-lang:master Oct 25, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 25, 2022
@compiler-errors compiler-errors deleted the anon-apit-lt-region-ice branch November 2, 2022 02:53
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] [Nightly] Compiler panicks on anonymous lifetime in impl Trait
5 participants