Skip to content

Commit

Permalink
Arbitrary self types v2: stabilize test changes
Browse files Browse the repository at this point in the history
All the test changes necessary for stabilization here.
  • Loading branch information
adetaylor committed Jan 22, 2025
1 parent c93c894 commit 78dbe11
Show file tree
Hide file tree
Showing 93 changed files with 397 additions and 401 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Adapted from rustc run-pass test suite

#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
#![feature(unsize, coerce_unsized, dispatch_from_dyn)]

use std::marker::Unsize;
use std::ops::{CoerceUnsized, Deref, DispatchFromDyn};
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_codegen_cranelift/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}

#[lang = "legacy_receiver"]
pub trait LegacyReceiver {}

impl<T: ?Sized> LegacyReceiver for &T {}
impl<T: ?Sized> LegacyReceiver for &mut T {}
impl<T: ?Sized> LegacyReceiver for Box<T> {}

#[lang = "copy"]
pub trait Copy {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Adapted from rustc run-pass test suite

#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
#![feature(unsize, coerce_unsized, dispatch_from_dyn)]
#![feature(rustc_attrs)]
#![allow(internal_features)]

Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_codegen_gcc/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}

#[lang = "legacy_receiver"]
pub trait LegacyReceiver {}

impl<T: ?Sized> LegacyReceiver for &T {}
impl<T: ?Sized> LegacyReceiver for &mut T {}
impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {}

#[lang = "copy"]
pub trait Copy {}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4894,8 +4894,6 @@ declare_lint! {
/// UB in safe code afterwards. For example:
///
/// ```ignore (causes a warning)
/// #![feature(arbitrary_self_types)]
///
/// trait Trait {
/// fn f(self: *const Self)
/// where
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ unsafe impl<T: ?Sized> DerefPure for &mut T {}

/// Indicates that a struct can be used as a method receiver.
/// That is, a type can use this type as a type of `self`, like this:
/// ```compile_fail
/// ```
/// # // This is currently compile_fail because the compiler-side parts
/// # // of arbitrary_self_types are not implemented
/// use std::ops::Receiver;
Expand Down
4 changes: 2 additions & 2 deletions src/doc/unstable-book/src/language-features/coroutines.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Feedback on the design and usage is always appreciated!
The `Coroutine` trait in `std::ops` currently looks like:

```rust
# #![feature(arbitrary_self_types, coroutine_trait)]
# #![feature(coroutine_trait)]
# use std::ops::CoroutineState;
# use std::pin::Pin;

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

```rust
#![feature(arbitrary_self_types, coroutine_trait)]
#![feature(coroutine_trait)]

use std::ops::{Coroutine, CoroutineState};
use std::pin::Pin;
Expand Down
5 changes: 0 additions & 5 deletions tests/auxiliary/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ macro_rules! impl_marker_trait {
#[lang = "sized"]
pub trait Sized {}

#[lang = "legacy_receiver"]
pub trait LegacyReceiver {}
impl<T: ?Sized> LegacyReceiver for &T {}
impl<T: ?Sized> LegacyReceiver for &mut T {}

#[lang = "copy"]
pub trait Copy: Sized {}

Expand Down
4 changes: 1 addition & 3 deletions tests/codegen/avr/avr-func-addrspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// It also validates that functions can be called through function pointers
// through traits.

#![feature(no_core, lang_items, intrinsics, unboxed_closures, arbitrary_self_types)]
#![feature(no_core, lang_items, intrinsics, unboxed_closures)]
#![crate_type = "lib"]
#![no_core]

Expand All @@ -18,8 +18,6 @@ pub trait Sized {}
#[lang = "copy"]
pub trait Copy {}
impl<T: ?Sized> Copy for *const T {}
#[lang = "legacy_receiver"]
pub trait LegacyReceiver {}
#[lang = "tuple_trait"]
pub trait Tuple {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0

#![crate_type = "lib"]
#![feature(arbitrary_self_types, no_core, lang_items)]
#![feature(no_core, lang_items)]
#![no_core]

#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
impl<T: ?Sized> Copy for &T {}
#[lang = "legacy_receiver"]
trait LegacyReceiver {}
#[lang = "dispatch_from_dyn"]
trait DispatchFromDyn<T> {}
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
Expand Down
3 changes: 0 additions & 3 deletions tests/rustdoc-json/impls/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#[lang = "sized"]
trait Sized {}

#[lang = "legacy_receiver"]
pub trait LegacyReceiver {}

pub auto trait Bar {}

/// has span
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/async-await/inference_var_self_argument.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `&dyn Foo`
LL | async fn foo(self: &dyn Foo) {
| ^^^^^^^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= 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`)
= note: type of `self` must be `Self` or some type implementing `Receiver`
= 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>`

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/inference_var_self_argument.rs:5:5
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/async-await/issue-66312.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `T`
LL | fn is_some(self: T);
| ^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= 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`)
= note: type of `self` must be `Self` or some type implementing `Receiver`
= 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>`

error[E0308]: mismatched types
--> $DIR/issue-66312.rs:9:8
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/async-await/issues/issue-53249.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ check-pass
//@ edition:2018

#![feature(arbitrary_self_types)]

use std::task::{self, Poll};
use std::future::Future;
use std::marker::Unpin;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/deriving/deriving-coerce-pointee-neg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(derive_coerce_pointee, arbitrary_self_types)]
#![feature(derive_coerce_pointee)]

extern crate core;
use std::marker::CoercePointee;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/deriving/deriving-coerce-pointee.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ run-pass
#![feature(derive_coerce_pointee, arbitrary_self_types)]
#![feature(derive_coerce_pointee)]

use std::marker::CoercePointee;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//@ revisions: default feature
#![cfg_attr(feature, feature(arbitrary_self_types))]

trait Foo {
fn foo(self: *const Self); //~ ERROR `*const Self` cannot be used as the type of `self`
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: `*const Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:11:18
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:8:18
|
LL | fn foo(self: *const Self) {}
| ^^^^^^^^^^^
Expand All @@ -10,7 +10,7 @@ LL | fn foo(self: *const Self) {}
= 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>`

error[E0658]: `*mut Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:15:18
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:12:18
|
LL | fn bar(self: *mut Self) {}
| ^^^^^^^^^
Expand All @@ -21,7 +21,7 @@ LL | fn bar(self: *mut Self) {}
= 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>`

error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:5:18
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:2:18
|
LL | fn foo(self: *const Self);
| ^^^^^^^^^^^
Expand Down
29 changes: 0 additions & 29 deletions tests/ui/feature-gates/feature-gate-arbitrary-self-types.rs

This file was deleted.

36 changes: 0 additions & 36 deletions tests/ui/feature-gates/feature-gate-arbitrary-self-types.stderr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Cell<&Self>`
LL | fn cell(self: Cell<&Self>);
| ^^^^^^^^^^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= 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`)
= note: type of `self` must be `Self` or some type implementing `Receiver`
= 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>`

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Check that a self parameter type requires a DispatchFromDyn impl to be dyn-compatible.

#![feature(arbitrary_self_types, unsize, coerce_unsized)]
#![feature(unsize, coerce_unsized)]

use std::{
marker::Unsize,
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/issues/issue-56806.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Box<(dyn Trait + 'static)>`
LL | fn dyn_instead_of_self(self: Box<dyn Trait>);
| ^^^^^^^^^^^^^^
|
= note: type of `self` must be `Self` or a type that dereferences to it
= 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`)
= note: type of `self` must be `Self` or some type implementing `Receiver`
= 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>`

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lifetimes/could-not-resolve-issue-121503.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
struct Struct;
impl Struct {
async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
//~^ ERROR Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without
//~^ ERROR the trait bound
&1
}
}
Expand Down
16 changes: 9 additions & 7 deletions tests/ui/lifetimes/could-not-resolve-issue-121503.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
error[E0658]: `Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
error[E0277]: the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied
--> $DIR/could-not-resolve-issue-121503.rs:6:35
|
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `impl FnMut(&mut Self)`
|
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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>`
note: required by a bound in `Box`
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
help: consider restricting opaque type `impl FnMut(&mut Self)` with unstable trait `Allocator`
|
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self) + std::alloc::Allocator>) -> &u32 {
| +++++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.
For more information about this error, try `rustc --explain E0277`.
1 change: 0 additions & 1 deletion tests/ui/lint/unused/must_use-in-stdlib-traits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![deny(unused_must_use)]
#![feature(arbitrary_self_types)]

use std::iter::Iterator;
use std::future::Future;
Expand Down
Loading

0 comments on commit 78dbe11

Please sign in to comment.