Skip to content

Commit 7aa15bd

Browse files
committed
Compiler: Finalize dyn compatibility renaming
1 parent a24bdc6 commit 7aa15bd

File tree

110 files changed

+204
-206
lines changed

Some content is hidden

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

110 files changed

+204
-206
lines changed

compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,9 @@ fn check_object_overlap<'tcx>(
198198

199199
for component_def_id in component_def_ids {
200200
if !tcx.is_dyn_compatible(component_def_id) {
201-
// FIXME(dyn_compat_renaming): Rename test and update comment.
202201
// Without the 'dyn_compatible_for_dispatch' feature this is an error
203202
// which will be reported by wfcheck. Ignore it here.
204-
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
203+
// This is tested by `coherence-impl-trait-for-trait-dyn-compatible.rs`.
205204
// With the feature enabled, the trait is not implemented automatically,
206205
// so this is valid.
207206
} else {

compiler/rustc_lint/src/multiple_supertrait_upcastable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare_lint_pass!(MultipleSupertraitUpcastable => [MULTIPLE_SUPERTRAIT_UPCASTAB
3737
impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
3838
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
3939
let def_id = item.owner_id.to_def_id();
40-
// NOTE(nbdd0121): use `object_safety_violations` instead of `is_dyn_compatible` because
40+
// NOTE(nbdd0121): use `dyn_compatibility_violations` instead of `is_dyn_compatible` because
4141
// the latter will report `where_clause_object_safety` lint.
4242
if let hir::ItemKind::Trait(_, _, _, _, _) = item.kind
4343
&& cx.tcx.is_dyn_compatible(def_id)

compiler/rustc_middle/src/ty/return_position_impl_trait_in_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::ty::{self, ExistentialPredicateStableCmpExt, TyCtxt};
44

55
impl<'tcx> TyCtxt<'tcx> {
66
/// Given a `def_id` of a trait or impl method, compute whether that method needs to
7-
/// have an RPITIT shim applied to it for it to be object safe. If so, return the
7+
/// have an RPITIT shim applied to it for it to be dyn compatible. If so, return the
88
/// `def_id` of the RPITIT, and also the args of trait method that returns the RPITIT.
99
///
1010
/// NOTE that these args are not, in general, the same as than the RPITIT's args. They

compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,11 @@ pub fn report_dyn_incompatibility<'tcx>(
497497
for (span, msg) in iter::zip(multi_span, messages) {
498498
note_span.push_span_label(span, msg);
499499
}
500-
// FIXME(dyn_compat_renaming): Update the URL.
501500
err.span_note(
502501
note_span,
503502
"for a trait to be \"dyn-compatible\" it needs to allow building a vtable to allow the call \
504503
to be resolvable dynamically; for more information visit \
505-
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
504+
<https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>",
506505
);
507506

508507
// Only provide the help if its a local trait, otherwise it's not actionable.

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn is_dyn_compatible(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
6464
}
6565

6666
/// We say a method is *vtable safe* if it can be invoked on a trait
67-
/// object. Note that object-safe traits can have some
67+
/// object. Note that dyn-compatible traits can have some
6868
/// non-vtable-safe methods, so long as they require `Self: Sized` or
6969
/// otherwise ensure that they cannot be used when `Self = Trait`.
7070
pub fn is_vtable_safe_method(tcx: TyCtxt<'_>, trait_def_id: DefId, method: ty::AssocItem) -> bool {
@@ -421,7 +421,7 @@ fn virtual_call_violations_for_method<'tcx>(
421421
let receiver_ty = tcx.liberate_late_bound_regions(method.def_id, sig.input(0));
422422

423423
// Until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on.
424-
// However, this is already considered object-safe. We allow it as a special case here.
424+
// However, this is already considered dyn compatible. We allow it as a special case here.
425425
// FIXME(mikeyhew) get rid of this `if` statement once `receiver_is_dispatchable` allows
426426
// `Receiver: Unsize<Receiver[Self => dyn Trait]>`.
427427
if receiver_ty != tcx.types.self_param {
@@ -631,7 +631,7 @@ fn object_ty_for_trait<'tcx>(
631631
/// - `self: Pin<Box<Self>>` requires `Pin<Box<Self>>: DispatchFromDyn<Pin<Box<dyn Trait>>>`.
632632
///
633633
/// The only case where the receiver is not dispatchable, but is still a valid receiver
634-
/// type (just not object-safe), is when there is more than one level of pointer indirection.
634+
/// type (just not dyn compatible), is when there is more than one level of pointer indirection.
635635
/// E.g., `self: &&Self`, `self: &Rc<Self>`, `self: Box<Box<Self>>`. In these cases, there
636636
/// is no way, or at least no inexpensive way, to coerce the receiver from the version where
637637
/// `Self = dyn Trait` to the version where `Self = T`, where `T` is the unknown erased type

compiler/rustc_trait_selection/src/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use tracing::debug;
2525
/// trait Bar {}
2626
/// trait Foo = Bar + Bar;
2727
///
28-
/// let not_object_safe: dyn Foo; // bad, two `Bar` principals.
28+
/// let dyn_incompatible: dyn Foo; // bad, two `Bar` principals.
2929
/// ```
3030
pub fn expand_trait_aliases<'tcx>(
3131
tcx: TyCtxt<'tcx>,

tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object
9898
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
9999
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
100100
|
101-
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>
101+
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#dyn-compatibility>
102102
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
103103
|
104104
LL | trait X {

tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ error[E0038]: the trait `SVec` cannot be made into an object
300300
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
301301
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
302302
|
303-
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>
303+
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#dyn-compatibility>
304304
--> $DIR/ice-generic-type-alias-105742.rs:15:17
305305
|
306306
LL | pub trait SVec: Index<

tests/ui/associated-consts/associated-const-in-trait.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
44
LL | impl dyn Trait {
55
| ^^^^^^^^^ `Trait` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/associated-const-in-trait.rs:4:11
99
|
1010
LL | trait Trait {
@@ -19,7 +19,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
1919
LL | const fn n() -> usize { Self::N }
2020
| ^^^^ `Trait` cannot be made into an object
2121
|
22-
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>
22+
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#dyn-compatibility>
2323
--> $DIR/associated-const-in-trait.rs:4:11
2424
|
2525
LL | trait Trait {

tests/ui/associated-item/issue-48027.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
44
LL | impl dyn Bar {}
55
| ^^^^^^^ `Bar` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/issue-48027.rs:2:11
99
|
1010
LL | trait Bar {

tests/ui/async-await/async-fn/dyn-pos.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object
44
LL | fn foo(x: &dyn AsyncFn()) {}
55
| ^^^^^^^^^ `AsyncFnMut` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
99
|
1010
= note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture`

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
44
LL | let x: &dyn Foo = todo!();
55
| ^^^^^^^^ `Foo` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/dyn-compatibility.rs:5:14
99
|
1010
LL | trait Foo {

tests/ui/async-await/inference_var_self_argument.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
1313
LL | async fn foo(self: &dyn Foo) {
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
1515
|
16-
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>
16+
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#dyn-compatibility>
1717
--> $DIR/inference_var_self_argument.rs:5:14
1818
|
1919
LL | trait Foo {

tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `DynIncompatible` cannot be made into an object
44
LL | impl DynIncompatible for dyn DynIncompatible { }
55
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:6:45
99
|
1010
LL | trait DynIncompatible { fn eq(&self, other: Self); }

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `ConstParamTy_` cannot be made into an object
44
LL | fn foo(a: &dyn ConstParamTy_) {}
55
| ^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $SRC_DIR/core/src/cmp.rs:LL:COL
99
|
1010
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
@@ -19,7 +19,7 @@ error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
1919
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
2020
| ^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
2121
|
22-
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>
22+
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#dyn-compatibility>
2323
--> $SRC_DIR/core/src/cmp.rs:LL:COL
2424
|
2525
= note: the trait cannot be made into an object because it uses `Self` as a type parameter

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
44
LL | fn use_dyn(v: &dyn Foo) {
55
| ^^^^^^^ `Foo` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/dyn-compatibility-err-ret.rs:8:8
99
|
1010
LL | trait Foo {
@@ -22,7 +22,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
2222
LL | v.test();
2323
| ^^^^^^^^ `Foo` cannot be made into an object
2424
|
25-
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>
25+
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#dyn-compatibility>
2626
--> $DIR/dyn-compatibility-err-ret.rs:8:8
2727
|
2828
LL | trait Foo {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
44
LL | fn use_dyn(v: &dyn Foo) {
55
| ^^^^^^^ `Foo` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
99
|
1010
LL | trait Foo {
@@ -20,7 +20,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
2020
LL | v.test();
2121
| ^^^^^^^^ `Foo` cannot be made into an object
2222
|
23-
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+
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#dyn-compatibility>
2424
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
2525
|
2626
LL | trait Foo {

tests/ui/const-generics/generic_const_exprs/issue-102768.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object
9898
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
9999
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
100100
|
101-
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>
101+
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#dyn-compatibility>
102102
--> $DIR/issue-102768.rs:5:10
103103
|
104104
LL | trait X {

tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LL | let _: &Copy + 'static;
2727
| ^^^^^ `Copy` cannot be made into an object
2828
|
2929
= note: the trait cannot be made into an object because it requires `Self: Sized`
30-
= 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>
30+
= 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#dyn-compatibility>
3131

3232
error: aborting due to 3 previous errors
3333

tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
44
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {
55
| ^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
66
|
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>
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#dyn-compatibility>
88
--> $DIR/almost-supertrait-associated-type.rs:33:34
99
|
1010
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
@@ -21,7 +21,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
2121
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
2222
| ^^^^^^^^^^^^^^ `Foo` cannot be made into an object
2323
|
24-
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+
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#dyn-compatibility>
2525
--> $DIR/almost-supertrait-associated-type.rs:33:34
2626
|
2727
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
@@ -38,7 +38,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
3838
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
3939
| ^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
4040
|
41-
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>
41+
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#dyn-compatibility>
4242
--> $DIR/almost-supertrait-associated-type.rs:33:34
4343
|
4444
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>

0 commit comments

Comments
 (0)