Skip to content

Conversation

kupiakos
Copy link
Contributor

@kupiakos kupiakos commented Oct 9, 2024

Also:

  • Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
  • Add a short section on union.
  • Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

This might need to wait for #131456 to merge first? Not sure.

r? compiler-errors

Also:

- Adjust the language slightly to be more consistent with other similar messages (`was created` instead of `got created`).
- Add a short section on `union`
- Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.
@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 Oct 9, 2024
@bors
Copy link
Collaborator

bors commented Oct 10, 2024

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

let foo = Foo { field1: 0 };
// Accessing the field directly is fine.
let val = foo.field1;
// A reference to a packed union field causes a error.
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
// A reference to a packed union field causes a error.
// A reference to a packed union field causes an error.

Comment on lines +74 to +77
// Accessing the field directly is fine.
let val = foo.field1;
// A reference to a packed union field causes a error.
let val = &foo.field1; // ERROR
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
// Accessing the field directly is fine.
let val = foo.field1;
// A reference to a packed union field causes a error.
let val = &foo.field1; // ERROR
// Accessing the field directly is fine.
let val = foo.field1;
// A reference to a packed union field causes a error.
let val = &foo.field1; // ERROR

@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot 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 Oct 14, 2024
@JohnCSimon
Copy link
Member

@kupiakos

ping from triage - can you post your status on this PR and address the comments from the reviewer?

@Dylan-DPC
Copy link
Member

Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks

@Dylan-DPC Dylan-DPC closed this Feb 26, 2025
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 26, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
E0793: Clarify that it applies to unions as well

pick up inactive PR: rust-lang#131472

Also:
Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
Add a short section on union.
Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

r? compiler-errors
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
E0793: Clarify that it applies to unions as well

pick up inactive PR: rust-lang#131472

Also:
Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
Add a short section on union.
Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

r? compiler-errors
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
E0793: Clarify that it applies to unions as well

pick up inactive PR: rust-lang#131472

Also:
Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
Add a short section on union.
Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

r? compiler-errors
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #144944 - He1pa:E0793, r=compiler-errors

E0793: Clarify that it applies to unions as well

pick up inactive PR: #131472

Also:
Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
Add a short section on union.
Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

r? compiler-errors
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 18, 2025
E0793: Clarify that it applies to unions as well

pick up inactive PR: rust-lang/rust#131472

Also:
Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
Add a short section on union.
Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

r? compiler-errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. 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