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

Continue to get rid of ty::Const::{try_}eval* #130950

Merged
merged 4 commits into from
Oct 21, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Sep 27, 2024

This PR mostly does:

  • Removes all of the try_eval_* and eval_* helpers from ty::Const, and replace their usages with try_to_*.
  • Remove ty::Const::eval.
  • Rename ty::Const::normalize to ty::Const::normalize_internal. This function is still used in the normalization code itself.
  • Fix some weirdness around the TransmuteFrom goal.

I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools.

r? BoxyUwU

Part of #130704

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 27, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 27, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in engine.rs, potentially modifying the public API of ObligationCtxt.

cc @lcnr, @compiler-errors

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in compiler/rustc_sanitizers

cc @rust-lang/project-exploit-mitigations, @rcvalle

The Miri subtree was changed

cc @rust-lang/miri

@compiler-errors compiler-errors changed the title Yeet eval Continue to get rid of try::Const::{try_}eval* Sep 27, 2024
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

ah debuginfo

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_const_eval/src/const_eval/mod.rs Outdated Show resolved Hide resolved
if let Some(len) =
len.try_eval_target_usize(self.tcx, self.tcx.param_env(adt.did()))
{
if let Some(len) = len.try_to_target_usize(self.tcx) {
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 possibly may need to be normalized w/ lazy norm?

compiler/rustc_middle/src/mir/consts.rs Show resolved Hide resolved
compiler/rustc_middle/src/ty/consts.rs Show resolved Hide resolved
@@ -290,6 +290,36 @@ where
Ok(ty)
}
}

/// Normalize a type for when it is structurally matched on.
Copy link
Member Author

Choose a reason for hiding this comment

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

We need this so we can structurally normalize a const in consider_builtin_transmute_candidate. That structurally matches on an Assume struct which contains a bunch of bools for configuration.

@@ -2220,117 +2220,136 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
span: Span,
) -> GetSafeTransmuteErrorAndReason {
use rustc_transmute::Answer;
self.probe(|_| {
Copy link
Member Author

Choose a reason for hiding this comment

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

Best reviewed without whitespace. We added a probe so we can normalize below without side-effects.

@@ -134,13 +133,8 @@ mod rustc {
use rustc_middle::ty::ScalarInt;
use rustc_span::symbol::sym;

let Ok((ty, cv)) = c.eval(tcx, param_env, DUMMY_SP) else {
return Some(Self {
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 was sketchy. If a const was failing to eval, we just returned "whatever". 🤔

src/librustdoc/clean/mod.rs Outdated Show resolved Hide resolved
@oli-obk oli-obk changed the title Continue to get rid of try::Const::{try_}eval* Continue to get rid of ty::Const::{try_}eval* Sep 27, 2024
@compiler-errors
Copy link
Member Author

@rustbot author

some doctest is failing fml

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 28, 2024
@bors
Copy link
Contributor

bors commented Sep 30, 2024

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

@compiler-errors
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2024
@bors
Copy link
Contributor

bors commented Oct 18, 2024

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

@BoxyUwU
Copy link
Member

BoxyUwU commented Oct 19, 2024

I resolved the large threads since they were making it hard to review the actual code changes themselves and it also seemed like @RalfJung had a better understanding of what's going on now? Apologies if this was over-eager ^^

Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

Thank you :3 Looks good to me, sorry for taking so long to review. Once you resolve the nit, rebase, and maybe squash some of these commits? r=me

compiler/rustc_next_trait_solver/src/solve/mod.rs Outdated Show resolved Hide resolved
@BoxyUwU
Copy link
Member

BoxyUwU commented Oct 20, 2024

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Oct 20, 2024

📌 Commit 5cf8107 has been approved by BoxyUwU

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 Oct 20, 2024
@bors
Copy link
Contributor

bors commented Oct 21, 2024

⌛ Testing commit 5cf8107 with merge f2ba411...

@bors
Copy link
Contributor

bors commented Oct 21, 2024

☀️ Test successful - checks-actions
Approved by: BoxyUwU
Pushing f2ba411 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 21, 2024
@bors bors merged commit f2ba411 into rust-lang:master Oct 21, 2024
7 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 21, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f2ba411): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary -1.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.9% [-4.5%, -3.2%] 2
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 781.459s -> 781.789s (0.04%)
Artifact size: 333.77 MiB -> 333.65 MiB (-0.03%)

@compiler-errors compiler-errors deleted the yeet-eval branch October 21, 2024 15:52
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. PG-exploit-mitigations Project group: Exploit mitigations 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants