Skip to content

Commit fc98248

Browse files
authored
Unrolled build for rust-lang#120311
Rollup merge of rust-lang#120311 - mina86:h, r=cuviper core: add `From<core::ascii::Char>` implementations Introduce `From<core::ascii::Char>` implementations for all unsigned numeric types and `char`. This matches the API of `char` type. Issue: rust-lang#110998
2 parents c073f56 + c4208fa commit fc98248

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

library/core/src/ascii/ascii_char.rs

+16
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,22 @@ impl AsciiChar {
537537
}
538538
}
539539

540+
macro_rules! into_int_impl {
541+
($($ty:ty)*) => {
542+
$(
543+
#[unstable(feature = "ascii_char", issue = "110998")]
544+
impl From<AsciiChar> for $ty {
545+
#[inline]
546+
fn from(chr: AsciiChar) -> $ty {
547+
chr as u8 as $ty
548+
}
549+
}
550+
)*
551+
}
552+
}
553+
554+
into_int_impl!(u8 u16 u32 u64 u128 char);
555+
540556
impl [AsciiChar] {
541557
/// Views this slice of ASCII characters as a UTF-8 `str`.
542558
#[unstable(feature = "ascii_char", issue = "110998")]

tests/ui/traits/issue-77982.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(
4444
| type must be known at this point
4545
|
4646
= note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
47+
- impl From<Char> for u32;
4748
- impl From<Ipv4Addr> for u32;
4849
- impl From<NonZeroU32> for u32;
4950
- impl From<bool> for u32;

tests/ui/try-trait/bad-interconversion.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LL | Ok(Err(123_i32)?)
1212
= help: the following other types implement trait `From<T>`:
1313
<u8 as From<bool>>
1414
<u8 as From<NonZeroU8>>
15+
<u8 as From<Char>>
1516
= note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`
1617

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

0 commit comments

Comments
 (0)