Skip to content

transmutability: Support char, NonZeroXxx #140215

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
Apr 26, 2025

Conversation

joshlf
Copy link
Contributor

@joshlf joshlf commented Apr 23, 2025

Note that NonZero support is not wired up, as the author encountered
bugs while attempting this. A future commit will wire up NonZero
support.

r? @jswrenn

@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 Apr 23, 2025
@joshlf joshlf force-pushed the transmutability-char-nonzero branch 2 times, most recently from a6671a7 to b4af1e4 Compare April 23, 2025 18:45
@rust-log-analyzer

This comment has been minimized.

@jswrenn jswrenn force-pushed the transmutability-char-nonzero branch from b4af1e4 to 5924db8 Compare April 23, 2025 19:03
@rust-log-analyzer

This comment has been minimized.

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from 5924db8 to 1a22b85 Compare April 23, 2025 19:38
@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 23, 2025
@rust-log-analyzer

This comment has been minimized.

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from 1a22b85 to 3df7f06 Compare April 23, 2025 19:59
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Apr 24, 2025

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

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from 3df7f06 to b70553b Compare April 24, 2025 16:44
@joshlf
Copy link
Contributor Author

joshlf commented Apr 24, 2025

@tmiasko Since you've expressed an interest in this, maybe you have a few cycles to poke at a bug that's been stumping me? Running the UI test transmutability/nonzero.rs is causing rustc to segfault. It appears to be somewhere in this match arm. No worries if not, obviously, but I figured that maybe something would jump out to you that isn't jumping out to me (as someone without much familiarity with the rustc codebase).

@rust-log-analyzer

This comment has been minimized.

@jswrenn
Copy link
Member

jswrenn commented Apr 24, 2025

@joshlf I recommend doing an rr trace of the stage1 rustc.

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from b70553b to fd62d29 Compare April 24, 2025 19:16
@joshlf joshlf marked this pull request as ready for review April 24, 2025 19:16
@joshlf
Copy link
Contributor Author

joshlf commented Apr 24, 2025

@jswrenn I'll work on that in parallel. In the meantime, this is ready for review (without wiring up NonZero types).

@joshlf joshlf changed the title transmutability: Support char, NonZeroXxx transmutability: Support char, NonZeroXxx, type aliases Apr 24, 2025
@joshlf joshlf force-pushed the transmutability-char-nonzero branch from fd62d29 to 700899a Compare April 24, 2025 19:20
@rust-log-analyzer

This comment has been minimized.

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from 700899a to c11c064 Compare April 24, 2025 22:34
@tmiasko
Copy link
Contributor

tmiasko commented Apr 25, 2025

Running the UI test transmutability/nonzero.rs is causing rustc to segfault. It appears to be somewhere in this match arm.

There is an infinite recursion in ty::Alias match arm. AliasTy::to_ty reconstructs ty::Alias, and then recurses without making any progress. The actual problem is probably missing normalization when computing a field type.

Self::from_struct((ty, layout), *adt_def, cx)
}
(AdtKind::Struct, Included(1), Included(_hi)) if is_transparent => {
// FIXME: Uncomment the code below and get it
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to tackle this in this PR, or a follow up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a follow-up. I've removed the commented-out code for now.

@@ -268,6 +384,10 @@ pub(crate) mod rustc {
}))
}

ty::Char => Ok(Self::char(cx.tcx().data_layout.endian.into())),

ty::Alias(_kind, ty) => Self::from_ty(ty.to_ty(cx.tcx()), cx),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ty::Alias(_kind, ty) => Self::from_ty(ty.to_ty(cx.tcx()), cx),
ty::Alias(_kind, ty) => Self::from_ty(/* normalize ty */),

@tmiasko / @compiler-errors, what's the current way to normalize a type when we do care about regions?

Copy link
Member

Choose a reason for hiding this comment

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

If we're punting on normalization, can you remove this branch so we don't regress projections to an infinite loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we're punting on normalization, can you remove this branch so we don't regress projections to an infinite loop?

Done.

@tmiasko / @compiler-errors, what's the current way to normalize a type when we do care about regions?

Maybe, for the time being (but in a separate PR), we could at least support 'static types by normalizing without caring about regions and returning an error when the type is non-'static? That would at least cover the NonZero case.

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from c11c064 to b482af6 Compare April 25, 2025 16:26
@jswrenn
Copy link
Member

jswrenn commented Apr 25, 2025

@joshlf Happy for us to punt NonZeroXxx and aliases to a future PR, but can you edit the commit message and PR title accordingly?

@joshlf joshlf force-pushed the transmutability-char-nonzero branch from b482af6 to 56df2e4 Compare April 25, 2025 19:54
Note that `NonZero` support is not wired up, as the author encountered
bugs while attempting this. A future commit will wire up `NonZero`
support.
@joshlf joshlf force-pushed the transmutability-char-nonzero branch from 56df2e4 to ae0c2fe Compare April 25, 2025 19:56
@joshlf joshlf changed the title transmutability: Support char, NonZeroXxx, type aliases transmutability: Support char, NonZeroXxx Apr 25, 2025
@joshlf
Copy link
Contributor Author

joshlf commented Apr 25, 2025

@joshlf Happy for us to punt NonZeroXxx and aliases to a future PR, but can you edit the commit message and PR title accordingly?

Done.

@jswrenn
Copy link
Member

jswrenn commented Apr 26, 2025

Thanks! I'll follow up with a normalization fix as soon as I unbork my devbox...

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 26, 2025

📌 Commit ae0c2fe has been approved by jswrenn

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 Apr 26, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 26, 2025
…o, r=jswrenn

transmutability: Support char, NonZeroXxx

Note that `NonZero` support is not wired up, as the author encountered
bugs while attempting this. A future commit will wire up `NonZero`
support.

r? `@jswrenn`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 26, 2025
…o, r=jswrenn

transmutability: Support char, NonZeroXxx

Note that `NonZero` support is not wired up, as the author encountered
bugs while attempting this. A future commit will wire up `NonZero`
support.

r? ``@jswrenn``
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#123239 (Implement a lint for implicit autoref of raw pointer dereference - take 2)
 - rust-lang#140215 (transmutability: Support char, NonZeroXxx)
 - rust-lang#140226 (Update wasm-component-ld to 0.5.13)
 - rust-lang#140302 (Move inline asm check to typeck, properly handle aliases)
 - rust-lang#140317 (Remove redundant check)
 - rust-lang#140318 (Simply try to unpeel AsyncFnKindHelper goal in `emit_specialized_closure_kind_error`)
 - rust-lang#140325 (Grammar fixes for BufRead::has_data_left docs)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 26, 2025
…o, r=jswrenn

transmutability: Support char, NonZeroXxx

Note that `NonZero` support is not wired up, as the author encountered
bugs while attempting this. A future commit will wire up `NonZero`
support.

r? ```@jswrenn```
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2025
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#123239 (Implement a lint for implicit autoref of raw pointer dereference - take 2)
 - rust-lang#140215 (transmutability: Support char, NonZeroXxx)
 - rust-lang#140226 (Update wasm-component-ld to 0.5.13)
 - rust-lang#140317 (Remove redundant check)
 - rust-lang#140318 (Simply try to unpeel AsyncFnKindHelper goal in `emit_specialized_closure_kind_error`)
 - rust-lang#140325 (Grammar fixes for BufRead::has_data_left docs)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2025
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#140215 (transmutability: Support char, NonZeroXxx)
 - rust-lang#140226 (Update wasm-component-ld to 0.5.13)
 - rust-lang#140317 (Remove redundant check)
 - rust-lang#140318 (Simply try to unpeel AsyncFnKindHelper goal in `emit_specialized_closure_kind_error`)
 - rust-lang#140320 (replace `GenericArg` with `Term` where applicable)
 - rust-lang#140325 (Grammar fixes for BufRead::has_data_left docs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cbf5d72 into rust-lang:master Apr 26, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 26, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2025
Rollup merge of rust-lang#140215 - joshlf:transmutability-char-nonzero, r=jswrenn

transmutability: Support char, NonZeroXxx

Note that `NonZero` support is not wired up, as the author encountered
bugs while attempting this. A future commit will wire up `NonZero`
support.

r? ````@jswrenn````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

6 participants