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

Fix ReErased leaking into typeck due to typeof(...) recovery #100185

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

compiler-errors
Copy link
Member

Fixes #100183

@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 5, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 5, 2022
let ty = tcx.type_of(tcx.hir().local_def_id(e.hir_id));
let ty_erased = tcx.type_of(tcx.hir().local_def_id(e.hir_id));
let ty = tcx.fold_regions(ty_erased, |r, _| {
if r.is_erased() { tcx.lifetimes.re_static } else { r }
Copy link
Member

Choose a reason for hiding this comment

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

Likely makes more sense to never create the ReErased in the first place...

Copy link
Member Author

@compiler-errors compiler-errors Aug 6, 2022

Choose a reason for hiding this comment

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

That would require changing the type_of query behavior for anon consts -- not sure what that would break though. I guess anon consts should be treating all those lifetimes as ReStatic like other consts though 🤔

Copy link
Member Author

@compiler-errors compiler-errors Aug 6, 2022

Choose a reason for hiding this comment

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

@jackh726: Oh... sooo this calls the typeck query on the body of the AnonConst, so all non-late lifetimes (incl ReStatic) are erased during writeback. Don't think I can avoid getting ReErased when I call tcx.type_of.

@wesleywiser
Copy link
Member

Thanks @compiler-errors! 🙂

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 12, 2022

📌 Commit 315d12d has been approved by wesleywiser

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 12, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 12, 2022
…sleywiser

Fix `ReErased` leaking into typeck due to `typeof(...)` recovery

Fixes rust-lang#100183
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 12, 2022
…sleywiser

Fix `ReErased` leaking into typeck due to `typeof(...)` recovery

Fixes rust-lang#100183
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2022
…llaumeGomez

Rollup of 8 pull requests

Successful merges:

 - rust-lang#100185 (Fix `ReErased` leaking into typeck due to `typeof(...)` recovery)
 - rust-lang#100291 (constify some `CStr` methods)
 - rust-lang#101677 (Add test for rust-lang#101211)
 - rust-lang#101723 (Impove diagnostic for `.await`ing non-futures)
 - rust-lang#101724 (Allow unauthenticated users to add the `const-hack` label)
 - rust-lang#101731 (rustdoc: improve rustdoc HTML suggestions handling of nested generics)
 - rust-lang#101732 (Feature gate the `rustdoc::missing_doc_code_examples` lint)
 - rust-lang#101735 (rustdoc: fix treatment of backslash-escaped HTML)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b7504d6 into rust-lang:master Sep 13, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 13, 2022
@compiler-errors compiler-errors deleted the issue-100183 branch August 11, 2023 20:03
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 when trying to use typeof(reference_expr) in a struct
6 participants