Skip to content

Commit

Permalink
Update based on wesleywiser review
Browse files Browse the repository at this point in the history
  • Loading branch information
GKFX committed Oct 31, 2023
1 parent 684cfae commit 7c5d6aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,8 +1299,8 @@ impl<T> SizedTypeProperties for T {}
/// Enum variants may be traversed as if they were fields. Variants themselves do
/// not have an offset.
///
/// Note that type layout is, in general, [platform-specific, and subject to
/// change](https://doc.rust-lang.org/reference/type-layout.html).
/// Note that type layout is, in general, [subject to change and
/// platform-specific](https://doc.rust-lang.org/reference/type-layout.html).
///
/// # Examples
///
Expand Down
1 change: 1 addition & 0 deletions tests/ui/offset-of/offset-of-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ fn main() {
offset_of!(Alpha, Two.1); //~ ERROR no field named `1` on enum variant `Alpha::Two`
offset_of!(Alpha, Two.foo); //~ ERROR no field named `foo` on enum variant `Alpha::Two`
offset_of!(Alpha, NonExistent); //~ ERROR no variant named `NonExistent` found for enum `Alpha`
offset_of!(Beta, One); //~ ERROR cannot find type `Beta` in this scope
}
12 changes: 9 additions & 3 deletions tests/ui/offset-of/offset-of-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ LL | offset_of!(Alpha::One, 0);
| not a type
| help: try using the variant's enum: `Alpha`

error[E0412]: cannot find type `Beta` in this scope
--> $DIR/offset-of-enum.rs:17:16
|
LL | offset_of!(Beta, One);
| ^^^^ not found in this scope

error[E0795]: `One` is an enum variant; expected field at end of `offset_of`
--> $DIR/offset-of-enum.rs:12:23
|
Expand Down Expand Up @@ -35,7 +41,7 @@ error[E0599]: no variant named `NonExistent` found for enum `Alpha`
LL | offset_of!(Alpha, NonExistent);
| ^^^^^^^^^^^ variant not found

error: aborting due to 5 previous errors
error: aborting due to 6 previous errors

Some errors have detailed explanations: E0573, E0599, E0609, E0795.
For more information about an error, try `rustc --explain E0573`.
Some errors have detailed explanations: E0412, E0573, E0599, E0609, E0795.
For more information about an error, try `rustc --explain E0412`.

0 comments on commit 7c5d6aa

Please sign in to comment.