Skip to content

fix an ICE when a valtree failed to evaluate #118498

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

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Dec 1, 2023

Fixes #118285

r? @lcnr

@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 Dec 1, 2023
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

r=me after nit

Comment on lines 307 to 316
let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)?
else {
// This can happen when we run on ill-typed code.
let e = tcx.sess.delay_span_bug(
span.unwrap_or(DUMMY_SP),
"`ty::Const::eval` called on a non-valtree-compatible type",
);
return Err(e.into());
};
Ok(c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)?
else {
// This can happen when we run on ill-typed code.
let e = tcx.sess.delay_span_bug(
span.unwrap_or(DUMMY_SP),
"`ty::Const::eval` called on a non-valtree-compatible type",
);
return Err(e.into());
};
Ok(c)
if let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)? {
Ok(c)
} else {
// This can happen when we run on ill-typed code.
let e = tcx.sess.delay_span_bug(
span.unwrap_or(DUMMY_SP),
"`ty::Const::eval` called on a non-valtree-compatible type",
);
Err(e.into())
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, IMO let else expresses the flow better here. We handle the error, then we continue on the main path.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I personally think that let-else is harder to read than an if let, so I only use it if I care about indentation 🤷 but given that it's a nit

@lcnr
Copy link
Contributor

lcnr commented Dec 1, 2023

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 1, 2023

📌 Commit 4a7372b has been approved by lcnr

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 Dec 1, 2023
@bors
Copy link
Collaborator

bors commented Dec 2, 2023

⌛ Testing commit 4a7372b with merge fe5cbbd...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 2, 2023
fix an ICE when a valtree failed to evaluate

Fixes rust-lang#118285

r? `@lcnr`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Dec 2, 2023

💔 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 Dec 2, 2023
@RalfJung
Copy link
Member Author

RalfJung commented Dec 2, 2023

@bors r=lcnr

@bors
Copy link
Collaborator

bors commented Dec 2, 2023

📌 Commit 1d120e6 has been approved by lcnr

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 Dec 2, 2023
@bors
Copy link
Collaborator

bors commented Dec 2, 2023

⌛ Testing commit 1d120e6 with merge 4eede98...

@bors
Copy link
Collaborator

bors commented Dec 2, 2023

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 4eede98 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 2, 2023
@bors bors merged commit 4eede98 into rust-lang:master Dec 2, 2023
@rustbot rustbot added this to the 1.76.0 milestone Dec 2, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4eede98): 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

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)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.7% [2.7%, 2.7%] 1

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: 672.207s -> 672.139s (-0.01%)
Artifact size: 313.91 MiB -> 313.94 MiB (0.01%)

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
Development

Successfully merging this pull request may close these issues.

ICE error in Rust compiler: ty::Const::eval called on a non-valtree-compatible type
6 participants