diff options
| author | bors <bors@rust-lang.org> | 2020-01-12 02:28:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-12 02:28:48 +0000 |
| commit | 0b6c116a84fb1dbb60b5870291f5d7df808c280d (patch) | |
| tree | 22efe869664863f74b929dcb29f0b28ad2ce25e6 /src/libcore/alloc.rs | |
| parent | f363745872f9b45cfec575f3c2cac42f0c242c03 (diff) | |
| parent | 82c19b4388dc671dd4c1224b8577a5e23ff315e4 (diff) | |
| download | rust-0b6c116a84fb1dbb60b5870291f5d7df808c280d.tar.gz rust-0b6c116a84fb1dbb60b5870291f5d7df808c280d.zip | |
Auto merge of #68142 - Centril:rollup-dl232e9, r=Centril
Rollup of 6 pull requests Successful merges: - #67494 (Constify more of alloc::Layout) - #67867 (Correctly check for opaque types in `assoc_ty_def`) - #67948 (Galloping search for binary_search_util) - #68045 (Move more of `rustc::lint` into `rustc_lint`) - #68089 (Unstabilize `Vec::remove_item`) - #68108 (Add suggestions when encountering chained comparisons) Failed merges: r? @ghost
Diffstat (limited to 'src/libcore/alloc.rs')
| -rw-r--r-- | src/libcore/alloc.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 163f9170b8b..4354e1c7b5f 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -64,8 +64,9 @@ impl Layout { /// must not overflow (i.e., the rounded value must be less than /// `usize::MAX`). #[stable(feature = "alloc_layout", since = "1.28.0")] + #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] #[inline] - pub fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr> { + pub const fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr> { if !align.is_power_of_two() { return Err(LayoutErr { private: () }); } @@ -106,15 +107,17 @@ impl Layout { /// The minimum size in bytes for a memory block of this layout. #[stable(feature = "alloc_layout", since = "1.28.0")] + #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] #[inline] - pub fn size(&self) -> usize { + pub const fn size(&self) -> usize { self.size_ } /// The minimum byte alignment for a memory block of this layout. #[stable(feature = "alloc_layout", since = "1.28.0")] + #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] #[inline] - pub fn align(&self) -> usize { + pub const fn align(&self) -> usize { self.align_.get() } @@ -181,8 +184,9 @@ impl Layout { /// address for the whole allocated block of memory. One way to /// satisfy this constraint is to ensure `align <= self.align()`. #[unstable(feature = "alloc_layout_extra", issue = "55724")] + #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")] #[inline] - pub fn padding_needed_for(&self, align: usize) -> usize { + pub const fn padding_needed_for(&self, align: usize) -> usize { let len = self.size(); // Rounded up value is: |
