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

Allow ValTree::try_to_raw_bytes on u8 array #99358

Merged
merged 1 commit into from
Jul 27, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 17, 2022

Fixes #99325

cc @b-naber I think who touched this last in 705d818

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 17, 2022
@rust-highfive
Copy link
Collaborator

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 17, 2022
// build-pass
//[mir] compile-flags: -Zunpretty=mir
Copy link
Member

Choose a reason for hiding this comment

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

IMO a separate test should be added. It is not super clear from looking at #70408 why this unpretty is necessary or why it is relevant to what’s described in the issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can split it out, I just didn't want to duplicate the file.

Comment on lines 112 to 114
.collect::<Vec<_>>();

return Some(tcx.arena.alloc_from_iter(leafs.into_iter()));
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to not collect as an intermediate step but just pass the iterator directly to the arena?

@@ -0,0 +1,14 @@
// build-pass
// compile-flags: -Zunpretty=mir
Copy link
Contributor

Choose a reason for hiding this comment

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

if you can reproduce with -Zdump-mir=main or -Zdump-mir=function_with_bytes, then you could turn this into a mir opt test instead of a ui test with mir output.

@compiler-errors compiler-errors 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 19, 2022
@nagisa
Copy link
Member

nagisa commented Jul 23, 2022

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned nagisa Jul 23, 2022
@compiler-errors
Copy link
Member Author

@rustbot ready

Converted to mir-opt test and addressed comments.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 26, 2022
},
_ => {}
// `[u8; N]` can be interpreted as raw bytes
ty::Array(array_ty, _) if *array_ty == tcx.types.u8 => {}
Copy link
Contributor

Choose a reason for hiding this comment

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

That's odd... why is this one not behind a reference?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the caller peeling references? But only for Sized pointers?

Copy link
Member Author

@compiler-errors compiler-errors Jul 26, 2022

Choose a reason for hiding this comment

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

No, the old implementation just used to never hit this path because for [u8, _] we got the raw bytes of the allocation: 705d818#diff-b56d8c5fa3d7803c5b0e19e1a8854d85c302974484c4c20bf51c76a19556f4a7L1459 -- it was rewritten to use valtree.try_to_raw_bytes but I guess never tested to hit this ICE.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 26, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 26, 2022

📌 Commit 91e91d8 has been approved by oli-obk

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 Jul 26, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2022
…laumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#94247 (Fix slice::ChunksMut aliasing)
 - rust-lang#99358 (Allow `ValTree::try_to_raw_bytes` on `u8` array)
 - rust-lang#99651 (Deeply deny fn and raw ptrs in const generics)
 - rust-lang#99710 (lint: add bad opt access internal lint)
 - rust-lang#99717 (Add some comments to the docs issue template to clarify)
 - rust-lang#99728 (Clean up HIR-based lifetime resolution)
 - rust-lang#99812 (Fix headings colors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4ce1b0f into rust-lang:master Jul 27, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 27, 2022
@compiler-errors compiler-errors deleted the issue-99325 branch August 11, 2023 20:05
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
6 participants