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

Make unsized casts illegal #116056

Merged
merged 1 commit into from
Sep 22, 2023
Merged

Make unsized casts illegal #116056

merged 1 commit into from
Sep 22, 2023

Conversation

ouz-a
Copy link
Contributor

@ouz-a ouz-a commented Sep 22, 2023

Weirdly enough this #115998 issue seems to exist since Rust 1.0 (couldn't check before that) but it's only recently been noticed. This change makes those casts illegal.

Fixes #115998

@rustbot
Copy link
Collaborator

rustbot commented Sep 22, 2023

r? @petrochenkov

(rustbot has picked a reviewer for you, use r? to override)

@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 Sep 22, 2023
@@ -725,6 +725,9 @@ impl<'a, 'tcx> CastCheck<'tcx> {
},
// array-ptr-cast
Ptr(mt) => {
if !mt.ty.is_sized(fcx.tcx, fcx.param_env) {
Copy link
Member

Choose a reason for hiding this comment

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

This type may have region variables. That'll cause an ICE. Try using:

Suggested change
if !mt.ty.is_sized(fcx.tcx, fcx.param_env) {
if !fcx.type_is_sized_modulo_regions(fcx.param_env, mt.ty) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Didn't know this.

@compiler-errors
Copy link
Member

please squash this into one commit

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 22, 2023

📌 Commit 861448b has been approved by compiler-errors

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 Sep 22, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 22, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#115770 (Match on elem first while building move paths)
 - rust-lang#115999 (Capture scrutinee of if let guards correctly)
 - rust-lang#116056 (Make unsized casts illegal)
 - rust-lang#116061 (Remove TaKO8Ki from review rotation)
 - rust-lang#116062 (Change `start` to `#[start]` in some diagnosis)
 - rust-lang#116067 (Open the FileEncoder file for reading and writing)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a38f230 into rust-lang:master Sep 22, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 22, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 22, 2023
Rollup merge of rust-lang#116056 - ouz-a:wide_ice, r=compiler-errors

Make unsized casts illegal

Weirdly enough this rust-lang#115998 issue seems to exist since Rust 1.0 (couldn't check before that) but it's only recently been noticed. This change makes those casts illegal.

Fixes rust-lang#115998
@ouz-a ouz-a deleted the wide_ice branch September 25, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 due to bad sized to unsized pointer cast in const item
5 participants