rust/tests
Stuart Cook dd4f062b07
Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35
liballoc: introduce String, Vec const-slicing

This change `const`-qualifies many methods on `Vec` and `String`, notably `as_slice`, `as_str`, `len`. These changes are made behind the unstable feature flag `const_vec_string_slice`.

## Motivation
This is to support simultaneous variance over ownership and constness. I have an enum type that may contain either `String` or `&str`, and I want to produce a `&str` from it in a possibly-`const` context.

```rust
enum StrOrString<'s> {
    Str(&'s str),
    String(String),
}

impl<'s> StrOrString<'s> {
    const fn as_str(&self) -> &str {
        match self {
             // In a const-context, I really only expect to see this variant, but I can't switch the implementation
             // in some mode like #[cfg(const)] -- there has to be a single body
             Self::Str(s) => s,

             // so this is a problem, since it's not `const`
             Self::String(s) => s.as_str(),
        }
    }
}
```

Currently `String` and `Vec` don't support this, but can without functional changes. Similar logic applies for `len`, `capacity`, `is_empty`.

## Changes

The essential thing enabling this change is that `Unique::as_ptr` is `const`. This lets us convert `RawVec::ptr` -> `Vec::as_ptr` -> `Vec::as_slice` -> `String::as_str`.

I had to move the `Deref` implementations into `as_{str,slice}` because `Deref` isn't `#[const_trait]`, but I would expect this change to be invisible up to inlining. I moved the `DerefMut` implementations as well for uniformity.
2024-10-07 15:37:06 +11:00
..
assembly more asm! -> naked_asm! in tests 2024-10-06 18:12:25 +02:00
auxiliary
codegen various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
codegen-units
coverage fix GVN trying to transmute pointers to integers 2024-10-05 17:55:23 +02:00
coverage-run-rustdoc
crashes more asm! -> naked_asm! in tests 2024-10-06 18:12:25 +02:00
debuginfo Reorder stack spills so that constants come later. 2024-09-17 16:45:26 -07:00
incremental Bless incremental tests. 2024-10-04 23:50:01 +00:00
mir-opt Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35 2024-10-07 15:37:06 +11:00
pretty Use doc(hidden) instead of allow(missing_docs) in the test harness 2024-09-11 12:14:35 +02:00
run-make various fixes for naked_asm! implementation 2024-10-06 19:00:09 +02:00
run-pass-valgrind Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustdoc Auto merge of #131076 - lukas-code:doc-stab2, r=notriddle 2024-10-01 04:30:33 +00:00
rustdoc-gui Rollup merge of #131257 - GuillaumeGomez:fix-list-margins, r=notriddle 2024-10-04 14:11:38 -07:00
rustdoc-js rustdoc-search: allow trailing Foo -> arg search 2024-09-05 17:58:05 -07:00
rustdoc-js-std Fix rustdoc-js-std path-ordering test due to API removal 2024-10-02 11:15:48 +02:00
rustdoc-json Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustdoc-ui Rollup merge of #131260 - notriddle:notriddle/disambiguator-error, r=GuillaumeGomez 2024-10-04 19:19:25 -07:00
ui Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35 2024-10-07 15:37:06 +11:00
ui-fulldeps Remove feature(control_flow_enum) in tests 2024-09-25 19:00:19 -07:00
COMPILER_TESTS.md