Skip to content

Improve the ICE message for invalid nullary intrinsic calls - #148118

Merged
bors merged 1 commit into
rust-lang:masterfrom
saethlin:nullary-intrinsic-check-bug-msg
Oct 26, 2025
Merged

Improve the ICE message for invalid nullary intrinsic calls#148118
bors merged 1 commit into
rust-lang:masterfrom
saethlin:nullary-intrinsic-check-bug-msg

Conversation

@saethlin

@saethlinsaethlin commented Oct 25, 2025

Copy link
Copy Markdown
Member

In #148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.

I expect this ICE to be hit in practice by people calling the size_of and align_of intrinsics, so it's now kind of helpful for those users too.

The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when #147793 ported two more the paragraph wasn't added. I've added it.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@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 Oct 25, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

r? @dianqk

rustbot has assigned @dianqk.
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

@rust-log-analyzer

This comment has been minimized.

@folkertdev

Copy link
Copy Markdown
Contributor

I expect this ICE to be hit in practice by people calling the size_of and align_of intrinsics. Maybe we should also add specific guidance for those users?

In this particular case it would have been helpful to know that the problem is calling the intrinsic directly. I did not consider that that might be happening (and core::mem::size_of logically calls the intrinsic, so the error talking about intrinsics didn't surprise me).

So yeah some note about how directly calling these intrinsics is discouraged (or some stronger word: it just does not work) would have helped.

@NoratriebNoratrieb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r=me after reflowing, this sounds good

View changes since this review

@saethlin
saethlinforce-pushed the nullary-intrinsic-check-bug-msg branch from d890b26 to 07f144eCompareOctober 25, 2025 22:41
@saethlin

Copy link
Copy Markdown
MemberAuthor

@bors r=Noratrieb rollup

@bors

bors commented Oct 25, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 07f144e has been approved by Noratrieb

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 Oct 25, 2025

@dianqkdianqk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we leave a comment stating that this can only be called at compile time? I can see this comment in some intrinsics (like needs_drop), but not in align_of. When I see Nullary intrinsic align_of must be called in a const block, I don't understand why this must be called in a const block.

View changes since this review

@saethlin

Copy link
Copy Markdown
MemberAuthor

I'll come back to that.
@bors r-

@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 Oct 26, 2025
@saethlin
saethlinforce-pushed the nullary-intrinsic-check-bug-msg branch from 07f144e to 7a0d9c8CompareOctober 26, 2025 01:32
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@saethlin

Copy link
Copy Markdown
MemberAuthor

I see what you meant. #142839 added a paragraph to the docs for all affected intrinsics then #147793 added size_of and align_of to this list of const-only intrinsics, but didn't add the paragraph for them.

@dianqkdianqk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dianqk

Copy link
Copy Markdown
Member

@bors r=Noratrieb,dianqk

@bors

bors commented Oct 26, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 7a0d9c8 has been approved by Noratrieb,dianqk

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 Oct 26, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 26, 2025
…ug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls
In rust-lang#148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.
I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.
The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when rust-lang#147793 ported two more the paragraph wasn't added. I've added it.
@ZalatharZalathar mentioned this pull request Oct 26, 2025
bors added a commit that referenced this pull request Oct 26, 2025
Rollup of 4 pull requests
Successful merges:
- #145665 (Don't require `T: RefUnwindSafe` for `vec::IntoIter<T>: UnwindSafe`)
- #147728 (tests: activate misspelled `gdb-check` in `function-arg-initialization.rs`)
- #148097 (tests/debuginfo/closures.rs: Activate misspelled `cdb-check`)
- #148118 (Improve the ICE message for invalid nullary intrinsic calls)
r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 26, 2025
…ug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls
In rust-lang#148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.
I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.
The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when rust-lang#147793 ported two more the paragraph wasn't added. I've added it.
@ZalatharZalathar mentioned this pull request Oct 26, 2025
bors added a commit that referenced this pull request Oct 26, 2025
Rollup of 2 pull requests
Successful merges:
- #148097 (tests/debuginfo/closures.rs: Activate misspelled `cdb-check`)
- #148118 (Improve the ICE message for invalid nullary intrinsic calls)
r? `@ghost`
`@rustbot` modify labels: rollup
@ZalatharZalathar mentioned this pull request Oct 26, 2025
bors added a commit that referenced this pull request Oct 26, 2025
Rollup of 2 pull requests
Successful merges:
- #148118 (Improve the ICE message for invalid nullary intrinsic calls)
- #148134 (Add myself as a windows-msvc maintainer)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 3bf838d into rust-lang:masterOct 26, 2025
11 checks passed
@rustbotrustbot added this to the 1.93.0 milestone Oct 26, 2025
rust-timer added a commit that referenced this pull request Oct 26, 2025
Rollup merge of #148118 - saethlin:nullary-intrinsic-check-bug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls
In #148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.
I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.
The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when #147793 ported two more the paragraph wasn't added. I've added it.
@saethlin
saethlin deleted the nullary-intrinsic-check-bug-msg branch November 26, 2025 00:21
github-actionsBot pushed a commit to model-checking/verify-rust-std that referenced this pull request Nov 30, 2025
…ug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls
In rust-lang#148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.
I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.
The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when rust-lang#147793 ported two more the paragraph wasn't added. I've added it.
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

Development

Successfully merging this pull request may close these issues.

7 participants

@saethlin@rustbot@rust-log-analyzer@folkertdev@bors@dianqk@Noratrieb