Skip to content

Commit 5f7bb5f

Browse files
committed
Replace "dyn-compatible" with "dyn compatible"
See rust-lang#126554 (comment)
1 parent 55d16b9 commit 5f7bb5f

File tree

145 files changed

+311
-311
lines changed

Some content is hidden

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

145 files changed

+311
-311
lines changed

compiler/rustc_const_eval/src/interpret/call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
614614
// codegen'd / interpreted as virtual calls through the vtable.
615615
ty::InstanceKind::Virtual(def_id, idx) => {
616616
let mut args = args.to_vec();
617-
// We have to implement all "dyn-compatible receivers". So we have to go search for a
617+
// We have to implement all "dyn compatible receivers". So we have to go search for a
618618
// pointer or `dyn Trait` type, but it could be wrapped in newtypes. So recursively
619619
// unwrap those newtypes until we are there.
620620
// An `InPlace` does nothing here, we keep the original receiver intact. We can't

compiler/rustc_error_codes/src/error_codes/E0038.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ trait, written in type positions) but this was a bit too confusing, so we now
55
write `dyn Trait`.
66

77
Some traits are not allowed to be used as trait object types. The traits that
8-
are allowed to be used as trait object types are called "dyn-compatible"[^1]
8+
are allowed to be used as trait object types are called "dyn compatible"[^1]
99
traits. Attempting to use a trait object type for a trait that is not
10-
dyn-compatible will trigger error E0038.
10+
dyn compatible will trigger error E0038.
1111

1212
Two general aspects of trait object types give rise to the restrictions:
1313

@@ -34,7 +34,7 @@ aspects.
3434
### The trait requires `Self: Sized`
3535

3636
Traits that are declared as `Trait: Sized` or which otherwise inherit a
37-
constraint of `Self:Sized` are not dyn-compatible.
37+
constraint of `Self:Sized` are not dyn compatible.
3838

3939
The reasoning behind this is somewhat subtle. It derives from the fact that Rust
4040
requires (and defines) that every trait object type `dyn Trait` automatically
@@ -61,7 +61,7 @@ implement a sized trait like `Trait:Sized`. So, rather than allow an exception
6161
to the rule that `dyn Trait` always implements `Trait`, Rust chooses to prohibit
6262
such a `dyn Trait` from existing at all.
6363

64-
Only unsized traits are considered dyn-compatible.
64+
Only unsized traits are considered dyn compatible.
6565

6666
Generally, `Self: Sized` is used to indicate that the trait should not be used
6767
as a trait object. If the trait comes from your own crate, consider removing
@@ -106,7 +106,7 @@ fn call_foo(x: Box<dyn Trait>) {
106106
}
107107
```
108108

109-
If only some methods aren't dyn-compatible, you can add a `where Self: Sized`
109+
If only some methods aren't dyn compatible, you can add a `where Self: Sized`
110110
bound on them to mark them as explicitly unavailable to trait objects. The
111111
functionality will still be available to all other implementers, including
112112
`Box<dyn Trait>` which is itself sized (assuming you `impl Trait for Box<dyn
@@ -120,7 +120,7 @@ trait Trait {
120120
```
121121

122122
Now, `foo()` can no longer be called on a trait object, but you will now be
123-
allowed to make a trait object, and that will be able to call any dyn-compatible
123+
allowed to make a trait object, and that will be able to call any dyn compatible
124124
methods. With such a bound, one can still call `foo()` on types implementing
125125
that trait that aren't behind trait objects.
126126

@@ -309,7 +309,7 @@ Here, the supertrait might have methods as follows:
309309

310310
```
311311
trait Super<A: ?Sized> {
312-
fn get_a(&self) -> &A; // note that this is dyn-compatible!
312+
fn get_a(&self) -> &A; // note that this is dyn compatible!
313313
}
314314
```
315315

@@ -318,8 +318,8 @@ If the trait `Trait` was deriving from something like `Super<String>` or
318318
`get_a()` will definitely return an object of that type.
319319

320320
However, if it derives from `Super<Self>`, even though `Super` is
321-
dyn-compatible, the method `get_a()` would return an object of unknown type when
322-
called on the function. `Self` type parameters let us make dyn-compatible traits
321+
dyn compatible, the method `get_a()` would return an object of unknown type when
322+
called on the function. `Self` type parameters let us make dyn compatible traits
323323
no longer compatible, so they are forbidden when specifying supertraits.
324324

325325
There's no easy fix for this. Generally, code will need to be refactored so that

compiler/rustc_error_codes/src/error_codes/E0802.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The `Async{Fn, FnMut, FnOnce}` traits are not yet `dyn`-compatible.
1+
The `Async{Fn, FnMut, FnOnce}` traits are not yet dyn compatible.
22

33
Erroneous code example:
44

compiler/rustc_error_codes/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ E0802: 0802,
625625
// E0314, // closure outlives stack frame
626626
// E0315, // cannot invoke closure outside of its lifetime
627627
// E0319, // trait impls for defaulted traits allowed just for structs/enums
628-
// E0372, // coherence not dyn-compatible
628+
// E0372, // coherence not dyn compatible
629629
// E0385, // {} in an aliasable location
630630
// E0402, // cannot use an outer type parameter in this context
631631
// E0406, // merged into 420

compiler/rustc_feature/src/removed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ declare_features! (
159159
/// then removed. But there was no utility storing it separately, so now
160160
/// it's in this list.
161161
(removed, no_stack_check, "1.0.0", None, None),
162-
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible (object safe).
162+
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible (object safe).
163163
/// Renamed to `dyn_compatible_for_dispatch`.
164164
(removed, object_safe_for_dispatch, "1.83.0", Some(43561),
165165
Some("renamed to `dyn_compatible_for_dispatch`")),

compiler/rustc_feature/src/unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ declare_features! (
269269
(unstable, doc_notable_trait, "1.52.0", Some(45040)),
270270
/// Allows using the `may_dangle` attribute (RFC 1327).
271271
(unstable, dropck_eyepatch, "1.10.0", Some(34761)),
272-
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
272+
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible[^1].
273273
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
274274
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
275275
///

compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn check_object_overlap<'tcx>(
184184
// check for overlap with the automatic `impl Trait for dyn Trait`
185185
if let ty::Dynamic(data, ..) = trait_ref.self_ty().kind() {
186186
// This is something like `impl Trait1 for Trait2`. Illegal if
187-
// Trait1 is a supertrait of Trait2 or Trait2 is not dyn-compatible.
187+
// Trait1 is a supertrait of Trait2 or Trait2 is not dyn compatible.
188188

189189
let component_def_ids = data.iter().flat_map(|predicate| {
190190
match predicate.skip_binder() {

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub(crate) fn orphan_check_impl(
116116
// We can allow f to be called on `dyn DynCompatibleTrait + AutoTrait`.
117117
//
118118
// If we didn't deny `impl AutoTrait for dyn Trait`, it would be unsound
119-
// for the `DynCompatibleTrait` shown above to be dyn-compatible because someone
119+
// for the `DynCompatibleTrait` shown above to be dyn compatible because someone
120120
// could take some type implementing `DynCompatibleTrait` but not `AutoTrait`,
121121
// unsize it to `dyn DynCompatibleTrait`, and call `.f()` which has no
122122
// concrete implementation (issue #50781).

compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
8080
if self_ty.span.can_be_used_for_suggestions()
8181
&& !self.maybe_suggest_impl_trait(self_ty, &mut diag)
8282
{
83-
// FIXME: Only emit this suggestion if the trait is dyn-compatible.
83+
// FIXME: Only emit this suggestion if the trait is dyn compatible.
8484
diag.multipart_suggestion_verbose(label, sugg, Applicability::MachineApplicable);
8585
}
8686
// Check if the impl trait that we are considering is an impl of a local trait.
@@ -102,7 +102,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
102102
lint.primary_message("trait objects without an explicit `dyn` are deprecated");
103103
if self_ty.span.can_be_used_for_suggestions() {
104104
lint.multipart_suggestion_verbose(
105-
"if this is a dyn-compatible trait, use `dyn`",
105+
"if this is a dyn compatible trait, use `dyn`",
106106
sugg,
107107
Applicability::MachineApplicable,
108108
);

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
771771
// give us a `QPath::TypeRelative` with a trait object as
772772
// `qself`. In that case, we want to avoid registering a WF obligation
773773
// for `dyn MyTrait`, since we don't actually need the trait
774-
// to be dyn-compatible.
774+
// to be dyn compatible.
775775
// We manually call `register_wf_obligation` in the success path
776776
// below.
777777
let ty = self.lowerer().lower_ty(qself);

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
307307
// distinct types (e.g., if `Self` appeared as an
308308
// argument type), but those cases have already
309309
// been ruled out when we deemed the trait to be
310-
// "dyn-compatible".
310+
// "dyn compatible".
311311
let original_poly_trait_ref = principal.with_self_ty(this.tcx, object_ty);
312312
let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id);
313313
let upcast_trait_ref =

compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ lint_mixed_script_confusables =
507507
.includes_note = the usage includes {$includes}
508508
.note = please recheck to make sure their usages are indeed what you want
509509
510-
lint_multiple_supertrait_upcastable = `{$ident}` is dyn-compatible and has multiple supertraits
510+
lint_multiple_supertrait_upcastable = `{$ident}` is dyn compatible and has multiple supertraits
511511
512512
lint_named_argument_used_positionally = named argument `{$named_arg_name}` is not used by name
513513
.label_named_arg = this named argument is referred to by position in formatting string

compiler/rustc_lint/src/multiple_supertrait_upcastable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_session::{declare_lint, declare_lint_pass};
44
use crate::{LateContext, LateLintPass, LintContext};
55

66
declare_lint! {
7-
/// The `multiple_supertrait_upcastable` lint detects when a dyn-compatible trait has multiple
7+
/// The `multiple_supertrait_upcastable` lint detects when a dyn compatible trait has multiple
88
/// supertraits.
99
///
1010
/// ### Example
@@ -28,7 +28,7 @@ declare_lint! {
2828
/// additional overhead is justified.
2929
pub MULTIPLE_SUPERTRAIT_UPCASTABLE,
3030
Allow,
31-
"detect when a dyn-compatible trait has multiple supertraits",
31+
"detect when a dyn compatible trait has multiple supertraits",
3232
@feature_gate = multiple_supertrait_upcastable;
3333
}
3434

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ rustc_queries! {
13671367
desc { |tcx| "determining dyn-compatibility of trait `{}`", tcx.def_path_str(trait_id) }
13681368
}
13691369
query is_dyn_compatible(trait_id: DefId) -> bool {
1370-
desc { |tcx| "checking if trait `{}` is dyn-compatible", tcx.def_path_str(trait_id) }
1370+
desc { |tcx| "checking if trait `{}` is dyn compatible", tcx.def_path_str(trait_id) }
13711371
}
13721372

13731373
/// Gets the ParameterEnvironment for a given item; this environment

compiler/rustc_middle/src/traits/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl DynCompatibilityViolation {
796796
format!("it contains the generic associated type `{name}`").into()
797797
}
798798
DynCompatibilityViolation::AsyncFnTrait { .. } => {
799-
"`async` function traits are not yet `dyn`-compatible".into()
799+
"async function traits are not yet dyn compatible".into()
800800
}
801801
}
802802
}
@@ -904,7 +904,7 @@ impl DynCompatibilityViolationSolution {
904904
}
905905
}
906906

907-
/// Reasons a method might not be dyn-compatible.
907+
/// Reasons a method might not be dyn compatible.
908908
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
909909
pub enum MethodViolationCode {
910910
/// e.g., `fn foo()`

compiler/rustc_middle/src/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub enum ReifyReason {
5050
/// * A vtable entry is directly converted to a function call (e.g. creating a fn ptr from a
5151
/// method on a `dyn` object).
5252
/// * A function with `#[track_caller]` is converted to a function pointer
53-
/// * If KCFI is enabled, creating a function pointer from a method on a dyn-compatible trait.
53+
/// * If KCFI is enabled, creating a function pointer from a method on a dyn compatible trait.
5454
/// This includes the case of converting `::call`-like methods on closure-likes to function
5555
/// pointers.
5656
FnPtr,

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,7 @@ define_print! {
31153115
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
31163116
ty::PredicateKind::Coerce(predicate) => p!(print(predicate)),
31173117
ty::PredicateKind::DynCompatible(trait_def_id) => {
3118-
p!("the trait `", print_def_path(trait_def_id, &[]), "` is dyn-compatible")
3118+
p!("the trait `", print_def_path(trait_def_id, &[]), "` is dyn compatible")
31193119
}
31203120
ty::PredicateKind::ConstEquate(c1, c2) => {
31213121
p!("the constant `", print(c1), "` equals `", print(c2), "`")

compiler/rustc_monomorphize/src/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
//! #### Unsizing Casts
121121
//! A subtle way of introducing use edges is by casting to a trait object.
122122
//! Since the resulting wide-pointer contains a reference to a vtable, we need to
123-
//! instantiate all dyn-compatible methods of the trait, as we need to store
123+
//! instantiate all dyn compatible methods of the trait, as we need to store
124124
//! pointers to these functions even if they never get called anywhere. This can
125125
//! be seen as a special case of taking a function reference.
126126
//!

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ where
792792
let cx = self.cx();
793793
let Goal { predicate: (a_ty, _), .. } = goal;
794794

795-
// Can only unsize to an dyn-compatible trait.
795+
// Can only unsize to an dyn compatible trait.
796796
if b_data.principal_def_id().is_some_and(|def_id| !cx.trait_is_dyn_compatible(def_id)) {
797797
return Err(NoSolution);
798798
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ pub fn report_dyn_incompatibility<'tcx>(
430430
let trait_str = tcx.def_path_str(trait_def_id);
431431

432432
// Avoid errors diving into the details of the `AsyncFn` traits if this is
433-
// a straightforward "`AsyncFn` is not yet `dyn`-compatible" error.
433+
// a straightforward "`AsyncFn` is not yet dyn compatible" error.
434434
if tcx.trait_is_async_fn(trait_def_id) {
435435
let fn_trait: Symbol = violations
436436
.iter()
@@ -446,20 +446,20 @@ pub fn report_dyn_incompatibility<'tcx>(
446446
tcx.dcx(),
447447
span,
448448
E0802,
449-
"the trait `{}` is not yet `dyn`-compatible",
449+
"the trait `{}` is not yet dyn compatible",
450450
fn_trait
451451
);
452452
// Note: this check is quite imprecise.
453453
// Comparing the DefIds or similar would be better, but we can't store
454454
// DefIds in `DynCompatibilityViolation`.
455455
if fn_trait.as_str() == trait_str {
456-
err.span_label(span, format!("`{fn_trait}` is not yet `dyn`-compatible"));
456+
err.span_label(span, format!("`{fn_trait}` is not yet dyn compatible"));
457457
} else {
458458
let trait_str = tcx.def_path_str(trait_def_id);
459459
err.span_label(
460460
span,
461461
format!(
462-
"`{trait_str}` inherits from `{fn_trait}` which is not yet `dyn`-compatible'"
462+
"`{trait_str}` inherits from `{fn_trait}` which is not yet dyn compatible'"
463463
),
464464
);
465465
}
@@ -522,7 +522,7 @@ pub fn report_dyn_incompatibility<'tcx>(
522522
// FIXME(dyn_compat_renaming): Update the URL.
523523
err.span_note(
524524
note_span,
525-
"for a trait to be \"dyn-compatible\" it needs to allow building a vtable to allow the call \
525+
"for a trait to be dyn compatible it needs to allow building a vtable to allow the call \
526526
to be resolvable dynamically; for more information visit \
527527
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
528528
);

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub fn dyn_compatibility_violations_for_assoc_item(
325325
}
326326

327327
match item.kind {
328-
// Associated consts are never dyn-compatible, as they can't have `where` bounds yet at all,
328+
// Associated consts are never dyn compatible, as they can't have `where` bounds yet at all,
329329
// and associated const bounds in trait objects aren't a thing yet either.
330330
ty::AssocKind::Const => {
331331
vec![DynCompatibilityViolation::AssocConst(item.name, item.ident(tcx).span)]
@@ -348,7 +348,7 @@ pub fn dyn_compatibility_violations_for_assoc_item(
348348
DynCompatibilityViolation::Method(item.name, v, span)
349349
})
350350
.collect(),
351-
// Associated types can only be dyn-compatible if they have `Self: Sized` bounds.
351+
// Associated types can only be dyn compatible if they have `Self: Sized` bounds.
352352
ty::AssocKind::Type => {
353353
if !tcx.features().generic_associated_types_extended()
354354
&& !tcx.generics_of(item.def_id).is_own_empty()
@@ -526,7 +526,7 @@ fn virtual_call_violations_for_method<'tcx>(
526526
/// This code checks that `receiver_is_dispatchable` is correctly implemented.
527527
///
528528
/// This check is outlined from the dyn-compatibility check to avoid cycles with
529-
/// layout computation, which relies on knowing whether methods are dyn-compatible.
529+
/// layout computation, which relies on knowing whether methods are dyn compatible.
530530
fn check_receiver_correct<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, method: ty::AssocItem) {
531531
if !is_vtable_safe_method(tcx, trait_def_id, method) {
532532
return;
@@ -663,7 +663,7 @@ fn object_ty_for_trait<'tcx>(
663663
/// a pointer.
664664
///
665665
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result in
666-
/// a new check that `Trait` is dyn-compatible, creating a cycle (until dyn_compatible_for_dispatch
666+
/// a new check that `Trait` is dyn compatible, creating a cycle (until dyn_compatible_for_dispatch
667667
/// is stabilized, see tracking issue <https://github.com/rust-lang/rust/issues/43561>).
668668
/// Instead, we fudge a little by introducing a new type parameter `U` such that
669669
/// `Self: Unsize<U>` and `U: Trait + ?Sized`, and use `U` in place of `dyn Trait`.

compiler/rustc_type_ir/src/predicate_kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum PredicateKind<I: Interner> {
5252
/// Prove a clause
5353
Clause(ClauseKind<I>),
5454

55-
/// Trait must be dyn-compatible.
55+
/// Trait must be dyn compatible.
5656
DynCompatible(I::DefId),
5757

5858
/// `T1 <: T2`

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#object-safety>
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#object-safety>
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#object-safety>
88
--> $DIR/issue-48027.rs:2:11
99
|
1010
LL | trait Bar {

0 commit comments

Comments
 (0)