Skip to content

Commit 03b2588

Browse files
committed
fix Layout struct member naming style
1 parent d12b857 commit 03b2588

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

library/core/src/alloc/layout.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const fn size_align<T>() -> (usize, usize) {
3030
#[lang = "alloc_layout"]
3131
pub struct Layout {
3232
// size of the requested block of memory, measured in bytes.
33-
size_: usize,
33+
size: usize,
3434

3535
// alignment of the requested block of memory, measured in bytes.
3636
// we ensure that this is always a power-of-two, because API's
@@ -39,7 +39,7 @@ pub struct Layout {
3939
//
4040
// (However, we do not analogously require `align >= sizeof(void*)`,
4141
// even though that is *also* a requirement of `posix_memalign`.)
42-
align_: ValidAlign,
42+
align: ValidAlign,
4343
}
4444

4545
impl Layout {
@@ -97,7 +97,7 @@ impl Layout {
9797
#[inline]
9898
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
9999
// SAFETY: the caller must ensure that `align` is a power of two.
100-
Layout { size_: size, align_: unsafe { ValidAlign::new_unchecked(align) } }
100+
Layout { size, align: unsafe { ValidAlign::new_unchecked(align) } }
101101
}
102102

103103
/// The minimum size in bytes for a memory block of this layout.
@@ -106,7 +106,7 @@ impl Layout {
106106
#[must_use]
107107
#[inline]
108108
pub const fn size(&self) -> usize {
109-
self.size_
109+
self.size
110110
}
111111

112112
/// The minimum byte alignment for a memory block of this layout.
@@ -116,7 +116,7 @@ impl Layout {
116116
without modifying the layout"]
117117
#[inline]
118118
pub const fn align(&self) -> usize {
119-
self.align_.as_nonzero().get()
119+
self.align.as_nonzero().get()
120120
}
121121

122122
/// Constructs a `Layout` suitable for holding a value of type `T`.

library/core/tests/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn layout_debug_shows_log2_of_alignment() {
1717
// `Debug` is not stable, but here's what it does right now
1818
let layout = Layout::from_size_align(24576, 8192).unwrap();
1919
let s = format!("{:?}", layout);
20-
assert_eq!(s, "Layout { size_: 24576, align_: 8192 (1 << 13) }");
20+
assert_eq!(s, "Layout { size: 24576, align: 8192 (1 << 13) }");
2121
}
2222

2323
// Running this normally doesn't do much, but it's also run in Miri, which

src/test/ui/consts/std/alloc.32bit.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
22
--> $DIR/alloc.rs:9:1
33
|
44
LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align_.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag
66
|
77
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88
= note: the raw bytes of the constant (size: 8, align: 4) {
@@ -13,7 +13,7 @@ error[E0080]: it is undefined behavior to use this value
1313
--> $DIR/alloc.rs:13:1
1414
|
1515
LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align_.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag
1717
|
1818
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919
= note: the raw bytes of the constant (size: 8, align: 4) {

src/test/ui/consts/std/alloc.64bit.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
22
--> $DIR/alloc.rs:9:1
33
|
44
LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align_.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
66
|
77
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88
= note: the raw bytes of the constant (size: 16, align: 8) {
@@ -13,7 +13,7 @@ error[E0080]: it is undefined behavior to use this value
1313
--> $DIR/alloc.rs:13:1
1414
|
1515
LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align_.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .align.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag
1717
|
1818
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
1919
= note: the raw bytes of the constant (size: 16, align: 8) {

0 commit comments

Comments
 (0)