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

delay bug when adjusting NeverToAny twice during diagnostic code #96379

Merged
merged 1 commit into from
Apr 26, 2022

Conversation

PrestonFrom
Copy link
Contributor

@PrestonFrom PrestonFrom commented Apr 25, 2022

Addresses Issue 96335 (#96335) by using delay_span_bug instead of an assert and returning an error type from check_expr_meets_expectation_or_error.

Fixes #96335

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 25, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @compiler-errors (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 25, 2022
Comment on lines 81 to 92
if self.typeck_results.borrow().adjustments().contains_key(expr.hir_id) {
self.tcx().sess.delay_span_bug(
expr.span,
"expression with never type wound up being adjusted",
);
return self.tcx().ty_error();
}

Copy link
Member

@compiler-errors compiler-errors Apr 25, 2022

Choose a reason for hiding this comment

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

It would be nice to return the adjusted type from here instead of ty_error, so it doesn't meddle with the function call argument diagnostic code in check_argument_types:

Suggested change
if self.typeck_results.borrow().adjustments().contains_key(expr.hir_id) {
self.tcx().sess.delay_span_bug(
expr.span,
"expression with never type wound up being adjusted",
);
return self.tcx().ty_error();
}
if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
self.tcx().sess.delay_span_bug(
expr.span,
"expression with never type wound up being adjusted",
);
if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] {
return target;
} else {
return self.tcx().ty_error();
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great idea! Thank you!

@compiler-errors
Copy link
Member

compiler-errors commented Apr 25, 2022

Can you squash the commit history to get rid of the merge commit and the work-in-progress code that you committed? Usually I just git pull --rebase to avoid merge commits when updating local branches, but I digress..

Also, for posterity, it would be nice to give this PR a name like "delay bug when adjusting NeverToAny twice during diagnostic code". Or whatever you think is a better descriptive title.

@PrestonFrom
Copy link
Contributor Author

Thank you for the quick review!!

Can you squash the commit history to get rid of the merge commit and the work-in-progress code that you committed? Usually I just git pull --rebase to avoid merge commits when updating local branches, but I digress..

I will certainly be using rebase from now on! I created a bit of a mess squashing, but I think it's correct now.

Also, for posterity, it would be nice to give this PR a name like "delay bug when adjusting NeverToAny twice during diagnostic code". Or whatever you think is a better descriptive title.

I like that suggestion!

@compiler-errors compiler-errors changed the title Issue 96335 delay bug when adjusting NeverToAny twice during diagnostic code Apr 25, 2022
@compiler-errors
Copy link
Member

Thanks for the contribution. Fixing ICEs is totally rad.

@bors r

@bors
Copy link
Contributor

bors commented Apr 25, 2022

📌 Commit 5165295 has been approved by compiler-errors

@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 Apr 25, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 25, 2022
…-errors

delay bug when adjusting `NeverToAny` twice during diagnostic code

Addresses Issue 96335 (rust-lang#96335) by using `delay_span_bug` instead of an assert and returning an error type from `check_expr_meets_expectation_or_error`.

Fixes rust-lang#96335
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 25, 2022
…-errors

delay bug when adjusting `NeverToAny` twice during diagnostic code

Addresses Issue 96335 (rust-lang#96335) by using `delay_span_bug` instead of an assert and returning an error type from `check_expr_meets_expectation_or_error`.

Fixes rust-lang#96335
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 25, 2022
…-errors

delay bug when adjusting `NeverToAny` twice during diagnostic code

Addresses Issue 96335 (rust-lang#96335) by using `delay_span_bug` instead of an assert and returning an error type from `check_expr_meets_expectation_or_error`.

Fixes rust-lang#96335
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Apr 25, 2022
…-errors

delay bug when adjusting `NeverToAny` twice during diagnostic code

Addresses Issue 96335 (rust-lang#96335) by using `delay_span_bug` instead of an assert and returning an error type from `check_expr_meets_expectation_or_error`.

Fixes rust-lang#96335
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#90312 (Fix some confusing wording and improve slice-search-related docs)
 - rust-lang#96149 (Remove unused macro rules)
 - rust-lang#96279 (rustdoc: Remove .woff font files)
 - rust-lang#96355 (Better handle too many `#` recovery in raw str)
 - rust-lang#96379 (delay bug when adjusting `NeverToAny` twice during diagnostic code)
 - rust-lang#96384 (do not consider two extern types to be similar)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8038a9e into rust-lang:master Apr 26, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 26, 2022
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.

thread 'rustc' panicked at 'expression with never type wound up being adjusted'
5 participants