summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/invalid_from_utf8.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/ui/lint/invalid_from_utf8.rs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/lint/invalid_from_utf8.rs')
-rw-r--r--tests/ui/lint/invalid_from_utf8.rs27
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() {}