diff options
Diffstat (limited to 'tests/ui/lint/invalid_from_utf8.rs')
-rw-r--r-- | tests/ui/lint/invalid_from_utf8.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/lint/invalid_from_utf8.rs b/tests/ui/lint/invalid_from_utf8.rs index 9c8c63681..43ceffb71 100644 --- a/tests/ui/lint/invalid_from_utf8.rs +++ b/tests/ui/lint/invalid_from_utf8.rs @@ -1,6 +1,8 @@ // check-pass +#![feature(inline_const)] #![feature(concat_bytes)] + #![warn(invalid_from_utf8_unchecked)] #![warn(invalid_from_utf8)] @@ -90,4 +92,29 @@ pub fn from_utf8() { } } +pub fn from_utf8_with_indirections() { + let mut a = [99, 108, 130, 105, 112, 112, 121]; + std::str::from_utf8_mut(&mut a); + //~^ WARN calls to `std::str::from_utf8_mut` + let mut b = &mut a; + let mut c = b; + std::str::from_utf8_mut(c); + //~^ WARN calls to `std::str::from_utf8_mut` + let mut c = &[99, 108, 130, 105, 112, 112, 121]; + std::str::from_utf8(c); + //~^ WARN calls to `std::str::from_utf8` + const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; + std::str::from_utf8(&INVALID_1); + //~^ WARN calls to `std::str::from_utf8` + static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; + std::str::from_utf8(&INVALID_2); + //~^ WARN calls to `std::str::from_utf8` + const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121]; + std::str::from_utf8(INVALID_3); + //~^ WARN calls to `std::str::from_utf8` + const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] }; + std::str::from_utf8(INVALID_4); + //~^ WARN calls to `std::str::from_utf8` +} + fn main() {} |