From 8cf861db3a396b56eaabdb928b88b933056ae2a1 Mon Sep 17 00:00:00 2001 From: Veera Date: Sun, 22 Sep 2024 21:43:46 -0400 Subject: [PATCH 1/8] Reorganize Test Headers --- .../stable-metric/ctfe-simple-loop.allow.stderr | 4 ++-- .../const-eval/stable-metric/ctfe-simple-loop.rs | 3 ++- .../stable-metric/ctfe-simple-loop.warn.stderr | 14 +++++++------- .../evade-deduplication-issue-118612.rs | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr index 30550f93ac10..7f6625bcfcdc 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr @@ -1,5 +1,5 @@ warning: constant evaluation is taking a long time - --> $DIR/ctfe-simple-loop.rs:9:5 + --> $DIR/ctfe-simple-loop.rs:10:5 | LL | / while index < n { LL | | @@ -10,7 +10,7 @@ LL | | } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated - --> $DIR/ctfe-simple-loop.rs:19:1 + --> $DIR/ctfe-simple-loop.rs:20:1 | LL | const Y: u32 = simple_loop(35); | ^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs index 42b93383c2b5..7fa338f025a7 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs @@ -1,9 +1,10 @@ //@ check-pass //@ revisions: warn allow +//@ compile-flags: -Z tiny-const-eval-limit + #![cfg_attr(warn, warn(long_running_const_eval))] #![cfg_attr(allow, allow(long_running_const_eval))] -//@ compile-flags: -Z tiny-const-eval-limit const fn simple_loop(n: u32) -> u32 { let mut index = 0; while index < n { diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr index 40fc4a876e9e..657f0e5bcba4 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr @@ -1,5 +1,5 @@ warning: constant evaluation is taking a long time - --> $DIR/ctfe-simple-loop.rs:9:5 + --> $DIR/ctfe-simple-loop.rs:10:5 | LL | / while index < n { LL | | @@ -12,18 +12,18 @@ LL | | } = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated - --> $DIR/ctfe-simple-loop.rs:18:1 + --> $DIR/ctfe-simple-loop.rs:19:1 | LL | const X: u32 = simple_loop(19); | ^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/ctfe-simple-loop.rs:3:24 + --> $DIR/ctfe-simple-loop.rs:5:24 | LL | #![cfg_attr(warn, warn(long_running_const_eval))] | ^^^^^^^^^^^^^^^^^^^^^^^ warning: constant evaluation is taking a long time - --> $DIR/ctfe-simple-loop.rs:9:5 + --> $DIR/ctfe-simple-loop.rs:10:5 | LL | / while index < n { LL | | @@ -36,13 +36,13 @@ LL | | } = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated - --> $DIR/ctfe-simple-loop.rs:19:1 + --> $DIR/ctfe-simple-loop.rs:20:1 | LL | const Y: u32 = simple_loop(35); | ^^^^^^^^^^^^ warning: constant evaluation is taking a long time - --> $DIR/ctfe-simple-loop.rs:9:5 + --> $DIR/ctfe-simple-loop.rs:10:5 | LL | / while index < n { LL | | @@ -53,7 +53,7 @@ LL | | } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated - --> $DIR/ctfe-simple-loop.rs:19:1 + --> $DIR/ctfe-simple-loop.rs:20:1 | LL | const Y: u32 = simple_loop(35); | ^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/stable-metric/evade-deduplication-issue-118612.rs b/tests/ui/consts/const-eval/stable-metric/evade-deduplication-issue-118612.rs index a2d34eaa384c..43b14bae56f4 100644 --- a/tests/ui/consts/const-eval/stable-metric/evade-deduplication-issue-118612.rs +++ b/tests/ui/consts/const-eval/stable-metric/evade-deduplication-issue-118612.rs @@ -1,8 +1,8 @@ //@ check-pass +//@ compile-flags: -Z tiny-const-eval-limit -Z deduplicate-diagnostics=yes #![allow(long_running_const_eval)] -//@ compile-flags: -Z tiny-const-eval-limit -Z deduplicate-diagnostics=yes const FOO: () = { let mut i = 0; loop { From 01a063f9df39fd7442874726afd8c9583987da44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 25 Sep 2024 10:38:40 +0200 Subject: [PATCH 2/8] Compiler: Rename "object safe" to "dyn compatible" --- .../rustc_const_eval/src/interpret/call.rs | 2 +- .../src/error_codes/E0038.md | 33 +++--- compiler/rustc_error_codes/src/lib.rs | 2 +- compiler/rustc_feature/src/unstable.rs | 5 +- compiler/rustc_hir_analysis/messages.ftl | 2 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 11 +- .../rustc_hir_analysis/src/coherence/mod.rs | 7 +- .../src/coherence/orphan.rs | 10 +- ...{object_safety.rs => dyn_compatibility.rs} | 22 ++-- .../src/hir_ty_lowering/errors.rs | 14 +-- .../src/hir_ty_lowering/lint.rs | 22 ++-- .../src/hir_ty_lowering/mod.rs | 2 +- compiler/rustc_hir_typeck/src/coercion.rs | 2 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- .../src/fn_ctxt/inspect_obligations.rs | 2 +- .../rustc_hir_typeck/src/method/confirm.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 4 +- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_lint/messages.ftl | 2 +- .../src/multiple_supertrait_upcastable.rs | 8 +- compiler/rustc_middle/src/arena.rs | 2 +- compiler/rustc_middle/src/query/mod.rs | 12 +- compiler/rustc_middle/src/traits/mod.rs | 104 +++++++++--------- compiler/rustc_middle/src/ty/context.rs | 4 +- compiler/rustc_middle/src/ty/flags.rs | 2 +- compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_middle/src/ty/predicate.rs | 8 +- compiler/rustc_middle/src/ty/print/pretty.rs | 4 +- compiler/rustc_middle/src/ty/util.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- .../src/solve/assembly/mod.rs | 4 +- .../src/solve/eval_ctxt/mod.rs | 4 +- .../rustc_next_trait_solver/src/solve/mod.rs | 4 +- .../src/solve/trait_goals.rs | 4 +- .../cfi/typeid/itanium_cxx_abi/transform.rs | 4 +- .../rustc_smir/src/rustc_smir/convert/ty.rs | 4 +- .../traits/fulfillment_errors.rs | 16 +-- .../src/error_reporting/traits/mod.rs | 15 +-- .../src/solve/fulfill.rs | 2 +- .../src/traits/auto_trait.rs | 2 +- ...{object_safety.rs => dyn_compatibility.rs} | 78 +++++++------ .../src/traits/fulfill.rs | 6 +- .../rustc_trait_selection/src/traits/mod.rs | 12 +- .../query/type_op/implied_outlives_bounds.rs | 4 +- .../src/traits/select/candidate_assembly.rs | 2 +- .../src/traits/select/confirmation.rs | 10 +- .../src/traits/select/mod.rs | 4 +- .../rustc_trait_selection/src/traits/wf.rs | 2 +- .../src/normalize_erasing_regions.rs | 2 +- compiler/rustc_type_ir/src/interner.rs | 2 +- compiler/rustc_type_ir/src/predicate_kind.rs | 8 +- compiler/stable_mir/src/ty.rs | 2 +- src/librustdoc/clean/types.rs | 2 +- .../invalid_const_in_lifetime_position.stderr | 2 +- tests/rustdoc-ui/issues/issue-105742.stderr | 2 +- .../associated-const-in-trait.stderr | 4 +- tests/ui/associated-item/issue-48027.stderr | 2 +- .../suggest-assoc-ty-bound-on-eq-bound.stderr | 4 +- tests/ui/async-await/async-fn/dyn-pos.stderr | 8 +- .../async-await/in-trait/object-safety.stderr | 2 +- .../inference_var_self_argument.stderr | 2 +- ...ce-impl-trait-for-trait-object-safe.stderr | 2 +- .../const_param_ty_object_safety.stderr | 4 +- .../generic_const_exprs/issue-102768.stderr | 2 +- .../object-safety-err-ret.stderr | 4 +- .../object-safety-err-where-bounds.stderr | 4 +- .../not_wf_param_in_rpitit.stderr | 6 +- .../consts/const_refs_to_static-ice-121413.rs | 2 +- .../const_refs_to_static-ice-121413.stderr | 2 +- tests/ui/did_you_mean/bad-assoc-ty.stderr | 2 +- ...reference-without-parens-suggestion.stderr | 2 +- .../dyn-keyword/dyn-2018-edition-lint.stderr | 6 +- .../ui/dyn-keyword/dyn-angle-brackets.stderr | 2 +- tests/ui/error-codes/E0038.stderr | 4 +- ...dynless-turbofish-e0191-issue-91997.stderr | 2 +- ...gate-dispatch-from-dyn-missing-impl.stderr | 4 +- ...ature-gate-object_safe_for_dispatch.stderr | 10 +- ...t-in-trait-path-undeclared-lifetime.stderr | 2 +- .../gat-in-trait-path.base.stderr | 6 +- .../gat-trait-path-parenthesised-args.stderr | 4 +- .../issue-67510-pass.base.stderr | 2 +- .../issue-67510.stderr | 2 +- .../issue-71176.stderr | 4 +- .../issue-76535.base.stderr | 4 +- .../issue-78671.base.stderr | 2 +- .../issue-79422.base.stderr | 4 +- .../missing_lifetime_args.stderr | 2 +- ...it-path-type-error-once-implemented.stderr | 2 +- .../trait-objects.base.stderr | 6 +- .../trait-bounds/span-bug-issue-121597.stderr | 4 +- ...lifetime-from-bare-trait-obj-114664.stderr | 4 +- ...e-visibilities-during-object-safety.stderr | 6 +- .../in-trait/foreign-dyn-error.stderr | 2 +- .../impl-trait/in-trait/object-safety.stderr | 8 +- ...-trait-in-return-position-dyn-trait.stderr | 8 +- tests/ui/issues/issue-18959.stderr | 10 +- tests/ui/issues/issue-19380.stderr | 6 +- tests/ui/issues/issue-26056.stderr | 2 +- tests/ui/issues/issue-28344.stderr | 4 +- tests/ui/issues/issue-34373.stderr | 2 +- tests/ui/issues/issue-50781.stderr | 6 +- tests/ui/issues/issue-58734.stderr | 2 +- tests/ui/issues/issue-86756.stderr | 2 +- .../kindck-inherited-copy-bound.curr.stderr | 4 +- ...copy-bound.object_safe_for_dispatch.stderr | 2 +- tests/ui/lint/bare-trait-objects-path.stderr | 8 +- .../allowed-group-warn-by-default-lint.stderr | 2 +- .../ui/lint/force-warn/cap-lints-allow.stderr | 2 +- ...up-allowed-cli-warn-by-default-lint.stderr | 2 +- .../lint-group-allowed-lint-group.stderr | 2 +- ...-group-allowed-warn-by-default-lint.stderr | 2 +- .../almost-supertrait-associated-type.stderr | 6 +- .../assoc_type_bounds_sized_unnecessary.rs | 2 +- ...assoc_type_bounds_sized_unnecessary.stderr | 2 +- .../avoid-ice-on-warning-2.new.stderr | 2 +- .../avoid-ice-on-warning-2.old.stderr | 6 +- .../avoid-ice-on-warning-3.new.stderr | 4 +- .../avoid-ice-on-warning-3.old.stderr | 16 +-- .../avoid-ice-on-warning.old.stderr | 2 +- .../bare-trait-dont-suggest-dyn.new.stderr | 2 +- .../bare-trait-dont-suggest-dyn.old.stderr | 4 +- tests/ui/object-safety/issue-102762.stderr | 6 +- tests/ui/object-safety/issue-19538.stderr | 4 +- ...bject-safety-associated-consts.curr.stderr | 4 +- ...ted-consts.object_safe_for_dispatch.stderr | 2 +- .../object-safety/object-safety-bounds.stderr | 2 +- .../object-safety-generics.curr.stderr | 10 +- ...y-generics.object_safe_for_dispatch.stderr | 4 +- .../object-safety-issue-22040.stderr | 6 +- .../object-safety-mentions-Self.curr.stderr | 8 +- ...tions-Self.object_safe_for_dispatch.stderr | 4 +- .../object-safety-no-static.curr.stderr | 6 +- ...-no-static.object_safe_for_dispatch.stderr | 2 +- .../object-safety-sized-2.curr.stderr | 4 +- ...ty-sized-2.object_safe_for_dispatch.stderr | 2 +- .../object-safety-sized.curr.stderr | 4 +- ...fety-sized.object_safe_for_dispatch.stderr | 2 +- ...ject-safety-supertrait-mentions-GAT.stderr | 2 +- ...ect-safety-supertrait-mentions-Self.stderr | 2 +- .../parser/trait-object-trait-parens.stderr | 6 +- tests/ui/resolve/issue-3907-2.stderr | 2 +- ...ary-self-types-not-object-safe.curr.stderr | 4 +- ...bject-safe.object_safe_for_dispatch.stderr | 2 +- .../unsizing-wfcheck-issue-127299.stderr | 6 +- tests/ui/suggestions/issue-116434-2015.rs | 8 +- tests/ui/suggestions/issue-116434-2015.stderr | 12 +- tests/ui/suggestions/issue-116434-2021.stderr | 4 +- tests/ui/suggestions/issue-61963.stderr | 4 +- tests/ui/suggestions/issue-98500.stderr | 2 +- ...object-unsafe-trait-references-self.stderr | 4 +- ...it-should-use-self-2021-without-dyn.stderr | 18 +-- ...t-unsafe-trait-should-use-self-2021.stderr | 4 +- ...object-unsafe-trait-should-use-self.stderr | 4 +- ...unsafe-trait-should-use-where-sized.stderr | 2 +- .../suggest-swapping-self-ty-and-trait.stderr | 6 +- tests/ui/traits/alias/object-fail.stderr | 2 +- .../ui/traits/bound/not-on-bare-trait.stderr | 2 +- tests/ui/traits/issue-20692.stderr | 4 +- tests/ui/traits/issue-28576.stderr | 2 +- tests/ui/traits/issue-38404.stderr | 6 +- tests/ui/traits/issue-38604.stderr | 4 +- tests/ui/traits/issue-72410.stderr | 2 +- tests/ui/traits/issue-78372.stderr | 2 +- tests/ui/traits/item-privacy.stderr | 2 +- .../supertrait-object-safety.stderr | 6 +- ...alize-fresh-infer-vars-issue-103626.stderr | 2 +- tests/ui/traits/object/macro-matcher.stderr | 2 +- .../object-unsafe-missing-assoc-type.stderr | 8 +- tests/ui/traits/object/pretty.stderr | 2 +- tests/ui/traits/object/safety.stderr | 4 +- tests/ui/traits/test-2.stderr | 6 +- .../multiple_supertrait_upcastable.rs | 2 +- .../multiple_supertrait_upcastable.stderr | 2 +- .../unspecified-self-in-trait-ref.stderr | 10 +- ...ter-defaults-referencing-Self-ppaux.stderr | 2 +- ...ir-wf-check-anon-const-issue-122199.stderr | 18 +-- ...ir-wf-check-anon-const-issue-122989.stderr | 8 +- tests/ui/wf/issue-87495.stderr | 2 +- .../wf/wf-convert-unsafe-trait-obj-box.stderr | 6 +- .../ui/wf/wf-convert-unsafe-trait-obj.stderr | 6 +- tests/ui/wf/wf-fn-where-clause.stderr | 2 +- tests/ui/wf/wf-object-safe.stderr | 2 +- tests/ui/wf/wf-unsafe-trait-obj-match.stderr | 4 +- 183 files changed, 523 insertions(+), 510 deletions(-) rename compiler/rustc_hir_analysis/src/hir_ty_lowering/{object_safety.rs => dyn_compatibility.rs} (96%) rename compiler/rustc_trait_selection/src/traits/{object_safety.rs => dyn_compatibility.rs} (94%) diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index f5a0a2c0ee36..19aa76bf1eae 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -598,7 +598,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // codegen'd / interpreted as virtual calls through the vtable. ty::InstanceKind::Virtual(def_id, idx) => { let mut args = args.to_vec(); - // We have to implement all "object safe receivers". So we have to go search for a + // We have to implement all "dyn-compatible receivers". So we have to go search for a // pointer or `dyn Trait` type, but it could be wrapped in newtypes. So recursively // unwrap those newtypes until we are there. // An `InPlace` does nothing here, we keep the original receiver intact. We can't diff --git a/compiler/rustc_error_codes/src/error_codes/E0038.md b/compiler/rustc_error_codes/src/error_codes/E0038.md index 8f8eabb15190..014d8c4f761c 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0038.md +++ b/compiler/rustc_error_codes/src/error_codes/E0038.md @@ -5,9 +5,9 @@ trait, written in type positions) but this was a bit too confusing, so we now write `dyn Trait`. Some traits are not allowed to be used as trait object types. The traits that -are allowed to be used as trait object types are called "object-safe" traits. -Attempting to use a trait object type for a trait that is not object-safe will -trigger error E0038. +are allowed to be used as trait object types are called "dyn-compatible"[^1] +traits. Attempting to use a trait object type for a trait that is not +dyn-compatible will trigger error E0038. Two general aspects of trait object types give rise to the restrictions: @@ -25,13 +25,16 @@ Two general aspects of trait object types give rise to the restrictions: objects with the same trait object type may point to vtables from different implementations. -The specific conditions that violate object-safety follow, most of which relate -to missing size information and vtable polymorphism arising from these aspects. +The specific conditions that violate dyn-compatibility follow, most of which +relate to missing size information and vtable polymorphism arising from these +aspects. + +[^1]: Formerly known as "object-safe". ### The trait requires `Self: Sized` Traits that are declared as `Trait: Sized` or which otherwise inherit a -constraint of `Self:Sized` are not object-safe. +constraint of `Self:Sized` are not dyn-compatible. The reasoning behind this is somewhat subtle. It derives from the fact that Rust requires (and defines) that every trait object type `dyn Trait` automatically @@ -58,7 +61,7 @@ implement a sized trait like `Trait:Sized`. So, rather than allow an exception to the rule that `dyn Trait` always implements `Trait`, Rust chooses to prohibit such a `dyn Trait` from existing at all. -Only unsized traits are considered object-safe. +Only unsized traits are considered dyn-compatible. Generally, `Self: Sized` is used to indicate that the trait should not be used as a trait object. If the trait comes from your own crate, consider removing @@ -103,8 +106,8 @@ fn call_foo(x: Box) { } ``` -If only some methods aren't object-safe, you can add a `where Self: Sized` bound -on them to mark them as explicitly unavailable to trait objects. The +If only some methods aren't dyn-compatible, you can add a `where Self: Sized` +bound on them to mark them as explicitly unavailable to trait objects. The functionality will still be available to all other implementers, including `Box` which is itself sized (assuming you `impl Trait for Box`). @@ -117,7 +120,7 @@ trait Trait { ``` Now, `foo()` can no longer be called on a trait object, but you will now be -allowed to make a trait object, and that will be able to call any object-safe +allowed to make a trait object, and that will be able to call any dyn-compatible methods. With such a bound, one can still call `foo()` on types implementing that trait that aren't behind trait objects. @@ -306,7 +309,7 @@ Here, the supertrait might have methods as follows: ``` trait Super { - fn get_a(&self) -> &A; // note that this is object safe! + fn get_a(&self) -> &A; // note that this is dyn-compatible! } ``` @@ -314,10 +317,10 @@ If the trait `Trait` was deriving from something like `Super` or `Super` (where `Foo` itself is `Foo`), this is okay, because given a type `get_a()` will definitely return an object of that type. -However, if it derives from `Super`, even though `Super` is object safe, -the method `get_a()` would return an object of unknown type when called on the -function. `Self` type parameters let us make object safe traits no longer safe, -so they are forbidden when specifying supertraits. +However, if it derives from `Super`, even though `Super` is +dyn-compatible, the method `get_a()` would return an object of unknown type when +called on the function. `Self` type parameters let us make dyn-compatible traits +no longer compatible, so they are forbidden when specifying supertraits. There's no easy fix for this. Generally, code will need to be refactored so that you no longer need to derive from `Super`. diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs index 8631de65ec82..27a34d6003db 100644 --- a/compiler/rustc_error_codes/src/lib.rs +++ b/compiler/rustc_error_codes/src/lib.rs @@ -623,7 +623,7 @@ E0800: 0800, // E0314, // closure outlives stack frame // E0315, // cannot invoke closure outside of its lifetime // E0319, // trait impls for defaulted traits allowed just for structs/enums -// E0372, // coherence not object safe +// E0372, // coherence not dyn-compatible // E0385, // {} in an aliasable location // E0402, // cannot use an outer type parameter in this context // E0406, // merged into 420 diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 63b4b272f76c..d304a52fbd5c 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -548,9 +548,12 @@ declare_features! ( (unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)), /// Allows `for` binders in where-clauses (incomplete, non_lifetime_binders, "1.69.0", Some(108185)), - /// Allows making `dyn Trait` well-formed even if `Trait` is not object safe. + /// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1]. /// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and /// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden. + /// + /// [^1]: Formerly known as "object safe". + // FIXME(dyn_compat_renaming): Rename feature. (unstable, object_safe_for_dispatch, "1.40.0", Some(43561)), /// Allows using enums in offset_of! (unstable, offset_of_enum, "1.75.0", Some(120141)), diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index 09d466339ff6..c73826c489f9 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -558,7 +558,7 @@ hir_analysis_unrecognized_intrinsic_function = .help = if you're adding an intrinsic, be sure to update `check_intrinsic_type` hir_analysis_unused_associated_type_bounds = - unnecessary associated type bound for not object safe associated type + unnecessary associated type bound for dyn-incompatible associated type .note = this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized` .suggestion = remove this bound diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index f8a19e93a412..a71e14ce463f 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -374,7 +374,7 @@ fn check_trait_item<'tcx>( hir::TraitItemKind::Type(_bounds, Some(ty)) => (None, ty.span), _ => (None, trait_item.span), }; - check_object_unsafe_self_trait_by_name(tcx, trait_item); + check_dyn_incompatible_self_trait_by_name(tcx, trait_item); let mut res = check_associated_item(tcx, def_id, span, method_sig); if matches!(trait_item.kind, hir::TraitItemKind::Fn(..)) { @@ -838,9 +838,10 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool { } } -/// Detect when an object unsafe trait is referring to itself in one of its associated items. -/// When this is done, suggest using `Self` instead. -fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) { +/// Detect when a dyn-incompatible trait is referring to itself in one of its associated items. +/// +/// In such cases, suggest using `Self` instead. +fn check_dyn_incompatible_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) { let (trait_name, trait_def_id) = match tcx.hir_node_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) { hir::Node::Item(item) => match item.kind { @@ -872,7 +873,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem _ => {} } if !trait_should_be_self.is_empty() { - if tcx.is_object_safe(trait_def_id) { + if tcx.is_dyn_compatible(trait_def_id) { return; } let sugg = trait_should_be_self.iter().map(|span| (*span, "Self".to_string())).collect(); diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index 185f3176f078..8c3c68751194 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -179,8 +179,8 @@ fn check_object_overlap<'tcx>( // check for overlap with the automatic `impl Trait for dyn Trait` if let ty::Dynamic(data, ..) = trait_ref.self_ty().kind() { - // This is something like impl Trait1 for Trait2. Illegal - // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe. + // This is something like `impl Trait1 for Trait2`. Illegal if + // Trait1 is a supertrait of Trait2 or Trait2 is not dyn-compatible. let component_def_ids = data.iter().flat_map(|predicate| { match predicate.skip_binder() { @@ -193,7 +193,8 @@ fn check_object_overlap<'tcx>( }); for component_def_id in component_def_ids { - if !tcx.is_object_safe(component_def_id) { + if !tcx.is_dyn_compatible(component_def_id) { + // FIXME(dyn_compat_renaming): Rename test and update comment. // Without the 'object_safe_for_dispatch' feature this is an error // which will be reported by wfcheck. Ignore it here. // This is tested by `coherence-impl-trait-for-trait-object-safe.rs`. diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 5fdaba41fb26..04770469132b 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -109,16 +109,16 @@ pub(crate) fn orphan_check_impl( // // auto trait AutoTrait {} // - // trait ObjectSafeTrait { + // trait DynCompatibleTrait { // fn f(&self) where Self: AutoTrait; // } // - // We can allow f to be called on `dyn ObjectSafeTrait + AutoTrait`. + // We can allow f to be called on `dyn DynCompatibleTrait + AutoTrait`. // // If we didn't deny `impl AutoTrait for dyn Trait`, it would be unsound - // for the ObjectSafeTrait shown above to be object safe because someone - // could take some type implementing ObjectSafeTrait but not AutoTrait, - // unsize it to `dyn ObjectSafeTrait`, and call .f() which has no + // for the `DynCompatibleTrait` shown above to be dyn-compatible because someone + // could take some type implementing `DynCompatibleTrait` but not `AutoTrait`, + // unsize it to `dyn DynCompatibleTrait`, and call `.f()` which has no // concrete implementation (issue #50781). enum LocalImpl { Allow, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs similarity index 96% rename from compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs rename to compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs index 87a240f626c3..e7b8e6e69b0c 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs @@ -11,8 +11,8 @@ use rustc_middle::ty::{ self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable, Upcast, }; use rustc_span::{ErrorGuaranteed, Span}; -use rustc_trait_selection::error_reporting::traits::report_object_safety_error; -use rustc_trait_selection::traits::{self, hir_ty_lowering_object_safety_violations}; +use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility; +use rustc_trait_selection::traits::{self, hir_ty_lowering_dyn_compatibility_violations}; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; @@ -99,19 +99,19 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { return Ty::new_error(tcx, reported); } - // Check that there are no gross object safety violations; + // Check that there are no gross dyn-compatibility violations; // most importantly, that the supertraits don't contain `Self`, // to avoid ICEs. for item in ®ular_traits { - let object_safety_violations = - hir_ty_lowering_object_safety_violations(tcx, item.trait_ref().def_id()); - if !object_safety_violations.is_empty() { - let reported = report_object_safety_error( + let violations = + hir_ty_lowering_dyn_compatibility_violations(tcx, item.trait_ref().def_id()); + if !violations.is_empty() { + let reported = report_dyn_incompatibility( tcx, span, Some(hir_id), item.trait_ref().def_id(), - &object_safety_violations, + &violations, ) .emit(); return Ty::new_error(tcx, reported); @@ -275,8 +275,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { tcx.item_name(def_id), ) .with_note( - rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![]) - .error_msg(), + rustc_middle::traits::DynCompatibilityViolation::SupertraitSelf( + smallvec![], + ) + .error_msg(), ) .emit(); } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 5e3203e84736..eaecd6b9b61e 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -19,9 +19,9 @@ use rustc_session::parse::feature_err; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::symbol::{Ident, kw, sym}; use rustc_span::{BytePos, DUMMY_SP, Span, Symbol}; -use rustc_trait_selection::error_reporting::traits::report_object_safety_error; +use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility; use rustc_trait_selection::traits::{ - FulfillmentError, TraitAliasExpansionInfo, object_safety_violations_for_assoc_item, + FulfillmentError, TraitAliasExpansionInfo, dyn_compatibility_violations_for_assoc_item, }; use crate::errors::{ @@ -739,7 +739,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // Account for things like `dyn Foo + 'a`, like in tests `issue-22434.rs` and // `issue-22560.rs`. let mut trait_bound_spans: Vec = vec![]; - let mut object_safety_violations = false; + let mut dyn_compatibility_violations = false; for (span, items) in &associated_types { if !items.is_empty() { trait_bound_spans.push(*span); @@ -750,14 +750,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { names_len += 1; let violations = - object_safety_violations_for_assoc_item(tcx, trait_def_id, *assoc_item); + dyn_compatibility_violations_for_assoc_item(tcx, trait_def_id, *assoc_item); if !violations.is_empty() { - report_object_safety_error(tcx, *span, None, trait_def_id, &violations).emit(); - object_safety_violations = true; + report_dyn_incompatibility(tcx, *span, None, trait_def_id, &violations).emit(); + dyn_compatibility_violations = true; } } } - if object_safety_violations { + if dyn_compatibility_violations { return; } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs index 1fbf70fa2015..a70f881f5fed 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs @@ -77,7 +77,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { if self_ty.span.can_be_used_for_suggestions() && !self.maybe_suggest_impl_trait(self_ty, &mut diag) { - // FIXME: Only emit this suggestion if the trait is object safe. + // FIXME: Only emit this suggestion if the trait is dyn-compatible. diag.multipart_suggestion_verbose(label, sugg, Applicability::MachineApplicable); } // Check if the impl trait that we are considering is an impl of a local trait. @@ -89,7 +89,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { lint.primary_message("trait objects without an explicit `dyn` are deprecated"); if self_ty.span.can_be_used_for_suggestions() { lint.multipart_suggestion_verbose( - "if this is an object-safe trait, use `dyn`", + "if this is a dyn-compatible trait, use `dyn`", sugg, Applicability::MachineApplicable, ); @@ -196,7 +196,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let mut is_downgradable = true; // Check if trait object is safe for suggesting dynamic dispatch. - let is_object_safe = match self_ty.kind { + let is_dyn_compatible = match self_ty.kind { hir::TyKind::TraitObject(objects, ..) => { objects.iter().all(|(o, _)| match o.trait_ref.path.res { Res::Def(DefKind::Trait, id) => { @@ -204,7 +204,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // For recursive traits, don't downgrade the error. (#119652) is_downgradable = false; } - tcx.is_object_safe(id) + tcx.is_dyn_compatible(id) } _ => false, }) @@ -221,8 +221,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { if let hir::FnRetTy::Return(ty) = sig.decl.output && ty.peel_refs().hir_id == self_ty.hir_id { - let pre = if !is_object_safe { - format!("`{trait_name}` is not object safe, ") + let pre = if !is_dyn_compatible { + format!("`{trait_name}` is dyn-incompatible, ") } else { String::new() }; @@ -234,7 +234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { diag.multipart_suggestion_verbose(msg, impl_sugg, Applicability::MachineApplicable); // Suggest `Box` for return type - if is_object_safe { + if is_dyn_compatible { // If the return type is `&Trait`, we don't want // the ampersand to be displayed in the `Box` // suggestion. @@ -253,7 +253,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { Applicability::MachineApplicable, ); } else if is_downgradable { - // We'll emit the object safety error already, with a structured suggestion. + // We'll emit the dyn-compatibility error already, with a structured suggestion. diag.downgrade_to_delayed_bug(); } return true; @@ -276,10 +276,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { impl_sugg, Applicability::MachineApplicable, ); - if !is_object_safe { - diag.note(format!("`{trait_name}` it is not object safe, so it can't be `dyn`")); + if !is_dyn_compatible { + diag.note(format!("`{trait_name}` it is dyn-incompatible, so it can't be `dyn`")); if is_downgradable { - // We'll emit the object safety error already, with a structured suggestion. + // We'll emit the dyn-compatibility error already, with a structured suggestion. diag.downgrade_to_delayed_bug(); } } else { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index e95b5142559f..dfd2525c2b28 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -15,10 +15,10 @@ mod bounds; mod cmse; +mod dyn_compatibility; pub mod errors; pub mod generics; mod lint; -mod object_safety; use std::slice; diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 7be91d78e19f..2d4c7af45202 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -655,7 +655,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { return Err(TypeError::Mismatch); } - // Object safety violations or miscellaneous. + // Dyn-compatibility violations or miscellaneous. Err(err) => { self.err_ctxt().report_selection_error(obligation.clone(), &obligation, &err); // Treat this like an obligation and follow through diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 2c469c0d52c4..62107877283a 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -757,7 +757,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // give us a `QPath::TypeRelative` with a trait object as // `qself`. In that case, we want to avoid registering a WF obligation // for `dyn MyTrait`, since we don't actually need the trait - // to be object-safe. + // to be dyn-compatible. // We manually call `register_wf_obligation` in the success path // below. let ty = self.lowerer().lower_ty(qself); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs index 2dcab9ed0044..2aad9a043f97 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs @@ -50,7 +50,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..)) | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..)) - | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::DynCompatible(..) | ty::PredicateKind::NormalizesTo(..) | ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index e3b0fa78eb70..72842075fec0 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -292,7 +292,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // distinct types (e.g., if `Self` appeared as an // argument type), but those cases have already // been ruled out when we deemed the trait to be - // "object safe". + // "dyn-compatible". let original_poly_trait_ref = principal.with_self_ty(this.tcx, object_ty); let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id); let upcast_trait_ref = diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 3828b40b8857..c2e33c1bcd41 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -779,8 +779,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { }); // It is illegal to invoke a method on a trait instance that refers to - // the `Self` type. An [`ObjectSafetyViolation::SupertraitSelf`] error - // will be reported by `object_safety.rs` if the method refers to the + // the `Self` type. An [`DynCompatibilityViolation::SupertraitSelf`] error + // will be reported by `dyn_compatibility.rs` if the method refers to the // `Self` type anywhere other than the receiver. Here, we use a // instantiation that replaces `Self` with the object type itself. Hence, // a `&self` method will wind up with an argument type like `&dyn Trait`. diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 617581cf667f..ce1e0ed2959c 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -912,7 +912,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { let traits = tcx.traits(LOCAL_CRATE); for &tr in traits { - if !tcx.is_object_safe(tr) { + if !tcx.is_dyn_compatible(tr) { continue; } diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index edfc7e547e59..fe1e93e415c0 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -516,7 +516,7 @@ lint_mixed_script_confusables = .includes_note = the usage includes {$includes} .note = please recheck to make sure their usages are indeed what you want -lint_multiple_supertrait_upcastable = `{$ident}` is object-safe and has multiple supertraits +lint_multiple_supertrait_upcastable = `{$ident}` is dyn-compatible and has multiple supertraits lint_named_argument_used_positionally = named argument `{$named_arg_name}` is not used by name .label_named_arg = this named argument is referred to by position in formatting string diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs index 78468020c4d5..9fde35f82d82 100644 --- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs +++ b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs @@ -4,7 +4,7 @@ use rustc_session::{declare_lint, declare_lint_pass}; use crate::{LateContext, LateLintPass, LintContext}; declare_lint! { - /// The `multiple_supertrait_upcastable` lint detects when an object-safe trait has multiple + /// The `multiple_supertrait_upcastable` lint detects when a dyn-compatible trait has multiple /// supertraits. /// /// ### Example @@ -28,7 +28,7 @@ declare_lint! { /// additional overhead is justified. pub MULTIPLE_SUPERTRAIT_UPCASTABLE, Allow, - "detect when an object-safe trait has multiple supertraits", + "detect when a dyn-compatible trait has multiple supertraits", @feature_gate = multiple_supertrait_upcastable; } @@ -37,10 +37,10 @@ declare_lint_pass!(MultipleSupertraitUpcastable => [MULTIPLE_SUPERTRAIT_UPCASTAB impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { let def_id = item.owner_id.to_def_id(); - // NOTE(nbdd0121): use `object_safety_violations` instead of `is_object_safe` because + // NOTE(nbdd0121): use `object_safety_violations` instead of `is_dyn_compatible` because // the latter will report `where_clause_object_safety` lint. if let hir::ItemKind::Trait(_, _, _, _, _) = item.kind - && cx.tcx.is_object_safe(def_id) + && cx.tcx.is_dyn_compatible(def_id) { let direct_super_traits_iter = cx .tcx diff --git a/compiler/rustc_middle/src/arena.rs b/compiler/rustc_middle/src/arena.rs index 7050a06b8dc2..52fe9956b477 100644 --- a/compiler/rustc_middle/src/arena.rs +++ b/compiler/rustc_middle/src/arena.rs @@ -83,7 +83,7 @@ macro_rules! arena_types { >, [] effective_visibilities: rustc_middle::middle::privacy::EffectiveVisibilities, [] upvars_mentioned: rustc_data_structures::fx::FxIndexMap, - [] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation, + [] dyn_compatibility_violations: rustc_middle::traits::DynCompatibilityViolation, [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>, [decode] attribute: rustc_ast::Attribute, [] name_set: rustc_data_structures::unord::UnordSet, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 00036097ef50..6eea5767095b 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -70,8 +70,8 @@ use crate::traits::query::{ MethodAutoderefStepsResult, NoSolution, NormalizationResult, OutlivesBound, }; use crate::traits::{ - CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause, - OverflowError, WellFormedLoc, specialization_graph, + CodegenObligationError, DynCompatibilityViolation, EvaluationResult, ImplSource, + ObligationCause, OverflowError, WellFormedLoc, specialization_graph, }; use crate::ty::fast_reject::SimplifiedType; use crate::ty::layout::ValidityRequirement; @@ -1338,11 +1338,11 @@ rustc_queries! { cache_on_disk_if { true } ensure_forwards_result_if_red } - query object_safety_violations(trait_id: DefId) -> &'tcx [ObjectSafetyViolation] { - desc { |tcx| "determining object safety of trait `{}`", tcx.def_path_str(trait_id) } + query dyn_compatibility_violations(trait_id: DefId) -> &'tcx [DynCompatibilityViolation] { + desc { |tcx| "determining dyn-compatibility of trait `{}`", tcx.def_path_str(trait_id) } } - query is_object_safe(trait_id: DefId) -> bool { - desc { |tcx| "checking if trait `{}` is object safe", tcx.def_path_str(trait_id) } + query is_dyn_compatible(trait_id: DefId) -> bool { + desc { |tcx| "checking if trait `{}` is dyn-compatible", tcx.def_path_str(trait_id) } } /// Gets the ParameterEnvironment for a given item; this environment diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index c3295a9ce51c..caa86da8a858 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -556,8 +556,8 @@ pub enum SelectionError<'tcx> { /// (which for closures includes the "input" type params) and they /// didn't resolve. See `confirm_poly_trait_refs` for more. SignatureMismatch(Box>), - /// The trait pointed by `DefId` is not object safe. - TraitNotObjectSafe(DefId), + /// The trait pointed by `DefId` is dyn-incompatible. + TraitDynIncompatible(DefId), /// A given constant couldn't be evaluated. NotConstEvaluatable(NotConstEvaluatable), /// Exceeded the recursion depth during type projection. @@ -690,7 +690,7 @@ pub struct ImplSourceUserDefinedData<'tcx, N> { } #[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)] -pub enum ObjectSafetyViolation { +pub enum DynCompatibilityViolation { /// `Self: Sized` declared on the trait. SizedSelf(SmallVec<[Span; 1]>), @@ -711,11 +711,11 @@ pub enum ObjectSafetyViolation { GAT(Symbol, Span), } -impl ObjectSafetyViolation { +impl DynCompatibilityViolation { pub fn error_msg(&self) -> Cow<'static, str> { match self { - ObjectSafetyViolation::SizedSelf(_) => "it requires `Self: Sized`".into(), - ObjectSafetyViolation::SupertraitSelf(ref spans) => { + DynCompatibilityViolation::SizedSelf(_) => "it requires `Self: Sized`".into(), + DynCompatibilityViolation::SupertraitSelf(ref spans) => { if spans.iter().any(|sp| *sp != DUMMY_SP) { "it uses `Self` as a type parameter".into() } else { @@ -723,81 +723,87 @@ impl ObjectSafetyViolation { .into() } } - ObjectSafetyViolation::SupertraitNonLifetimeBinder(_) => { + DynCompatibilityViolation::SupertraitNonLifetimeBinder(_) => { "where clause cannot reference non-lifetime `for<...>` variables".into() } - ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod(_), _) => { + DynCompatibilityViolation::Method(name, MethodViolationCode::StaticMethod(_), _) => { format!("associated function `{name}` has no `self` parameter").into() } - ObjectSafetyViolation::Method( + DynCompatibilityViolation::Method( name, MethodViolationCode::ReferencesSelfInput(_), DUMMY_SP, ) => format!("method `{name}` references the `Self` type in its parameters").into(), - ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelfInput(_), _) => { - format!("method `{name}` references the `Self` type in this parameter").into() - } - ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelfOutput, _) => { - format!("method `{name}` references the `Self` type in its return type").into() - } - ObjectSafetyViolation::Method( + DynCompatibilityViolation::Method( + name, + MethodViolationCode::ReferencesSelfInput(_), + _, + ) => format!("method `{name}` references the `Self` type in this parameter").into(), + DynCompatibilityViolation::Method( + name, + MethodViolationCode::ReferencesSelfOutput, + _, + ) => format!("method `{name}` references the `Self` type in its return type").into(), + DynCompatibilityViolation::Method( name, MethodViolationCode::ReferencesImplTraitInTrait(_), _, ) => { format!("method `{name}` references an `impl Trait` type in its return type").into() } - ObjectSafetyViolation::Method(name, MethodViolationCode::AsyncFn, _) => { + DynCompatibilityViolation::Method(name, MethodViolationCode::AsyncFn, _) => { format!("method `{name}` is `async`").into() } - ObjectSafetyViolation::Method( + DynCompatibilityViolation::Method( name, MethodViolationCode::WhereClauseReferencesSelf, _, ) => format!("method `{name}` references the `Self` type in its `where` clause").into(), - ObjectSafetyViolation::Method(name, MethodViolationCode::Generic, _) => { + DynCompatibilityViolation::Method(name, MethodViolationCode::Generic, _) => { format!("method `{name}` has generic type parameters").into() } - ObjectSafetyViolation::Method( + DynCompatibilityViolation::Method( name, MethodViolationCode::UndispatchableReceiver(_), _, ) => format!("method `{name}`'s `self` parameter cannot be dispatched on").into(), - ObjectSafetyViolation::AssocConst(name, DUMMY_SP) => { + DynCompatibilityViolation::AssocConst(name, DUMMY_SP) => { format!("it contains associated `const` `{name}`").into() } - ObjectSafetyViolation::AssocConst(..) => "it contains this associated `const`".into(), - ObjectSafetyViolation::GAT(name, _) => { + DynCompatibilityViolation::AssocConst(..) => { + "it contains this associated `const`".into() + } + DynCompatibilityViolation::GAT(name, _) => { format!("it contains the generic associated type `{name}`").into() } } } - pub fn solution(&self) -> ObjectSafetyViolationSolution { + pub fn solution(&self) -> DynCompatibilityViolationSolution { match self { - ObjectSafetyViolation::SizedSelf(_) - | ObjectSafetyViolation::SupertraitSelf(_) - | ObjectSafetyViolation::SupertraitNonLifetimeBinder(..) => { - ObjectSafetyViolationSolution::None + DynCompatibilityViolation::SizedSelf(_) + | DynCompatibilityViolation::SupertraitSelf(_) + | DynCompatibilityViolation::SupertraitNonLifetimeBinder(..) => { + DynCompatibilityViolationSolution::None } - ObjectSafetyViolation::Method( + DynCompatibilityViolation::Method( name, MethodViolationCode::StaticMethod(Some((add_self_sugg, make_sized_sugg))), _, - ) => ObjectSafetyViolationSolution::AddSelfOrMakeSized { + ) => DynCompatibilityViolationSolution::AddSelfOrMakeSized { name: *name, add_self_sugg: add_self_sugg.clone(), make_sized_sugg: make_sized_sugg.clone(), }, - ObjectSafetyViolation::Method( + DynCompatibilityViolation::Method( name, MethodViolationCode::UndispatchableReceiver(Some(span)), _, - ) => ObjectSafetyViolationSolution::ChangeToRefSelf(*name, *span), - ObjectSafetyViolation::AssocConst(name, _) - | ObjectSafetyViolation::GAT(name, _) - | ObjectSafetyViolation::Method(name, ..) => { - ObjectSafetyViolationSolution::MoveToAnotherTrait(*name) + ) => DynCompatibilityViolationSolution::ChangeToRefSelf(*name, *span), + DynCompatibilityViolation::AssocConst(name, _) + | DynCompatibilityViolation::GAT(name, _) + | DynCompatibilityViolation::Method(name, ..) => { + DynCompatibilityViolationSolution::MoveToAnotherTrait(*name) } } } @@ -806,12 +812,12 @@ impl ObjectSafetyViolation { // When `span` comes from a separate crate, it'll be `DUMMY_SP`. Treat it as `None` so // diagnostics use a `note` instead of a `span_label`. match self { - ObjectSafetyViolation::SupertraitSelf(spans) - | ObjectSafetyViolation::SizedSelf(spans) - | ObjectSafetyViolation::SupertraitNonLifetimeBinder(spans) => spans.clone(), - ObjectSafetyViolation::AssocConst(_, span) - | ObjectSafetyViolation::GAT(_, span) - | ObjectSafetyViolation::Method(_, _, span) + DynCompatibilityViolation::SupertraitSelf(spans) + | DynCompatibilityViolation::SizedSelf(spans) + | DynCompatibilityViolation::SupertraitNonLifetimeBinder(spans) => spans.clone(), + DynCompatibilityViolation::AssocConst(_, span) + | DynCompatibilityViolation::GAT(_, span) + | DynCompatibilityViolation::Method(_, _, span) if *span != DUMMY_SP => { smallvec![*span] @@ -822,7 +828,7 @@ impl ObjectSafetyViolation { } #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub enum ObjectSafetyViolationSolution { +pub enum DynCompatibilityViolationSolution { None, AddSelfOrMakeSized { name: Symbol, @@ -833,11 +839,11 @@ pub enum ObjectSafetyViolationSolution { MoveToAnotherTrait(Symbol), } -impl ObjectSafetyViolationSolution { +impl DynCompatibilityViolationSolution { pub fn add_to(self, err: &mut Diag<'_, G>) { match self { - ObjectSafetyViolationSolution::None => {} - ObjectSafetyViolationSolution::AddSelfOrMakeSized { + DynCompatibilityViolationSolution::None => {} + DynCompatibilityViolationSolution::AddSelfOrMakeSized { name, add_self_sugg, make_sized_sugg, @@ -860,7 +866,7 @@ impl ObjectSafetyViolationSolution { Applicability::MaybeIncorrect, ); } - ObjectSafetyViolationSolution::ChangeToRefSelf(name, span) => { + DynCompatibilityViolationSolution::ChangeToRefSelf(name, span) => { err.span_suggestion( span, format!("consider changing method `{name}`'s `self` parameter to be `&self`"), @@ -868,14 +874,14 @@ impl ObjectSafetyViolationSolution { Applicability::MachineApplicable, ); } - ObjectSafetyViolationSolution::MoveToAnotherTrait(name) => { + DynCompatibilityViolationSolution::MoveToAnotherTrait(name) => { err.help(format!("consider moving `{name}` to another trait")); } } } } -/// Reasons a method might not be object-safe. +/// Reasons a method might not be dyn-compatible. #[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)] pub enum MethodViolationCode { /// e.g., `fn foo()` diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f017216489d0..df60950a6b25 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -527,8 +527,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> { self.trait_is_alias(trait_def_id) } - fn trait_is_object_safe(self, trait_def_id: DefId) -> bool { - self.is_object_safe(trait_def_id) + fn trait_is_dyn_compatible(self, trait_def_id: DefId) -> bool { + self.is_dyn_compatible(trait_def_id) } fn trait_is_fundamental(self, def_id: DefId) -> bool { diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index fc079592583e..92a975c028e5 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -301,7 +301,7 @@ impl FlagComputation { ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { self.add_args(slice::from_ref(&arg)); } - ty::PredicateKind::ObjectSafe(_def_id) => {} + ty::PredicateKind::DynCompatible(_def_id) => {} ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(uv)) => { self.add_const(uv); } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index bfef4c4c8c6b..b1c5ff50fdc8 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -50,7 +50,7 @@ pub enum ReifyReason { /// * A vtable entry is directly converted to a function call (e.g. creating a fn ptr from a /// method on a `dyn` object). /// * A function with `#[track_caller]` is converted to a function pointer - /// * If KCFI is enabled, creating a function pointer from a method on an object-safe trait. + /// * If KCFI is enabled, creating a function pointer from a method on a dyn-compatible trait. /// This includes the case of converting `::call`-like methods on closure-likes to function /// pointers. FnPtr, diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 534a8c99c5ad..fd4e8f1cd4e7 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -36,7 +36,7 @@ pub type PolyProjectionPredicate<'tcx> = ty::Binder<'tcx, ProjectionPredicate<'t /// A statement that can be proven by a trait solver. This includes things that may /// show up in where clauses, such as trait predicates and projection predicates, -/// and also things that are emitted as part of type checking such as `ObjectSafe` +/// and also things that are emitted as part of type checking such as `DynCompatible` /// predicate which is emitted when a type is coerced to a trait object. /// /// Use this rather than `PredicateKind`, whenever possible. @@ -147,7 +147,7 @@ impl<'tcx> Predicate<'tcx> { | PredicateKind::Clause(ClauseKind::TypeOutlives(_)) | PredicateKind::Clause(ClauseKind::Projection(_)) | PredicateKind::Clause(ClauseKind::ConstArgHasType(..)) - | PredicateKind::ObjectSafe(_) + | PredicateKind::DynCompatible(_) | PredicateKind::Subtype(_) | PredicateKind::Coerce(_) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(_)) @@ -647,7 +647,7 @@ impl<'tcx> Predicate<'tcx> { | PredicateKind::Coerce(..) | PredicateKind::Clause(ClauseKind::RegionOutlives(..)) | PredicateKind::Clause(ClauseKind::WellFormed(..)) - | PredicateKind::ObjectSafe(..) + | PredicateKind::DynCompatible(..) | PredicateKind::Clause(ClauseKind::TypeOutlives(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::ConstEquate(..) @@ -667,7 +667,7 @@ impl<'tcx> Predicate<'tcx> { | PredicateKind::Coerce(..) | PredicateKind::Clause(ClauseKind::RegionOutlives(..)) | PredicateKind::Clause(ClauseKind::WellFormed(..)) - | PredicateKind::ObjectSafe(..) + | PredicateKind::DynCompatible(..) | PredicateKind::Clause(ClauseKind::TypeOutlives(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::ConstEquate(..) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 5b4ee2791f8d..8fd4c30457f8 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -3088,8 +3088,8 @@ define_print! { } ty::PredicateKind::Subtype(predicate) => p!(print(predicate)), ty::PredicateKind::Coerce(predicate) => p!(print(predicate)), - ty::PredicateKind::ObjectSafe(trait_def_id) => { - p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe") + ty::PredicateKind::DynCompatible(trait_def_id) => { + p!("the trait `", print_def_path(trait_def_id, &[]), "` is dyn-compatible") } ty::PredicateKind::ConstEquate(c1, c2) => { p!("the constant `", print(c1), "` equals `", print(c2), "`") diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 321b51289fb0..0a917120b3ba 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1602,7 +1602,7 @@ impl<'tcx> ExplicitSelf<'tcx> { /// `Other`. /// This is mainly used to require the arbitrary_self_types feature /// in the case of `Other`, to improve error messages in the common cases, - /// and to make `Other` non-object-safe. + /// and to make `Other` dyn-incompatible. /// /// Examples: /// diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 0cdd237dc003..d21bbce2ae24 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -120,7 +120,7 @@ //! #### Unsizing Casts //! A subtle way of introducing use edges is by casting to a trait object. //! Since the resulting fat-pointer contains a reference to a vtable, we need to -//! instantiate all object-safe methods of the trait, as we need to store +//! instantiate all dyn-compatible methods of the trait, as we need to store //! pointers to these functions even if they never get called anywhere. This can //! be seen as a special case of taking a function reference. //! diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index 520afbeb645c..cebeef76bfc0 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -639,8 +639,8 @@ where ty::Dynamic(bounds, ..) => bounds, }; - // Do not consider built-in object impls for non-object-safe types. - if bounds.principal_def_id().is_some_and(|def_id| !cx.trait_is_object_safe(def_id)) { + // Do not consider built-in object impls for dyn-incompatible types. + if bounds.principal_def_id().is_some_and(|def_id| !cx.trait_is_dyn_compatible(def_id)) { return; } diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index 12ad0724b5cb..270d50b5af4b 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -423,8 +423,8 @@ where ty::PredicateKind::Coerce(predicate) => { self.compute_coerce_goal(Goal { param_env, predicate }) } - ty::PredicateKind::ObjectSafe(trait_def_id) => { - self.compute_object_safe_goal(trait_def_id) + ty::PredicateKind::DynCompatible(trait_def_id) => { + self.compute_dyn_compatible_goal(trait_def_id) } ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { self.compute_well_formed_goal(Goal { param_env, predicate: arg }) diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index 536b502136ad..309ab7f28d15 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -111,8 +111,8 @@ where } } - fn compute_object_safe_goal(&mut self, trait_def_id: I::DefId) -> QueryResult { - if self.cx().trait_is_object_safe(trait_def_id) { + fn compute_dyn_compatible_goal(&mut self, trait_def_id: I::DefId) -> QueryResult { + if self.cx().trait_is_dyn_compatible(trait_def_id) { self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } else { Err(NoSolution) diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 781ca127e151..703e88d1339a 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -832,8 +832,8 @@ where let cx = self.cx(); let Goal { predicate: (a_ty, _), .. } = goal; - // Can only unsize to an object-safe trait. - if b_data.principal_def_id().is_some_and(|def_id| !cx.trait_is_object_safe(def_id)) { + // Can only unsize to an dyn-compatible trait. + if b_data.principal_def_id().is_some_and(|def_id| !cx.trait_is_dyn_compatible(def_id)) { return Err(NoSolution); } diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs index 80a9ba79c285..5f7184a42407 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs @@ -475,7 +475,7 @@ fn implemented_method<'tcx>( } else { return None; }; - let vtable_possible = - traits::is_vtable_safe_method(tcx, trait_id, trait_method) && tcx.is_object_safe(trait_id); + let vtable_possible = traits::is_vtable_safe_method(tcx, trait_id, trait_method) + && tcx.is_dyn_compatible(trait_id); vtable_possible.then_some((trait_ref, method_id, ancestor)) } diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index e54ab1f7e24c..271f46ea9433 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -632,8 +632,8 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> { PredicateKind::Clause(clause_kind) => { stable_mir::ty::PredicateKind::Clause(clause_kind.stable(tables)) } - PredicateKind::ObjectSafe(did) => { - stable_mir::ty::PredicateKind::ObjectSafe(tables.trait_def(*did)) + PredicateKind::DynCompatible(did) => { + stable_mir::ty::PredicateKind::DynCompatible(tables.trait_def(*did)) } PredicateKind::Subtype(subtype_predicate) => { stable_mir::ty::PredicateKind::SubType(subtype_predicate.stable(tables)) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 19e2679ae4da..b3a913c4c5b8 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -37,7 +37,7 @@ use super::{ }; use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::infer::TyCategory; -use crate::error_reporting::traits::report_object_safety_error; +use crate::error_reporting::traits::report_dyn_incompatibility; use crate::errors::{ AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, }; @@ -46,7 +46,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _; use crate::traits::{ MismatchedProjectionTypes, NormalizeExt, Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt, Overflow, PredicateObligation, SelectionError, SignatureMismatch, - TraitNotObjectSafe, elaborate, + TraitDynIncompatible, elaborate, }; impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { @@ -547,9 +547,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ) } - ty::PredicateKind::ObjectSafe(trait_def_id) => { - let violations = self.tcx.object_safety_violations(trait_def_id); - report_object_safety_error(self.tcx, span, None, trait_def_id, violations) + ty::PredicateKind::DynCompatible(trait_def_id) => { + let violations = self.tcx.dyn_compatibility_violations(trait_def_id); + report_dyn_incompatibility(self.tcx, span, None, trait_def_id, violations) } ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => { @@ -624,9 +624,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { def_id, ), - TraitNotObjectSafe(did) => { - let violations = self.tcx.object_safety_violations(did); - report_object_safety_error(self.tcx, span, None, did, violations) + TraitDynIncompatible(did) => { + let violations = self.tcx.dyn_compatibility_violations(did); + report_dyn_incompatibility(self.tcx, span, None, did, violations) } SelectionError::NotConstEvaluatable(NotConstEvaluatable::MentionsInfer) => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index b229499a9f4c..109bae10b54c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -12,8 +12,8 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, LangItem}; use rustc_infer::traits::{ - ObjectSafetyViolation, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation, - SelectionError, + DynCompatibilityViolation, Obligation, ObligationCause, ObligationCauseCode, + PredicateObligation, SelectionError, }; use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths}; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -406,12 +406,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } -pub fn report_object_safety_error<'tcx>( +pub fn report_dyn_incompatibility<'tcx>( tcx: TyCtxt<'tcx>, span: Span, hir_id: Option, trait_def_id: DefId, - violations: &[ObjectSafetyViolation], + violations: &[DynCompatibilityViolation], ) -> Diag<'tcx> { let trait_str = tcx.def_path_str(trait_def_id); let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node { @@ -449,12 +449,12 @@ pub fn report_object_safety_error<'tcx>( let mut multi_span = vec![]; let mut messages = vec![]; for violation in violations { - if let ObjectSafetyViolation::SizedSelf(sp) = &violation + if let DynCompatibilityViolation::SizedSelf(sp) = &violation && !sp.is_empty() { // Do not report `SizedSelf` without spans pointing at `SizedSelf` obligations // with a `Span`. - reported_violations.insert(ObjectSafetyViolation::SizedSelf(vec![].into())); + reported_violations.insert(DynCompatibilityViolation::SizedSelf(vec![].into())); } if reported_violations.insert(violation.clone()) { let spans = violation.spans(); @@ -481,9 +481,10 @@ pub fn report_object_safety_error<'tcx>( for (span, msg) in iter::zip(multi_span, messages) { note_span.push_span_label(span, msg); } + // FIXME(dyn_compat_renaming): Update the URL. err.span_note( note_span, - "for a trait to be \"object safe\" it needs to allow building a vtable to allow the call \ + "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 \ ", ); diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index fc15f5b5906f..c6e3ba3c9573 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -275,7 +275,7 @@ fn fulfillment_error_for_no_solution<'tcx>( FulfillmentErrorCode::Subtype(expected_found, TypeError::Sorts(expected_found)) } ty::PredicateKind::Clause(_) - | ty::PredicateKind::ObjectSafe(_) + | ty::PredicateKind::DynCompatible(_) | ty::PredicateKind::Ambiguous => { FulfillmentErrorCode::Select(SelectionError::Unimplemented) } diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index f68e05833079..12aeee0d02fe 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -802,7 +802,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { | ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..)) | ty::PredicateKind::NormalizesTo(..) | ty::PredicateKind::AliasRelate(..) - | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::DynCompatible(..) | ty::PredicateKind::Subtype(..) // FIXME(generic_const_exprs): you can absolutely add this as a where clauses | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs similarity index 94% rename from compiler/rustc_trait_selection/src/traits/object_safety.rs rename to compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index b6169f8508d5..d5d7681a8d60 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -28,43 +28,43 @@ use tracing::{debug, instrument}; use super::elaborate; use crate::infer::TyCtxtInferExt; -pub use crate::traits::ObjectSafetyViolation; +pub use crate::traits::DynCompatibilityViolation; use crate::traits::query::evaluate_obligation::InferCtxtExt; use crate::traits::{MethodViolationCode, Obligation, ObligationCause, util}; -/// Returns the object safety violations that affect HIR ty lowering. +/// Returns the dyn-compatibility violations that affect HIR ty lowering. /// /// Currently that is `Self` in supertraits. This is needed -/// because `object_safety_violations` can't be used during +/// because `dyn_compatibility_violations` can't be used during /// type collection. -#[instrument(level = "debug", skip(tcx))] -pub fn hir_ty_lowering_object_safety_violations( +#[instrument(level = "debug", skip(tcx), ret)] +pub fn hir_ty_lowering_dyn_compatibility_violations( tcx: TyCtxt<'_>, trait_def_id: DefId, -) -> Vec { +) -> Vec { debug_assert!(tcx.generics_of(trait_def_id).has_self); - let violations = tcx - .supertrait_def_ids(trait_def_id) + tcx.supertrait_def_ids(trait_def_id) .map(|def_id| predicates_reference_self(tcx, def_id, true)) .filter(|spans| !spans.is_empty()) - .map(ObjectSafetyViolation::SupertraitSelf) - .collect(); - debug!(?violations); - violations + .map(DynCompatibilityViolation::SupertraitSelf) + .collect() } -fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &'_ [ObjectSafetyViolation] { +fn dyn_compatibility_violations( + tcx: TyCtxt<'_>, + trait_def_id: DefId, +) -> &'_ [DynCompatibilityViolation] { debug_assert!(tcx.generics_of(trait_def_id).has_self); - debug!("object_safety_violations: {:?}", trait_def_id); + debug!("dyn_compatibility_violations: {:?}", trait_def_id); tcx.arena.alloc_from_iter( tcx.supertrait_def_ids(trait_def_id) - .flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id)), + .flat_map(|def_id| dyn_compatibility_violations_for_trait(tcx, def_id)), ) } -fn is_object_safe(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool { - tcx.object_safety_violations(trait_def_id).is_empty() +fn is_dyn_compatible(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool { + tcx.dyn_compatibility_violations(trait_def_id).is_empty() } /// We say a method is *vtable safe* if it can be invoked on a trait @@ -82,34 +82,35 @@ pub fn is_vtable_safe_method(tcx: TyCtxt<'_>, trait_def_id: DefId, method: ty::A virtual_call_violations_for_method(tcx, trait_def_id, method).is_empty() } -fn object_safety_violations_for_trait( +#[instrument(level = "debug", skip(tcx), ret)] +fn dyn_compatibility_violations_for_trait( tcx: TyCtxt<'_>, trait_def_id: DefId, -) -> Vec { +) -> Vec { // Check assoc items for violations. let mut violations: Vec<_> = tcx .associated_items(trait_def_id) .in_definition_order() - .flat_map(|&item| object_safety_violations_for_assoc_item(tcx, trait_def_id, item)) + .flat_map(|&item| dyn_compatibility_violations_for_assoc_item(tcx, trait_def_id, item)) .collect(); // Check the trait itself. if trait_has_sized_self(tcx, trait_def_id) { // We don't want to include the requirement from `Sized` itself to be `Sized` in the list. let spans = get_sized_bounds(tcx, trait_def_id); - violations.push(ObjectSafetyViolation::SizedSelf(spans)); + violations.push(DynCompatibilityViolation::SizedSelf(spans)); } let spans = predicates_reference_self(tcx, trait_def_id, false); if !spans.is_empty() { - violations.push(ObjectSafetyViolation::SupertraitSelf(spans)); + violations.push(DynCompatibilityViolation::SupertraitSelf(spans)); } let spans = bounds_reference_self(tcx, trait_def_id); if !spans.is_empty() { - violations.push(ObjectSafetyViolation::SupertraitSelf(spans)); + violations.push(DynCompatibilityViolation::SupertraitSelf(spans)); } let spans = super_predicates_have_non_lifetime_binders(tcx, trait_def_id); if !spans.is_empty() { - violations.push(ObjectSafetyViolation::SupertraitNonLifetimeBinder(spans)); + violations.push(DynCompatibilityViolation::SupertraitNonLifetimeBinder(spans)); } if violations.is_empty() { @@ -120,11 +121,6 @@ fn object_safety_violations_for_trait( } } - debug!( - "object_safety_violations_for_trait(trait_def_id={:?}) = {:?}", - trait_def_id, violations - ); - violations } @@ -296,13 +292,13 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool { }) } -/// Returns `Some(_)` if this item makes the containing trait not object safe. +/// Returns `Some(_)` if this item makes the containing trait dyn-incompatible. #[instrument(level = "debug", skip(tcx), ret)] -pub fn object_safety_violations_for_assoc_item( +pub fn dyn_compatibility_violations_for_assoc_item( tcx: TyCtxt<'_>, trait_def_id: DefId, item: ty::AssocItem, -) -> Vec { +) -> Vec { // Any item that has a `Self : Sized` requisite is otherwise // exempt from the regulations. if tcx.generics_require_sized_self(item.def_id) { @@ -310,10 +306,10 @@ pub fn object_safety_violations_for_assoc_item( } match item.kind { - // Associated consts are never object safe, as they can't have `where` bounds yet at all, + // Associated consts are never dyn-compatible, as they can't have `where` bounds yet at all, // and associated const bounds in trait objects aren't a thing yet either. ty::AssocKind::Const => { - vec![ObjectSafetyViolation::AssocConst(item.name, item.ident(tcx).span)] + vec![DynCompatibilityViolation::AssocConst(item.name, item.ident(tcx).span)] } ty::AssocKind::Fn => virtual_call_violations_for_method(tcx, trait_def_id, item) .into_iter() @@ -330,16 +326,16 @@ pub fn object_safety_violations_for_assoc_item( _ => item.ident(tcx).span, }; - ObjectSafetyViolation::Method(item.name, v, span) + DynCompatibilityViolation::Method(item.name, v, span) }) .collect(), - // Associated types can only be object safe if they have `Self: Sized` bounds. + // Associated types can only be dyn-compatible if they have `Self: Sized` bounds. ty::AssocKind::Type => { if !tcx.features().generic_associated_types_extended && !tcx.generics_of(item.def_id).is_own_empty() && !item.is_impl_trait_in_trait() { - vec![ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span)] + vec![DynCompatibilityViolation::GAT(item.name, item.ident(tcx).span)] } else { // We will permit associated types if they are explicitly mentioned in the trait object. // We can't check this here, as here we only check if it is guaranteed to not be possible. @@ -351,8 +347,8 @@ pub fn object_safety_violations_for_assoc_item( /// Returns `Some(_)` if this method cannot be called on a trait /// object; this does not necessarily imply that the enclosing trait -/// is not object safe, because the method might have a where clause -/// `Self:Sized`. +/// is dyn-incompatible, because the method might have a where clause +/// `Self: Sized`. fn virtual_call_violations_for_method<'tcx>( tcx: TyCtxt<'tcx>, trait_def_id: DefId, @@ -932,8 +928,8 @@ fn contains_illegal_impl_trait_in_trait<'tcx>( pub(crate) fn provide(providers: &mut Providers) { *providers = Providers { - object_safety_violations, - is_object_safe, + dyn_compatibility_violations, + is_dyn_compatible, generics_require_sized_self, ..*providers }; diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index fcd0936c055c..33b8cf037017 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -363,7 +363,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> { | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_)) | ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..)) | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) - | ty::PredicateKind::ObjectSafe(_) + | ty::PredicateKind::DynCompatible(_) | ty::PredicateKind::Subtype(_) | ty::PredicateKind::Coerce(_) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) @@ -418,8 +418,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> { ) } - ty::PredicateKind::ObjectSafe(trait_def_id) => { - if !self.selcx.tcx().is_object_safe(trait_def_id) { + ty::PredicateKind::DynCompatible(trait_def_id) => { + if !self.selcx.tcx().is_dyn_compatible(trait_def_id) { ProcessResult::Error(FulfillmentErrorCode::Select(Unimplemented)) } else { ProcessResult::Changed(vec![]) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 61592d477847..655bef0bab74 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -5,11 +5,11 @@ pub mod auto_trait; pub(crate) mod coherence; pub mod const_evaluatable; +mod dyn_compatibility; mod engine; mod fulfill; pub mod misc; pub mod normalize; -mod object_safety; pub mod outlives_bounds; pub mod project; pub mod query; @@ -43,13 +43,13 @@ pub use self::coherence::{ InCrate, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams, add_placeholder_note, orphan_check_trait_ref, overlapping_impls, }; +pub use self::dyn_compatibility::{ + DynCompatibilityViolation, dyn_compatibility_violations_for_assoc_item, + hir_ty_lowering_dyn_compatibility_violations, is_vtable_safe_method, +}; pub use self::engine::{ObligationCtxt, TraitEngineExt}; pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation}; pub use self::normalize::NormalizeExt; -pub use self::object_safety::{ - ObjectSafetyViolation, hir_ty_lowering_object_safety_violations, is_vtable_safe_method, - object_safety_violations_for_assoc_item, -}; pub use self::project::{normalize_inherent_projection, normalize_projection_ty}; pub use self::select::{ EvaluationCache, EvaluationResult, IntercrateAmbiguityCause, OverflowError, SelectionCache, @@ -593,7 +593,7 @@ fn is_impossible_associated_item( } pub fn provide(providers: &mut Providers) { - object_safety::provide(providers); + dyn_compatibility::provide(providers); vtable::provide(providers); *providers = Providers { specialization_graph_of: specialize::specialization_graph_provider, diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs index 3d9dc1a8d4d5..bab038af9ed2 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs @@ -113,7 +113,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>( | ty::PredicateKind::Subtype(..) | ty::PredicateKind::Coerce(..) | ty::PredicateKind::Clause(ty::ClauseKind::Projection(..)) - | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::DynCompatible(..) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::Ambiguous @@ -217,7 +217,7 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>( | ty::PredicateKind::Subtype(..) | ty::PredicateKind::Coerce(..) | ty::PredicateKind::Clause(ty::ClauseKind::Projection(..)) - | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::DynCompatible(..) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::Ambiguous diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index e5f1d5c36daf..084b61115dbc 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -883,7 +883,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if let Some(principal) = data.principal() { if !self.infcx.tcx.features().object_safe_for_dispatch { principal.with_self_ty(self.tcx(), self_ty) - } else if self.tcx().is_object_safe(principal.def_id()) { + } else if self.tcx().is_dyn_compatible(principal.def_id()) { principal.with_self_ty(self.tcx(), self_ty) } else { return; diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index d15acd51c86e..5141e969608e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -30,7 +30,7 @@ use crate::traits::util::{self, closure_trait_ref_and_return_type}; use crate::traits::{ ImplDerivedCause, ImplSource, ImplSourceUserDefinedData, Normalized, Obligation, ObligationCause, PolyTraitObligation, PredicateObligation, Selection, SelectionError, - SignatureMismatch, TraitNotObjectSafe, TraitObligation, Unimplemented, + SignatureMismatch, TraitDynIncompatible, TraitObligation, Unimplemented, }; impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { @@ -630,7 +630,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation.cause.span, "GATs in trait object shouldn't have been considered", ); - return Err(SelectionError::TraitNotObjectSafe(trait_predicate.trait_ref.def_id)); + return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id)); } // This maybe belongs in wf, but that can't (doesn't) handle @@ -1187,11 +1187,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ImplSource::Builtin(BuiltinImplSource::Misc, obligations) } - // `T` -> `Trait` + // `T` -> `dyn Trait` (_, &ty::Dynamic(data, r, ty::Dyn)) => { let mut object_dids = data.auto_traits().chain(data.principal_def_id()); - if let Some(did) = object_dids.find(|did| !tcx.is_object_safe(*did)) { - return Err(TraitNotObjectSafe(did)); + if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) { + return Err(TraitDynIncompatible(did)); } let predicate_to_obligation = |predicate| { diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index cbc17a058f6d..20b540831aa5 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -772,8 +772,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ok(EvaluatedToOkModuloRegions) } - ty::PredicateKind::ObjectSafe(trait_def_id) => { - if self.tcx().is_object_safe(trait_def_id) { + ty::PredicateKind::DynCompatible(trait_def_id) => { + if self.tcx().is_dyn_compatible(trait_def_id) { Ok(EvaluatedToOk) } else { Ok(EvaluatedToErr) diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 354f3034b8ac..7e140ecfee08 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -838,7 +838,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { self.cause(ObligationCauseCode::WellFormed(None)), self.recursion_depth, self.param_env, - ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)), + ty::Binder::dummy(ty::PredicateKind::DynCompatible(principal)), )); } } diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index c5ebc2d26a79..f01a12b0a00c 100644 --- a/compiler/rustc_traits/src/normalize_erasing_regions.rs +++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs @@ -59,7 +59,7 @@ fn not_outlives_predicate(p: ty::Predicate<'_>) -> bool { | ty::PredicateKind::NormalizesTo(..) | ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..)) - | ty::PredicateKind::ObjectSafe(..) + | ty::PredicateKind::DynCompatible(..) | ty::PredicateKind::Subtype(..) | ty::PredicateKind::Coerce(..) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 8dec2133a45d..b2ac67efef61 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -255,7 +255,7 @@ pub trait Interner: fn trait_is_alias(self, trait_def_id: Self::DefId) -> bool; - fn trait_is_object_safe(self, trait_def_id: Self::DefId) -> bool; + fn trait_is_dyn_compatible(self, trait_def_id: Self::DefId) -> bool; fn trait_is_fundamental(self, def_id: Self::DefId) -> bool; diff --git a/compiler/rustc_type_ir/src/predicate_kind.rs b/compiler/rustc_type_ir/src/predicate_kind.rs index c8a210285883..a5148a5e6daf 100644 --- a/compiler/rustc_type_ir/src/predicate_kind.rs +++ b/compiler/rustc_type_ir/src/predicate_kind.rs @@ -46,8 +46,8 @@ pub enum PredicateKind { /// Prove a clause Clause(ClauseKind), - /// Trait must be object-safe. - ObjectSafe(I::DefId), + /// Trait must be dyn-compatible. + DynCompatible(I::DefId), /// `T1 <: T2` /// @@ -128,8 +128,8 @@ impl fmt::Debug for PredicateKind { PredicateKind::Clause(a) => a.fmt(f), PredicateKind::Subtype(pair) => pair.fmt(f), PredicateKind::Coerce(pair) => pair.fmt(f), - PredicateKind::ObjectSafe(trait_def_id) => { - write!(f, "ObjectSafe({trait_def_id:?})") + PredicateKind::DynCompatible(trait_def_id) => { + write!(f, "DynCompatible({trait_def_id:?})") } PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({c1:?}, {c2:?})"), PredicateKind::Ambiguous => write!(f, "Ambiguous"), diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index b3dc4d9bb820..9e6fbc8ea0c1 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -1420,7 +1420,7 @@ pub struct GenericPredicates { #[derive(Clone, Debug, Eq, PartialEq, Serialize)] pub enum PredicateKind { Clause(ClauseKind), - ObjectSafe(TraitDef), + DynCompatible(TraitDef), SubType(SubtypePredicate), Coerce(CoercePredicate), ConstEquate(TyConst, TyConst), diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 31710bc014af..300745bcbaca 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1444,7 +1444,7 @@ impl Trait { tcx.trait_def(self.def_id).safety } pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool { - tcx.is_object_safe(self.def_id) + tcx.is_dyn_compatible(self.def_id) } } diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr index ef551cbea3e6..0c3826c56655 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr @@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn f<'a>(arg : Box = &'a ()>>) {} | ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/invalid_const_in_lifetime_position.rs:2:10 | LL | trait X { diff --git a/tests/rustdoc-ui/issues/issue-105742.stderr b/tests/rustdoc-ui/issues/issue-105742.stderr index 0f01bc59759d..0f09d637f38f 100644 --- a/tests/rustdoc-ui/issues/issue-105742.stderr +++ b/tests/rustdoc-ui/issues/issue-105742.stderr @@ -300,7 +300,7 @@ error[E0038]: the trait `SVec` cannot be made into an object LL | pub fn next<'a, T>(s: &'a mut dyn SVec) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-105742.rs:14:17 | LL | pub trait SVec: Index< diff --git a/tests/ui/associated-consts/associated-const-in-trait.stderr b/tests/ui/associated-consts/associated-const-in-trait.stderr index 88360cd2dd5c..b40c10057972 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.stderr +++ b/tests/ui/associated-consts/associated-const-in-trait.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | impl dyn Trait { | ^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/associated-const-in-trait.rs:4:11 | LL | trait Trait { @@ -19,7 +19,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | const fn n() -> usize { Self::N } | ^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/associated-const-in-trait.rs:4:11 | LL | trait Trait { diff --git a/tests/ui/associated-item/issue-48027.stderr b/tests/ui/associated-item/issue-48027.stderr index 45ea419336b2..2883259ce2fd 100644 --- a/tests/ui/associated-item/issue-48027.stderr +++ b/tests/ui/associated-item/issue-48027.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | impl dyn Bar {} | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-48027.rs:2:11 | LL | trait Bar { diff --git a/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr b/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr index 13be2162c52b..bec60187e425 100644 --- a/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr +++ b/tests/ui/associated-type-bounds/suggest-assoc-ty-bound-on-eq-bound.stderr @@ -5,7 +5,7 @@ LL | fn f(_: impl Trait) {} | ^^^^^^^^ `Copy` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 error[E0225]: only auto traits can be used as additional traits in a trait object --> $DIR/suggest-assoc-ty-bound-on-eq-bound.rs:10:42 @@ -24,7 +24,7 @@ error[E0038]: the trait `Eq` cannot be made into an object LL | fn g(_: impl Trait) {} | ^^^^^^^^^^^^^^^^^^^^ `Eq` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter diff --git a/tests/ui/async-await/async-fn/dyn-pos.stderr b/tests/ui/async-await/async-fn/dyn-pos.stderr index 3bef5a278971..78e915d49e78 100644 --- a/tests/ui/async-await/async-fn/dyn-pos.stderr +++ b/tests/ui/async-await/async-fn/dyn-pos.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object LL | fn foo(x: &dyn async Fn()) {} | ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture` @@ -19,7 +19,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object LL | fn foo(x: &dyn async Fn()) {} | ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture` @@ -35,7 +35,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object LL | fn foo(x: &dyn async Fn()) {} | ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture` @@ -51,7 +51,7 @@ error[E0038]: the trait `AsyncFn` cannot be made into an object LL | fn foo(x: &dyn async Fn()) {} | ^^^^^^^^^^^^^^ `AsyncFn` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture` diff --git a/tests/ui/async-await/in-trait/object-safety.stderr b/tests/ui/async-await/in-trait/object-safety.stderr index f45e6a2c8bb5..8e73abab9335 100644 --- a/tests/ui/async-await/in-trait/object-safety.stderr +++ b/tests/ui/async-await/in-trait/object-safety.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let x: &dyn Foo = todo!(); | ^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety.rs:5:14 | LL | trait Foo { diff --git a/tests/ui/async-await/inference_var_self_argument.stderr b/tests/ui/async-await/inference_var_self_argument.stderr index f94ae2a27c33..7bfa9be66dd3 100644 --- a/tests/ui/async-await/inference_var_self_argument.stderr +++ b/tests/ui/async-await/inference_var_self_argument.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | async fn foo(self: &dyn Foo) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/inference_var_self_argument.rs:5:14 | LL | trait Foo { diff --git a/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr b/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr index 1dcc30ee652d..ce65e079ab45 100644 --- a/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr +++ b/tests/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object LL | impl NotObjectSafe for dyn NotObjectSafe { } | ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:6:43 | LL | trait NotObjectSafe { fn eq(&self, other: Self); } diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_object_safety.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_object_safety.stderr index ba38f63d5df7..831b40887ac4 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_object_safety.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_object_safety.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `ConstParamTy_` cannot be made into an object LL | fn foo(a: &dyn ConstParamTy_) {} | ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/cmp.rs:LL:COL | = 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 LL | fn bar(a: &dyn UnsizedConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter diff --git a/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr b/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr index 37e09a075fe3..9a75f372879f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr @@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn f2<'a>(arg: Box = &'a ()>>) {} | ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-102768.rs:5:10 | LL | trait X { diff --git a/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr b/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr index 31f271cc7ba3..fb57da42bb29 100644 --- a/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr +++ b/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn use_dyn(v: &dyn Foo) { | ^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-err-ret.rs:8:8 | LL | trait Foo { @@ -22,7 +22,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | v.test(); | ^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-err-ret.rs:8:8 | LL | trait Foo { diff --git a/tests/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr b/tests/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr index fde5d3ce7725..831bda712954 100644 --- a/tests/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr +++ b/tests/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn use_dyn(v: &dyn Foo) { | ^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-err-where-bounds.rs:8:8 | LL | trait Foo { @@ -20,7 +20,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | v.test(); | ^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-err-where-bounds.rs:8:8 | LL | trait Foo { diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr index 9095948d22b8..82e251f1306c 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr @@ -24,7 +24,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | trait Trait { | ^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/not_wf_param_in_rpitit.rs:11:14 | LL | trait Trait { @@ -47,7 +47,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/not_wf_param_in_rpitit.rs:11:14 | LL | trait Trait { @@ -78,7 +78,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/not_wf_param_in_rpitit.rs:11:14 | LL | trait Trait { diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.rs b/tests/ui/consts/const_refs_to_static-ice-121413.rs index 8fc3912efd08..5afe80d9f8de 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.rs +++ b/tests/ui/consts/const_refs_to_static-ice-121413.rs @@ -12,7 +12,7 @@ const REF_INTERIOR_MUT: &usize = { //~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time //~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| HELP if this is an object-safe trait, use `dyn` + //~| HELP if this is a dyn-compatible trait, use `dyn` //~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)` //~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)` unsafe { &*(&FOO as *const _ as *const usize) } diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index fbe32a70293a..48e6ee333466 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -18,7 +18,7 @@ LL | static FOO: Sync = AtomicUsize::new(0); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | static FOO: dyn Sync = AtomicUsize::new(0); | +++ diff --git a/tests/ui/did_you_mean/bad-assoc-ty.stderr b/tests/ui/did_you_mean/bad-assoc-ty.stderr index b349332bcb9c..41039ae82a6f 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.stderr @@ -182,7 +182,7 @@ LL | type H = Fn(u8) -> (u8)::Output; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | type H = (u8)>::Output; | ++++ + diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr index a33a8c776c8e..8ef0d1784444 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr @@ -27,7 +27,7 @@ LL | let _: &Copy + 'static; | ^^^^^ `Copy` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 error: aborting due to 3 previous errors diff --git a/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr b/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr index 711bfa188ecd..b930815d13bb 100644 --- a/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr +++ b/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr @@ -11,7 +11,7 @@ note: the lint level is defined here | LL | #[deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn function(x: &dyn SomeTrait, y: Box) { | +++ @@ -24,7 +24,7 @@ LL | fn function(x: &SomeTrait, y: Box) { | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn function(x: &SomeTrait, y: Box) { | +++ @@ -37,7 +37,7 @@ LL | let _x: &SomeTrait = todo!(); | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let _x: &dyn SomeTrait = todo!(); | +++ diff --git a/tests/ui/dyn-keyword/dyn-angle-brackets.stderr b/tests/ui/dyn-keyword/dyn-angle-brackets.stderr index 41298cc73c81..6a29dab04868 100644 --- a/tests/ui/dyn-keyword/dyn-angle-brackets.stderr +++ b/tests/ui/dyn-keyword/dyn-angle-brackets.stderr @@ -11,7 +11,7 @@ note: the lint level is defined here | LL | #![deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | ::fmt(self, f) | +++ diff --git a/tests/ui/error-codes/E0038.stderr b/tests/ui/error-codes/E0038.stderr index 6e8eaab8ddf4..54b489c655f6 100644 --- a/tests/ui/error-codes/E0038.stderr +++ b/tests/ui/error-codes/E0038.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | fn call_foo(x: Box) { | ^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/E0038.rs:2:22 | LL | trait Trait { @@ -19,7 +19,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | let y = x.foo(); | ^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/E0038.rs:2:22 | LL | trait Trait { diff --git a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr index 68d8adc5a401..24f00cfa6be9 100644 --- a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr +++ b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr @@ -7,7 +7,7 @@ LL | let _ = MyIterator::next; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let _ = ::next; | ++++ + diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr index 00b8c0eef989..28caaf8356f8 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr @@ -7,7 +7,7 @@ LL | fn ptr(self: Ptr); LL | Ptr(Box::new(4)) as Ptr; | ^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18 | LL | trait Trait { @@ -25,7 +25,7 @@ LL | fn ptr(self: Ptr); LL | Ptr(Box::new(4)) as Ptr; | ^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18 | LL | trait Trait { diff --git a/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr index d76c697fe737..fd5ed9c40f7a 100644 --- a/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr +++ b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `NonObjectSafe1` cannot be made into an object LL | fn takes_non_object_safe_ref(obj: &dyn NonObjectSafe1) { | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23 | LL | trait NonObjectSafe1: Sized {} @@ -18,7 +18,7 @@ error[E0038]: the trait `NonObjectSafe2` cannot be made into an object LL | fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 { | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe2` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-object_safe_for_dispatch.rs:7:8 | LL | trait NonObjectSafe2 { @@ -40,7 +40,7 @@ error[E0038]: the trait `NonObjectSafe3` cannot be made into an object LL | fn takes_non_object_safe_box(obj: Box) { | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8 | LL | trait NonObjectSafe3 { @@ -55,7 +55,7 @@ error[E0038]: the trait `NonObjectSafe4` cannot be made into an object LL | fn return_non_object_safe_rc() -> std::rc::Rc { | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22 | LL | trait NonObjectSafe4 { @@ -70,7 +70,7 @@ error[E0038]: the trait `NonObjectSafe1` cannot be made into an object LL | impl Trait for dyn NonObjectSafe1 {} | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23 | LL | trait NonObjectSafe1: Sized {} diff --git a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr index 4a56b20eb59b..867f55b0deea 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr @@ -42,7 +42,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn _f(arg : Box X = &'a [u32]>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:2:8 | LL | trait X { diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr index 37491ca12b00..34642f8fdc6c 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn f(_arg : Box Foo = &'a ()>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/gat-in-trait-path.rs:10:10 | LL | trait Foo { @@ -22,7 +22,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | f(Box::new(foo)); | ^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/gat-in-trait-path.rs:10:10 | LL | trait Foo { @@ -40,7 +40,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | f(Box::new(foo)); | ^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/gat-in-trait-path.rs:10:10 | LL | trait Foo { diff --git a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr index 9d8e91c02ca3..97b7019b3851 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr +++ b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr @@ -129,7 +129,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn foo<'a>(arg: Box>) {} | ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 | LL | trait X { @@ -194,7 +194,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn bar<'a>(arg: Box>) {} | ^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 | LL | trait X { diff --git a/tests/ui/generic-associated-types/issue-67510-pass.base.stderr b/tests/ui/generic-associated-types/issue-67510-pass.base.stderr index f39d00554282..cac8010018ec 100644 --- a/tests/ui/generic-associated-types/issue-67510-pass.base.stderr +++ b/tests/ui/generic-associated-types/issue-67510-pass.base.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn _func1<'a>(_x: Box=&'a ()>>) {} | ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-67510-pass.rs:9:10 | LL | trait X { diff --git a/tests/ui/generic-associated-types/issue-67510.stderr b/tests/ui/generic-associated-types/issue-67510.stderr index d25c5b0f387c..416f04ac2fd6 100644 --- a/tests/ui/generic-associated-types/issue-67510.stderr +++ b/tests/ui/generic-associated-types/issue-67510.stderr @@ -35,7 +35,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn f(x: Box = &'a ()>>) {} | ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-67510.rs:2:10 | LL | trait X { diff --git a/tests/ui/generic-associated-types/issue-71176.stderr b/tests/ui/generic-associated-types/issue-71176.stderr index 9f83c162c02c..15d5a3df6f27 100644 --- a/tests/ui/generic-associated-types/issue-71176.stderr +++ b/tests/ui/generic-associated-types/issue-71176.stderr @@ -54,7 +54,7 @@ error[E0038]: the trait `Provider` cannot be made into an object LL | inner: Box>, | ^^^^^^^^^^^^^^^^^^^ `Provider` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-71176.rs:2:10 | LL | trait Provider { @@ -70,7 +70,7 @@ error[E0038]: the trait `Provider` cannot be made into an object LL | inner: Box::new(()), | ^^^^^^^^^^^^ `Provider` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-71176.rs:2:10 | LL | trait Provider { diff --git a/tests/ui/generic-associated-types/issue-76535.base.stderr b/tests/ui/generic-associated-types/issue-76535.base.stderr index 88c08051da7e..a44c8dc51e7e 100644 --- a/tests/ui/generic-associated-types/issue-76535.base.stderr +++ b/tests/ui/generic-associated-types/issue-76535.base.stderr @@ -20,7 +20,7 @@ error[E0038]: the trait `SuperTrait` cannot be made into an object LL | let sub: Box> = Box::new(SuperStruct::new(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-76535.rs:9:10 | LL | pub trait SuperTrait { @@ -37,7 +37,7 @@ error[E0038]: the trait `SuperTrait` cannot be made into an object LL | let sub: Box> = Box::new(SuperStruct::new(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-76535.rs:9:10 | LL | pub trait SuperTrait { diff --git a/tests/ui/generic-associated-types/issue-78671.base.stderr b/tests/ui/generic-associated-types/issue-78671.base.stderr index bad8c1c9dba7..9f2be785460f 100644 --- a/tests/ui/generic-associated-types/issue-78671.base.stderr +++ b/tests/ui/generic-associated-types/issue-78671.base.stderr @@ -20,7 +20,7 @@ error[E0038]: the trait `CollectionFamily` cannot be made into an object LL | Box::new(Family) as &dyn CollectionFamily | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-78671.rs:7:10 | LL | trait CollectionFamily { diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr index 551ad2a8fdff..3ea62bdbb276 100644 --- a/tests/ui/generic-associated-types/issue-79422.base.stderr +++ b/tests/ui/generic-associated-types/issue-79422.base.stderr @@ -20,7 +20,7 @@ error[E0038]: the trait `MapLike` cannot be made into an object LL | as Box>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-79422.rs:23:10 | LL | trait MapLike { @@ -38,7 +38,7 @@ error[E0038]: the trait `MapLike` cannot be made into an object LL | let m = Box::new(std::collections::BTreeMap::::new()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-79422.rs:23:10 | LL | trait MapLike { diff --git a/tests/ui/generic-associated-types/missing_lifetime_args.stderr b/tests/ui/generic-associated-types/missing_lifetime_args.stderr index 18c2d8c7eedf..61cf4f3dd4a7 100644 --- a/tests/ui/generic-associated-types/missing_lifetime_args.stderr +++ b/tests/ui/generic-associated-types/missing_lifetime_args.stderr @@ -54,7 +54,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn foo<'c, 'd>(_arg: Box>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/missing_lifetime_args.rs:2:10 | LL | trait X { diff --git a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr index 539b6695e9e8..91f0f7b3fcf2 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr +++ b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr @@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn f2<'a>(arg : Box = &'a ()>>) {} | ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/trait-path-type-error-once-implemented.rs:2:10 | LL | trait X { diff --git a/tests/ui/generic-associated-types/trait-objects.base.stderr b/tests/ui/generic-associated-types/trait-objects.base.stderr index 2b5060289ab2..0b5a9b9f7fb6 100644 --- a/tests/ui/generic-associated-types/trait-objects.base.stderr +++ b/tests/ui/generic-associated-types/trait-objects.base.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/trait-objects.rs:7:10 | LL | trait StreamingIterator { @@ -19,7 +19,7 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object LL | x.size_hint().0 | ^^^^^^^^^ `StreamingIterator` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/trait-objects.rs:7:10 | LL | trait StreamingIterator { @@ -34,7 +34,7 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object LL | x.size_hint().0 | ^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/trait-objects.rs:7:10 | LL | trait StreamingIterator { diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr index 27f82563aae7..d48bf8a471d6 100644 --- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let x: &dyn Foo = &(); | ^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/span-bug-issue-121597.rs:4:12 | LL | trait Foo: for Bar {} @@ -19,7 +19,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let x: &dyn Foo = &(); | ^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/span-bug-issue-121597.rs:4:12 | LL | trait Foo: for Bar {} diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr index d82b2c0f6066..418f9acf5899 100644 --- a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr +++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr @@ -7,7 +7,7 @@ LL | fn ice() -> impl AsRef { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn ice() -> impl AsRef { | +++ @@ -21,7 +21,7 @@ LL | fn ice() -> impl AsRef { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn ice() -> impl AsRef { | +++ diff --git a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr index 90285d512ef0..af624e2a7587 100644 --- a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-object-safety.stderr @@ -14,7 +14,7 @@ error[E0038]: the trait `MyTrait` cannot be made into an object LL | MyTrait::foo(&self) | ^^^^^^^^^^^^ `MyTrait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22 | LL | trait MyTrait { @@ -38,7 +38,7 @@ error[E0038]: the trait `MyTrait` cannot be made into an object LL | impl dyn MyTrait { | ^^^^^^^^^^^ `MyTrait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22 | LL | trait MyTrait { @@ -54,7 +54,7 @@ error[E0038]: the trait `MyTrait` cannot be made into an object LL | fn other(&self) -> impl Marker { | ^^^^ `MyTrait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22 | LL | trait MyTrait { diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr index a0840699268a..895d8686742b 100644 --- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let _: &dyn rpitit::Foo = todo!(); | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/auxiliary/rpitit.rs:4:21 | LL | fn bar(self) -> impl Deref; diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr index a7be0516cd32..e2f23bca621c 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let i = Box::new(42_u32) as Box; | ^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety.rs:4:22 | LL | trait Foo { @@ -20,7 +20,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let s = i.baz(); | ^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety.rs:4:22 | LL | trait Foo { @@ -36,7 +36,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let s = i.baz(); | ^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety.rs:4:22 | LL | trait Foo { @@ -52,7 +52,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let i = Box::new(42_u32) as Box; | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety.rs:4:22 | LL | trait Foo { diff --git a/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr index 09a689e6396e..2a36824e2925 100644 --- a/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr +++ b/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object LL | fn car() -> dyn NotObjectSafe { | ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8 | LL | trait NotObjectSafe { @@ -29,7 +29,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object LL | fn cat() -> Box { | ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8 | LL | trait NotObjectSafe { @@ -71,7 +71,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object LL | return Box::new(A); | ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8 | LL | trait NotObjectSafe { @@ -97,7 +97,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object LL | Box::new(B) | ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8 | LL | trait NotObjectSafe { diff --git a/tests/ui/issues/issue-18959.stderr b/tests/ui/issues/issue-18959.stderr index 83d46f0331ca..5bb452250aa4 100644 --- a/tests/ui/issues/issue-18959.stderr +++ b/tests/ui/issues/issue-18959.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn foo(b: &dyn Bar) { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } @@ -19,7 +19,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | b.foo(&0) | ^^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } @@ -34,7 +34,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | let test: &dyn Bar = &mut thing; | ^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } @@ -49,7 +49,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | let test: &dyn Bar = &mut thing; | ^^^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } @@ -65,7 +65,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | foo(test); | ^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } diff --git a/tests/ui/issues/issue-19380.stderr b/tests/ui/issues/issue-19380.stderr index 1d7aa6bd459e..afbe67befa1a 100644 --- a/tests/ui/issues/issue-19380.stderr +++ b/tests/ui/issues/issue-19380.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Qiz` cannot be made into an object LL | foos: &'static [&'static (dyn Qiz + 'static)] | ^^^^^^^^^^^^^^^^^ `Qiz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-19380.rs:2:6 | LL | trait Qiz { @@ -27,7 +27,7 @@ error[E0038]: the trait `Qiz` cannot be made into an object LL | const BAR : Bar = Bar { foos: &[&FOO]}; | ^^^^ `Qiz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-19380.rs:2:6 | LL | trait Qiz { @@ -51,7 +51,7 @@ error[E0038]: the trait `Qiz` cannot be made into an object LL | const BAR : Bar = Bar { foos: &[&FOO]}; | ^^^^^^^ `Qiz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-19380.rs:2:6 | LL | trait Qiz { diff --git a/tests/ui/issues/issue-26056.stderr b/tests/ui/issues/issue-26056.stderr index f1f553adf0f6..be5453ec19df 100644 --- a/tests/ui/issues/issue-26056.stderr +++ b/tests/ui/issues/issue-26056.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Map` cannot be made into an object LL | as &dyn Map; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Map` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-26056.rs:9:12 | LL | trait Map: MapLookup<::Key> { diff --git a/tests/ui/issues/issue-28344.stderr b/tests/ui/issues/issue-28344.stderr index b7e0790f6796..261f8b67b52c 100644 --- a/tests/ui/issues/issue-28344.stderr +++ b/tests/ui/issues/issue-28344.stderr @@ -7,7 +7,7 @@ LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let x: u8 = ::bitor(0 as u8, 0 as u8); | ++++ + @@ -35,7 +35,7 @@ LL | let g = BitXor::bitor; | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let g = ::bitor; | ++++ + diff --git a/tests/ui/issues/issue-34373.stderr b/tests/ui/issues/issue-34373.stderr index 784fe935bf8a..4e8e7c61fee8 100644 --- a/tests/ui/issues/issue-34373.stderr +++ b/tests/ui/issues/issue-34373.stderr @@ -23,7 +23,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | pub struct Foo>>; | ^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-34373.rs:4:8 | LL | trait Trait { diff --git a/tests/ui/issues/issue-50781.stderr b/tests/ui/issues/issue-50781.stderr index 6b0b42ca53a6..3e54a53aa95f 100644 --- a/tests/ui/issues/issue-50781.stderr +++ b/tests/ui/issues/issue-50781.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | impl Trait for dyn X {} | ^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-50781.rs:4:8 | LL | trait X { @@ -20,7 +20,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | ::foo(&()); | ^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-50781.rs:4:8 | LL | trait X { @@ -37,7 +37,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | ::foo(&()); | ^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-50781.rs:4:8 | LL | trait X { diff --git a/tests/ui/issues/issue-58734.stderr b/tests/ui/issues/issue-58734.stderr index 71581e96844e..a2acd9dcf818 100644 --- a/tests/ui/issues/issue-58734.stderr +++ b/tests/ui/issues/issue-58734.stderr @@ -7,7 +7,7 @@ LL | Trait::nonexistent(()); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | ::nonexistent(()); | ++++ + diff --git a/tests/ui/issues/issue-86756.stderr b/tests/ui/issues/issue-86756.stderr index d0906a6fa74f..728d7ea70955 100644 --- a/tests/ui/issues/issue-86756.stderr +++ b/tests/ui/issues/issue-86756.stderr @@ -21,7 +21,7 @@ LL | eq:: = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | eq:: | +++ diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr index 979525ff4073..e797ca01f4bc 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr @@ -25,7 +25,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let z = &x as &dyn Foo; | ^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/kindck-inherited-copy-bound.rs:10:13 | LL | trait Foo : Copy { @@ -39,7 +39,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let z = &x as &dyn Foo; | ^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/kindck-inherited-copy-bound.rs:10:13 | LL | trait Foo : Copy { diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr index 30f90b88160e..b4424f4750e6 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr @@ -25,7 +25,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let z = &x as &dyn Foo; | ^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/kindck-inherited-copy-bound.rs:10:13 | LL | trait Foo : Copy { diff --git a/tests/ui/lint/bare-trait-objects-path.stderr b/tests/ui/lint/bare-trait-objects-path.stderr index da1d9f248a01..d2d139dd025a 100644 --- a/tests/ui/lint/bare-trait-objects-path.stderr +++ b/tests/ui/lint/bare-trait-objects-path.stderr @@ -7,7 +7,7 @@ LL | let _: Dyn::Ty; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let _: ::Ty; | ++++ + @@ -26,7 +26,7 @@ LL | Dyn::func(); | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | ::func(); | ++++ + @@ -39,7 +39,7 @@ LL | ::Dyn::func(); | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | ::func(); | ++++++ ++ @@ -52,7 +52,7 @@ LL | Dyn::CONST; | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | ::CONST; | ++++ + diff --git a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr index 388dc6160cb9..a1aa29dd6977 100644 --- a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr @@ -7,7 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: requested on the command line with `--force-warn bare-trait-objects` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | pub fn function(_x: Box) {} | +++ diff --git a/tests/ui/lint/force-warn/cap-lints-allow.stderr b/tests/ui/lint/force-warn/cap-lints-allow.stderr index a037fb671af2..0d10a43a14d7 100644 --- a/tests/ui/lint/force-warn/cap-lints-allow.stderr +++ b/tests/ui/lint/force-warn/cap-lints-allow.stderr @@ -7,7 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: requested on the command line with `--force-warn bare-trait-objects` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | pub fn function(_x: Box) {} | +++ diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr index dc85e8cf9617..d52bd67e36af 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -7,7 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | pub fn function(_x: Box) {} | +++ diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr index 55cfad838f84..22483a3d874d 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -7,7 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | pub fn function(_x: Box) {} | +++ diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr index b7bf0c4ee212..aa183b9ba54c 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -7,7 +7,7 @@ LL | pub fn function(_x: Box) {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | pub fn function(_x: Box) {} | +++ diff --git a/tests/ui/object-safety/almost-supertrait-associated-type.stderr b/tests/ui/object-safety/almost-supertrait-associated-type.stderr index 97a51c2f3816..99bcccc20c01 100644 --- a/tests/ui/object-safety/almost-supertrait-associated-type.stderr +++ b/tests/ui/object-safety/almost-supertrait-associated-type.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | impl Dyn for dyn Foo + '_ { | ^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/almost-supertrait-associated-type.rs:33:34 | LL | trait Foo: Super @@ -21,7 +21,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | (&PhantomData:: as &dyn Foo).transmute(t) | ^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/almost-supertrait-associated-type.rs:33:34 | LL | trait Foo: Super @@ -38,7 +38,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | (&PhantomData:: as &dyn Foo).transmute(t) | ^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/almost-supertrait-associated-type.rs:33:34 | LL | trait Foo: Super diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs index 711bed808cc8..e9216da59272 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs @@ -7,7 +7,7 @@ trait Foo { } fn foo(_: &dyn Foo) {} -//~^ WARN: unnecessary associated type bound for not object safe associated type +//~^ WARN: unnecessary associated type bound for dyn-incompatible associated type #[allow(unused_associated_type_bounds)] fn bar(_: &dyn Foo) {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr index 7cd6175a5ad6..aaadc4ed7b1e 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr @@ -1,4 +1,4 @@ -warning: unnecessary associated type bound for not object safe associated type +warning: unnecessary associated type bound for dyn-incompatible associated type --> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20 | LL | fn foo(_: &dyn Foo) {} diff --git a/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr b/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr index 0bc396390d7d..3ac1ebb30e21 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning-2.new.stderr @@ -5,7 +5,7 @@ LL | fn id(f: Copy) -> usize { | ^^^^ `Copy` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 error[E0618]: expected function, found `(dyn Copy + 'static)` --> $DIR/avoid-ice-on-warning-2.rs:11:5 diff --git a/tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr b/tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr index f1f33a6c6d67..3a586450fc57 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning-2.old.stderr @@ -7,7 +7,7 @@ LL | fn id(f: Copy) -> usize { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn id(f: dyn Copy) -> usize { | +++ @@ -21,7 +21,7 @@ LL | fn id(f: Copy) -> usize { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn id(f: dyn Copy) -> usize { | +++ @@ -33,7 +33,7 @@ LL | fn id(f: Copy) -> usize { | ^^^^ `Copy` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 error[E0618]: expected function, found `(dyn Copy + 'static)` --> $DIR/avoid-ice-on-warning-2.rs:11:5 diff --git a/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr b/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr index fd92d43ef9a2..fdd3e8ab5072 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning-3.new.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `A` cannot be made into an object LL | trait B { fn f(a: A) -> A; } | ^ `A` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/avoid-ice-on-warning-3.rs:12:14 | LL | trait A { fn g(b: B) -> B; } @@ -26,7 +26,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | trait A { fn g(b: B) -> B; } | ^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/avoid-ice-on-warning-3.rs:4:14 | LL | trait B { fn f(a: A) -> A; } diff --git a/tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr b/tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr index f499e2d946ff..bd362abb3550 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning-3.old.stderr @@ -7,7 +7,7 @@ LL | trait B { fn f(a: A) -> A; } = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait B { fn f(a: dyn A) -> A; } | +++ @@ -20,7 +20,7 @@ LL | trait B { fn f(a: A) -> A; } | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait B { fn f(a: A) -> dyn A; } | +++ @@ -33,7 +33,7 @@ LL | trait A { fn g(b: B) -> B; } | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait A { fn g(b: dyn B) -> B; } | +++ @@ -46,7 +46,7 @@ LL | trait A { fn g(b: B) -> B; } | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait A { fn g(b: B) -> dyn B; } | +++ @@ -60,7 +60,7 @@ LL | trait B { fn f(a: A) -> A; } = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait B { fn f(a: dyn A) -> A; } | +++ @@ -71,7 +71,7 @@ error[E0038]: the trait `A` cannot be made into an object LL | trait B { fn f(a: A) -> A; } | ^ `A` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/avoid-ice-on-warning-3.rs:12:14 | LL | trait A { fn g(b: B) -> B; } @@ -96,7 +96,7 @@ LL | trait A { fn g(b: B) -> B; } = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait A { fn g(b: dyn B) -> B; } | +++ @@ -107,7 +107,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | trait A { fn g(b: B) -> B; } | ^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/avoid-ice-on-warning-3.rs:4:14 | LL | trait B { fn f(a: A) -> A; } diff --git a/tests/ui/object-safety/avoid-ice-on-warning.old.stderr b/tests/ui/object-safety/avoid-ice-on-warning.old.stderr index de45ec8c405a..646fb57af9ed 100644 --- a/tests/ui/object-safety/avoid-ice-on-warning.old.stderr +++ b/tests/ui/object-safety/avoid-ice-on-warning.old.stderr @@ -24,7 +24,7 @@ LL | fn call_this(f: F) : Fn(&str) + call_that {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn call_this(f: F) : dyn Fn(&str) + call_that {} | +++ diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr index efddab6dff63..bb2bf6ddcda8 100644 --- a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr +++ b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.new.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Ord` cannot be made into an object LL | fn ord_prefer_dot(s: String) -> Ord { | ^^^ `Ord` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter diff --git a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr index 0545a1afcc14..45c9b0ce5d9c 100644 --- a/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr +++ b/tests/ui/object-safety/bare-trait-dont-suggest-dyn.old.stderr @@ -11,7 +11,7 @@ note: the lint level is defined here | LL | #![deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn ord_prefer_dot(s: String) -> dyn Ord { | +++ @@ -22,7 +22,7 @@ error[E0038]: the trait `Ord` cannot be made into an object LL | fn ord_prefer_dot(s: String) -> Ord { | ^^^ `Ord` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter diff --git a/tests/ui/object-safety/issue-102762.stderr b/tests/ui/object-safety/issue-102762.stderr index e746628aa377..05451eb8399c 100644 --- a/tests/ui/object-safety/issue-102762.stderr +++ b/tests/ui/object-safety/issue-102762.stderr @@ -7,7 +7,7 @@ LL | fn get<'a>(self: &'a Box) -> Pin> LL | fn fetcher() -> Box { | ^^^^^^^^^^^ `Fetcher` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-102762.rs:10:22 | LL | pub trait Fetcher: Send + Sync { @@ -24,7 +24,7 @@ LL | fn get<'a>(self: &'a Box) -> Pin> LL | let fetcher = fetcher(); | ^^^^^^^^^ `Fetcher` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-102762.rs:10:22 | LL | pub trait Fetcher: Send + Sync { @@ -41,7 +41,7 @@ LL | fn get<'a>(self: &'a Box) -> Pin> LL | let _ = fetcher.get(); | ^^^^^^^^^^^^^ `Fetcher` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-102762.rs:10:22 | LL | pub trait Fetcher: Send + Sync { diff --git a/tests/ui/object-safety/issue-19538.stderr b/tests/ui/object-safety/issue-19538.stderr index 31657501e258..3dbe389686a4 100644 --- a/tests/ui/object-safety/issue-19538.stderr +++ b/tests/ui/object-safety/issue-19538.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | let test: &mut dyn Bar = &mut thing; | ^^^^^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-19538.rs:2:8 | LL | fn foo(&self, val: T); @@ -21,7 +21,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | let test: &mut dyn Bar = &mut thing; | ^^^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-19538.rs:2:8 | LL | fn foo(&self, val: T); diff --git a/tests/ui/object-safety/object-safety-associated-consts.curr.stderr b/tests/ui/object-safety/object-safety-associated-consts.curr.stderr index bd558d36f73f..3c070f17c82a 100644 --- a/tests/ui/object-safety/object-safety-associated-consts.curr.stderr +++ b/tests/ui/object-safety/object-safety-associated-consts.curr.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn make_bar(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-associated-consts.rs:9:11 | LL | trait Bar { @@ -19,7 +19,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-associated-consts.rs:9:11 | LL | trait Bar { diff --git a/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr index d0c78f9cd699..5b98cc35505c 100644 --- a/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-associated-consts.rs:9:11 | LL | trait Bar { diff --git a/tests/ui/object-safety/object-safety-bounds.stderr b/tests/ui/object-safety/object-safety-bounds.stderr index bf3c055f4e3f..96a81a69639b 100644 --- a/tests/ui/object-safety/object-safety-bounds.stderr +++ b/tests/ui/object-safety/object-safety-bounds.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `X` cannot be made into an object LL | fn f() -> Box> { | ^^^^^^^^^^^^^^ `X` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-bounds.rs:4:13 | LL | trait X { diff --git a/tests/ui/object-safety/object-safety-generics.curr.stderr b/tests/ui/object-safety/object-safety-generics.curr.stderr index 85adeace3c7f..7528785d90b4 100644 --- a/tests/ui/object-safety/object-safety-generics.curr.stderr +++ b/tests/ui/object-safety/object-safety-generics.curr.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn make_bar(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { @@ -19,7 +19,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn make_bar_explicit(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { @@ -34,7 +34,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { @@ -50,7 +50,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t as &dyn Bar | ^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { @@ -65,7 +65,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t as &dyn Bar | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { diff --git a/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr index 498ad0d8a5e0..4686b994b33e 100644 --- a/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { @@ -20,7 +20,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t as &dyn Bar | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-generics.rs:10:8 | LL | trait Bar { diff --git a/tests/ui/object-safety/object-safety-issue-22040.stderr b/tests/ui/object-safety/object-safety-issue-22040.stderr index 767c232c6ce2..e5723f12258f 100644 --- a/tests/ui/object-safety/object-safety-issue-22040.stderr +++ b/tests/ui/object-safety/object-safety-issue-22040.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Expr` cannot be made into an object LL | elements: Vec>, | ^^^^^^^^^^^^^ `Expr` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-issue-22040.rs:5:21 | LL | trait Expr: Debug + PartialEq { @@ -19,7 +19,7 @@ error[E0038]: the trait `Expr` cannot be made into an object LL | let a: Box = Box::new(SExpr::new()); | ^^^^^^^^ `Expr` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-issue-22040.rs:5:21 | LL | trait Expr: Debug + PartialEq { @@ -34,7 +34,7 @@ error[E0038]: the trait `Expr` cannot be made into an object LL | let b: Box = Box::new(SExpr::new()); | ^^^^^^^^ `Expr` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-issue-22040.rs:5:21 | LL | trait Expr: Debug + PartialEq { diff --git a/tests/ui/object-safety/object-safety-mentions-Self.curr.stderr b/tests/ui/object-safety/object-safety-mentions-Self.curr.stderr index 28c9c9d64a06..7efb6ec3542d 100644 --- a/tests/ui/object-safety/object-safety-mentions-Self.curr.stderr +++ b/tests/ui/object-safety/object-safety-mentions-Self.curr.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn make_bar(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-mentions-Self.rs:11:22 | LL | trait Bar { @@ -19,7 +19,7 @@ error[E0038]: the trait `Baz` cannot be made into an object LL | fn make_baz(t: &T) -> &dyn Baz { | ^^^^^^^ `Baz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-mentions-Self.rs:15:22 | LL | trait Baz { @@ -34,7 +34,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-mentions-Self.rs:11:22 | LL | trait Bar { @@ -50,7 +50,7 @@ error[E0038]: the trait `Baz` cannot be made into an object LL | t | ^ `Baz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-mentions-Self.rs:15:22 | LL | trait Baz { diff --git a/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr index 414614d8d0bf..d0efb9c587e4 100644 --- a/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-mentions-Self.rs:11:22 | LL | trait Bar { @@ -20,7 +20,7 @@ error[E0038]: the trait `Baz` cannot be made into an object LL | t | ^ `Baz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-mentions-Self.rs:15:22 | LL | trait Baz { diff --git a/tests/ui/object-safety/object-safety-no-static.curr.stderr b/tests/ui/object-safety/object-safety-no-static.curr.stderr index 8e5b0cbf9ddc..91c3d89602e8 100644 --- a/tests/ui/object-safety/object-safety-no-static.curr.stderr +++ b/tests/ui/object-safety/object-safety-no-static.curr.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn diverges() -> Box { | ^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-no-static.rs:9:8 | LL | trait Foo { @@ -27,7 +27,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let b: Box = Box::new(Bar); | ^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-no-static.rs:9:8 | LL | trait Foo { @@ -50,7 +50,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let b: Box = Box::new(Bar); | ^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-no-static.rs:9:8 | LL | trait Foo { diff --git a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr index e155a350f894..52f6865b6f3c 100644 --- a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let b: Box = Box::new(Bar); | ^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-no-static.rs:9:8 | LL | trait Foo { diff --git a/tests/ui/object-safety/object-safety-sized-2.curr.stderr b/tests/ui/object-safety/object-safety-sized-2.curr.stderr index 03b078c2a44e..4ce7ac5704e4 100644 --- a/tests/ui/object-safety/object-safety-sized-2.curr.stderr +++ b/tests/ui/object-safety/object-safety-sized-2.curr.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn make_bar(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-sized-2.rs:9:18 | LL | trait Bar @@ -18,7 +18,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-sized-2.rs:9:18 | LL | trait Bar diff --git a/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr index 69af9bfe92b9..99066c104b7c 100644 --- a/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-sized-2.rs:9:18 | LL | trait Bar diff --git a/tests/ui/object-safety/object-safety-sized.curr.stderr b/tests/ui/object-safety/object-safety-sized.curr.stderr index 0513780a81f1..b61f968d9021 100644 --- a/tests/ui/object-safety/object-safety-sized.curr.stderr +++ b/tests/ui/object-safety/object-safety-sized.curr.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | fn make_bar(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-sized.rs:8:12 | LL | trait Bar: Sized { @@ -18,7 +18,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-sized.rs:8:12 | LL | trait Bar: Sized { diff --git a/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr index d988293c0e9a..5ce713375a49 100644 --- a/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | t | ^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-sized.rs:8:12 | LL | trait Bar: Sized { diff --git a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr index 2d2bb27b8f39..4d44627e7792 100644 --- a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr +++ b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr @@ -26,7 +26,7 @@ error[E0038]: the trait `SuperTrait` cannot be made into an object LL | fn c(&self) -> dyn SuperTrait; | ^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-supertrait-mentions-GAT.rs:4:10 | LL | type Gat<'a> diff --git a/tests/ui/object-safety/object-safety-supertrait-mentions-Self.stderr b/tests/ui/object-safety/object-safety-supertrait-mentions-Self.stderr index 6beb04e5b937..b1a70fb859d7 100644 --- a/tests/ui/object-safety/object-safety-supertrait-mentions-Self.stderr +++ b/tests/ui/object-safety/object-safety-supertrait-mentions-Self.stderr @@ -24,7 +24,7 @@ error[E0038]: the trait `Baz` cannot be made into an object LL | fn make_baz(t: &T) -> &dyn Baz { | ^^^^^^^ `Baz` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-safety-supertrait-mentions-Self.rs:8:13 | LL | trait Baz : Bar { diff --git a/tests/ui/parser/trait-object-trait-parens.stderr b/tests/ui/parser/trait-object-trait-parens.stderr index ff32b173d494..d75352b6811e 100644 --- a/tests/ui/parser/trait-object-trait-parens.stderr +++ b/tests/ui/parser/trait-object-trait-parens.stderr @@ -34,7 +34,7 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let _: Box Trait<'a>)>; | +++ @@ -58,7 +58,7 @@ LL | let _: Box Trait<'a>) + (Obj)>; | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let _: Box Trait<'a>) + (Obj)>; | +++ @@ -82,7 +82,7 @@ LL | let _: Box Trait<'a> + (Obj) + (?Sized)>; | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let _: Box Trait<'a> + (Obj) + (?Sized)>; | +++ diff --git a/tests/ui/resolve/issue-3907-2.stderr b/tests/ui/resolve/issue-3907-2.stderr index 364edb788c68..7c966ba98912 100644 --- a/tests/ui/resolve/issue-3907-2.stderr +++ b/tests/ui/resolve/issue-3907-2.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `issue_3907::Foo` cannot be made into an object LL | fn bar(_x: Foo) {} | ^^^ `issue_3907::Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/auxiliary/issue-3907.rs:2:8 | LL | fn bar(); diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr index fdd18c6b37b5..e2d73fc08f6d 100644 --- a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr +++ b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr @@ -7,7 +7,7 @@ LL | fn foo(self: &Rc) -> usize; LL | let x = Rc::new(5usize) as Rc; | ^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/arbitrary-self-types-not-object-safe.rs:8:18 | LL | trait Foo { @@ -25,7 +25,7 @@ LL | fn foo(self: &Rc) -> usize; LL | let x = Rc::new(5usize) as Rc; | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/arbitrary-self-types-not-object-safe.rs:8:18 | LL | trait Foo { diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr index 363ba072c816..fda07765c662 100644 --- a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr +++ b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr @@ -7,7 +7,7 @@ LL | fn foo(self: &Rc) -> usize; LL | let x = Rc::new(5usize) as Rc; | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/arbitrary-self-types-not-object-safe.rs:8:18 | LL | trait Foo { diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr index 49e8d87f3547..59e09e48523d 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Qux` cannot be made into an object LL | pub desc: &'static dyn Qux, | ^^^^^^^ `Qux` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/unsizing-wfcheck-issue-127299.rs:4:8 | LL | trait Qux { @@ -42,7 +42,7 @@ error[E0038]: the trait `Qux` cannot be made into an object LL | static FOO: &Lint = &Lint { desc: "desc" }; | ^^^^^^ `Qux` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/unsizing-wfcheck-issue-127299.rs:4:8 | LL | trait Qux { @@ -65,7 +65,7 @@ error[E0038]: the trait `Qux` cannot be made into an object LL | static FOO: &Lint = &Lint { desc: "desc" }; | ^^^^^^ `Qux` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/unsizing-wfcheck-issue-127299.rs:4:8 | LL | trait Qux { diff --git a/tests/ui/suggestions/issue-116434-2015.rs b/tests/ui/suggestions/issue-116434-2015.rs index a53e2a044e93..2e94473eb1a1 100644 --- a/tests/ui/suggestions/issue-116434-2015.rs +++ b/tests/ui/suggestions/issue-116434-2015.rs @@ -3,10 +3,10 @@ trait Foo { fn foo() -> Clone; //~^ WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| HELP if this is an object-safe trait, use `dyn` + //~| HELP if this is a dyn-compatible trait, use `dyn` //~| WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| HELP if this is an object-safe trait, use `dyn` + //~| HELP if this is a dyn-compatible trait, use `dyn` //~| ERROR the trait `Clone` cannot be made into an object [E0038] //~| HELP there is an associated type with the same name } @@ -18,10 +18,10 @@ trait DbInterface { fn handle() -> DbHandle; //~^ WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| HELP if this is an object-safe trait, use `dyn` + //~| HELP if this is a dyn-compatible trait, use `dyn` //~| WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| HELP if this is an object-safe trait, use `dyn` + //~| HELP if this is a dyn-compatible trait, use `dyn` //~| ERROR the trait `DbHandle` cannot be made into an object [E0038] //~| HELP there is an associated type with the same name } diff --git a/tests/ui/suggestions/issue-116434-2015.stderr b/tests/ui/suggestions/issue-116434-2015.stderr index 73a1cfa9c1d5..24fc87f765f8 100644 --- a/tests/ui/suggestions/issue-116434-2015.stderr +++ b/tests/ui/suggestions/issue-116434-2015.stderr @@ -7,7 +7,7 @@ LL | fn foo() -> Clone; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn foo() -> dyn Clone; | +++ @@ -20,7 +20,7 @@ LL | fn handle() -> DbHandle; | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn handle() -> dyn DbHandle; | +++ @@ -34,7 +34,7 @@ LL | fn foo() -> Clone; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn foo() -> dyn Clone; | +++ @@ -46,7 +46,7 @@ LL | fn foo() -> Clone; | ^^^^^ `Clone` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 help: there is an associated type with the same name | LL | fn foo() -> Self::Clone; @@ -61,7 +61,7 @@ LL | fn handle() -> DbHandle; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn handle() -> dyn DbHandle; | +++ @@ -72,7 +72,7 @@ error[E0038]: the trait `DbHandle` cannot be made into an object LL | fn handle() -> DbHandle; | ^^^^^^^^ `DbHandle` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-116434-2015.rs:14:17 | LL | trait DbHandle: Sized {} diff --git a/tests/ui/suggestions/issue-116434-2021.stderr b/tests/ui/suggestions/issue-116434-2021.stderr index a10d6ef6da4d..7f8cc147210e 100644 --- a/tests/ui/suggestions/issue-116434-2021.stderr +++ b/tests/ui/suggestions/issue-116434-2021.stderr @@ -5,7 +5,7 @@ LL | fn foo() -> Clone; | ^^^^^ `Clone` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 help: there is an associated type with the same name | LL | fn foo() -> Self::Clone; @@ -17,7 +17,7 @@ error[E0038]: the trait `DbHandle` cannot be made into an object LL | fn handle() -> DbHandle; | ^^^^^^^^ `DbHandle` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-116434-2021.rs:10:17 | LL | trait DbHandle: Sized {} diff --git a/tests/ui/suggestions/issue-61963.stderr b/tests/ui/suggestions/issue-61963.stderr index 084b0cbeef29..734c88f3fd67 100644 --- a/tests/ui/suggestions/issue-61963.stderr +++ b/tests/ui/suggestions/issue-61963.stderr @@ -11,7 +11,7 @@ note: the lint level is defined here | LL | #![deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | bar: Box, | +++ @@ -24,7 +24,7 @@ LL | pub struct Foo { | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | dyn pub struct Foo { | +++ diff --git a/tests/ui/suggestions/issue-98500.stderr b/tests/ui/suggestions/issue-98500.stderr index aa66a9aa1e7f..c4b446763afe 100644 --- a/tests/ui/suggestions/issue-98500.stderr +++ b/tests/ui/suggestions/issue-98500.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | struct S(Box); | ^^^^^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/auxiliary/not-object-safe.rs:4:8 | LL | fn f(); diff --git a/tests/ui/suggestions/object-unsafe-trait-references-self.stderr b/tests/ui/suggestions/object-unsafe-trait-references-self.stderr index 642700684711..6af55e7bcaeb 100644 --- a/tests/ui/suggestions/object-unsafe-trait-references-self.stderr +++ b/tests/ui/suggestions/object-unsafe-trait-references-self.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | fn bar(x: &dyn Trait) {} | ^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-references-self.rs:2:22 | LL | trait Trait { @@ -23,7 +23,7 @@ error[E0038]: the trait `Other` cannot be made into an object LL | fn foo(x: &dyn Other) {} | ^^^^^^^^^ `Other` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-references-self.rs:11:14 | LL | trait Other: Sized {} diff --git a/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021-without-dyn.stderr b/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021-without-dyn.stderr index 60eb72ab4f76..a17f821ebec4 100644 --- a/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021-without-dyn.stderr +++ b/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021-without-dyn.stderr @@ -17,7 +17,7 @@ error[E0038]: the trait `A` cannot be made into an object LL | fn f(a: A) -> A; | ^ `A` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self-2021-without-dyn.rs:3:10 | LL | trait A: Sized { @@ -44,7 +44,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | fn f(b: B) -> B; | ^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self-2021-without-dyn.rs:11:8 | LL | trait B { @@ -81,7 +81,7 @@ LL | fn f(&self, c: C) -> C; | | | help: consider changing method `f`'s `self` parameter to be `&self` (notice the capitalization): `&Self` | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self-2021-without-dyn.rs:18:10 | LL | trait C { @@ -95,7 +95,7 @@ error[E0782]: trait objects must include the `dyn` keyword LL | fn f(a: A) -> A; | ^ | - = note: `A` it is not object safe, so it can't be `dyn` + = note: `A` it is dyn-incompatible, so it can't be `dyn` help: use a new generic type parameter, constrained by `A` | LL | fn f(a: T) -> A; @@ -111,7 +111,7 @@ error[E0782]: trait objects must include the `dyn` keyword LL | fn f(a: A) -> A; | ^ | -help: `A` is not object safe, use `impl A` to return an opaque type, as long as you return a single underlying type +help: `A` is dyn-incompatible, use `impl A` to return an opaque type, as long as you return a single underlying type | LL | fn f(a: A) -> impl A; | ++++ @@ -122,7 +122,7 @@ error[E0782]: trait objects must include the `dyn` keyword LL | fn f(b: B) -> B; | ^ | - = note: `B` it is not object safe, so it can't be `dyn` + = note: `B` it is dyn-incompatible, so it can't be `dyn` help: use a new generic type parameter, constrained by `B` | LL | fn f(b: T) -> B; @@ -138,7 +138,7 @@ error[E0782]: trait objects must include the `dyn` keyword LL | fn f(b: B) -> B; | ^ | -help: `B` is not object safe, use `impl B` to return an opaque type, as long as you return a single underlying type +help: `B` is dyn-incompatible, use `impl B` to return an opaque type, as long as you return a single underlying type | LL | fn f(b: B) -> impl B; | ++++ @@ -149,7 +149,7 @@ error[E0782]: trait objects must include the `dyn` keyword LL | fn f(&self, c: C) -> C; | ^ | - = note: `C` it is not object safe, so it can't be `dyn` + = note: `C` it is dyn-incompatible, so it can't be `dyn` help: use a new generic type parameter, constrained by `C` | LL | fn f(&self, c: T) -> C; @@ -165,7 +165,7 @@ error[E0782]: trait objects must include the `dyn` keyword LL | fn f(&self, c: C) -> C; | ^ | -help: `C` is not object safe, use `impl C` to return an opaque type, as long as you return a single underlying type +help: `C` is dyn-incompatible, use `impl C` to return an opaque type, as long as you return a single underlying type | LL | fn f(&self, c: C) -> impl C; | ++++ diff --git a/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021.stderr b/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021.stderr index d6376be9c046..a7d36d9ebee5 100644 --- a/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021.stderr +++ b/tests/ui/suggestions/object-unsafe-trait-should-use-self-2021.stderr @@ -17,7 +17,7 @@ error[E0038]: the trait `A` cannot be made into an object LL | fn f(a: dyn A) -> dyn A; | ^^^^^ `A` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self-2021.rs:3:10 | LL | trait A: Sized { @@ -44,7 +44,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | fn f(a: dyn B) -> dyn B; | ^^^^^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self-2021.rs:9:8 | LL | trait B { diff --git a/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr b/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr index 55047b42698b..28952933c644 100644 --- a/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr +++ b/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr @@ -17,7 +17,7 @@ error[E0038]: the trait `A` cannot be made into an object LL | fn f(a: A) -> A; | ^ `A` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self.rs:2:10 | LL | trait A: Sized { @@ -44,7 +44,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | fn f(a: B) -> B; | ^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-self.rs:8:8 | LL | trait B { diff --git a/tests/ui/suggestions/object-unsafe-trait-should-use-where-sized.stderr b/tests/ui/suggestions/object-unsafe-trait-should-use-where-sized.stderr index abbf56cfac86..5e3a0290d42c 100644 --- a/tests/ui/suggestions/object-unsafe-trait-should-use-where-sized.stderr +++ b/tests/ui/suggestions/object-unsafe-trait-should-use-where-sized.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | fn bar(x: &dyn Trait) {} | ^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-trait-should-use-where-sized.rs:5:8 | LL | trait Trait { diff --git a/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr b/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr index 5d805d97a435..d1da9a89c191 100644 --- a/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr +++ b/tests/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr @@ -67,7 +67,7 @@ LL | impl<'a, T> Struct for Trait<'a, T> {} = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | impl<'a, T> Struct for dyn Trait<'a, T> {} | +++ @@ -80,7 +80,7 @@ LL | impl<'a, T> Enum for Trait<'a, T> {} | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | impl<'a, T> Enum for dyn Trait<'a, T> {} | +++ @@ -93,7 +93,7 @@ LL | impl<'a, T> Union for Trait<'a, T> {} | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | impl<'a, T> Union for dyn Trait<'a, T> {} | +++ diff --git a/tests/ui/traits/alias/object-fail.stderr b/tests/ui/traits/alias/object-fail.stderr index a27a3ea0ec03..1b89b87db9f8 100644 --- a/tests/ui/traits/alias/object-fail.stderr +++ b/tests/ui/traits/alias/object-fail.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Eq` cannot be made into an object LL | let _: &dyn EqAlias = &123; | ^^^^^^^^^^^ `Eq` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter diff --git a/tests/ui/traits/bound/not-on-bare-trait.stderr b/tests/ui/traits/bound/not-on-bare-trait.stderr index f1e7a28654a7..1e385f73823a 100644 --- a/tests/ui/traits/bound/not-on-bare-trait.stderr +++ b/tests/ui/traits/bound/not-on-bare-trait.stderr @@ -7,7 +7,7 @@ LL | fn foo(_x: Foo + Send) { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn foo(_x: dyn Foo + Send) { | +++ diff --git a/tests/ui/traits/issue-20692.stderr b/tests/ui/traits/issue-20692.stderr index 30e3c9da1a03..5e6a967fdc4e 100644 --- a/tests/ui/traits/issue-20692.stderr +++ b/tests/ui/traits/issue-20692.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Array` cannot be made into an object LL | &dyn Array; | ^^^^^^^^^^ `Array` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-20692.rs:1:14 | LL | trait Array: Sized + Copy {} @@ -19,7 +19,7 @@ error[E0038]: the trait `Array` cannot be made into an object LL | let _ = x | ^ `Array` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-20692.rs:1:14 | LL | trait Array: Sized + Copy {} diff --git a/tests/ui/traits/issue-28576.stderr b/tests/ui/traits/issue-28576.stderr index 7e0f52bc4fe0..23581f2ee51a 100644 --- a/tests/ui/traits/issue-28576.stderr +++ b/tests/ui/traits/issue-28576.stderr @@ -25,7 +25,7 @@ LL | / dyn Bar LL | | | |________________________^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-28576.rs:5:16 | LL | pub trait Bar: Foo { diff --git a/tests/ui/traits/issue-38404.stderr b/tests/ui/traits/issue-38404.stderr index 19d4035b54c8..145eeb88dd5e 100644 --- a/tests/ui/traits/issue-38404.stderr +++ b/tests/ui/traits/issue-38404.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | trait C: A> {} | ^^^^^^^^^^^^^^^^^^^^^^^^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-38404.rs:1:13 | LL | trait A: std::ops::Add + Sized {} @@ -18,7 +18,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | trait C: A> {} | ^^^^^^^^^^^^^^^^^^^^^^^^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-38404.rs:1:13 | LL | trait A: std::ops::Add + Sized {} @@ -33,7 +33,7 @@ error[E0038]: the trait `B` cannot be made into an object LL | trait C: A> {} | ^^^^^^^^^^^^^^^^^^^^^^^^ `B` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-38404.rs:1:13 | LL | trait A: std::ops::Add + Sized {} diff --git a/tests/ui/traits/issue-38604.stderr b/tests/ui/traits/issue-38604.stderr index 3ab9af21bc45..5c788b0c85d1 100644 --- a/tests/ui/traits/issue-38604.stderr +++ b/tests/ui/traits/issue-38604.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let _f: Box = | ^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-38604.rs:2:22 | LL | trait Foo where u32: Q { @@ -19,7 +19,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | Box::new(()); | ^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-38604.rs:2:22 | LL | trait Foo where u32: Q { diff --git a/tests/ui/traits/issue-72410.stderr b/tests/ui/traits/issue-72410.stderr index 58266e1842e2..6d56a198fc1c 100644 --- a/tests/ui/traits/issue-72410.stderr +++ b/tests/ui/traits/issue-72410.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object LL | where for<'a> &'a mut [dyn Bar]: ; | ^^^^^^^^^^^^^^^^^ `Bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-72410.rs:13:8 | LL | pub trait Bar { diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr index cdcb0cdf2593..9b93ffe8efb7 100644 --- a/tests/ui/traits/issue-78372.stderr +++ b/tests/ui/traits/issue-78372.stderr @@ -64,7 +64,7 @@ LL | fn foo(self: Smaht); LL | impl Marker for dyn Foo {} | ^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-78372.rs:9:18 | LL | trait Foo: X {} diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index fd474fac1558..c20d2f723c59 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -142,7 +142,7 @@ error[E0038]: the trait `assoc_const::C` cannot be made into an object LL | ::A; | ^^^^^ `assoc_const::C` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/item-privacy.rs:25:15 | LL | const A: u8 = 0; diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr index b6e540c5ffcb..0854ea28150f 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr +++ b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr @@ -13,7 +13,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let x: &dyn Foo = &(); | ^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/supertrait-object-safety.rs:4:12 | LL | trait Foo: for Bar {} @@ -29,7 +29,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | let x: &dyn Foo = &(); | ^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/supertrait-object-safety.rs:4:12 | LL | trait Foo: for Bar {} @@ -44,7 +44,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | needs_bar(x); | ^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/supertrait-object-safety.rs:4:12 | LL | trait Foo: for Bar {} diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr index d5e9b1be63b0..960802e2f8f8 100644 --- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr +++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr @@ -12,7 +12,7 @@ error[E0038]: the trait `FromResidual` cannot be made into an object LL | let b: &dyn FromResidual = &(); | ^^^^^^^^^^^^^^^^^ `FromResidual` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:2:8 | LL | trait FromResidual::Residual> { diff --git a/tests/ui/traits/object/macro-matcher.stderr b/tests/ui/traits/object/macro-matcher.stderr index 6d1e236c0483..7924c86e2940 100644 --- a/tests/ui/traits/object/macro-matcher.stderr +++ b/tests/ui/traits/object/macro-matcher.stderr @@ -11,7 +11,7 @@ LL | m!(dyn Copy + Send + 'static); | ^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 error: aborting due to 2 previous errors diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr index 4c636c5e922e..9258b38f26c3 100644 --- a/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn bar(x: &dyn Foo) {} | ^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 | LL | trait Foo { @@ -19,7 +19,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn bar(x: &dyn Foo) {} | ^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 | LL | trait Foo { @@ -35,7 +35,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn bar(x: &dyn Foo) {} | ^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 | LL | trait Foo { @@ -51,7 +51,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | fn bar(x: &dyn Foo) {} | ^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 | LL | trait Foo { diff --git a/tests/ui/traits/object/pretty.stderr b/tests/ui/traits/object/pretty.stderr index 6964d97c08ed..ca56bdbb67a5 100644 --- a/tests/ui/traits/object/pretty.stderr +++ b/tests/ui/traits/object/pretty.stderr @@ -1,4 +1,4 @@ -warning: unnecessary associated type bound for not object safe associated type +warning: unnecessary associated type bound for dyn-incompatible associated type --> $DIR/pretty.rs:41:35 | LL | fn dyn_has_gat(x: &dyn HasGat = ()>) { x } diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr index 19a46a502c2e..a2cb656b08d3 100644 --- a/tests/ui/traits/object/safety.stderr +++ b/tests/ui/traits/object/safety.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Tr` cannot be made into an object LL | let _: &dyn Tr = &St; | ^^^ `Tr` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/safety.rs:4:8 | LL | trait Tr { @@ -28,7 +28,7 @@ error[E0038]: the trait `Tr` cannot be made into an object LL | let _: &dyn Tr = &St; | ^^^^^^^ `Tr` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/safety.rs:4:8 | LL | trait Tr { diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index 0ee64cc09522..3da95b478448 100644 --- a/tests/ui/traits/test-2.stderr +++ b/tests/ui/traits/test-2.stderr @@ -32,7 +32,7 @@ error[E0038]: the trait `bar` cannot be made into an object LL | (Box::new(10) as Box).dup(); | ^^^^^^^^^^^^ `bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/test-2.rs:4:30 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } @@ -52,7 +52,7 @@ error[E0038]: the trait `bar` cannot be made into an object LL | (Box::new(10) as Box).dup(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/test-2.rs:4:30 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } @@ -72,7 +72,7 @@ error[E0038]: the trait `bar` cannot be made into an object LL | (Box::new(10) as Box).dup(); | ^^^^^^^^^^^^ `bar` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/test-2.rs:4:30 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } diff --git a/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs index 3c6ab86e4c65..626630e60b72 100644 --- a/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs +++ b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.rs @@ -5,6 +5,6 @@ trait A {} trait B {} trait C: A + B {} -//~^ ERROR `C` is object-safe and has multiple supertraits +//~^ ERROR `C` is dyn-compatible and has multiple supertraits fn main() {} diff --git a/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr index d075102b2e85..fab781026b11 100644 --- a/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr +++ b/tests/ui/traits/trait-upcasting/multiple_supertrait_upcastable.stderr @@ -1,4 +1,4 @@ -error: `C` is object-safe and has multiple supertraits +error: `C` is dyn-compatible and has multiple supertraits --> $DIR/multiple_supertrait_upcastable.rs:7:1 | LL | trait C: A + B {} diff --git a/tests/ui/traits/unspecified-self-in-trait-ref.stderr b/tests/ui/traits/unspecified-self-in-trait-ref.stderr index 3614348ceedc..22dceadc10de 100644 --- a/tests/ui/traits/unspecified-self-in-trait-ref.stderr +++ b/tests/ui/traits/unspecified-self-in-trait-ref.stderr @@ -7,7 +7,7 @@ LL | let a = Foo::lol(); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let a = ::lol(); | ++++ + @@ -26,7 +26,7 @@ LL | let b = Foo::<_>::lol(); | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let b = >::lol(); | ++++ + @@ -45,7 +45,7 @@ LL | let c = Bar::lol(); | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let c = ::lol(); | ++++ + @@ -64,7 +64,7 @@ LL | let d = Bar::::lol(); | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let d = >::lol(); | ++++ + @@ -83,7 +83,7 @@ LL | let e = Bar::::lol(); | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | let e = >::lol(); | ++++ + diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr index 4412c49eaddd..2d5bcf1fbc4c 100644 --- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr +++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -16,7 +16,7 @@ error[E0038]: the trait `MyAdd` cannot be made into an object LL | let y = x as dyn MyAdd; | ^^^^^^^^^^^^^^ `MyAdd` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:6:55 | LL | trait MyAdd { fn add(&self, other: &Rhs) -> Self; } diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index f2456f99e623..6b309c223aff 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -34,7 +34,7 @@ LL | trait Trait { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait Trait { | +++ @@ -67,7 +67,7 @@ LL | fn fnc(&self) -> Trait { | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn fnc(&self) -> Trait { | +++ @@ -80,7 +80,7 @@ LL | fn fnc(&self) -> Trait { | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn fnc(&self) -> dyn Trait { | +++ @@ -94,7 +94,7 @@ LL | trait Trait { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait Trait { | +++ @@ -105,7 +105,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | trait Trait { | ^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { @@ -121,7 +121,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { @@ -162,7 +162,7 @@ LL | fn fnc(&self) -> Trait { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | fn fnc(&self) -> Trait { | +++ @@ -173,7 +173,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | fn fnc(&self) -> Trait { | ^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { @@ -189,7 +189,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index a0fd11de2dc6..d2b0e2d92e01 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -7,7 +7,7 @@ LL | trait Foo> { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see = note: `#[warn(bare_trait_objects)]` on by default -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait Foo> { | +++ @@ -20,7 +20,7 @@ LL | trait Bar> {} | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see -help: if this is an object-safe trait, use `dyn` +help: if this is a dyn-compatible trait, use `dyn` | LL | trait Bar> {} | +++ @@ -50,7 +50,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | trait Foo> { | ^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:8:8 | LL | trait Foo> { @@ -81,7 +81,7 @@ error[E0038]: the trait `Foo` cannot be made into an object LL | trait Bar> {} | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:8:8 | LL | trait Foo> { diff --git a/tests/ui/wf/issue-87495.stderr b/tests/ui/wf/issue-87495.stderr index 3ccfd7f8d792..5973fff3e009 100644 --- a/tests/ui/wf/issue-87495.stderr +++ b/tests/ui/wf/issue-87495.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `T` cannot be made into an object LL | const CONST: (bool, dyn T); | ^^^^^ `T` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/issue-87495.rs:4:11 | LL | trait T { diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr index 85f5073364ff..2565e25a2429 100644 --- a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr +++ b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | let t_box: Box = Box::new(S); | ^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-convert-unsafe-trait-obj-box.rs:6:14 | LL | trait Trait: Sized {} @@ -20,7 +20,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | takes_box(Box::new(S)); | ^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-convert-unsafe-trait-obj-box.rs:6:14 | LL | trait Trait: Sized {} @@ -36,7 +36,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | Box::new(S) as Box; | ^^^^^^^^^^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-convert-unsafe-trait-obj-box.rs:6:14 | LL | trait Trait: Sized {} diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr index a2a196316495..97f6bcd0428b 100644 --- a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr +++ b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | let t: &dyn Trait = &S; | ^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-convert-unsafe-trait-obj.rs:6:14 | LL | trait Trait: Sized {} @@ -20,7 +20,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | takes_trait(&S); | ^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-convert-unsafe-trait-obj.rs:6:14 | LL | trait Trait: Sized {} @@ -36,7 +36,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | &S as &dyn Trait; | ^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-convert-unsafe-trait-obj.rs:6:14 | LL | trait Trait: Sized {} diff --git a/tests/ui/wf/wf-fn-where-clause.stderr b/tests/ui/wf/wf-fn-where-clause.stderr index 40f2f4526393..fbfe42ac6247 100644 --- a/tests/ui/wf/wf-fn-where-clause.stderr +++ b/tests/ui/wf/wf-fn-where-clause.stderr @@ -21,7 +21,7 @@ LL | fn bar() where Vec:, {} | ^^^^^^^^^^^^^ `Copy` cannot be made into an object | = note: the trait cannot be made into an object because it requires `Self: Sized` - = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + = 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 error[E0277]: the size for values of type `(dyn Copy + 'static)` cannot be known at compilation time --> $DIR/wf-fn-where-clause.rs:12:16 diff --git a/tests/ui/wf/wf-object-safe.stderr b/tests/ui/wf/wf-object-safe.stderr index cc5351346b35..7c14f3d2f8bf 100644 --- a/tests/ui/wf/wf-object-safe.stderr +++ b/tests/ui/wf/wf-object-safe.stderr @@ -4,7 +4,7 @@ error[E0038]: the trait `A` cannot be made into an object LL | let _x: &dyn A; | ^^^^^^ `A` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-object-safe.rs:5:23 | LL | trait A { diff --git a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr index 8d5b377988c0..edbdec6a5efc 100644 --- a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr +++ b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr @@ -18,7 +18,7 @@ error[E0038]: the trait `Trait` cannot be made into an object LL | Some(()) => &S, | ^^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-unsafe-trait-obj-match.rs:6:14 | LL | trait Trait: Sized {} @@ -40,7 +40,7 @@ LL | | None => &R, LL | | }; | |_____^ `Trait` cannot be made into an object | -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +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 --> $DIR/wf-unsafe-trait-obj-match.rs:6:14 | LL | trait Trait: Sized {} From 8ba2c7d42b37497802499540b8a4cc4b3506fc64 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 27 Sep 2024 12:58:16 +0900 Subject: [PATCH 3/8] fix minor typo in triagebot config --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 5d80b9e656ea..aba366928280 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -823,7 +823,7 @@ If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/util message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp." [mentions."test/crashes"] -message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, please move into the correspondig `ui` subdir and add 'Fixes #' to the pr description to autoclose the issue upon merge." +message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, please move into the corresponding `ui` subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge." [mentions."tests/ui/deriving/deriving-all-codegen.stdout"] message = "Changes to the code generated for builtin derived traits." From 892d192b157a4289599a1fe3e8e02589fe8dbf42 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Fri, 27 Sep 2024 09:41:56 +0000 Subject: [PATCH 4/8] Update Cargo.lock --- library/Cargo.lock | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index 2343b2baf834..913b75d5d3ee 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -42,9 +42,12 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "cc" -version = "1.0.99" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -312,6 +315,12 @@ dependencies = [ "std", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "std" version = "0.0.0" From 6c852d3ec40f72f9f84ffa36578410b1068ffa07 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Fri, 27 Sep 2024 10:06:48 +0000 Subject: [PATCH 5/8] Allow shlex stdlib dependency --- src/tools/tidy/src/deps.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index b880f312715e..698fb42180f0 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -481,6 +481,7 @@ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[ "rand_core", "rand_xorshift", "rustc-demangle", + "shlex", "unicode-width", "unwinding", "wasi", From 6453f7e51463c7e94081bd135219c44e15bc174a Mon Sep 17 00:00:00 2001 From: Kajetan Puchalski Date: Tue, 24 Sep 2024 01:45:56 +0100 Subject: [PATCH 6/8] etc: Add rust-analyzer configs for eglot & helix LSP configuration in editors like Emacs (eglot) and helix does not use the same JSON format as vscode and vim do. It is not obvious how to set up LSP for rustc in those editors and the dev guide currently does not cover them. Adding sample configuration files for those editors alongside the currently existing JSON one would be helpful. --- src/etc/rust_analyzer_eglot.el | 29 +++++++++++++++++++ src/etc/rust_analyzer_helix.toml | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/etc/rust_analyzer_eglot.el create mode 100644 src/etc/rust_analyzer_helix.toml diff --git a/src/etc/rust_analyzer_eglot.el b/src/etc/rust_analyzer_eglot.el new file mode 100644 index 000000000000..e55d80d98dec --- /dev/null +++ b/src/etc/rust_analyzer_eglot.el @@ -0,0 +1,29 @@ +((rustic-mode + .((eglot-workspace-configuration + . (:rust-analyzer + ( :check ( :invocationLocation "root" + :invocationStrategy "once" + :overrideCommand ["python3" + "x.py" + "check" + "--json-output"]) + :linkedProjects ["Cargo.toml" + "src/tools/x/Cargo.toml" + "src/bootstrap/Cargo.toml" + "src/tools/rust-analyzer/Cargo.toml" + "compiler/rustc_codegen_cranelift/Cargo.toml" + "compiler/rustc_codegen_gcc/Cargo.toml"] + :rustfmt ( :overrideCommand ["build/host/rustfmt/bin/rustfmt" + "--edition=2021"]) + :procMacro ( :server "build/host/stage0/libexec/rust-analyzer-proc-macro-srv" + :enable t) + :cargo ( :buildScripts ( :enable t + :invocationLocation "root" + :invocationStrategy "once" + :overrideCommand ["python3" + "x.py" + "check" + "--json-output"]) + :sysrootSrc "./library" + :extraEnv (:RUSTC_BOOTSTRAP "1")) + :rustc ( :source "./Cargo.toml" ))))))) diff --git a/src/etc/rust_analyzer_helix.toml b/src/etc/rust_analyzer_helix.toml new file mode 100644 index 000000000000..642350cad343 --- /dev/null +++ b/src/etc/rust_analyzer_helix.toml @@ -0,0 +1,49 @@ +[language-server.rust-analyzer.config] +linkedProjects = [ + "Cargo.toml", + "src/tools/x/Cargo.toml", + "src/bootstrap/Cargo.toml", + "src/tools/rust-analyzer/Cargo.toml", + "compiler/rustc_codegen_cranelift/Cargo.toml", + "compiler/rustc_codegen_gcc/Cargo.toml" +] + +[language-server.rust-analyzer.config.check] +invocationLocation = "root" +invocationStrategy = "once" +overrideCommand = [ + "python3", + "x.py", + "check", + "--json-output", +] + +[language-server.rust-analyzer.config.rustfmt] +overrideCommand = [ + "build-rust-analyzer/host/rustfmt/bin/rustfmt", + "--edition=2021" +] + +[language-server.rust-analyzer.config.procMacro] +server = "build-rust-analyzer/host/stage0/libexec/rust-analyzer-proc-macro-srv" +enable = true + +[language-server.rust-analyzer.config.rustc] +source = "./Cargo.toml" + +[language-server.rust-analyzer.config.cargo] +sysrootSrc = "./library" + +[language-server.rust-analyzer.config.cargo.extraEnv] +RUSTC_BOOTSTRAP = "1" + +[language-server.rust-analyzer.config.cargo.buildScripts] +enable = true +invocationLocation = "root" +invocationStrategy = "once" +overrideCommand = [ + "python3", + "x.py", + "check", + "--json-output", +] From a1846ec22f33748aca79b2106fa85c3576e5db68 Mon Sep 17 00:00:00 2001 From: Kajetan Puchalski Date: Fri, 27 Sep 2024 17:29:31 +0100 Subject: [PATCH 7/8] gitignore: Add eglot LSP config file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2e6499081a63..d6d8b99f6023 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ Session.vim .favorites.json .settings/ .vs/ +.dir-locals.el ## Tool .valgrindrc From e5e1fadc2b9b6395a29a76396d20827ca5405809 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Sun, 22 Sep 2024 15:42:55 -0400 Subject: [PATCH 8/8] Cleanup some known-bug issues --- .../in-trait/async-generics-and-bounds.rs | 3 +-- .../in-trait/async-generics-and-bounds.stderr | 4 +-- .../ui/async-await/in-trait/async-generics.rs | 3 +-- .../in-trait/async-generics.stderr | 4 +-- .../coherence/auxiliary/parametrized-trait.rs | 3 +++ .../coherence/occurs-check/associated-type.rs | 2 +- .../orphan-check-alias.classic.stderr | 15 +++++++++++ .../coherence/orphan-check-alias.next.stderr | 15 +++++++++++ tests/ui/coherence/orphan-check-alias.rs | 25 +++++++++++++++++++ .../bugs/issue-100013.rs | 2 +- .../bugs/issue-87735.rs | 2 +- .../bugs/issue-91762.rs | 2 +- tests/ui/never_type/exhaustive_patterns.rs | 4 ++- .../ui/never_type/exhaustive_patterns.stderr | 4 +-- ...102048.stderr => issue-102048.next.stderr} | 2 +- .../next-solver/coherence/issue-102048.rs | 9 +++++-- .../implied_lifetime_wf_check.error.stderr | 12 +++++++++ .../implied_lifetime_wf_check.rs | 12 +++++---- 18 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 tests/ui/coherence/orphan-check-alias.classic.stderr create mode 100644 tests/ui/coherence/orphan-check-alias.next.stderr create mode 100644 tests/ui/coherence/orphan-check-alias.rs rename tests/ui/traits/next-solver/coherence/{issue-102048.stderr => issue-102048.next.stderr} (96%) create mode 100644 tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index aede820f6fd0..89f6e057aaac 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs @@ -1,5 +1,4 @@ -//@ check-fail -//@ known-bug: #102682 +//@ known-bug: #130935 //@ edition: 2021 use std::fmt::Debug; diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr index b547da7126a4..183b0fa152aa 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:9:5 + --> $DIR/async-generics-and-bounds.rs:8:5 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: Debug + Sized, U: Has | ++++ ++ ++ +++++++ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:9:5 + --> $DIR/async-generics-and-bounds.rs:8:5 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index eedc63fa24c6..2302407e1ebe 100644 --- a/tests/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs @@ -1,5 +1,4 @@ -//@ check-fail -//@ known-bug: #102682 +//@ known-bug: #130935 //@ edition: 2021 trait MyTrait { diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr index 2e29a9bcc77a..8916ef5ab683 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.stderr @@ -1,5 +1,5 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:6:5 + --> $DIR/async-generics.rs:5:5 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: 'a; | ++++ ++ ++ +++++++++++ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:6:5 + --> $DIR/async-generics.rs:5:5 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/coherence/auxiliary/parametrized-trait.rs b/tests/ui/coherence/auxiliary/parametrized-trait.rs index 88a3d5cd52dc..f9dbdd4ff185 100644 --- a/tests/ui/coherence/auxiliary/parametrized-trait.rs +++ b/tests/ui/coherence/auxiliary/parametrized-trait.rs @@ -1,2 +1,5 @@ pub trait Trait0 {} pub trait Trait1 {} +pub trait Trait2 { + type Assoc; +} diff --git a/tests/ui/coherence/occurs-check/associated-type.rs b/tests/ui/coherence/occurs-check/associated-type.rs index df03d5f60a02..4441c38ba6d6 100644 --- a/tests/ui/coherence/occurs-check/associated-type.rs +++ b/tests/ui/coherence/occurs-check/associated-type.rs @@ -1,7 +1,7 @@ //@ revisions: old next //@[next] compile-flags: -Znext-solver -// A regression test for #105787 +// A (partial) regression test for #105787 // Using the higher ranked projection hack to prevent us from replacing the projection // with an inference variable. diff --git a/tests/ui/coherence/orphan-check-alias.classic.stderr b/tests/ui/coherence/orphan-check-alias.classic.stderr new file mode 100644 index 000000000000..3fd62b05b4df --- /dev/null +++ b/tests/ui/coherence/orphan-check-alias.classic.stderr @@ -0,0 +1,15 @@ +warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`B`) + --> $DIR/orphan-check-alias.rs:21:6 + | +LL | impl foreign::Trait2 for ::Assoc { + | ^ type parameter `T` must be covered by another type when it appears before the first local type (`B`) + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124559 + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: `#[warn(uncovered_param_in_projection)]` on by default + +warning: 1 warning emitted + +For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-alias.next.stderr b/tests/ui/coherence/orphan-check-alias.next.stderr new file mode 100644 index 000000000000..3fd62b05b4df --- /dev/null +++ b/tests/ui/coherence/orphan-check-alias.next.stderr @@ -0,0 +1,15 @@ +warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`B`) + --> $DIR/orphan-check-alias.rs:21:6 + | +LL | impl foreign::Trait2 for ::Assoc { + | ^ type parameter `T` must be covered by another type when it appears before the first local type (`B`) + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124559 + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: `#[warn(uncovered_param_in_projection)]` on by default + +warning: 1 warning emitted + +For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-alias.rs b/tests/ui/coherence/orphan-check-alias.rs new file mode 100644 index 000000000000..d6c9d0aa8bea --- /dev/null +++ b/tests/ui/coherence/orphan-check-alias.rs @@ -0,0 +1,25 @@ +// Alias might not cover type parameters. + +//@ revisions: classic next +//@[next] compile-flags: -Znext-solver + +//@ aux-crate:foreign=parametrized-trait.rs +//@ edition:2021 + +//@ known-bug: #99554 +//@ check-pass + +trait Id { + type Assoc; +} + +impl Id for T { + type Assoc = T; +} + +pub struct B; +impl foreign::Trait2 for ::Assoc { + type Assoc = usize; +} + +fn main() {} diff --git a/tests/ui/generic-associated-types/bugs/issue-100013.rs b/tests/ui/generic-associated-types/bugs/issue-100013.rs index 994f41e9f86b..ac72c29c03b9 100644 --- a/tests/ui/generic-associated-types/bugs/issue-100013.rs +++ b/tests/ui/generic-associated-types/bugs/issue-100013.rs @@ -1,5 +1,5 @@ //@ check-fail -//@ known-bug: unknown +//@ known-bug: #100013 //@ edition: 2021 // We really should accept this, but we need implied bounds between the regions diff --git a/tests/ui/generic-associated-types/bugs/issue-87735.rs b/tests/ui/generic-associated-types/bugs/issue-87735.rs index e864ad7c815d..0a24151cda77 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87735.rs +++ b/tests/ui/generic-associated-types/bugs/issue-87735.rs @@ -1,5 +1,5 @@ //@ check-fail -//@ known-bug: #87735, #88526 +//@ known-bug: unknown // This should pass, but we need an extension of implied bounds (probably). diff --git a/tests/ui/generic-associated-types/bugs/issue-91762.rs b/tests/ui/generic-associated-types/bugs/issue-91762.rs index b4799eb12f46..77bd275fa88e 100644 --- a/tests/ui/generic-associated-types/bugs/issue-91762.rs +++ b/tests/ui/generic-associated-types/bugs/issue-91762.rs @@ -1,5 +1,5 @@ //@ check-fail -//@ known-bug: unknown +//@ known-bug: #91762 // We almost certainly want this to pass, but // it's particularly difficult currently, because we need a way of specifying diff --git a/tests/ui/never_type/exhaustive_patterns.rs b/tests/ui/never_type/exhaustive_patterns.rs index 3c53ac319b4a..b56eab6cb9d9 100644 --- a/tests/ui/never_type/exhaustive_patterns.rs +++ b/tests/ui/never_type/exhaustive_patterns.rs @@ -1,5 +1,4 @@ //@ check-fail -//@ known-bug: #104034 #![feature(exhaustive_patterns, never_type)] @@ -17,5 +16,8 @@ fn foo() -> Either<(), !> { } fn main() { + // We can't treat this a irrefutable, because `Either::B` could become + // inhabited in the future because it's private. let Either::A(()) = foo(); + //~^ error refutable pattern in local binding } diff --git a/tests/ui/never_type/exhaustive_patterns.stderr b/tests/ui/never_type/exhaustive_patterns.stderr index ee7d9070cd32..1314cbc52f88 100644 --- a/tests/ui/never_type/exhaustive_patterns.stderr +++ b/tests/ui/never_type/exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/exhaustive_patterns.rs:20:9 + --> $DIR/exhaustive_patterns.rs:21:9 | LL | let Either::A(()) = foo(); | ^^^^^^^^^^^^^ pattern `Either::B(_)` not covered @@ -7,7 +7,7 @@ LL | let Either::A(()) = foo(); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Either<(), !>` defined here - --> $DIR/exhaustive_patterns.rs:10:6 + --> $DIR/exhaustive_patterns.rs:9:6 | LL | enum Either { | ^^^^^^ diff --git a/tests/ui/traits/next-solver/coherence/issue-102048.stderr b/tests/ui/traits/next-solver/coherence/issue-102048.next.stderr similarity index 96% rename from tests/ui/traits/next-solver/coherence/issue-102048.stderr rename to tests/ui/traits/next-solver/coherence/issue-102048.next.stderr index 4e93ae284969..39fde307f23f 100644 --- a/tests/ui/traits/next-solver/coherence/issue-102048.stderr +++ b/tests/ui/traits/next-solver/coherence/issue-102048.next.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Trait fn(<_ as WithAssoc1<'a>>::Assoc, <_ as WithAssoc2<'a>>::Assoc)>` for type `(_, _)` - --> $DIR/issue-102048.rs:39:1 + --> $DIR/issue-102048.rs:44:1 | LL | / impl Trait fn(>::Assoc, >::Assoc)> for (T, U) LL | | where diff --git a/tests/ui/traits/next-solver/coherence/issue-102048.rs b/tests/ui/traits/next-solver/coherence/issue-102048.rs index 64b223822c6e..16ae5d98488d 100644 --- a/tests/ui/traits/next-solver/coherence/issue-102048.rs +++ b/tests/ui/traits/next-solver/coherence/issue-102048.rs @@ -17,7 +17,12 @@ // that to `i32`. We then try to unify `i32` from `impl1` with `u32` from `impl2` which fails, // causing coherence to consider these two impls distinct. -//@ compile-flags: -Znext-solver +//@ revisions: classic next +//@[next] compile-flags: -Znext-solver + +//@[classic] known-bug: #102048 +//@[classic] check-pass + pub trait Trait {} pub trait WithAssoc1<'a> { @@ -37,7 +42,7 @@ where // impl 2 impl Trait fn(>::Assoc, u32)> for (T, U) where - U: for<'a> WithAssoc1<'a> //~^ ERROR conflicting implementations of trait + U: for<'a> WithAssoc1<'a> //[next]~^ ERROR conflicting implementations of trait { } diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr new file mode 100644 index 000000000000..a97227e481ef --- /dev/null +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.error.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Yay` for type `Alias` + --> $DIR/implied_lifetime_wf_check.rs:26:1 + | +LL | impl Yay for <() as HideIt>::Assoc {} + | ---------------------------------- first implementation here +LL | #[cfg(error)] +LL | impl Yay for i32 {} + | ^^^^^^^^^^^^^^^^ conflicting implementation for `Alias` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs index bc9d760cd297..d85c7f60023e 100644 --- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs +++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs @@ -1,8 +1,9 @@ #![feature(type_alias_impl_trait)] -//@ known-bug: #99840 -// this should not compile -//@ check-pass +//@ revisions: pass error + +//@[pass] check-pass +//@[error] check-fail type Alias = impl Sized; @@ -21,7 +22,8 @@ impl HideIt for () { pub trait Yay {} impl Yay for <() as HideIt>::Assoc {} -// impl Yay for i32 {} // this already errors -// impl Yay for u32 {} // this also already errors +#[cfg(error)] +impl Yay for i32 {} +//[error]~^ error conflicting implementations fn main() {}