Skip to content

Make lit_to_mir_constant and lit_to_const infallible - #135195

Merged
bors merged 5 commits into
rust-lang:masterfrom
oli-obk:push-toyoyrupruko
Jan 9, 2025
Merged

Make lit_to_mir_constant and lit_to_const infallible#135195
bors merged 5 commits into
rust-lang:masterfrom
oli-obk:push-toyoyrupruko

Conversation

@oli-obk

@oli-obkoli-obk commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

My motivation for this change is just that it's annoying to check everywhere, especially since all but one call site was just ICEing on errors anyway right there.

They can still fail, but now just return an error constant instead of having the caller handle the error.

fixes#114317
fixes#126182

@rustbot

Copy link
Copy Markdown
Collaborator

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot 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 Jan 7, 2025
@oli-obkoli-obk changed the title Make lit_to_mir_constant infallibleMake lit_to_mir_constant and lit_to_const infallibleJan 7, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @rust-lang/wg-const-eval

Some changes occurred in match checking

cc @Nadrieril

HIR ty lowering was modified

cc @fmease

Some changes occurred in rustc_ty_utils::consts.rs

cc @BoxyUwU

Comment threadcompiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs Outdated
@rust-log-analyzer

This comment has been minimized.

trunc(if neg { (n.get() as i128).overflowing_neg().0 as u128 } else { n.get() })
}
(ast::LitKind::Float(n, _), ty::Float(fty)) => {
parse_float_into_constval(*n, *fty, neg).unwrap()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

delayed_bug to bug, it's unreachable I guess? 😁 though given we've got no tests for that, I don't mind merging this and reacting to a fuzzer ICE if it's reachable

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

yea, I looked into this before the holidays and if memory serves right the parser ensures we don't get anything that could fail here.

@lcnrlcnr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

gamer

r=me after nits

@lcnrlcnr assigned lcnr and unassigned fee1-deadJan 8, 2025
@rust-log-analyzer

This comment has been minimized.

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

@bors r=lcnr

@bors

bors commented Jan 8, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit c92ed62 has been approved by lcnr

It is now in the queue for this repository.

@borsbors 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 Jan 8, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 8, 2025
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#134228 (Exhaustively handle expressions in patterns)
- rust-lang#135194 (triagebot: mark tidy changes with a more specific `A-tidy` label)
- rust-lang#135222 (Ensure that we don't try to access fields on a non-struct pattern type)
- rust-lang#135250 (A couple simple borrowck cleanups)
- rust-lang#135252 (Fix release notes link)
- rust-lang#135253 (Revert rust-lang#131365)
Failed merges:
- rust-lang#135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible)
r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 8, 2025
Make `lit_to_mir_constant` and `lit_to_const` infallible
My motivation for this change is just that it's annoying to check everywhere, especially since all but one call site was just ICEing on errors anyway right there.
They can still fail, but now just return an error constant instead of having the caller handle the error.
fixesrust-lang#114317fixesrust-lang#126182
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 8, 2025
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#134228 (Exhaustively handle expressions in patterns)
- rust-lang#135194 (triagebot: mark tidy changes with a more specific `A-tidy` label)
- rust-lang#135222 (Ensure that we don't try to access fields on a non-struct pattern type)
- rust-lang#135250 (A couple simple borrowck cleanups)
- rust-lang#135252 (Fix release notes link)
- rust-lang#135253 (Revert rust-lang#131365)
Failed merges:
- rust-lang#135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2025
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#128110 (Suggest Replacing Comma with Semicolon in Incorrect Repeat Expressions)
- rust-lang#134609 (Add new `{x86_64,i686}-win7-windows-gnu` targets)
- rust-lang#134875 (Implement `const Destruct` in old solver)
- rust-lang#135221 (Include rustc and rustdoc book in replace-version-placeholder)
- rust-lang#135231 (bootstrap: Add more comments to some of the test steps)
- rust-lang#135256 (Move `mod cargo` below the import statements)
Failed merges:
- rust-lang#135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible)
r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr

Copy link
Copy Markdown
Member

@bors r-
needs rebase

@borsbors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 9, 2025
@oli-obk

Copy link
Copy Markdown
ContributorAuthor

@bors r=lcnr

@bors

bors commented Jan 9, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 84c8d4f has been approved by lcnr

It is now in the queue for this repository.

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 9, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2025
…iaskrgr
Rollup of 3 pull requests
Successful merges:
- rust-lang#134898 (Make it easier to run CI jobs locally)
- rust-lang#135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible)
- rust-lang#135261 (Account for identity substituted items in symbol mangling)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2025
…iaskrgr
Rollup of 3 pull requests
Successful merges:
- rust-lang#134898 (Make it easier to run CI jobs locally)
- rust-lang#135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible)
- rust-lang#135261 (Account for identity substituted items in symbol mangling)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 8ff355a into rust-lang:masterJan 9, 2025
@rustbotrustbot added this to the 1.86.0 milestone Jan 9, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2025
Rollup merge of rust-lang#135195 - oli-obk:push-toyoyrupruko, r=lcnr
Make `lit_to_mir_constant` and `lit_to_const` infallible
My motivation for this change is just that it's annoying to check everywhere, especially since all but one call site was just ICEing on errors anyway right there.
They can still fail, but now just return an error constant instead of having the caller handle the error.
fixesrust-lang#114317fixesrust-lang#126182
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

8 participants

@oli-obk@rustbot@rust-log-analyzer@bors@matthiaskrgr@BoxyUwU@lcnr@fee1-dead