Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inherent constructors on str #131118

Closed
wants to merge 7 commits into from

Conversation

robertbastian
Copy link
Contributor

@robertbastian robertbastian commented Oct 1, 2024

#131114

Unresolved questions

Do we mark the core::str functions as future-deprecation? This will causes warnings when core::str is imported and str::from_utf8 is used, because the compiler decides to interpret that as the module, not the type.

@rustbot
Copy link
Collaborator

rustbot commented Oct 1, 2024

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 1, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the O-windows Operating system: Windows label Oct 1, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Oct 2, 2024
@bors
Copy link
Contributor

bors commented Oct 5, 2024

☔ The latest upstream changes (presumably #131269) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Oct 16, 2024

☔ The latest upstream changes (presumably #131767) made this pull request unmergeable. Please resolve the merge conflicts.

@scottmcm
Copy link
Member

Do we mark the core::str functions as future-deprecation?

I think it'll make your life much easier to do it in different PRs. Add the new ones first, then you can do separate PRs to update different parts of things to use the new ones, then once you're through that you can PR the future-deprecation.

(Keeping it locally will help you make those other PRs, but no need to check it in for a while.)

@alex-semenyuk alex-semenyuk added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 20, 2024
@alex-semenyuk
Copy link
Member

@robertbastian
From wg-triage. Do you have any updates on this PR?

@robertbastian
Copy link
Contributor Author

Sorry I'm afk until January 🙃

@alex-semenyuk
Copy link
Member

alex-semenyuk commented Jan 20, 2025

@robertbastian
Thanks for your contribution

Sorry I'm afk until January 🙃

Do you have plans to proceed with this soon?

@robertbastian
Copy link
Contributor Author

Thanks for the bump, will try to get to this today.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jan 21, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Jan 21, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@@ -2110,7 +2110,7 @@ impl String {
#[inline]
pub fn leak<'a>(self) -> &'a mut str {
let slice = self.vec.leak();
unsafe { from_utf8_unchecked_mut(slice) }
unsafe { str::from_utf8_unchecked_mut(slice) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of places in this PR that change from std:str::* to the new inherent methods. Is there a reason for this? It would be much cleaner to add the inherent methods now, but don't replace any existing uses until a follow up PR (and once the feature is closer to stable).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I've tried to future-deprecation-warning them, so I already cleaned up all usages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do that in the same PR. Add the unstable API first, we can consider encouraging the newer APIs somehow once this is closer to stabilization - but certainly not while it is unstable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's basically undoing the whole PR.

@@ -83,16 +82,8 @@ use crate::{mem, ptr};
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_str_from_utf8_shared", since = "1.63.0")]
#[rustc_diagnostic_item = "str_from_utf8"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't move the existing diagnostic items. This feature will be unstable for a while, we don't want to break everything that relies on these in the meantime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restored

Comment on lines 122 to 128
// FIXME(const-hack): This should use `?` again, once it's `const`
match run_utf8_validation(v) {
match super::run_utf8_validation(v) {
Ok(_) => {
// SAFETY: validation succeeded.
Ok(unsafe { from_utf8_unchecked_mut(v) })
Ok(unsafe { str::from_utf8_unchecked_mut(v) })
}
Err(err) => Err(err),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this block be str::from_utf8_mut, rather than matching and calling str::from_utf8_unchecked_mut?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, I feel like there's a reason why it isn't but that's lost to time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test shouldn't be needed once the compiler feature is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the most recent test failure, it would be easiest for the new methods in this file to call the core::str::* functions rather than moving the implementations here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like these to be the canonical implementations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't matter, and can change in a future PR if there is a reason. For now it is cleanest to touch the existing methods as little as possible.

/// assert_eq!("💖", sparkle_heart);
/// ```
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
#[rustc_const_unstable(feature = "inherent_str_constructors", issue = "131114")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustc_const_unstable shouldn't be needed anymore for functions that are #[unstable(...)] and const

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#22 exporting to docker image format
#22 sending tarball 28.3s done
#22 DONE 32.3s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
-    |
- LL |         std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
-    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
-    |                                                |
-    |                                                the literal was valid UTF-8 up to the 2 bytes
- note: the lint level is defined here
-   --> $DIR/invalid_from_utf8.rs:5:9
-    |
- 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
-   --> $DIR/invalid_from_utf8.rs:22:9
-    |
- 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
- warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
-   --> $DIR/invalid_from_utf8.rs:40: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
- warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
-   --> $DIR/invalid_from_utf8.rs:42:9
-    |
-    |
- 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
- warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
-   --> $DIR/invalid_from_utf8.rs:44:9
-    |
-    |
- LL |         std::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 a invalid literal are undefined behavior
-   --> $DIR/invalid_from_utf8.rs:46:9
-    |
-    |
- LL |         std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
-    |                                       |
-    |                                       |
-    |                                       the literal was valid UTF-8 up to the 2 bytes
55 warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
56   --> $DIR/invalid_from_utf8.rs:63:9
57    |

---
To only update this specific test, also pass `--test-args lint/invalid_from_utf8.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/invalid_from_utf8.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/invalid_from_utf8" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
--- stderr -------------------------------
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:63:9
   |
   |
LL |         std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
   |                                      |
   |                                      the literal was valid UTF-8 up to the 2 bytes
note: the lint level is defined here
  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:6:9
   |
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]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:65:9
   |
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
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:83: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
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:85:9
   |
   |
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
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:87:9
   |
   |
LL |         std::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 a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:89:9
   |
   |
LL |         std::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 a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:96: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
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]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:100:5
   |
   |
LL |     let mut a = [99, 108, 130, 105, 112, 112, 121];
   |                 ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
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 `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:103:5
   |
LL |     let mut c = &[99, 108, 130, 105, 112, 112, 121];
   |                  ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
LL |     std::str::from_utf8(c);

warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:106: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 |     std::str::from_utf8(&INVALID_1);

warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:109: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 |     std::str::from_utf8(&INVALID_2);

warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:112: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 |     std::str::from_utf8(INVALID_3);

warning: calls to `std::str::from_utf8` with a invalid literal always return an error
##[warning]  --> /checkout/tests/ui/lint/invalid_from_utf8.rs:115: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 |     std::str::from_utf8(INVALID_4);

warning: 13 warnings emitted
------------------------------------------



---- [ui] tests/ui/suggestions/suggest-std-when-using-type.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-std-when-using-type/suggest-std-when-using-type.stderr"
diff of stderr:

9 LL |     let pi = std::f32::consts::PI;
11 
- error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
-   --> $DIR/suggest-std-when-using-type.rs:5:23
+ error[E0658]: use of unstable library feature `inherent_str_constructors`
+ error[E0658]: use of unstable library feature `inherent_str_constructors`
+   --> $DIR/suggest-std-when-using-type.rs:5:18
14    |
15 LL |     let string = str::from_utf8(bytes).unwrap();
+    |                  ^^^^^^^^^^^^^^
17    |
- help: you are looking for the module in `std`, not the primitive type
-    |
-    |
- LL |     let string = std::str::from_utf8(bytes).unwrap();
+    = note: see issue #131114 <https://github.com/rust-lang/rust/issues/131114> for more information
+    = help: add `#![feature(inherent_str_constructors)]` to the crate attributes to enable
+    = help: add `#![feature(inherent_str_constructors)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
23 error: aborting due to 2 previous errors
24 

- Some errors have detailed explanations: E0223, E0599.
---
+ error[E0658]: use of unstable library feature `inherent_str_constructors`
+   --> $DIR/suggest-std-when-using-type.rs:5:18
+    |                  ^^^^^^^^^^^^^^
+    = note: see issue #131114 <https://github.com/rust-lang/rust/issues/131114> for more information
+    = help: add `#![feature(inherent_str_constructors)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date


The actual stderr differed from the expected stderr.
Saved the actual fixed to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-std-when-using-type/suggest-std-when-using-type.fixed"
Saved the actual fixed to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-std-when-using-type/suggest-std-when-using-type.fixed"
diff of fixed:

2 fn main() {
3     let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type
4     let bytes = "hello world".as_bytes();
-     let string = std::str::from_utf8(bytes).unwrap();
+     let string = str::from_utf8(bytes).unwrap();
6     //~^ ERROR no function or associated item named `from_utf8` found
7     println!("{pi} {bytes:?} {string}");


The actual fixed differed from the expected fixed.
To update references, rerun the tests and pass the `--bless` flag
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args suggestions/suggest-std-when-using-type.rs`

error: 2 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/suggestions/suggest-std-when-using-type.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/suggestions/suggest-std-when-using-type" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
--- stderr -------------------------------
error[E0223]: ambiguous associated type
##[error]  --> /checkout/tests/ui/suggestions/suggest-std-when-using-type.rs:3:14
   |
   |
LL |     let pi = f32::consts::PI; //~ ERROR ambiguous associated type
   |
help: you are looking for the module in `std`, not the primitive type
   |
   |
LL |     let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type

error[E0658]: use of unstable library feature `inherent_str_constructors`
##[error]  --> /checkout/tests/ui/suggestions/suggest-std-when-using-type.rs:5:18
   |
   |
LL |     let string = str::from_utf8(bytes).unwrap();
   |
   = note: see issue #131114 <https://github.com/rust-lang/rust/issues/131114> for more information
   = help: add `#![feature(inherent_str_constructors)]` to the crate attributes to enable
   = help: add `#![feature(inherent_str_constructors)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0223, E0658.
For more information about an error, try `rustc --explain E0223`.

@robertbastian
Copy link
Contributor Author

I'm closing this because I cannot be bothered. This is way more work than it should be.

@tgross35
Copy link
Contributor

The initial change should only be additions to library/core/src/str/mod.rs that call to the existing std::str methods - that should be reasonably straightforward if you are interested in putting only these changes into a new PR (only the one file needs to be updated).

We should not be deprecating, migrating, or changing diagnostics for anything at the same time, especially without a stable replacement (yet). Attempting to do this at once is part of why the changes seems more complex than needed (doing so requires updates to the compiler and tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants