Skip to content

Commit a02fdc1

Browse files
authored
Unrolled build for #155054
Rollup merge of #155054 - Lars-Schumann:const-vec-ops, r=dtolnay constify `Index(Mut)`, `Deref(Mut)` for `Vec` Relevant tracking issues const_convert: #143773 const_index: #143775
2 parents e22c616 + 804f495 commit a02fdc1

4 files changed

Lines changed: 16 additions & 20 deletions

File tree

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#![feature(const_destruct)]
107107
#![feature(const_eval_select)]
108108
#![feature(const_heap)]
109+
#![feature(const_index)]
109110
#![feature(const_option_ops)]
110111
#![feature(const_try)]
111112
#![feature(copied_into_inner)]

library/alloc/src/vec/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,8 @@ impl<T: TrivialClone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
37473747
////////////////////////////////////////////////////////////////////////////////
37483748

37493749
#[stable(feature = "rust1", since = "1.0.0")]
3750-
impl<T, A: Allocator> ops::Deref for Vec<T, A> {
3750+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
3751+
impl<T, A: Allocator> const ops::Deref for Vec<T, A> {
37513752
type Target = [T];
37523753

37533754
#[inline]
@@ -3757,7 +3758,8 @@ impl<T, A: Allocator> ops::Deref for Vec<T, A> {
37573758
}
37583759

37593760
#[stable(feature = "rust1", since = "1.0.0")]
3760-
impl<T, A: Allocator> ops::DerefMut for Vec<T, A> {
3761+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
3762+
impl<T, A: Allocator> const ops::DerefMut for Vec<T, A> {
37613763
#[inline]
37623764
fn deref_mut(&mut self) -> &mut [T] {
37633765
self.as_mut_slice()
@@ -3822,7 +3824,8 @@ impl<T: Hash, A: Allocator> Hash for Vec<T, A> {
38223824
}
38233825

38243826
#[stable(feature = "rust1", since = "1.0.0")]
3825-
impl<T, I: SliceIndex<[T]>, A: Allocator> Index<I> for Vec<T, A> {
3827+
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
3828+
impl<T, I: [const] SliceIndex<[T]>, A: Allocator> const Index<I> for Vec<T, A> {
38263829
type Output = I::Output;
38273830

38283831
#[inline]
@@ -3832,7 +3835,8 @@ impl<T, I: SliceIndex<[T]>, A: Allocator> Index<I> for Vec<T, A> {
38323835
}
38333836

38343837
#[stable(feature = "rust1", since = "1.0.0")]
3835-
impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
3838+
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
3839+
impl<T, I: [const] SliceIndex<[T]>, A: Allocator> const IndexMut<I> for Vec<T, A> {
38363840
#[inline]
38373841
fn index_mut(&mut self, index: I) -> &mut Self::Output {
38383842
IndexMut::index_mut(&mut **self, index)

tests/ui/consts/issue-94675.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ struct Foo<'a> {
99
impl<'a> Foo<'a> {
1010
const fn spam(&mut self, baz: &mut Vec<u32>) {
1111
self.bar[0] = baz.len();
12-
//~^ ERROR: `Vec<usize>: [const] Index<_>` is not satisfied
13-
//~| ERROR: `Vec<usize>: [const] IndexMut<usize>` is not satisfied
12+
//~^ ERROR: `IndexMut` is not yet stable as a const trait
1413
}
1514
}
1615

tests/ui/consts/issue-94675.stderr

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
error[E0277]: the trait bound `Vec<usize>: [const] Index<_>` is not satisfied
2-
--> $DIR/issue-94675.rs:11:9
1+
error: `IndexMut` is not yet stable as a const trait
2+
--> $DIR/issue-94675.rs:11:17
33
|
44
LL | self.bar[0] = baz.len();
5-
| ^^^^^^^^^^^
5+
| ^^^
66
|
7-
note: trait `Index` is implemented but not `const`
8-
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
9-
10-
error[E0277]: the trait bound `Vec<usize>: [const] IndexMut<usize>` is not satisfied
11-
--> $DIR/issue-94675.rs:11:9
7+
help: add `#![feature(const_index)]` to the crate attributes to enable
128
|
13-
LL | self.bar[0] = baz.len();
14-
| ^^^^^^^^^^^
9+
LL + #![feature(const_index)]
1510
|
16-
note: trait `IndexMut` is implemented but not `const`
17-
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
1811

19-
error: aborting due to 2 previous errors
12+
error: aborting due to 1 previous error
2013

21-
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)