forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#136517 - m4rch3n1ng:inherent-str-constructors, r=jhpratt implement inherent str constructors implement rust-lang#131114 this implements - str::from_utf8 - str::from_utf8_mut - str::from_utf8_unchecked - str::from_utf8_unchecked_mut i left `std::str::from_raw_parts` and `std::str::from_raw_parts_mut` out of this as those are unstable and were not mentioned by the tracking issue or the original pull request, but i can add those here as well. i was also unsure of what to do with the `rustc_const_(un)stable` attributes: i removed the `#[rustc_const_stable]` attribute from `str::from_utf8`, `str::from_utf8_unchecked` and `str::from_utf8_unchecked_mut`, and left the`#[rust_const_unstable]` in `str::from_utf8_mut` (btw why is that one not const stable yet with rust-lang#57349 merged?). is there a way to redirect users to the stable `std::str::from_utf8` instead of only saying "hey this is unstable"? for now i just removed the check for `str::from_utf8` in the test in `tests/ui/suggestions/suggest-std-when-using-type.rs`.
- Loading branch information
Showing
4 changed files
with
180 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type | ||
let bytes = "hello world".as_bytes(); | ||
let string = std::str::from_utf8(bytes).unwrap(); | ||
//~^ ERROR no function or associated item named `from_utf8` found | ||
println!("{pi} {bytes:?} {string}"); | ||
println!("{pi}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
let pi = f32::consts::PI; //~ ERROR ambiguous associated type | ||
let bytes = "hello world".as_bytes(); | ||
let string = str::from_utf8(bytes).unwrap(); | ||
//~^ ERROR no function or associated item named `from_utf8` found | ||
println!("{pi} {bytes:?} {string}"); | ||
println!("{pi}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters