mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
invalid_from_utf8[_unchecked]: also lint inherent methods
This commit is contained in:
parent
4229b80f50
commit
f53d0f502d
@ -439,11 +439,11 @@ lint_invalid_crate_type_value = invalid `crate_type` value
|
|||||||
.suggestion = did you mean
|
.suggestion = did you mean
|
||||||
|
|
||||||
# FIXME: we should ordinalize $valid_up_to when we add support for doing so
|
# FIXME: we should ordinalize $valid_up_to when we add support for doing so
|
||||||
lint_invalid_from_utf8_checked = calls to `{$method}` with a invalid literal always return an error
|
lint_invalid_from_utf8_checked = calls to `{$method}` with an invalid literal always return an error
|
||||||
.label = the literal was valid UTF-8 up to the {$valid_up_to} bytes
|
.label = the literal was valid UTF-8 up to the {$valid_up_to} bytes
|
||||||
|
|
||||||
# FIXME: we should ordinalize $valid_up_to when we add support for doing so
|
# FIXME: we should ordinalize $valid_up_to when we add support for doing so
|
||||||
lint_invalid_from_utf8_unchecked = calls to `{$method}` with a invalid literal are undefined behavior
|
lint_invalid_from_utf8_unchecked = calls to `{$method}` with an invalid literal are undefined behavior
|
||||||
.label = the literal was valid UTF-8 up to the {$valid_up_to} bytes
|
.label = the literal was valid UTF-8 up to the {$valid_up_to} bytes
|
||||||
|
|
||||||
lint_invalid_nan_comparisons_eq_ne = incorrect NaN comparison, NaN cannot be directly compared to itself
|
lint_invalid_nan_comparisons_eq_ne = incorrect NaN comparison, NaN cannot be directly compared to itself
|
||||||
|
@ -70,12 +70,20 @@ impl<'tcx> LateLintPass<'tcx> for InvalidFromUtf8 {
|
|||||||
sym::str_from_utf8_mut,
|
sym::str_from_utf8_mut,
|
||||||
sym::str_from_utf8_unchecked,
|
sym::str_from_utf8_unchecked,
|
||||||
sym::str_from_utf8_unchecked_mut,
|
sym::str_from_utf8_unchecked_mut,
|
||||||
|
sym::str_inherent_from_utf8,
|
||||||
|
sym::str_inherent_from_utf8_mut,
|
||||||
|
sym::str_inherent_from_utf8_unchecked,
|
||||||
|
sym::str_inherent_from_utf8_unchecked_mut,
|
||||||
]
|
]
|
||||||
.contains(&diag_item)
|
.contains(&diag_item)
|
||||||
{
|
{
|
||||||
let lint = |label, utf8_error: Utf8Error| {
|
let lint = |label, utf8_error: Utf8Error| {
|
||||||
let method = diag_item.as_str().strip_prefix("str_").unwrap();
|
let method = diag_item.as_str().strip_prefix("str_").unwrap();
|
||||||
let method = format!("std::str::{method}");
|
let method = if let Some(method) = method.strip_prefix("inherent_") {
|
||||||
|
format!("str::{method}")
|
||||||
|
} else {
|
||||||
|
format!("std::str::{method}")
|
||||||
|
};
|
||||||
let valid_up_to = utf8_error.valid_up_to();
|
let valid_up_to = utf8_error.valid_up_to();
|
||||||
let is_unchecked_variant = diag_item.as_str().contains("unchecked");
|
let is_unchecked_variant = diag_item.as_str().contains("unchecked");
|
||||||
|
|
||||||
|
@ -1973,6 +1973,10 @@ symbols! {
|
|||||||
str_from_utf8_mut,
|
str_from_utf8_mut,
|
||||||
str_from_utf8_unchecked,
|
str_from_utf8_unchecked,
|
||||||
str_from_utf8_unchecked_mut,
|
str_from_utf8_unchecked_mut,
|
||||||
|
str_inherent_from_utf8,
|
||||||
|
str_inherent_from_utf8_mut,
|
||||||
|
str_inherent_from_utf8_unchecked,
|
||||||
|
str_inherent_from_utf8_unchecked_mut,
|
||||||
str_len,
|
str_len,
|
||||||
str_split_whitespace,
|
str_split_whitespace,
|
||||||
str_starts_with,
|
str_starts_with,
|
||||||
|
@ -238,6 +238,7 @@ impl str {
|
|||||||
/// assert_eq!("💖", sparkle_heart);
|
/// assert_eq!("💖", sparkle_heart);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
||||||
|
#[rustc_diagnostic_item = "str_inherent_from_utf8"]
|
||||||
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
|
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
|
||||||
converts::from_utf8(v)
|
converts::from_utf8(v)
|
||||||
}
|
}
|
||||||
@ -274,6 +275,7 @@ impl str {
|
|||||||
/// errors that can be returned.
|
/// errors that can be returned.
|
||||||
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
||||||
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
|
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
|
||||||
|
#[rustc_diagnostic_item = "str_inherent_from_utf8_mut"]
|
||||||
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
||||||
converts::from_utf8_mut(v)
|
converts::from_utf8_mut(v)
|
||||||
}
|
}
|
||||||
@ -306,6 +308,7 @@ impl str {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
||||||
|
#[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked"]
|
||||||
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
||||||
// SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function.
|
// SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function.
|
||||||
unsafe { converts::from_utf8_unchecked(v) }
|
unsafe { converts::from_utf8_unchecked(v) }
|
||||||
@ -331,6 +334,7 @@ impl str {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
|
||||||
|
#[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked_mut"]
|
||||||
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
|
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
|
||||||
// SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function.
|
// SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function.
|
||||||
unsafe { converts::from_utf8_unchecked_mut(v) }
|
unsafe { converts::from_utf8_unchecked_mut(v) }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//@ check-pass
|
//@ check-pass
|
||||||
|
|
||||||
#![feature(concat_bytes)]
|
#![feature(concat_bytes)]
|
||||||
|
#![feature(inherent_str_constructors)]
|
||||||
#![warn(invalid_from_utf8_unchecked)]
|
#![warn(invalid_from_utf8_unchecked)]
|
||||||
#![warn(invalid_from_utf8)]
|
#![warn(invalid_from_utf8)]
|
||||||
|
|
||||||
@ -9,7 +9,9 @@ pub fn from_utf8_unchecked_mut() {
|
|||||||
// Valid
|
// Valid
|
||||||
unsafe {
|
unsafe {
|
||||||
std::str::from_utf8_unchecked_mut(&mut [99, 108, 105, 112, 112, 121]);
|
std::str::from_utf8_unchecked_mut(&mut [99, 108, 105, 112, 112, 121]);
|
||||||
|
str::from_utf8_unchecked_mut(&mut [99, 108, 105, 112, 112, 121]);
|
||||||
std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
|
str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
|
|
||||||
let x = 0xA0;
|
let x = 0xA0;
|
||||||
std::str::from_utf8_unchecked_mut(&mut [0xC0, x]);
|
std::str::from_utf8_unchecked_mut(&mut [0xC0, x]);
|
||||||
@ -19,8 +21,12 @@ pub fn from_utf8_unchecked_mut() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
//~^ WARN calls to `std::str::from_utf8_unchecked_mut`
|
//~^ WARN calls to `std::str::from_utf8_unchecked_mut`
|
||||||
|
str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
//~^ WARN calls to `str::from_utf8_unchecked_mut`
|
||||||
std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
//~^ WARN calls to `std::str::from_utf8_unchecked_mut`
|
//~^ WARN calls to `std::str::from_utf8_unchecked_mut`
|
||||||
|
str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
//~^ WARN calls to `str::from_utf8_unchecked_mut`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,23 +34,35 @@ pub fn from_utf8_unchecked() {
|
|||||||
// Valid
|
// Valid
|
||||||
unsafe {
|
unsafe {
|
||||||
std::str::from_utf8_unchecked(&[99, 108, 105, 112, 112, 121]);
|
std::str::from_utf8_unchecked(&[99, 108, 105, 112, 112, 121]);
|
||||||
|
str::from_utf8_unchecked(&[99, 108, 105, 112, 112, 121]);
|
||||||
std::str::from_utf8_unchecked(&[b'c', b'l', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8_unchecked(&[b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
|
str::from_utf8_unchecked(&[b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
std::str::from_utf8_unchecked(b"clippy");
|
std::str::from_utf8_unchecked(b"clippy");
|
||||||
|
str::from_utf8_unchecked(b"clippy");
|
||||||
|
|
||||||
let x = 0xA0;
|
let x = 0xA0;
|
||||||
std::str::from_utf8_unchecked(&[0xC0, x]);
|
std::str::from_utf8_unchecked(&[0xC0, x]);
|
||||||
|
str::from_utf8_unchecked(&[0xC0, x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid
|
// Invalid
|
||||||
unsafe {
|
unsafe {
|
||||||
std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
|
std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
||||||
|
str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
//~^ WARN calls to `str::from_utf8_unchecked`
|
||||||
std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
||||||
|
str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
//~^ WARN calls to `str::from_utf8_unchecked`
|
||||||
std::str::from_utf8_unchecked(b"cl\x82ippy");
|
std::str::from_utf8_unchecked(b"cl\x82ippy");
|
||||||
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
||||||
|
str::from_utf8_unchecked(b"cl\x82ippy");
|
||||||
|
//~^ WARN calls to `str::from_utf8_unchecked`
|
||||||
std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
|
std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
//~^ WARN calls to `std::str::from_utf8_unchecked`
|
||||||
|
str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
|
//~^ WARN calls to `str::from_utf8_unchecked`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,18 +70,25 @@ pub fn from_utf8_mut() {
|
|||||||
// Valid
|
// Valid
|
||||||
{
|
{
|
||||||
std::str::from_utf8_mut(&mut [99, 108, 105, 112, 112, 121]);
|
std::str::from_utf8_mut(&mut [99, 108, 105, 112, 112, 121]);
|
||||||
|
str::from_utf8_mut(&mut [99, 108, 105, 112, 112, 121]);
|
||||||
std::str::from_utf8_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
|
str::from_utf8_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
|
|
||||||
let x = 0xa0;
|
let x = 0xa0;
|
||||||
std::str::from_utf8_mut(&mut [0xc0, x]);
|
std::str::from_utf8_mut(&mut [0xc0, x]);
|
||||||
|
str::from_utf8_mut(&mut [0xc0, x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid
|
// Invalid
|
||||||
{
|
{
|
||||||
std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
//~^ WARN calls to `std::str::from_utf8_mut`
|
//~^ WARN calls to `std::str::from_utf8_mut`
|
||||||
|
str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
//~^ WARN calls to `str::from_utf8_mut`
|
||||||
std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
//~^ WARN calls to `std::str::from_utf8_mut`
|
//~^ WARN calls to `std::str::from_utf8_mut`
|
||||||
|
str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
//~^ WARN calls to `str::from_utf8_mut`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,23 +96,35 @@ pub fn from_utf8() {
|
|||||||
// Valid
|
// Valid
|
||||||
{
|
{
|
||||||
std::str::from_utf8(&[99, 108, 105, 112, 112, 121]);
|
std::str::from_utf8(&[99, 108, 105, 112, 112, 121]);
|
||||||
|
str::from_utf8(&[99, 108, 105, 112, 112, 121]);
|
||||||
std::str::from_utf8(&[b'c', b'l', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8(&[b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
|
str::from_utf8(&[b'c', b'l', b'i', b'p', b'p', b'y']);
|
||||||
std::str::from_utf8(b"clippy");
|
std::str::from_utf8(b"clippy");
|
||||||
|
str::from_utf8(b"clippy");
|
||||||
|
|
||||||
let x = 0xA0;
|
let x = 0xA0;
|
||||||
std::str::from_utf8(&[0xC0, x]);
|
std::str::from_utf8(&[0xC0, x]);
|
||||||
|
str::from_utf8(&[0xC0, x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid
|
// Invalid
|
||||||
{
|
{
|
||||||
std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
|
std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
std::str::from_utf8(b"cl\x82ippy");
|
std::str::from_utf8(b"cl\x82ippy");
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(b"cl\x82ippy");
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
|
std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,25 +132,39 @@ pub fn from_utf8_with_indirections() {
|
|||||||
let mut a = [99, 108, 130, 105, 112, 112, 121];
|
let mut a = [99, 108, 130, 105, 112, 112, 121];
|
||||||
std::str::from_utf8_mut(&mut a);
|
std::str::from_utf8_mut(&mut a);
|
||||||
//~^ WARN calls to `std::str::from_utf8_mut`
|
//~^ WARN calls to `std::str::from_utf8_mut`
|
||||||
|
str::from_utf8_mut(&mut a);
|
||||||
|
//~^ WARN calls to `str::from_utf8_mut`
|
||||||
let mut b = &mut a;
|
let mut b = &mut a;
|
||||||
let mut c = b;
|
let mut c = b;
|
||||||
std::str::from_utf8_mut(c);
|
std::str::from_utf8_mut(c);
|
||||||
//~^ WARN calls to `std::str::from_utf8_mut`
|
//~^ WARN calls to `std::str::from_utf8_mut`
|
||||||
|
str::from_utf8_mut(c);
|
||||||
|
//~^ WARN calls to `str::from_utf8_mut`
|
||||||
let mut c = &[99, 108, 130, 105, 112, 112, 121];
|
let mut c = &[99, 108, 130, 105, 112, 112, 121];
|
||||||
std::str::from_utf8(c);
|
std::str::from_utf8(c);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(c);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
||||||
std::str::from_utf8(&INVALID_1);
|
std::str::from_utf8(&INVALID_1);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(&INVALID_1);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
||||||
std::str::from_utf8(&INVALID_2);
|
std::str::from_utf8(&INVALID_2);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(&INVALID_2);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
|
const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
|
||||||
std::str::from_utf8(INVALID_3);
|
std::str::from_utf8(INVALID_3);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(INVALID_3);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
|
const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
|
||||||
std::str::from_utf8(INVALID_4);
|
std::str::from_utf8(INVALID_4);
|
||||||
//~^ WARN calls to `std::str::from_utf8`
|
//~^ WARN calls to `std::str::from_utf8`
|
||||||
|
str::from_utf8(INVALID_4);
|
||||||
|
//~^ WARN calls to `str::from_utf8`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior
|
warning: calls to `std::str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:20:9
|
--> $DIR/invalid_from_utf8.rs:22:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
LL | std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
@ -12,48 +12,96 @@ note: the lint level is defined here
|
|||||||
LL | #![warn(invalid_from_utf8_unchecked)]
|
LL | #![warn(invalid_from_utf8_unchecked)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior
|
warning: calls to `str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:22:9
|
--> $DIR/invalid_from_utf8.rs:24:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior
|
||||||
|
--> $DIR/invalid_from_utf8.rs:26:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
LL | std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
|
warning: calls to `str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:40:9
|
--> $DIR/invalid_from_utf8.rs:28:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
|
--> $DIR/invalid_from_utf8.rs:50:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
|
LL | std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
|
warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:42:9
|
--> $DIR/invalid_from_utf8.rs:52:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
|
--> $DIR/invalid_from_utf8.rs:54:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
|
warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:44:9
|
--> $DIR/invalid_from_utf8.rs:56:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
|
--> $DIR/invalid_from_utf8.rs:58:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_unchecked(b"cl\x82ippy");
|
LL | std::str::from_utf8_unchecked(b"cl\x82ippy");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
|
warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:46:9
|
--> $DIR/invalid_from_utf8.rs:60:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_unchecked(b"cl\x82ippy");
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^-------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
|
--> $DIR/invalid_from_utf8.rs:62:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
|
LL | std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
|
warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior
|
||||||
--> $DIR/invalid_from_utf8.rs:63:9
|
--> $DIR/invalid_from_utf8.rs:64:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:84:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
LL | std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
@ -66,56 +114,113 @@ note: the lint level is defined here
|
|||||||
LL | #![warn(invalid_from_utf8)]
|
LL | #![warn(invalid_from_utf8)]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
|
warning: calls to `str::from_utf8_mut` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:65:9
|
--> $DIR/invalid_from_utf8.rs:86:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:88:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
LL | std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8_mut` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:83:9
|
--> $DIR/invalid_from_utf8.rs:90:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:112:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
|
LL | std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:85:9
|
--> $DIR/invalid_from_utf8.rs:114:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
|
||||||
|
| ^^^^^^^^^^^^^^^^----------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:116:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
LL | std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:87:9
|
--> $DIR/invalid_from_utf8.rs:118:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
|
||||||
|
| ^^^^^^^^^^^^^^^^---------------------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:120:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8(b"cl\x82ippy");
|
LL | std::str::from_utf8(b"cl\x82ippy");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^-------------^
|
| ^^^^^^^^^^^^^^^^^^^^-------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:89:9
|
--> $DIR/invalid_from_utf8.rs:122:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8(b"cl\x82ippy");
|
||||||
|
| ^^^^^^^^^^^^^^^-------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:124:9
|
||||||
|
|
|
|
||||||
LL | std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
|
LL | std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^---------------------------------^
|
| ^^^^^^^^^^^^^^^^^^^^---------------------------------^
|
||||||
| |
|
| |
|
||||||
| the literal was valid UTF-8 up to the 2 bytes
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:96:5
|
--> $DIR/invalid_from_utf8.rs:126:9
|
||||||
|
|
|
||||||
|
LL | str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
|
||||||
|
| ^^^^^^^^^^^^^^^---------------------------------^
|
||||||
|
| |
|
||||||
|
| the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:133:5
|
||||||
|
|
|
|
||||||
LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
LL | std::str::from_utf8_mut(&mut a);
|
LL | std::str::from_utf8_mut(&mut a);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
|
warning: calls to `str::from_utf8_mut` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:100:5
|
--> $DIR/invalid_from_utf8.rs:135:5
|
||||||
|
|
|
||||||
|
LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8_mut(&mut a);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:139:5
|
||||||
|
|
|
|
||||||
LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
@ -123,45 +228,99 @@ LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
|||||||
LL | std::str::from_utf8_mut(c);
|
LL | std::str::from_utf8_mut(c);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8_mut` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:103:5
|
--> $DIR/invalid_from_utf8.rs:141:5
|
||||||
|
|
|
||||||
|
LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8_mut(c);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:144:5
|
||||||
|
|
|
|
||||||
LL | let mut c = &[99, 108, 130, 105, 112, 112, 121];
|
LL | let mut c = &[99, 108, 130, 105, 112, 112, 121];
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
LL | std::str::from_utf8(c);
|
LL | std::str::from_utf8(c);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:106:5
|
--> $DIR/invalid_from_utf8.rs:146:5
|
||||||
|
|
|
||||||
|
LL | let mut c = &[99, 108, 130, 105, 112, 112, 121];
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8(c);
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:149:5
|
||||||
|
|
|
|
||||||
LL | const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
LL | const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
LL | std::str::from_utf8(&INVALID_1);
|
LL | std::str::from_utf8(&INVALID_1);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:109:5
|
--> $DIR/invalid_from_utf8.rs:151:5
|
||||||
|
|
|
||||||
|
LL | const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8(&INVALID_1);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:154:5
|
||||||
|
|
|
|
||||||
LL | static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
LL | static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
LL | std::str::from_utf8(&INVALID_2);
|
LL | std::str::from_utf8(&INVALID_2);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:112:5
|
--> $DIR/invalid_from_utf8.rs:156:5
|
||||||
|
|
|
||||||
|
LL | static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8(&INVALID_2);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:159:5
|
||||||
|
|
|
|
||||||
LL | const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
|
LL | const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
LL | std::str::from_utf8(INVALID_3);
|
LL | std::str::from_utf8(INVALID_3);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
--> $DIR/invalid_from_utf8.rs:115:5
|
--> $DIR/invalid_from_utf8.rs:161:5
|
||||||
|
|
|
||||||
|
LL | const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8(INVALID_3);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: calls to `std::str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:164:5
|
||||||
|
|
|
|
||||||
LL | const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
|
LL | const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
|
||||||
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
LL | std::str::from_utf8(INVALID_4);
|
LL | std::str::from_utf8(INVALID_4);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: 19 warnings emitted
|
warning: calls to `str::from_utf8` with an invalid literal always return an error
|
||||||
|
--> $DIR/invalid_from_utf8.rs:166:5
|
||||||
|
|
|
||||||
|
LL | const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
|
||||||
|
| ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
|
||||||
|
...
|
||||||
|
LL | str::from_utf8(INVALID_4);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
warning: 38 warnings emitted
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user