Skip to content

Commit 3210aed

Browse files
committed
UI tests: Rename "object safe" to "dyn compatible"
1 parent 2e7a52b commit 3210aed

File tree

155 files changed

+361
-359
lines changed

Some content is hidden

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

155 files changed

+361
-359
lines changed

src/tools/tidy/src/issues.txt

-4
Original file line numberDiff line numberDiff line change
@@ -3173,10 +3173,6 @@ ui/nll/user-annotations/issue-55241.rs
31733173
ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs
31743174
ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs
31753175
ui/numbers-arithmetic/issue-8460.rs
3176-
ui/object-safety/issue-102762.rs
3177-
ui/object-safety/issue-102933.rs
3178-
ui/object-safety/issue-106247.rs
3179-
ui/object-safety/issue-19538.rs
31803176
ui/on-unimplemented/issue-104140.rs
31813177
ui/or-patterns/issue-64879-trailing-before-guard.rs
31823178
ui/or-patterns/issue-67514-irrefutable-param.rs

tests/ui/allocator/dyn-compatible.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ run-pass
2+
3+
// Check that `Allocator` is dyn-compatible, this allows for polymorphic allocators
4+
5+
#![feature(allocator_api)]
6+
7+
use std::alloc::{Allocator, System};
8+
9+
fn ensure_dyn_compatible(_: &dyn Allocator) {}
10+
11+
fn main() {
12+
ensure_dyn_compatible(&System);
13+
}

tests/ui/allocator/object-safe.rs

-13
This file was deleted.

tests/ui/associated-type-bounds/entails-sized-object-safety.rs tests/ui/associated-type-bounds/entails-sized-dyn-compatibility.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ trait Tr1: Sized { type As1; }
44
trait Tr2<'a>: Sized { type As2; }
55

66
trait ObjTr1 { fn foo() -> Self where Self: Tr1<As1: Copy>; }
7-
fn _assert_obj_safe_1(_: Box<dyn ObjTr1>) {}
7+
fn _assert_dyn_compat_1(_: Box<dyn ObjTr1>) {}
88

99
trait ObjTr2 { fn foo() -> Self where Self: Tr1<As1: 'static>; }
10-
fn _assert_obj_safe_2(_: Box<dyn ObjTr2>) {}
10+
fn _assert_dyn_compat_2(_: Box<dyn ObjTr2>) {}
1111

1212
trait ObjTr3 { fn foo() -> Self where Self: Tr1<As1: Into<u8> + 'static + Copy>; }
13-
fn _assert_obj_safe_3(_: Box<dyn ObjTr3>) {}
13+
fn _assert_dyn_compat_3(_: Box<dyn ObjTr3>) {}
1414

1515
trait ObjTr4 { fn foo() -> Self where Self: Tr1<As1: for<'a> Tr2<'a>>; }
16-
fn _assert_obj_safe_4(_: Box<dyn ObjTr4>) {}
16+
fn _assert_dyn_compat_4(_: Box<dyn ObjTr4>) {}
1717

1818
trait ObjTr5 { fn foo() -> Self where for<'a> Self: Tr1<As1: Tr2<'a>>; }
19-
fn _assert_obj_safe_5(_: Box<dyn ObjTr5>) {}
19+
fn _assert_dyn_compat_5(_: Box<dyn ObjTr5>) {}
2020

2121
trait ObjTr6 { fn foo() -> Self where Self: for<'a> Tr1<As1: Tr2<'a, As2: for<'b> Tr2<'b>>>; }
22-
fn _assert_obj_safe_6(_: Box<dyn ObjTr6>) {}
22+
fn _assert_dyn_compat_6(_: Box<dyn ObjTr6>) {}
2323

2424
fn main() {}

tests/ui/async-await/in-trait/object-safety.stderr tests/ui/async-await/in-trait/dyn-compatibility.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0038]: the trait `Foo` cannot be made into an object
2-
--> $DIR/object-safety.rs:9:12
2+
--> $DIR/dyn-compatibility.rs:9:12
33
|
44
LL | let x: &dyn Foo = todo!();
55
| ^^^^^^^^ `Foo` cannot be made into an object
66
|
77
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8-
--> $DIR/object-safety.rs:5:14
8+
--> $DIR/dyn-compatibility.rs:5:14
99
|
1010
LL | trait Foo {
1111
| --- this trait cannot be made into an object...

tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Test that we give suitable error messages when the user attempts to
22
// impl a trait `Trait` for its own object type.
33

4-
// If the trait is not object-safe, we give a more tailored message
4+
// If the trait is dyn-incompatible, we give a more tailored message
55
// because we're such schnuckels:
6-
trait NotObjectSafe { fn eq(&self, other: Self); }
7-
impl NotObjectSafe for dyn NotObjectSafe { }
6+
trait DynIncompatible { fn eq(&self, other: Self); }
7+
impl DynIncompatible for dyn DynIncompatible { }
88
//~^ ERROR E0038
99
//~| ERROR E0046
1010

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0038]: the trait `DynIncompatible` cannot be made into an object
2+
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:26
3+
|
4+
LL | impl DynIncompatible for dyn DynIncompatible { }
5+
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` cannot be made into an object
6+
|
7+
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8+
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:6:45
9+
|
10+
LL | trait DynIncompatible { fn eq(&self, other: Self); }
11+
| --------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
12+
| |
13+
| this trait cannot be made into an object...
14+
= help: consider moving `eq` to another trait
15+
16+
error[E0046]: not all trait items implemented, missing: `eq`
17+
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:1
18+
|
19+
LL | trait DynIncompatible { fn eq(&self, other: Self); }
20+
| -------------------------- `eq` from trait
21+
LL | impl DynIncompatible for dyn DynIncompatible { }
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation
23+
24+
error: aborting due to 2 previous errors
25+
26+
Some errors have detailed explanations: E0038, E0046.
27+
For more information about an error, try `rustc --explain E0038`.

tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr

-27
This file was deleted.

tests/ui/const-generics/adt_const_params/const_param_ty_object_safety.stderr tests/ui/const-generics/adt_const_params/const_param_ty_dyn_compatibility.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
2-
--> $DIR/const_param_ty_object_safety.rs:6:12
2+
--> $DIR/const_param_ty_dyn_compatibility.rs:6:12
33
|
44
LL | fn foo(a: &dyn ConstParamTy_) {}
55
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
@@ -14,7 +14,7 @@ LL | fn foo(a: &impl ConstParamTy_) {}
1414
| ~~~~
1515

1616
error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
17-
--> $DIR/const_param_ty_object_safety.rs:9:12
17+
--> $DIR/const_param_ty_dyn_compatibility.rs:9:12
1818
|
1919
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
2020
| ^^^^^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object

tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0038]: the trait `Foo` cannot be made into an object
2-
--> $DIR/object-safety-err-ret.rs:17:16
2+
--> $DIR/dyn-compatibility-err-ret.rs:17:16
33
|
44
LL | fn use_dyn(v: &dyn Foo) {
55
| ^^^^^^^ `Foo` cannot be made into an object
66
|
77
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8-
--> $DIR/object-safety-err-ret.rs:8:8
8+
--> $DIR/dyn-compatibility-err-ret.rs:8:8
99
|
1010
LL | trait Foo {
1111
| --- this trait cannot be made into an object...
@@ -17,13 +17,13 @@ LL | fn test(&self) -> [u8; bar::<Self>()];
1717
= help: only type `()` implements the trait, consider using it directly instead
1818

1919
error[E0038]: the trait `Foo` cannot be made into an object
20-
--> $DIR/object-safety-err-ret.rs:18:5
20+
--> $DIR/dyn-compatibility-err-ret.rs:18:5
2121
|
2222
LL | v.test();
2323
| ^^^^^^^^ `Foo` cannot be made into an object
2424
|
2525
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
26-
--> $DIR/object-safety-err-ret.rs:8:8
26+
--> $DIR/dyn-compatibility-err-ret.rs:8:8
2727
|
2828
LL | trait Foo {
2929
| --- this trait cannot be made into an object...

tests/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0038]: the trait `Foo` cannot be made into an object
2-
--> $DIR/object-safety-err-where-bounds.rs:15:16
2+
--> $DIR/dyn-compatibility-err-where-bounds.rs:15:16
33
|
44
LL | fn use_dyn(v: &dyn Foo) {
55
| ^^^^^^^ `Foo` cannot be made into an object
66
|
77
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8-
--> $DIR/object-safety-err-where-bounds.rs:8:8
8+
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
99
|
1010
LL | trait Foo {
1111
| --- this trait cannot be made into an object...
@@ -15,13 +15,13 @@ LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
1515
= help: only type `()` implements the trait, consider using it directly instead
1616

1717
error[E0038]: the trait `Foo` cannot be made into an object
18-
--> $DIR/object-safety-err-where-bounds.rs:17:5
18+
--> $DIR/dyn-compatibility-err-where-bounds.rs:17:5
1919
|
2020
LL | v.test();
2121
| ^^^^^^^^ `Foo` cannot be made into an object
2222
|
2323
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
24-
--> $DIR/object-safety-err-where-bounds.rs:8:8
24+
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
2525
|
2626
LL | trait Foo {
2727
| --- this trait cannot be made into an object...

tests/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0284]: type annotations needed
2-
--> $DIR/object-safety-ok-infer-err.rs:19:5
2+
--> $DIR/dyn-compatibility-ok-infer-err.rs:19:5
33
|
44
LL | use_dyn(&());
55
| ^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `use_dyn`
66
|
77
note: required by a const generic parameter in `use_dyn`
8-
--> $DIR/object-safety-ok-infer-err.rs:14:12
8+
--> $DIR/dyn-compatibility-ok-infer-err.rs:14:12
99
|
1010
LL | fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized {
1111
| ^^^^^^^^^^^^^^ required by this const generic parameter in `use_dyn`
@@ -15,15 +15,15 @@ LL | use_dyn::<N>(&());
1515
| +++++
1616

1717
error[E0284]: type annotations needed
18-
--> $DIR/object-safety-ok-infer-err.rs:19:5
18+
--> $DIR/dyn-compatibility-ok-infer-err.rs:19:5
1919
|
2020
LL | use_dyn(&());
2121
| ^^^^^^^ --- type must be known at this point
2222
| |
2323
| cannot infer the value of the const parameter `N` declared on the function `use_dyn`
2424
|
2525
note: required for `()` to implement `Foo<_>`
26-
--> $DIR/object-safety-ok-infer-err.rs:8:22
26+
--> $DIR/dyn-compatibility-ok-infer-err.rs:8:22
2727
|
2828
LL | impl<const N: usize> Foo<N> for () {
2929
| -------------- ^^^^^^ ^^

tests/ui/object-safety/almost-supertrait-associated-type.rs tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test for fixed unsoundness in #126079.
2-
// Enforces that the associated types that are object safe
2+
// Enforces that the associated types that are dyn-compatible.
33

44
use std::marker::PhantomData;
55

tests/ui/object-safety/object-safety-associated-consts.curr.stderr tests/ui/dyn-compatibility/associated-consts.curr.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0038]: the trait `Bar` cannot be made into an object
2-
--> $DIR/object-safety-associated-consts.rs:12:31
2+
--> $DIR/associated-consts.rs:12:31
33
|
44
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
55
| ^^^^^^^ `Bar` cannot be made into an object
66
|
77
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8-
--> $DIR/object-safety-associated-consts.rs:9:11
8+
--> $DIR/associated-consts.rs:9:11
99
|
1010
LL | trait Bar {
1111
| --- this trait cannot be made into an object...
@@ -14,13 +14,13 @@ LL | const X: usize;
1414
= help: consider moving `X` to another trait
1515

1616
error[E0038]: the trait `Bar` cannot be made into an object
17-
--> $DIR/object-safety-associated-consts.rs:14:5
17+
--> $DIR/associated-consts.rs:14:5
1818
|
1919
LL | t
2020
| ^ `Bar` cannot be made into an object
2121
|
2222
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
23-
--> $DIR/object-safety-associated-consts.rs:9:11
23+
--> $DIR/associated-consts.rs:9:11
2424
|
2525
LL | trait Bar {
2626
| --- this trait cannot be made into an object...

tests/ui/object-safety/object-safety-associated-consts.dyn_compatible_for_dispatch.stderr tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0038]: the trait `Bar` cannot be made into an object
2-
--> $DIR/object-safety-associated-consts.rs:14:5
2+
--> $DIR/associated-consts.rs:14:5
33
|
44
LL | t
55
| ^ `Bar` cannot be made into an object
66
|
77
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8-
--> $DIR/object-safety-associated-consts.rs:9:11
8+
--> $DIR/associated-consts.rs:9:11
99
|
1010
LL | trait Bar {
1111
| --- this trait cannot be made into an object...

tests/ui/object-safety/object-safety-bounds.rs tests/ui/dyn-compatibility/bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Traits with bounds mentioning `Self` are not object safe
1+
// Traits with bounds mentioning `Self` are dyn-incompatible.
22

33
trait X {
44
type U: PartialEq<Self>;

tests/ui/object-safety/object-safety-bounds.stderr tests/ui/dyn-compatibility/bounds.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0038]: the trait `X` cannot be made into an object
2-
--> $DIR/object-safety-bounds.rs:7:15
2+
--> $DIR/bounds.rs:7:15
33
|
44
LL | fn f() -> Box<dyn X<U = u32>> {
55
| ^^^^^^^^^^^^^^ `X` cannot be made into an object
66
|
77
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8-
--> $DIR/object-safety-bounds.rs:4:13
8+
--> $DIR/bounds.rs:4:13
99
|
1010
LL | trait X {
1111
| - this trait cannot be made into an object...

tests/ui/object-safety/object-safety-by-value-self-use.rs tests/ui/dyn-compatibility/by-value-self-use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Check that while a trait with by-value self is object-safe, we
1+
// Check that while a trait with by-value self is dyn-compatible, we
22
// can't actually invoke it from an object (yet...?).
33

44
#![feature(rustc_attrs)]

tests/ui/object-safety/object-safety-by-value-self-use.stderr tests/ui/dyn-compatibility/by-value-self-use.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0161]: cannot move a value of type `dyn Bar`
2-
--> $DIR/object-safety-by-value-self-use.rs:15:5
2+
--> $DIR/by-value-self-use.rs:15:5
33
|
44
LL | t.bar()
55
| ^ the size of `dyn Bar` cannot be statically determined

tests/ui/object-safety/object-safety-by-value-self.rs tests/ui/dyn-compatibility/by-value-self.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Check that a trait with by-value self is considered object-safe.
1+
// Check that a trait with by-value self is considered dyn-compatible.
22

33
//@ build-pass (FIXME(62277): could be check-pass?)
44
#![allow(dead_code)]

tests/ui/object-safety/issue-102933.rs tests/ui/dyn-compatibility/elaborated-predicates-ordering.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ check-pass
2+
// issue: rust-lang/rust#102933
23

34
use std::future::Future;
45

0 commit comments

Comments
 (0)