File tree Expand file tree Collapse file tree 9 files changed +52
-12
lines changed
Expand file tree Collapse file tree 9 files changed +52
-12
lines changed Original file line number Diff line number Diff line change 3333#![ feature( thin_box) ]
3434#![ feature( drain_keep_rest) ]
3535#![ feature( local_waker) ]
36+ #![ feature( str_as_str) ]
3637#![ feature( strict_provenance_lints) ]
3738#![ feature( string_replace_in_place) ]
3839#![ feature( vec_deque_truncate_front) ]
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ impl ByteStr {
7474 /// it helps dereferencing other "container" types,
7575 /// for example `Box<ByteStr>` or `Arc<ByteStr>`.
7676 #[ inline]
77+ // #[unstable(feature = "str_as_str", issue = "130366")]
7778 #[ unstable( feature = "bstr" , issue = "134915" ) ]
7879 pub const fn as_byte_str ( & self ) -> & ByteStr {
7980 self
@@ -85,6 +86,7 @@ impl ByteStr {
8586 /// it helps dereferencing other "container" types,
8687 /// for example `Box<ByteStr>` or `MutexGuard<ByteStr>`.
8788 #[ inline]
89+ // #[unstable(feature = "str_as_str", issue = "130366")]
8890 #[ unstable( feature = "bstr" , issue = "134915" ) ]
8991 pub const fn as_mut_byte_str ( & mut self ) -> & mut ByteStr {
9092 self
Original file line number Diff line number Diff line change @@ -655,8 +655,7 @@ impl CStr {
655655 /// it helps dereferencing other string-like types to string slices,
656656 /// for example references to `Box<CStr>` or `Arc<CStr>`.
657657 #[ inline]
658- #[ stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
659- #[ rustc_const_stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
658+ #[ unstable( feature = "str_as_str" , issue = "130366" ) ]
660659 pub const fn as_c_str ( & self ) -> & CStr {
661660 self
662661 }
Original file line number Diff line number Diff line change @@ -5337,8 +5337,7 @@ impl<T> [T] {
53375337 /// it helps dereferencing other "container" types to slices,
53385338 /// for example `Box<[T]>` or `Arc<[T]>`.
53395339 #[ inline]
5340- #[ stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
5341- #[ rustc_const_stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
5340+ #[ unstable( feature = "str_as_str" , issue = "130366" ) ]
53425341 pub const fn as_slice ( & self ) -> & [ T ] {
53435342 self
53445343 }
@@ -5349,8 +5348,7 @@ impl<T> [T] {
53495348 /// it helps dereferencing other "container" types to slices,
53505349 /// for example `Box<[T]>` or `MutexGuard<[T]>`.
53515350 #[ inline]
5352- #[ stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
5353- #[ rustc_const_stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
5351+ #[ unstable( feature = "str_as_str" , issue = "130366" ) ]
53545352 pub const fn as_mut_slice ( & mut self ) -> & mut [ T ] {
53555353 self
53565354 }
Original file line number Diff line number Diff line change @@ -3137,8 +3137,7 @@ impl str {
31373137 /// it helps dereferencing other string-like types to string slices,
31383138 /// for example references to `Box<str>` or `Arc<str>`.
31393139 #[ inline]
3140- #[ stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
3141- #[ rustc_const_stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
3140+ #[ unstable( feature = "str_as_str" , issue = "130366" ) ]
31423141 pub const fn as_str ( & self ) -> & str {
31433142 self
31443143 }
Original file line number Diff line number Diff line change @@ -1285,8 +1285,7 @@ impl OsStr {
12851285 /// it helps dereferencing other string-like types to string slices,
12861286 /// for example references to `Box<OsStr>` or `Arc<OsStr>`.
12871287 #[ inline]
1288- #[ stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
1289- #[ rustc_const_stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
1288+ #[ unstable( feature = "str_as_str" , issue = "130366" ) ]
12901289 pub const fn as_os_str ( & self ) -> & OsStr {
12911290 self
12921291 }
Original file line number Diff line number Diff line change @@ -3235,8 +3235,7 @@ impl Path {
32353235 /// it helps dereferencing other `PathBuf`-like types to `Path`s,
32363236 /// for example references to `Box<Path>` or `Arc<Path>`.
32373237 #[ inline]
3238- #[ stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
3239- #[ rustc_const_stable( feature = "str_as_str" , since = "CURRENT_RUSTC_VERSION" ) ]
3238+ #[ unstable( feature = "str_as_str" , issue = "130366" ) ]
32403239 pub const fn as_path ( & self ) -> & Path {
32413240 self
32423241 }
Original file line number Diff line number Diff line change 1+ //@ check-pass
2+ // This is a regression test for github.com/rust-lang/rust/issues/152961
3+ // This broke when a method `as_slice` was added on slices
4+ // This pattern is used in the `rgb` crate
5+
6+ struct Meow ;
7+
8+ trait ComponentSlice < T > {
9+ fn as_slice ( & self ) -> & [ T ] ;
10+ }
11+
12+ impl ComponentSlice < u8 > for [ Meow ] {
13+ fn as_slice ( & self ) -> & [ u8 ] {
14+ todo ! ( )
15+ }
16+ }
17+
18+ fn a ( data : & [ Meow ] ) {
19+ b ( data. as_slice ( ) ) ;
20+ //~^ WARN a method with this name may be added to the standard library in the future
21+ //~| WARN once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
22+ }
23+
24+ fn b ( _b : & [ u8 ] ) { }
25+
26+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ warning: a method with this name may be added to the standard library in the future
2+ --> $DIR/slice-as-slice.rs:19:12
3+ |
4+ LL | b(data.as_slice());
5+ | ^^^^^^^^
6+ |
7+ = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
8+ = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
9+ = help: call with fully qualified syntax `ComponentSlice::as_slice(...)` to keep using the current method
10+ = note: `#[warn(unstable_name_collisions)]` (part of `#[warn(future_incompatible)]`) on by default
11+ help: add `#![feature(str_as_str)]` to the crate attributes to enable `core::slice::<impl [T]>::as_slice`
12+ |
13+ LL + #![feature(str_as_str)]
14+ |
15+
16+ warning: 1 warning emitted
17+
You can’t perform that action at this time.
0 commit comments