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

Move various checks to typeck so them failing causes the typeck result to get tainted #96046

Merged
merged 9 commits into from
May 27, 2022

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 14, 2022

Fixes #69487
fixes #79047

cc @RalfJung this gets rid of the Transmute invalid program error variant

@rust-highfive
Copy link
Collaborator

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

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

r? @jackh726

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 14, 2022
@@ -148,8 +148,6 @@ pub enum InvalidProgramInfo<'tcx> {
/// (which unfortunately typeck does not reject).
/// Not using `FnAbiError` as that contains a nested `LayoutError`.
FnAbiAdjustForForeignAbi(call::AdjustForForeignAbiError),
/// An invalid transmute happened.
TransmuteSizeDiff(Ty<'tcx>, Ty<'tcx>),
Copy link
Member

Choose a reason for hiding this comment

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

That's great. :D So does this also fix #79047 ?

What about SizeOfUnsizedType, which seems similar to me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

similar, but when I looked into it it was a different beast that I'll tackle seperately

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 great. :D So does this also fix #79047 ?

yes, the corresponding test has been updated

Copy link
Member

@RalfJung RalfJung Apr 14, 2022

Choose a reason for hiding this comment

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

We might want to keep the issue open for SizeOfUnsizedType though. Do we have a nice example of that (or an existing separate issue)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I saw an example when I removed that variant ^^ but I don't remember where

Copy link
Member

Choose a reason for hiding this comment

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

What about SizeOfUnsizedType, which seems similar to me?

I have opened #97477 for this.

@bors
Copy link
Contributor

bors commented Apr 16, 2022

☔ The latest upstream changes (presumably #94468) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726
Copy link
Member

This looks fine to me, but I'm not really familiar with this code, so maybe @RalfJung wants to give the final say?

@RalfJung
Copy link
Member

typeck is outside my purview, sorry -- I can't really help with this PR, other than that I like the end-to-end effect of turning that one check in the interpreter into an assertion.

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 23, 2022

Rerolling the reviewer dice

r? rust-lang/compiler

@oli-obk
Copy link
Contributor Author

oli-obk commented May 5, 2022

r? rust-lang/compiler

@rust-highfive rust-highfive assigned nagisa and unassigned cjgillot May 5, 2022
@bors
Copy link
Contributor

bors commented May 7, 2022

☔ The latest upstream changes (presumably #96531) made this pull request unmergeable. Please resolve the merge conflicts.

@nagisa
Copy link
Member

nagisa commented May 10, 2022

r? rust-lang/compiler

I won't be able to get to reviewing things for the upcoming next couple weeks.

@bors
Copy link
Contributor

bors commented May 17, 2022

☔ The latest upstream changes (presumably #96825) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

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

I can't really review the typeck algorithm, but left a few questions where comments could be appropriate.

compiler/rustc_typeck/src/check/expr.rs Show resolved Hide resolved
compiler/rustc_typeck/src/check/expr.rs Show resolved Hide resolved
compiler/rustc_typeck/src/check/intrinsicck.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/intrinsicck.rs Outdated Show resolved Hide resolved
fcx.check_transmutes();
}

fcx.check_asms();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the difference between check_transmutes and check_asms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to replicate the previous diagnostics. For transmute that meant not to check if there were other errors already happening, as that would just cause useless errors in the transmute checks

@@ -274,6 +274,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
error: &SelectionError<'tcx>,
fallback_has_occurred: bool,
) {
self.set_tainted_by_errors();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. It avoids ICEs and bogus errors in CTFE.

@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 26, 2022

📌 Commit 6ba8da6 has been approved by cjgillot

@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 May 26, 2022
@bors
Copy link
Contributor

bors commented May 26, 2022

⌛ Testing commit 6ba8da6 with merge d3e7c4b8bb35907bab7d8714b84b21e7bc39fda0...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 26, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 26, 2022
@oli-obk
Copy link
Contributor Author

oli-obk commented May 27, 2022

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented May 27, 2022

📌 Commit 4332c2f has been approved by cjgillot

@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 May 27, 2022
@bors
Copy link
Contributor

bors commented May 27, 2022

⌛ Testing commit 4332c2f with merge 56fd680...

@bors
Copy link
Contributor

bors commented May 27, 2022

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 56fd680 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 27, 2022
@bors bors merged commit 56fd680 into rust-lang:master May 27, 2022
@rustbot rustbot added this to the 1.63.0 milestone May 27, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (56fd680): comparison url.

Instruction count

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
0.9% 1.1% 4
Improvements 🎉
(primary)
-0.3% -0.4% 4
Improvements 🎉
(secondary)
-0.3% -0.3% 24
All 😿🎉 (primary) -0.3% -0.4% 4

Max RSS (memory usage)

Results
  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.5% 2.5% 1
Improvements 🎉
(primary)
-2.4% -2.8% 2
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -2.4% -2.8% 2

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-2.8% -3.2% 2
All 😿🎉 (primary) N/A N/A 0

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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