Skip to content

[beta] Do not call check_expr twice in check_compatible #99397

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

compiler-errors
Copy link
Member

This fixes #98894 and #98897 on the beta branch, since my original fix #98785 does not merge cleanly onto beta.

Should I nominate this for beta backport again, since it's basically a different fix compared to the one that was approved? Regardless, it's actually a slightly smaller change than #98785.

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

r? @jackh726

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

@rust-highfive
Copy link
Contributor

⚠️ Warning ⚠️

  • Pull requests are usually filed against the master branch for this repo, but this one is against beta. Please double check that you specified the right target!

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 18, 2022
// so I prodded this method and made it pub(super) so I could call it, and it seems to work well.
let checked_ty = self.check_expr_kind(provided_arg, expectation);
let already_checked_ty = self.typeck_results.borrow().expr_ty_adjusted_opt(provided_arg);
let checked_ty = already_checked_ty.unwrap_or_else(|| self.check_expr(provided_arg));
Copy link
Member Author

@compiler-errors compiler-errors Jul 18, 2022

Choose a reason for hiding this comment

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

After #98785, we can assume that expr_ty_adjusted_opt called on an arg expression always returns Some, but since that PR is not on beta yet, we cannot -- so only call check_expr if we haven't already evaluated it once.

@Mark-Simulacrum
Copy link
Member

I think a new beta nomination won't hurt, but isn't strictly necessary. We should definitely get a fresh review from someone familiar with the code though!

@compiler-errors
Copy link
Member Author

@jackh726 is familiar with this code, though feel free to reassign as always.

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

LGTM

@compiler-errors compiler-errors added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jul 18, 2022
@pnkfelix
Copy link
Member

pnkfelix commented Jul 21, 2022

@rustbot label: +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jul 21, 2022
@ehuss ehuss removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jul 22, 2022
@ehuss ehuss added this to the 1.63.0 milestone Jul 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 22, 2022
[beta] Beta 1.63 backports

* Reference: Revert $$ macro_metavar rust-lang/reference#1192
* Revert "Stabilize $$ in Rust 1.63.0" rust-lang#99435
* rustdoc: avoid inlining items with duplicate `(type, name)` rust-lang#99344
* Do not call `check_expr` twice in `check_compatible` rust-lang#99397
@ehuss
Copy link
Contributor

ehuss commented Jul 22, 2022

I took the comments from jackh and pnkfelix as approval. Closing as merged via #99586.

@ehuss ehuss closed this Jul 22, 2022
@compiler-errors compiler-errors deleted the 🅱-arg-mismatch-adjustment-bug branch August 11, 2023 20:22
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants