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

Rollup of 6 pull requests #102867

Merged
merged 18 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
From<Alignment> for usize & NonZeroUsize
  • Loading branch information
scottmcm committed Oct 9, 2022
commit 0718aeceb3b739e467381d1b95a3748ed9ec6bc2
16 changes: 16 additions & 0 deletions library/core/src/ptr/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ impl TryFrom<usize> for Alignment {
}
}

#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl From<Alignment> for NonZeroUsize {
#[inline]
fn from(align: Alignment) -> NonZeroUsize {
align.as_nonzero()
}
}

#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl From<Alignment> for usize {
#[inline]
fn from(align: Alignment) -> usize {
align.as_usize()
}
}

#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl cmp::Ord for Alignment {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/try-trait/bad-interconversion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LL | Ok(Err(123_i32)?)
<f64 as From<i16>>
<f64 as From<i32>>
<f64 as From<i8>>
and 67 others
and 68 others
= note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`

error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
Expand Down