Skip to content

Commit bf26fdd

Browse files
committed
Arbitrary self types v2: stabilize test changes
All the test changes necessary for stabilization here.
1 parent 51df8a4 commit bf26fdd

File tree

101 files changed

+413
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+413
-415
lines changed

compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Adapted from rustc run-pass test suite
22

3-
#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
3+
#![feature(unsize, coerce_unsized, dispatch_from_dyn)]
44

55
use std::marker::Unsize;
66
use std::ops::{CoerceUnsized, Deref, DispatchFromDyn};

compiler/rustc_codegen_cranelift/example/mini_core.rs

-7
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
4747
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
4848
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
4949

50-
#[lang = "legacy_receiver"]
51-
pub trait LegacyReceiver {}
52-
53-
impl<T: ?Sized> LegacyReceiver for &T {}
54-
impl<T: ?Sized> LegacyReceiver for &mut T {}
55-
impl<T: ?Sized> LegacyReceiver for Box<T> {}
56-
5750
#[lang = "copy"]
5851
pub trait Copy {}
5952

compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Adapted from rustc run-pass test suite
22

3-
#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
3+
#![feature(unsize, coerce_unsized, dispatch_from_dyn)]
44
#![feature(rustc_attrs)]
55
#![allow(internal_features)]
66

compiler/rustc_codegen_gcc/example/mini_core.rs

-7
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
4444
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
4545
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
4646

47-
#[lang = "legacy_receiver"]
48-
pub trait LegacyReceiver {}
49-
50-
impl<T: ?Sized> LegacyReceiver for &T {}
51-
impl<T: ?Sized> LegacyReceiver for &mut T {}
52-
impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {}
53-
5447
#[lang = "copy"]
5548
pub trait Copy {}
5649

compiler/rustc_lint_defs/src/builtin.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4846,8 +4846,6 @@ declare_lint! {
48464846
/// UB in safe code afterwards. For example:
48474847
///
48484848
/// ```ignore (causes a warning)
4849-
/// #![feature(arbitrary_self_types)]
4850-
///
48514849
/// trait Trait {
48524850
/// fn f(self: *const Self)
48534851
/// where

library/core/src/marker.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,8 @@ pub trait FnPtr: Copy + Clone {
11691169
/// type as a receiver are dyn-compatible. For example, this compiles:
11701170
///
11711171
/// ```
1172-
/// #![feature(arbitrary_self_types, derive_coerce_pointee)]
1172+
/// #![feature(derive_coerce_pointee)]
1173+
/// # #![cfg_attr(bootstrap, feature(legacy_receiver_trait))]
11731174
/// use std::marker::CoercePointee;
11741175
/// use std::ops::Deref;
11751176
///
@@ -1183,6 +1184,9 @@ pub trait FnPtr: Copy + Clone {
11831184
/// &self.0
11841185
/// }
11851186
/// }
1187+
/// #
1188+
/// # #[cfg(bootstrap)]
1189+
/// # impl<T: ?Sized> core::ops::LegacyReceiver for MySmartPointer<T> {}
11861190
///
11871191
/// // You can always define this trait. (as long as you have #![feature(arbitrary_self_types)])
11881192
/// trait MyTrait {

library/core/src/ops/deref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ unsafe impl<T: ?Sized> DerefPure for &mut T {}
303303

304304
/// Indicates that a struct can be used as a method receiver.
305305
/// That is, a type can use this type as a type of `self`, like this:
306-
/// ```compile_fail
306+
/// ```
307307
/// # // This is currently compile_fail because the compiler-side parts
308308
/// # // of arbitrary_self_types are not implemented
309309
/// use std::ops::Receiver;

src/doc/unstable-book/src/language-features/coroutines.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Feedback on the design and usage is always appreciated!
8989
The `Coroutine` trait in `std::ops` currently looks like:
9090

9191
```rust
92-
# #![feature(arbitrary_self_types, coroutine_trait)]
92+
# #![feature(coroutine_trait)]
9393
# use std::ops::CoroutineState;
9494
# use std::pin::Pin;
9595

@@ -184,7 +184,7 @@ fn main() {
184184
This coroutine literal will compile down to something similar to:
185185

186186
```rust
187-
#![feature(arbitrary_self_types, coroutine_trait)]
187+
#![feature(coroutine_trait)]
188188

189189
use std::ops::{Coroutine, CoroutineState};
190190
use std::pin::Pin;

tests/auxiliary/minicore.rs

-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ macro_rules! impl_marker_trait {
4343
#[lang = "sized"]
4444
pub trait Sized {}
4545

46-
#[lang = "legacy_receiver"]
47-
pub trait LegacyReceiver {}
48-
impl<T: ?Sized> LegacyReceiver for &T {}
49-
impl<T: ?Sized> LegacyReceiver for &mut T {}
50-
5146
#[lang = "copy"]
5247
pub trait Copy: Sized {}
5348

tests/codegen/avr/avr-func-addrspace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// It also validates that functions can be called through function pointers
1111
// through traits.
1212

13-
#![feature(no_core, lang_items, intrinsics, unboxed_closures, arbitrary_self_types)]
13+
#![feature(no_core, lang_items, intrinsics, unboxed_closures)]
1414
#![crate_type = "lib"]
1515
#![no_core]
1616

tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0
1010

1111
#![crate_type = "lib"]
12-
#![feature(arbitrary_self_types, no_core, lang_items)]
12+
#![feature(no_core, lang_items)]
1313
#![no_core]
1414

1515
extern crate minicore;

tests/rustdoc-json/impls/auto.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#[lang = "sized"]
55
trait Sized {}
66

7-
#[lang = "legacy_receiver"]
8-
pub trait LegacyReceiver {}
9-
107
pub auto trait Bar {}
118

129
/// has span
@@ -15,8 +12,8 @@ impl Foo {
1512
}
1613

1714
// Testing spans, so all tests below code
18-
//@ is "$.index[*][?(@.docs=='has span')].span.begin" "[13, 0]"
19-
//@ is "$.index[*][?(@.docs=='has span')].span.end" "[15, 1]"
15+
//@ is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]"
16+
//@ is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]"
2017
// FIXME: this doesn't work due to https://github.com/freestrings/jsonpath/issues/91
2118
// is "$.index[*][?(@.inner.impl.is_synthetic==true)].span" null
2219
pub struct Foo;

tests/ui/async-await/inference_var_self_argument.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `&dyn Foo`
44
LL | async fn foo(self: &dyn Foo) {
55
| ^^^^^^^^
66
|
7-
= note: type of `self` must be `Self` or a type that dereferences to it
8-
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
7+
= note: type of `self` must be `Self` or some type implementing `Receiver`
8+
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
99

1010
error[E0038]: the trait `Foo` is not dyn compatible
1111
--> $DIR/inference_var_self_argument.rs:5:5

tests/ui/async-await/issue-66312.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `T`
44
LL | fn is_some(self: T);
55
| ^
66
|
7-
= note: type of `self` must be `Self` or a type that dereferences to it
8-
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
7+
= note: type of `self` must be `Self` or some type implementing `Receiver`
8+
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
99

1010
error[E0308]: mismatched types
1111
--> $DIR/issue-66312.rs:9:8

tests/ui/async-await/issues/issue-53249.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//@ check-pass
22
//@ edition:2018
33

4-
#![feature(arbitrary_self_types)]
5-
64
use std::task::{self, Poll};
75
use std::future::Future;
86
use std::marker::Unpin;

tests/ui/deriving/deriving-coerce-pointee-neg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ proc-macro: malicious-macro.rs
2-
#![feature(derive_coerce_pointee, arbitrary_self_types)]
2+
#![feature(derive_coerce_pointee)]
33

44
extern crate core;
55
extern crate malicious_macro;

tests/ui/deriving/deriving-coerce-pointee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ run-pass
2-
#![feature(derive_coerce_pointee, arbitrary_self_types)]
2+
#![feature(derive_coerce_pointee)]
33

44
use std::marker::CoercePointee;
55

tests/ui/feature-gates/feature-gate-arbitrary-self-types-pointers.feature.stderr

-36
This file was deleted.

tests/ui/feature-gates/feature-gate-arbitrary-self-types-pointers.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//@ revisions: default feature
2-
#![cfg_attr(feature, feature(arbitrary_self_types))]
3-
41
trait Foo {
52
fn foo(self: *const Self); //~ ERROR `*const Self` cannot be used as the type of `self`
63
}

tests/ui/feature-gates/feature-gate-arbitrary-self-types-pointers.default.stderr tests/ui/feature-gates/feature-gate-arbitrary-self-types-pointers.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: `*const Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
2-
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:11:18
2+
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:8:18
33
|
44
LL | fn foo(self: *const Self) {}
55
| ^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | fn foo(self: *const Self) {}
1010
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
1111

1212
error[E0658]: `*mut Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
13-
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:15:18
13+
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:12:18
1414
|
1515
LL | fn bar(self: *mut Self) {}
1616
| ^^^^^^^^^
@@ -21,7 +21,7 @@ LL | fn bar(self: *mut Self) {}
2121
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
2222

2323
error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
24-
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:5:18
24+
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:2:18
2525
|
2626
LL | fn foo(self: *const Self);
2727
| ^^^^^^^^^^^

tests/ui/feature-gates/feature-gate-arbitrary-self-types.rs

-29
This file was deleted.

tests/ui/feature-gates/feature-gate-arbitrary-self-types.stderr

-36
This file was deleted.

tests/ui/feature-gates/feature-gate-dispatch-from-dyn-cell.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Cell<&Self>`
44
LL | fn cell(self: Cell<&Self>);
55
| ^^^^^^^^^^^
66
|
7-
= note: type of `self` must be `Self` or a type that dereferences to it
8-
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
7+
= note: type of `self` must be `Self` or some type implementing `Receiver`
8+
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
99

1010
error: aborting due to 1 previous error
1111

tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Check that a self parameter type requires a DispatchFromDyn impl to be dyn-compatible.
22

3-
#![feature(arbitrary_self_types, unsize, coerce_unsized)]
3+
#![feature(unsize, coerce_unsized)]
44

55
use std::{
66
marker::Unsize,

tests/ui/issues/issue-56806.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Box<(dyn Trait + 'static)>`
44
LL | fn dyn_instead_of_self(self: Box<dyn Trait>);
55
| ^^^^^^^^^^^^^^
66
|
7-
= note: type of `self` must be `Self` or a type that dereferences to it
8-
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
7+
= note: type of `self` must be `Self` or some type implementing `Receiver`
8+
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
99

1010
error: aborting due to 1 previous error
1111

tests/ui/lifetimes/could-not-resolve-issue-121503.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
struct Struct;
55
impl Struct {
66
async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
7-
//~^ ERROR Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without
7+
//~^ ERROR the trait bound
88
&1
99
}
1010
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
error[E0658]: `Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
1+
error[E0277]: the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied
22
--> $DIR/could-not-resolve-issue-121503.rs:6:35
33
|
44
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `impl FnMut(&mut Self)`
66
|
7-
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
8-
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
9-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10-
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
7+
note: required by a bound in `Box`
8+
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
9+
help: consider restricting opaque type `impl FnMut(&mut Self)` with unstable trait `Allocator`
10+
|
11+
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self) + std::alloc::Allocator>) -> &u32 {
12+
| +++++++++++++++++++++++
1113

1214
error: aborting due to 1 previous error
1315

14-
For more information about this error, try `rustc --explain E0658`.
16+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)