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

Normalize in infcx instead of globally for Option::as_deref suggestion #112303

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

Nilstrieb
Copy link
Member

fixes #112293

The projection may contain inference variables. These inference variables are local to the local inference context. Using tcx.normalize_erasing_regions doesn't work here because this method is global and does not have access to the inference context. It's therefore unable to deal with the inference variables. We normalize in the local inference context instead, which knowns about the inference variables.

The test looks a little different than the issue example, I made it more minimal and verified that it still ICEs on nightly.

Also contains a drive-by fix to properly compare the types.

r? @compiler-errors

The projection may contain inference variables. These inference
variables are local to the local inference context. Using
`tcx.normalize_erasing_regions` doesn't work here because this method is
global and does not have access to the inference context. It's therefore
unable to deal with the inference variables. We normalize in the local
inference context instead, which knowns about the inference variables.
@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 Jun 5, 2023
LL - fn generic_ref<T>(_: &T) -> Option<()> {
LL + fn generic_ref<T>(_: T) -> Option<()> {
|
help: call `Option::as_deref()` first
Copy link
Member Author

Choose a reason for hiding this comment

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

This now shows up because of the first commit :)

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.

good enough. i wonder if this should be changed to use ObligationCtxt::normalize but probably does not matter.

@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 5, 2023

📌 Commit c12575d 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 Jun 5, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#112081 (Avoid ICE on `#![doc(test(...)]` with literal parameter)
 - rust-lang#112196 (Resolve vars in result from `scrape_region_constraints`)
 - rust-lang#112303 (Normalize in infcx instead of globally for `Option::as_deref` suggestion)
 - rust-lang#112316 (Ensure space is inserted after keyword in `unused_delims`)
 - rust-lang#112318 (Merge method, type and const object safety checks)
 - rust-lang#112322 (Don't mention `IMPLIED_BOUNDS_ENTAILMENT` if signatures reference error)

Failed merges:

 - rust-lang#112251 (rustdoc: convert `if let Some()` that always matches to variable)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ff43249 into rust-lang:master Jun 6, 2023
11 checks passed
@rustbot rustbot added this to the 1.72.0 milestone Jun 6, 2023
@Nilstrieb Nilstrieb deleted the as-deref branch June 6, 2023 04:24
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: report_selection_error did not emit an error
4 participants