diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 6f55e7c8be8ca..43c5f7cf6b939 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -4324,8 +4324,9 @@ impl u8 { /// assert!(!non_ascii.is_ascii()); /// ``` #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] + #[rustc_const_stable(feature = "const_ascii_methods_on_intrinsics", since = "1.43.0")] #[inline] - pub fn is_ascii(&self) -> bool { + pub const fn is_ascii(&self) -> bool { *self & 128 == 0 } diff --git a/src/test/ui/consts/std/char.rs b/src/test/ui/consts/is_ascii.rs similarity index 54% rename from src/test/ui/consts/std/char.rs rename to src/test/ui/consts/is_ascii.rs index fe79059a2e497..d8424549f93e6 100644 --- a/src/test/ui/consts/std/char.rs +++ b/src/test/ui/consts/is_ascii.rs @@ -3,7 +3,13 @@ static X: bool = 'a'.is_ascii(); static Y: bool = 'รค'.is_ascii(); +static BX: bool = b'a'.is_ascii(); +static BY: bool = 192u8.is_ascii(); + fn main() { assert!(X); assert!(!Y); + + assert!(BX); + assert!(!BY); }