Refactor dyn-compatibility error and suggestions

This CL makes a number of small changes to dyn compatibility errors:
- "object safety" has been renamed to "dyn-compatibility" throughout
- "Convert to enum" suggestions are no longer generated when there
  exists a type-generic impl of the trait or an impl for `dyn OtherTrait`
- Several error messages are reorganized for user readability

Additionally, the dyn compatibility error creation code has been
split out into functions.

cc #132713
cc #133267
This commit is contained in:
Taylor Cramer
2024-11-20 14:19:36 -08:00
parent b2728d5426
commit d00d4dfe0d
175 changed files with 1338 additions and 1102 deletions
@@ -264,15 +264,15 @@ trait Foo {
### Trait contains associated constants
Just like static functions, associated constants aren't stored on the method
table. If the trait or any subtrait contain an associated constant, they cannot
be made into an object.
table. If the trait or any subtrait contain an associated constant, they are not
dyn compatible.
```compile_fail,E0038
trait Foo {
const X: i32;
}
impl Foo {}
impl dyn Foo {}
```
A simple workaround is to use a helper method instead:
+1 -1
View File
@@ -163,7 +163,7 @@ macro_rules! declare_features {
/// then removed. But there was no utility storing it separately, so now
/// it's in this list.
(removed, no_stack_check, "1.0.0", None, None),
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible (object safe).
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible (object safe).
/// Renamed to `dyn_compatible_for_dispatch`.
(removed, object_safe_for_dispatch, "1.83.0", Some(43561),
Some("renamed to `dyn_compatible_for_dispatch`")),
+1 -1
View File
@@ -272,7 +272,7 @@ pub fn internal(&self, feature: Symbol) -> bool {
(unstable, doc_notable_trait, "1.52.0", Some(45040)),
/// Allows using the `may_dangle` attribute (RFC 1327).
(unstable, dropck_eyepatch, "1.10.0", Some(34761)),
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
/// 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.
///
@@ -185,7 +185,7 @@ 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 dyn-compatible.
// 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() {
@@ -433,34 +433,19 @@ pub fn report_dyn_incompatibility<'tcx>(
hir::Node::Item(item) => Some(item.ident.span),
_ => None,
});
let mut err = struct_span_code_err!(
tcx.dcx(),
span,
E0038,
"the {} `{}` cannot be made into an object",
"the {} `{}` is not dyn compatible",
tcx.def_descr(trait_def_id),
trait_str
);
err.span_label(span, format!("`{trait_str}` cannot be made into an object"));
err.span_label(span, format!("`{trait_str}` is not dyn compatible"));
attempt_dyn_to_impl_suggestion(tcx, hir_id, &mut err);
if let Some(hir_id) = hir_id
&& let hir::Node::Ty(ty) = tcx.hir_node(hir_id)
&& let hir::TyKind::TraitObject([trait_ref, ..], ..) = ty.kind
{
let mut hir_id = hir_id;
while let hir::Node::Ty(ty) = tcx.parent_hir_node(hir_id) {
hir_id = ty.hir_id;
}
if tcx.parent_hir_node(hir_id).fn_sig().is_some() {
// Do not suggest `impl Trait` when dealing with things like super-traits.
err.span_suggestion_verbose(
ty.span.until(trait_ref.span),
"consider using an opaque type instead",
"impl ",
Applicability::MaybeIncorrect,
);
}
}
let mut reported_violations = FxIndexSet::default();
let mut multi_span = vec![];
let mut messages = vec![];
@@ -475,7 +460,7 @@ pub fn report_dyn_incompatibility<'tcx>(
if reported_violations.insert(violation.clone()) {
let spans = violation.spans();
let msg = if trait_span.is_none() || spans.is_empty() {
format!("the trait cannot be made into an object because {}", violation.error_msg())
format!("the trait is not dyn compatible because {}", violation.error_msg())
} else {
format!("...because {}", violation.error_msg())
};
@@ -492,7 +477,7 @@ pub fn report_dyn_incompatibility<'tcx>(
let has_multi_span = !multi_span.is_empty();
let mut note_span = MultiSpan::from_spans(multi_span.clone());
if let (Some(trait_span), true) = (trait_span, has_multi_span) {
note_span.push_span_label(trait_span, "this trait cannot be made into an object...");
note_span.push_span_label(trait_span, "this trait is not dyn compatible...");
}
for (span, msg) in iter::zip(multi_span, messages) {
note_span.push_span_label(span, msg);
@@ -500,16 +485,12 @@ pub fn report_dyn_incompatibility<'tcx>(
// FIXME(dyn_compat_renaming): Update the URL.
err.span_note(
note_span,
"for a trait to be \"dyn-compatible\" it needs to allow building a vtable to allow the call \
to be resolvable dynamically; for more information visit \
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
"for a trait to be dyn compatible it needs to allow building a vtable\n\
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
);
// Only provide the help if its a local trait, otherwise it's not actionable.
if trait_span.is_some() {
let mut reported_violations: Vec<_> = reported_violations.into_iter().collect();
reported_violations.sort();
let mut potential_solutions: Vec<_> =
reported_violations.into_iter().map(|violation| violation.solution()).collect();
potential_solutions.sort();
@@ -520,68 +501,116 @@ pub fn report_dyn_incompatibility<'tcx>(
}
}
let impls_of = tcx.trait_impls_of(trait_def_id);
let impls = if impls_of.blanket_impls().is_empty() {
impls_of
.non_blanket_impls()
.values()
.flatten()
.filter(|def_id| {
!matches!(tcx.type_of(*def_id).instantiate_identity().kind(), ty::Dynamic(..))
})
.collect::<Vec<_>>()
} else {
vec![]
};
let externally_visible = if !impls.is_empty()
&& let Some(def_id) = trait_def_id.as_local()
// We may be executing this during typeck, which would result in cycle
// if we used effective_visibilities query, which looks into opaque types
// (and therefore calls typeck).
&& tcx.resolutions(()).effective_visibilities.is_exported(def_id)
{
true
} else {
false
};
match &impls[..] {
[] => {}
_ if impls.len() > 9 => {}
[only] if externally_visible => {
err.help(with_no_trimmed_paths!(format!(
"only type `{}` is seen to implement the trait in this crate, consider using it \
directly instead",
tcx.type_of(*only).instantiate_identity(),
)));
}
[only] => {
err.help(with_no_trimmed_paths!(format!(
"only type `{}` implements the trait, consider using it directly instead",
tcx.type_of(*only).instantiate_identity(),
)));
}
impls => {
let types = impls
.iter()
.map(|t| {
with_no_trimmed_paths!(format!(" {}", tcx.type_of(*t).instantiate_identity(),))
})
.collect::<Vec<_>>();
err.help(format!(
"the following types implement the trait, consider defining an enum where each \
variant holds one of these types, implementing `{}` for this new enum and using \
it instead:\n{}",
trait_str,
types.join("\n"),
));
}
}
if externally_visible {
err.note(format!(
"`{trait_str}` can be implemented in other crates; if you want to support your users \
passing their own types here, you can't refer to a specific type",
));
}
attempt_dyn_to_enum_suggestion(tcx, trait_def_id, &*trait_str, &mut err);
err
}
/// Attempt to suggest converting the `dyn Trait` argument to an enumeration
/// over the types that implement `Trait`.
fn attempt_dyn_to_enum_suggestion(
tcx: TyCtxt<'_>,
trait_def_id: DefId,
trait_str: &str,
err: &mut Diag<'_>,
) {
let impls_of = tcx.trait_impls_of(trait_def_id);
if !impls_of.blanket_impls().is_empty() {
return;
}
let concrete_impls: Option<Vec<Ty<'_>>> = impls_of
.non_blanket_impls()
.values()
.flatten()
.map(|impl_id| {
// Don't suggest conversion to enum if the impl types have type parameters.
// It's unlikely the user wants to define a generic enum.
let Some(impl_type) = tcx.type_of(*impl_id).no_bound_vars() else { return None };
// Obviously unsized impl types won't be usable in an enum.
// Note: this doesn't use `Ty::is_trivially_sized` because that function
// defaults to assuming that things are *not* sized, whereas we want to
// fall back to assuming that things may be sized.
match impl_type.kind() {
ty::Str | ty::Slice(_) | ty::Dynamic(_, _, ty::DynKind::Dyn) => {
return None;
}
_ => {}
}
Some(impl_type)
})
.collect();
let Some(concrete_impls) = concrete_impls else { return };
const MAX_IMPLS_TO_SUGGEST_CONVERTING_TO_ENUM: usize = 9;
if concrete_impls.is_empty() || concrete_impls.len() > MAX_IMPLS_TO_SUGGEST_CONVERTING_TO_ENUM {
return;
}
let externally_visible = if let Some(def_id) = trait_def_id.as_local() {
// We may be executing this during typeck, which would result in cycle
// if we used effective_visibilities query, which looks into opaque types
// (and therefore calls typeck).
tcx.resolutions(()).effective_visibilities.is_exported(def_id)
} else {
false
};
if let [only_impl] = &concrete_impls[..] {
let within = if externally_visible { " within this crate" } else { "" };
err.help(with_no_trimmed_paths!(format!(
"only type `{only_impl}` implements `{trait_str}`{within}; \
consider using it directly instead."
)));
} else {
let types = concrete_impls
.iter()
.map(|t| with_no_trimmed_paths!(format!(" {}", t)))
.collect::<Vec<String>>()
.join("\n");
err.help(format!(
"the following types implement `{trait_str}`:\n\
{types}\n\
consider defining an enum where each variant holds one of these types,\n\
implementing `{trait_str}` for this new enum and using it instead",
));
}
if externally_visible {
err.note(format!(
"`{trait_str}` may be implemented in other crates; if you want to support your users \
passing their own types here, you can't refer to a specific type",
));
}
}
/// Attempt to suggest that a `dyn Trait` argument or return type be converted
/// to use `impl Trait`.
fn attempt_dyn_to_impl_suggestion(tcx: TyCtxt<'_>, hir_id: Option<hir::HirId>, err: &mut Diag<'_>) {
let Some(hir_id) = hir_id else { return };
let hir::Node::Ty(ty) = tcx.hir_node(hir_id) else { return };
let hir::TyKind::TraitObject([trait_ref, ..], ..) = ty.kind else { return };
// Only suggest converting `dyn` to `impl` if we're in a function signature.
// This ensures that we don't suggest converting e.g.
// `type Alias = Box<dyn DynIncompatibleTrait>;` to
// `type Alias = Box<impl DynIncompatibleTrait>;`
let Some((_id, first_non_type_parent_node)) =
tcx.hir().parent_iter(hir_id).find(|(_id, node)| !matches!(node, hir::Node::Ty(_)))
else {
return;
};
if first_non_type_parent_node.fn_sig().is_none() {
return;
}
err.span_suggestion_verbose(
ty.span.until(trait_ref.span),
"consider using an opaque type instead",
"impl ",
Applicability::MaybeIncorrect,
);
}
@@ -53,7 +53,6 @@ fn dyn_compatibility_violations(
) -> &'_ [DynCompatibilityViolation] {
debug_assert!(tcx.generics_of(trait_def_id).has_self);
debug!("dyn_compatibility_violations: {:?}", trait_def_id);
tcx.arena.alloc_from_iter(
elaborate::supertrait_def_ids(tcx, trait_def_id)
.flat_map(|def_id| dyn_compatibility_violations_for_trait(tcx, def_id)),
@@ -8,4 +8,4 @@ fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR trait `X` cannot be made into an object
//~| ERROR trait `X` is not dyn compatible
@@ -92,17 +92,18 @@ LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/invalid_const_in_lifetime_position.rs:4:20
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -5,8 +5,8 @@
pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| the trait `SVec` cannot be made into an object
//~| `SVec` cannot be made into an object
//~| the trait `SVec` is not dyn compatible
//~| `SVec` is not dyn compatible
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
let _ = s;
@@ -294,19 +294,20 @@ help: add missing generic argument
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0038]: the trait `SVec` cannot be made into an object
error[E0038]: the trait `SVec` is not dyn compatible
--> $DIR/ice-generic-type-alias-105742.rs:5:35
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/ice-generic-type-alias-105742.rs:15:17
|
LL | pub trait SVec: Index<
| ____________----__^
| | |
| | this trait cannot be made into an object...
| | this trait is not dyn compatible...
LL | | <Self as SVec>::Item,
... |
LL | |/ Output = <Index<<Self as SVec>::Item,
@@ -5,9 +5,9 @@ trait Trait {
}
impl dyn Trait {
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
//~^ ERROR the trait `Trait` is not dyn compatible [E0038]
const fn n() -> usize { Self::N }
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
//~^ ERROR the trait `Trait` is not dyn compatible [E0038]
}
fn main() {}
@@ -1,29 +1,31 @@
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/associated-const-in-trait.rs:7:6
|
LL | impl dyn Trait {
| ^^^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-const-in-trait.rs:4:11
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/associated-const-in-trait.rs:9:29
|
LL | const fn n() -> usize { Self::N }
| ^^^^ `Trait` cannot be made into an object
| ^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-const-in-trait.rs:4:11
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait
+1 -1
View File
@@ -3,6 +3,6 @@ trait Bar {
fn return_n(&self) -> [u8; Bar::X]; //~ ERROR: E0790
}
impl dyn Bar {} //~ ERROR: the trait `Bar` cannot be made into an object
impl dyn Bar {} //~ ERROR: the trait `Bar` is not dyn compatible
fn main() {}
+5 -4
View File
@@ -1,14 +1,15 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/issue-48027.rs:6:6
|
LL | impl dyn Bar {}
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-48027.rs:2:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait
+1 -1
View File
@@ -1,6 +1,6 @@
//@ edition:2018
fn foo(x: &dyn AsyncFn()) {}
//~^ ERROR the trait `AsyncFnMut` cannot be made into an object
//~^ ERROR the trait `AsyncFnMut` is not dyn compatible
fn main() {}
+5 -8
View File
@@ -1,17 +1,14 @@
error[E0038]: the trait `AsyncFnMut` cannot be made into an object
error[E0038]: the trait `AsyncFnMut` is not dyn compatible
--> $DIR/dyn-pos.rs:3:16
|
LL | fn foo(x: &dyn AsyncFn()) {}
| ^^^^^^^^^ `AsyncFnMut` cannot be made into an object
| ^^^^^^^^^ `AsyncFnMut` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $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`
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead:
&F
&mut F
std::boxed::Box<F, A>
= note: the trait is not dyn compatible because it contains the generic associated type `CallRefFuture`
error: aborting due to 1 previous error
@@ -7,5 +7,5 @@ trait Foo {
fn main() {
let x: &dyn Foo = todo!();
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
}
@@ -1,14 +1,15 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility.rs:9:12
|
LL | let x: &dyn Foo = todo!();
| ^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility.rs:5:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn foo(&self);
| ^^^ ...because method `foo` is `async`
= help: consider moving `foo` to another trait
@@ -3,7 +3,7 @@
trait Foo {
async fn foo(self: &dyn Foo) {
//~^ ERROR: `Foo` cannot be made into an object
//~^ ERROR: `Foo` is not dyn compatible
//~| ERROR invalid `self` parameter type: `&dyn Foo`
todo!()
}
@@ -7,17 +7,18 @@ LL | async fn foo(self: &dyn Foo) {
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/inference_var_self_argument.rs:5:5
|
LL | async fn foo(self: &dyn Foo) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/inference_var_self_argument.rs:5:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn foo(self: &dyn Foo) {
| ^^^ ...because method `foo` is `async`
= help: consider moving `foo` to another trait
@@ -1,16 +1,17 @@
error[E0038]: the trait `DynIncompatible` cannot be made into an object
error[E0038]: the trait `DynIncompatible` is not dyn compatible
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:26
|
LL | impl DynIncompatible for dyn DynIncompatible { }
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:6:45
|
LL | trait DynIncompatible { fn eq(&self, other: Self); }
| --------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
= help: consider moving `eq` to another trait
error[E0046]: not all trait items implemented, missing: `eq`
@@ -1,28 +1,30 @@
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
error[E0038]: the trait `ConstParamTy_` is not dyn compatible
--> $DIR/const_param_ty_dyn_compatibility.rs:6:16
|
LL | fn foo(a: &dyn ConstParamTy_) {}
| ^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
| ^^^^^^^^^^^^^ `ConstParamTy_` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $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
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn foo(a: &impl ConstParamTy_) {}
| ~~~~
error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
error[E0038]: the trait `UnsizedConstParamTy` is not dyn compatible
--> $DIR/const_param_ty_dyn_compatibility.rs:9:16
|
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $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
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn bar(a: &impl UnsizedConstParamTy) {}
@@ -14,8 +14,8 @@ impl Foo for () {
}
}
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` cannot be made into an object
v.test(); //~ERROR the trait `Foo` cannot be made into an object
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` is not dyn compatible
v.test(); //~ERROR the trait `Foo` is not dyn compatible
}
fn main() {}
@@ -1,38 +1,40 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-ret.rs:17:16
|
LL | fn use_dyn(v: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-ret.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
| |
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-ret.rs:18:5
|
LL | v.test();
| ^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-ret.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
| |
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error: aborting due to 2 previous errors
@@ -13,9 +13,9 @@ impl Foo for () {
}
fn use_dyn(v: &dyn Foo) {
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
v.test();
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
}
fn main() {}
@@ -1,34 +1,36 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-where-bounds.rs:15:16
|
LL | fn use_dyn(v: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-where-bounds.rs:17:5
|
LL | v.test();
| ^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error: aborting due to 2 previous errors
@@ -13,7 +13,7 @@ fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR `X` cannot be made into an object
//~| ERROR `X` is not dyn compatible
};
fn main() {}
@@ -92,17 +92,18 @@ LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-102768.rs:9:24
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-102768.rs:5:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -2,6 +2,6 @@
fn main() {
let _: &Copy + 'static; //~ ERROR expected a path
//~^ ERROR cannot be made into an object
//~^ ERROR is not dyn compatible
let _: &'static Copy + 'static; //~ ERROR expected a path
}
@@ -20,14 +20,15 @@ help: try adding parentheses
LL | let _: &'static (Copy + 'static);
| + +
error[E0038]: the trait `Copy` cannot be made into an object
error[E0038]: the trait `Copy` is not dyn compatible
--> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12
|
LL | let _: &Copy + 'static;
| ^^^^^ `Copy` cannot be made into an object
| ^^^^^ `Copy` is not dyn compatible
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
= note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
= note: the trait is not dyn compatible because it requires `Self: Sized`
= note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
error: aborting due to 3 previous errors
@@ -5,8 +5,8 @@
fn transmute<T, U>(t: T) -> U {
(&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
//~^ ERROR the trait `Foo` cannot be made into an object
//~| ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
}
struct ActuallySuper;
@@ -19,7 +19,7 @@ trait Dyn {
type Out;
}
impl<T, U> Dyn for dyn Foo<T, U> + '_ {
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
type Out = U;
}
impl<S: Dyn<Out = U> + ?Sized, U> Super<NotActuallySuper> for S {
@@ -1,53 +1,53 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:21:20
|
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {
| ^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait
= help: only type `std::marker::PhantomData<T>` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:7:27
|
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
| ^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait
= help: only type `std::marker::PhantomData<T>` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:7:6
|
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
| ^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait
= help: only type `std::marker::PhantomData<T>` implements the trait, consider using it directly instead
= note: required for the cast from `&PhantomData<T>` to `&dyn Foo<T, U>`
error: aborting due to 3 previous errors
@@ -1,29 +1,31 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/associated-consts.rs:12:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/associated-consts.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait
@@ -1,14 +1,15 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/associated-consts.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait
@@ -26,14 +26,15 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | fn id<F>(f: dyn Copy) -> usize {
| +++
error[E0038]: the trait `Copy` cannot be made into an object
error[E0038]: the trait `Copy` is not dyn compatible
--> $DIR/avoid-ice-on-warning-2.rs:4:13
|
LL | fn id<F>(f: Copy) -> usize {
| ^^^^ `Copy` cannot be made into an object
| ^^^^ `Copy` is not dyn compatible
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
= note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
= note: the trait is not dyn compatible because it requires `Self: Sized`
= note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
error[E0618]: expected function, found `(dyn Copy + 'static)`
--> $DIR/avoid-ice-on-warning-2.rs:12:5
@@ -3,7 +3,7 @@
//@[new] edition:2021
fn id<F>(f: Copy) -> usize {
//[new]~^ ERROR expected a type, found a trait
//[old]~^^ ERROR the trait `Copy` cannot be made into an object
//[old]~^^ ERROR the trait `Copy` is not dyn compatible
//[old]~| ERROR the size for values of type `(dyn Copy + 'static)`
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
@@ -65,19 +65,20 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | trait B { fn f(a: dyn A) -> A; }
| +++
error[E0038]: the trait `A` cannot be made into an object
error[E0038]: the trait `A` is not dyn compatible
--> $DIR/avoid-ice-on-warning-3.rs:4:19
|
LL | trait B { fn f(a: A) -> A; }
| ^ `A` cannot be made into an object
| ^ `A` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/avoid-ice-on-warning-3.rs:14:14
|
LL | trait A { fn g(b: B) -> B; }
| - ^ ...because associated function `g` has no `self` parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
help: consider turning `g` into a method by giving it a `&self` argument
|
LL | trait A { fn g(&self, b: B) -> B; }
@@ -101,19 +102,20 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | trait A { fn g(b: dyn B) -> B; }
| +++
error[E0038]: the trait `B` cannot be made into an object
error[E0038]: the trait `B` is not dyn compatible
--> $DIR/avoid-ice-on-warning-3.rs:14:19
|
LL | trait A { fn g(b: B) -> B; }
| ^ `B` cannot be made into an object
| ^ `B` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/avoid-ice-on-warning-3.rs:4:14
|
LL | trait B { fn f(a: A) -> A; }
| - ^ ...because associated function `f` has no `self` parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
help: consider turning `f` into a method by giving it a `&self` argument
|
LL | trait B { fn f(&self, a: A) -> A; }
@@ -4,7 +4,7 @@
trait B { fn f(a: A) -> A; }
//[new]~^ ERROR expected a type, found a trait
//[new]~| ERROR expected a type, found a trait
//[old]~^^^ ERROR the trait `A` cannot be made into an object
//[old]~^^^ ERROR the trait `A` is not dyn compatible
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
@@ -14,7 +14,7 @@
trait A { fn g(b: B) -> B; }
//[new]~^ ERROR expected a type, found a trait
//[new]~| ERROR expected a type, found a trait
//[old]~^^^ ERROR the trait `B` cannot be made into an object
//[old]~^^^ ERROR the trait `B` is not dyn compatible
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
@@ -5,7 +5,7 @@
#![deny(bare_trait_objects)]
fn ord_prefer_dot(s: String) -> impl Ord {
//[new]~^ ERROR expected a type, found a trait
//[old]~^^ ERROR the trait `Ord` cannot be made into an object
//[old]~^^ ERROR the trait `Ord` is not dyn compatible
//[old]~| ERROR trait objects without an explicit `dyn` are deprecated
//[old]~| WARNING this is accepted in the current edition (Rust 2015)
(s.starts_with("."), s)
@@ -16,19 +16,20 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | fn ord_prefer_dot(s: String) -> dyn Ord {
| +++
error[E0038]: the trait `Ord` cannot be made into an object
error[E0038]: the trait `Ord` is not dyn compatible
--> $DIR/bare-trait-dont-suggest-dyn.rs:6:33
|
LL | fn ord_prefer_dot(s: String) -> Ord {
| ^^^ `Ord` cannot be made into an object
| ^^^ `Ord` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $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
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
::: $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
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn ord_prefer_dot(s: String) -> impl Ord {
@@ -5,7 +5,7 @@
#![deny(bare_trait_objects)]
fn ord_prefer_dot(s: String) -> Ord {
//[new]~^ ERROR expected a type, found a trait
//[old]~^^ ERROR the trait `Ord` cannot be made into an object
//[old]~^^ ERROR the trait `Ord` is not dyn compatible
//[old]~| ERROR trait objects without an explicit `dyn` are deprecated
//[old]~| WARNING this is accepted in the current edition (Rust 2015)
(s.starts_with("."), s)
+1 -1
View File
@@ -5,7 +5,7 @@ trait X {
}
fn f() -> Box<dyn X<U = u32>> {
//~^ ERROR the trait `X` cannot be made into an object
//~^ ERROR the trait `X` is not dyn compatible
loop {}
}
+5 -4
View File
@@ -1,14 +1,15 @@
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/bounds.rs:7:15
|
LL | fn f() -> Box<dyn X<U = u32>> {
| ^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/bounds.rs:4:13
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type U: PartialEq<Self>;
| ^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter
@@ -0,0 +1,18 @@
// Test that the dyn-compatibility diagnostics for GATs refer first to the
// user-named trait, not the GAT-containing supertrait.
//
// NOTE: this test is currently broken, and first reports:
// "the trait `Super` is not dyn compatible"
//
//@ edition:2018
trait Super {
type Assoc<'a>;
}
trait Child: Super {}
fn take_dyn(_: &dyn Child) {}
//~^ ERROR the trait `Super` is not dyn compatible
fn main() {}
@@ -0,0 +1,19 @@
error[E0038]: the trait `Super` is not dyn compatible
--> $DIR/gat-incompatible-supertrait.rs:15:21
|
LL | fn take_dyn(_: &dyn Child) {}
| ^^^^^ `Super` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-incompatible-supertrait.rs:10:10
|
LL | trait Super {
| ----- this trait is not dyn compatible...
LL | type Assoc<'a>;
| ^^^^^ ...because it contains the generic associated type `Assoc`
= help: consider moving `Assoc` to another trait
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.
+25 -20
View File
@@ -1,75 +1,80 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:18:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:25:40
|
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:20:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:27:10
|
LL | t as &dyn Bar
| ^^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:27:5
|
LL | t as &dyn Bar
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
@@ -1,30 +1,32 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:20:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:27:5
|
LL | t as &dyn Bar
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
@@ -1,36 +1,38 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:15
|
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
LL | fn foo<T>(&self, val: T);
| ^^^ ...because method `foo` has generic type parameters
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
= help: only type `Thing` implements the trait, consider using it directly instead
= help: only type `Thing` implements `Bar`; consider using it directly instead.
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:30
|
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
LL | fn foo<T>(&self, val: T);
| ^^^ ...because method `foo` has generic type parameters
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
= help: only type `Thing` implements the trait, consider using it directly instead
= help: only type `Thing` implements `Bar`; consider using it directly instead.
= note: required for the cast from `&mut Thing` to `&mut dyn Bar`
error: aborting due to 2 previous errors
@@ -36,9 +36,9 @@ fn print_element_count(&self) {
fn main() {
let a: Box<dyn Expr> = Box::new(SExpr::new());
//~^ ERROR: `Expr` cannot be made into an object
//~^ ERROR: `Expr` is not dyn compatible
let b: Box<dyn Expr> = Box::new(SExpr::new());
//~^ ERROR: `Expr` cannot be made into an object
//~^ ERROR: `Expr` is not dyn compatible
// assert_eq!(a , b);
}
@@ -1,47 +1,47 @@
error[E0038]: the trait `Expr` cannot be made into an object
error[E0038]: the trait `Expr` is not dyn compatible
--> $DIR/mentions-Self-in-super-predicates.rs:12:27
|
LL | elements: Vec<Box<dyn Expr + 'x>>,
| ^^^^ `Expr` cannot be made into an object
| ^^^^ `Expr` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
| this trait is not dyn compatible...
error[E0038]: the trait `Expr` cannot be made into an object
error[E0038]: the trait `Expr` is not dyn compatible
--> $DIR/mentions-Self-in-super-predicates.rs:38:20
|
LL | let a: Box<dyn Expr> = Box::new(SExpr::new());
| ^^^^ `Expr` cannot be made into an object
| ^^^^ `Expr` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
| this trait is not dyn compatible...
error[E0038]: the trait `Expr` cannot be made into an object
error[E0038]: the trait `Expr` is not dyn compatible
--> $DIR/mentions-Self-in-super-predicates.rs:40:20
|
LL | let b: Box<dyn Expr> = Box::new(SExpr::new());
| ^^^^ `Expr` cannot be made into an object
| ^^^^ `Expr` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
| this trait is not dyn compatible...
error: aborting due to 3 previous errors
@@ -1,60 +1,64 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mentions-Self.rs:22:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/mentions-Self.rs:28:31
|
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^^^^^ `Baz` cannot be made into an object
| ^^^^^^^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mentions-Self.rs:24:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/mentions-Self.rs:30:5
|
LL | t
| ^ `Baz` cannot be made into an object
| ^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait
@@ -1,30 +1,32 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mentions-Self.rs:24:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/mentions-Self.rs:30:5
|
LL | t
| ^ `Baz` cannot be made into an object
| ^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait
@@ -2,6 +2,6 @@ trait Foo {
type Bar<T>;
}
fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` cannot be made into an object
fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` is not dyn compatible
fn main() {}
@@ -1,14 +1,15 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/missing-assoc-type.rs:5:16
|
LL | fn bar(x: &dyn Foo) {}
| ^^^ `Foo` cannot be made into an object
| ^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/missing-assoc-type.rs:2:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type Bar<T>;
| ^^^ ...because it contains the generic associated type `Bar`
= help: consider moving `Bar` to another trait
@@ -1,17 +1,18 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:12:22
|
LL | fn diverges() -> Box<dyn Foo> {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) {}
@@ -21,20 +22,21 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
LL | fn foo() where Self: Sized {}
| +++++++++++++++++
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:22:12
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) {}
@@ -44,20 +46,21 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
LL | fn foo() where Self: Sized {}
| +++++++++++++++++
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:22:27
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
help: consider turning `foo` into a method by giving it a `&self` argument
|
@@ -1,17 +1,18 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:22:27
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
help: consider turning `foo` into a method by giving it a `&self` argument
|
+10 -8
View File
@@ -1,28 +1,30 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized-2.rs:14:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized-2.rs:9:18
|
LL | trait Bar
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | where Self : Sized
| ^^^^^ ...because it requires `Self: Sized`
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized-2.rs:16:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized-2.rs:9:18
|
LL | trait Bar
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | where Self : Sized
| ^^^^^ ...because it requires `Self: Sized`
= note: required for the cast from `&T` to `&dyn Bar`
@@ -1,14 +1,15 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized-2.rs:16:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized-2.rs:9:18
|
LL | trait Bar
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | where Self : Sized
| ^^^^^ ...because it requires `Self: Sized`
= note: required for the cast from `&T` to `&dyn Bar`
+10 -8
View File
@@ -1,30 +1,32 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized.rs:12:32
|
LL | fn make_bar<T: Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized.rs:8:12
|
LL | trait Bar: Sized {
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized.rs:8:12
|
LL | trait Bar: Sized {
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
= note: required for the cast from `&T` to `&dyn Bar`
error: aborting due to 2 previous errors
@@ -1,16 +1,17 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized.rs:8:12
|
LL | trait Bar: Sized {
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
= note: required for the cast from `&T` to `&dyn Bar`
error: aborting due to 1 previous error
@@ -9,7 +9,7 @@ trait GatTrait {
trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> {
fn c(&self) -> dyn SuperTrait<T>;
//~^ ERROR associated item referring to unboxed trait object for its own trait
//~| ERROR the trait `SuperTrait` cannot be made into an object
//~| ERROR the trait `SuperTrait` is not dyn compatible
}
fn main() {}
@@ -20,20 +20,21 @@ help: you might have meant to use `Self` to refer to the implementing type
LL | fn c(&self) -> Self;
| ~~~~
error[E0038]: the trait `SuperTrait` cannot be made into an object
error[E0038]: the trait `SuperTrait` is not dyn compatible
--> $DIR/supertrait-mentions-GAT.rs:10:20
|
LL | fn c(&self) -> dyn SuperTrait<T>;
| ^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
| ^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/supertrait-mentions-GAT.rs:4:10
|
LL | type Gat<'a>
| ^^^ ...because it contains the generic associated type `Gat`
...
LL | trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> {
| ---------- this trait cannot be made into an object...
| ---------- this trait is not dyn compatible...
= help: consider moving `Gat` to another trait
error: aborting due to 3 previous errors
@@ -18,19 +18,20 @@ help: consider relaxing the implicit `Sized` restriction
LL | trait Bar<T: ?Sized> {
| ++++++++
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/supertrait-mentions-Self.rs:16:35
|
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^ `Baz` cannot be made into an object
| ^^^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/supertrait-mentions-Self.rs:8:13
|
LL | trait Baz : Bar<Self> {
| --- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
help: consider using an opaque type instead
|
LL | fn make_baz<T:Baz>(t: &T) -> &impl Baz {
@@ -1,14 +1,15 @@
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:15
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^^^^^^^^^ `Qux` cannot be made into an object
| ^^^^^^^^^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
help: consider turning `bar` into a method by giving it a `&self` argument
@@ -20,17 +21,18 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
LL | fn bar() where Self: Sized;
| +++++++++++++++++
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:33
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^ `Qux` cannot be made into an object
| ^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
= note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)`
@@ -43,17 +45,18 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
LL | fn bar() where Self: Sized;
| +++++++++++++++++
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:15
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^^^^^^^^^ `Qux` cannot be made into an object
| ^^^^^^^^^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
@@ -1,14 +1,15 @@
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:33
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^ `Qux` cannot be made into an object
| ^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
= note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)`
@@ -9,8 +9,8 @@ trait Qux {
}
static FOO: &(dyn Qux + Sync) = "desc";
//~^ the trait `Qux` cannot be made into an object
//[curr]~| the trait `Qux` cannot be made into an object
//[curr]~| the trait `Qux` cannot be made into an object
//~^ the trait `Qux` is not dyn compatible
//[curr]~| the trait `Qux` is not dyn compatible
//[curr]~| the trait `Qux` is not dyn compatible
fn main() {}
@@ -17,13 +17,13 @@ fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
}
fn fetcher() -> Box<dyn Fetcher> {
//~^ ERROR the trait `Fetcher` cannot be made into an object
//~^ ERROR the trait `Fetcher` is not dyn compatible
todo!()
}
pub fn foo() {
let fetcher = fetcher();
//~^ ERROR the trait `Fetcher` cannot be made into an object
//~^ ERROR the trait `Fetcher` is not dyn compatible
let _ = fetcher.get();
//~^ ERROR the trait `Fetcher` cannot be made into an object
//~^ ERROR the trait `Fetcher` is not dyn compatible
}
@@ -1,51 +1,54 @@
error[E0038]: the trait `Fetcher` cannot be made into an object
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:19:21
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | fn fetcher() -> Box<dyn Fetcher> {
| ^^^^^^^^^^^ `Fetcher` cannot be made into an object
| ^^^^^^^^^^^ `Fetcher` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
error[E0038]: the trait `Fetcher` cannot be made into an object
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:25:19
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | let fetcher = fetcher();
| ^^^^^^^^^ `Fetcher` cannot be made into an object
| ^^^^^^^^^ `Fetcher` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
error[E0038]: the trait `Fetcher` cannot be made into an object
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:27:13
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | let _ = fetcher.get();
| ^^^^^^^^^^^^^ `Fetcher` cannot be made into an object
| ^^^^^^^^^^^^^ `Fetcher` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
+10 -8
View File
@@ -1,29 +1,31 @@
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/E0038.rs:5:20
|
LL | fn call_foo(x: Box<dyn Trait>) {
| ^^^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/E0038.rs:7:13
|
LL | let y = x.foo();
| ^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
@@ -5,10 +5,10 @@ trait Foo {
}
async fn takes_dyn_trait(x: &dyn Foo) {
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
x.bar().await;
//~^ ERROR the trait `Foo` cannot be made into an object
//~| ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
}
fn main() {}
@@ -1,44 +1,47 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:7:30
|
LL | async fn takes_dyn_trait(x: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:7
|
LL | x.bar().await;
| ^^^ `Foo` cannot be made into an object
| ^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:5
|
LL | x.bar().await;
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
@@ -30,6 +30,6 @@ fn ptr(self: Ptr<Self>) {}
fn main() {
Ptr(Box::new(4)) as Ptr<dyn Trait>;
//~^ ERROR the trait `Trait` cannot be made into an object
//~^^ ERROR the trait `Trait` cannot be made into an object
//~^ ERROR the trait `Trait` is not dyn compatible
//~^^ ERROR the trait `Trait` is not dyn compatible
}
@@ -1,38 +1,40 @@
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:25
|
LL | fn ptr(self: Ptr<Self>);
| --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self`
...
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
| ^^^^^^^^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | fn ptr(self: Ptr<Self>);
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
= help: only type `i32` implements the trait, consider using it directly instead
= help: only type `i32` implements `Trait`; consider using it directly instead.
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5
|
LL | fn ptr(self: Ptr<Self>);
| --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self`
...
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
| ^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^^^^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | fn ptr(self: Ptr<Self>);
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
= help: only type `i32` implements the trait, consider using it directly instead
= help: only type `i32` implements `Trait`; consider using it directly instead.
= note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>`
error: aborting due to 2 previous errors
@@ -1,28 +1,30 @@
error[E0038]: the trait `DynIncompatible1` cannot be made into an object
error[E0038]: the trait `DynIncompatible1` is not dyn compatible
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:18:40
|
LL | fn takes_dyn_incompatible_ref<T>(obj: &dyn DynIncompatible1) {
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:4:25
|
LL | trait DynIncompatible1: Sized {}
| ---------------- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
error[E0038]: the trait `DynIncompatible2` cannot be made into an object
error[E0038]: the trait `DynIncompatible2` is not dyn compatible
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:22:46
|
LL | fn return_dyn_incompatible_ref() -> &'static dyn DynIncompatible2 {
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible2` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible2` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:7:8
|
LL | trait DynIncompatible2 {
| ---------------- this trait cannot be made into an object...
| ---------------- this trait is not dyn compatible...
LL | fn static_fn() {}
| ^^^^^^^^^ ...because associated function `static_fn` has no `self` parameter
help: consider turning `static_fn` into a method by giving it a `&self` argument
@@ -34,49 +36,52 @@ help: alternatively, consider constraining `static_fn` so it does not apply to t
LL | fn static_fn() where Self: Sized {}
| +++++++++++++++++
error[E0038]: the trait `DynIncompatible3` cannot be made into an object
error[E0038]: the trait `DynIncompatible3` is not dyn compatible
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:27:40
|
LL | fn takes_dyn_incompatible_box(obj: Box<dyn DynIncompatible3>) {
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible3` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible3` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:11:8
|
LL | trait DynIncompatible3 {
| ---------------- this trait cannot be made into an object...
| ---------------- this trait is not dyn compatible...
LL | fn foo<T>(&self);
| ^^^ ...because method `foo` has generic type parameters
= help: consider moving `foo` to another trait
error[E0038]: the trait `DynIncompatible4` cannot be made into an object
error[E0038]: the trait `DynIncompatible4` is not dyn compatible
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:31:48
|
LL | fn return_dyn_incompatible_rc() -> std::rc::Rc<dyn DynIncompatible4> {
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible4` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible4` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:15:22
|
LL | trait DynIncompatible4 {
| ---------------- this trait cannot be made into an object...
| ---------------- this trait is not dyn compatible...
LL | fn foo(&self, s: &Self);
| ^^^^^ ...because method `foo` references the `Self` type in this parameter
= help: consider moving `foo` to another trait
error[E0038]: the trait `DynIncompatible1` cannot be made into an object
error[E0038]: the trait `DynIncompatible1` is not dyn compatible
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:38:16
|
LL | impl Trait for dyn DynIncompatible1 {}
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:4:25
|
LL | trait DynIncompatible1: Sized {}
| ---------------- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
error: aborting due to 5 previous errors
@@ -8,5 +8,5 @@ fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
//~| ERROR: binding for associated type `Y` references lifetime
//~| ERROR: binding for associated type `Y` references lifetime
//~| ERROR: binding for associated type `Y` references lifetime
//~| ERROR: the trait `X` cannot be made into an object
//~| ERROR: the trait `X` is not dyn compatible
}
@@ -36,17 +36,18 @@ LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:19
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:2:8
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'x>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -1,56 +1,50 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/gat-in-trait-path.rs:26:17
|
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:10:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/gat-in-trait-path.rs:32:5
|
LL | f(Box::new(foo));
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:10:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/gat-in-trait-path.rs:32:5
|
LL | f(Box::new(foo));
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:10:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>
= note: required for the cast from `Box<Fooer<{integer}>>` to `Box<(dyn Foo<A<'a> = &'a ()> + 'static)>`
error: aborting due to 3 previous errors
@@ -20,12 +20,11 @@ impl<T> Foo for Fooer<T> {
}
fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
//~^ the trait `Foo` cannot be made into an object
//~^ the trait `Foo` is not dyn compatible
fn main() {
let foo = Fooer(5);
f(Box::new(foo));
//~^ the trait `Foo` cannot be made into an object
//~| the trait `Foo` cannot be made into an object
//~^ the trait `Foo` is not dyn compatible
//~| the trait `Foo` is not dyn compatible
}
@@ -1,56 +1,50 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/gat-in-trait-path.rs:22:17
|
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:6:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/gat-in-trait-path.rs:28:5
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/gat-in-trait-path.rs:27:5
|
LL | f(Box::new(foo));
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:6:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/gat-in-trait-path.rs:28:5
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/gat-in-trait-path.rs:27:5
|
LL | f(Box::new(foo));
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:6:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>
= note: required for the cast from `Box<Fooer<{integer}>>` to `Box<(dyn Foo<A<'a> = &'a ()> + 'static)>`
error: aborting due to 3 previous errors
@@ -12,7 +12,7 @@ fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR at least one trait is required
//~| ERROR: the trait `X` cannot be made into an object
//~| ERROR: the trait `X` is not dyn compatible
fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
@@ -20,6 +20,6 @@ fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR: the trait `X` cannot be made into an object
//~| ERROR: the trait `X` is not dyn compatible
fn main() {}
@@ -123,17 +123,18 @@ error[E0224]: at least one trait is required for an object type
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/gat-trait-path-parenthesised-args.rs:5:21
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -188,17 +189,18 @@ help: add missing lifetime argument
LL | fn bar<'a>(arg: Box<dyn X<Y('_) = ()>>) {}
| ++
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/gat-trait-path-parenthesised-args.rs:18:21
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -1,14 +1,15 @@
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-67510-pass.rs:12:23
|
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510-pass.rs:9:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -5,6 +5,6 @@ trait X {
}
fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
//~^ ERROR the trait `X` cannot be made into an object
//~^ ERROR the trait `X` is not dyn compatible
fn main() {}
@@ -1,14 +1,15 @@
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-67510-pass.rs:7:23
|
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510-pass.rs:4:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -5,6 +5,6 @@ trait X {
fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
//~^ ERROR: use of undeclared lifetime name `'a`
//~| ERROR: use of undeclared lifetime name `'a`
//~| ERROR: the trait `X` cannot be made into an object [E0038]
//~| ERROR: the trait `X` is not dyn compatible [E0038]
fn main() {}
@@ -29,17 +29,18 @@ help: consider introducing lifetime `'a` here
LL | fn f<'a>(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ++++
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-67510.rs:5:13
|
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510.rs:2:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -11,13 +11,13 @@ struct Holder<B> {
//~^ ERROR: missing generics for associated type
//~| ERROR: missing generics for associated type
//~| ERROR: missing generics for associated type
//~| ERROR: the trait `Provider` cannot be made into an object
//~| ERROR: the trait `Provider` is not dyn compatible
}
fn main() {
Holder {
inner: Box::new(()),
//~^ ERROR: the trait `Provider` cannot be made into an object
//~| ERROR: the trait `Provider` cannot be made into an object
//~^ ERROR: the trait `Provider` is not dyn compatible
//~| ERROR: the trait `Provider` is not dyn compatible
};
}
@@ -48,53 +48,56 @@ help: add missing lifetime argument
LL | inner: Box<dyn Provider<A<'a> = B>>,
| ++++
error[E0038]: the trait `Provider` cannot be made into an object
error[E0038]: the trait `Provider` is not dyn compatible
--> $DIR/issue-71176.rs:10:14
|
LL | inner: Box<dyn Provider<A = B>>,
| ^^^^^^^^^^^^^^^^^^^ `Provider` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `Provider` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-71176.rs:2:10
|
LL | trait Provider {
| -------- this trait cannot be made into an object...
| -------- this trait is not dyn compatible...
LL | type A<'a>;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Provider`; consider using it directly instead.
error[E0038]: the trait `Provider` cannot be made into an object
error[E0038]: the trait `Provider` is not dyn compatible
--> $DIR/issue-71176.rs:19:16
|
LL | inner: Box::new(()),
| ^^^^^^^^^^^^ `Provider` cannot be made into an object
| ^^^^^^^^^^^^ `Provider` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-71176.rs:2:10
|
LL | trait Provider {
| -------- this trait cannot be made into an object...
| -------- this trait is not dyn compatible...
LL | type A<'a>;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Provider`; consider using it directly instead.
error[E0038]: the trait `Provider` cannot be made into an object
error[E0038]: the trait `Provider` is not dyn compatible
--> $DIR/issue-71176.rs:19:16
|
LL | inner: Box::new(()),
| ^^^^^^^^^^^^ `Provider` cannot be made into an object
| ^^^^^^^^^^^^ `Provider` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-71176.rs:2:10
|
LL | trait Provider {
| -------- this trait cannot be made into an object...
| -------- this trait is not dyn compatible...
LL | type A<'a>;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Provider`; consider using it directly instead.
= note: required for the cast from `Box<()>` to `Box<(dyn Provider<A<'_> = _> + 'static), {type error}>`
error: aborting due to 6 previous errors
@@ -14,39 +14,41 @@ help: add missing lifetime argument
LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0));
| ++++
error[E0038]: the trait `SuperTrait` cannot be made into an object
error[E0038]: the trait `SuperTrait` is not dyn compatible
--> $DIR/issue-76535.rs:39:14
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:9:10
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
| ---------- this trait is not dyn compatible...
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
= note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= help: only type `SuperStruct` implements `SuperTrait` within this crate. Consider using it directly instead.
= note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
error[E0038]: the trait `SuperTrait` cannot be made into an object
error[E0038]: the trait `SuperTrait` is not dyn compatible
--> $DIR/issue-76535.rs:39:57
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:9:10
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
| ---------- this trait is not dyn compatible...
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
= note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= help: only type `SuperStruct` implements `SuperTrait` within this crate. Consider using it directly instead.
= note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType<'_> = SubStruct<'_>>>`
error: aborting due to 3 previous errors
@@ -14,39 +14,41 @@ help: add missing lifetime argument
LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0));
| ++++
error[E0038]: the trait `SuperTrait` cannot be made into an object
error[E0038]: the trait `SuperTrait` is not dyn compatible
--> $DIR/issue-76535.rs:34:14
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:4:10
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
| ---------- this trait is not dyn compatible...
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
= note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead.
= note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
error[E0038]: the trait `SuperTrait` cannot be made into an object
error[E0038]: the trait `SuperTrait` is not dyn compatible
--> $DIR/issue-76535.rs:34:57
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:4:10
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
| ---------- this trait is not dyn compatible...
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
= note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead.
= note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType<'_> = SubStruct<'_>>>`
error: aborting due to 3 previous errors
@@ -14,17 +14,18 @@ help: add missing generic argument
LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize>
| +++
error[E0038]: the trait `CollectionFamily` cannot be made into an object
error[E0038]: the trait `CollectionFamily` is not dyn compatible
--> $DIR/issue-78671.rs:10:25
|
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-78671.rs:7:10
|
LL | trait CollectionFamily {
| ---------------- this trait cannot be made into an object...
| ---------------- this trait is not dyn compatible...
LL | type Member<T>;
| ^^^^^^ ...because it contains the generic associated type `Member`
= help: consider moving `Member` to another trait
@@ -4,7 +4,7 @@ trait CollectionFamily {
fn floatify() {
Box::new(Family) as &dyn CollectionFamily<Member=usize>
//~^ ERROR: missing generics for associated type
//~| ERROR: the trait `CollectionFamily` cannot be made into an object
//~| ERROR: the trait `CollectionFamily` is not dyn compatible
}
struct Family;
@@ -14,17 +14,18 @@ help: add missing generic argument
LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize>
| +++
error[E0038]: the trait `CollectionFamily` cannot be made into an object
error[E0038]: the trait `CollectionFamily` is not dyn compatible
--> $DIR/issue-78671.rs:5:25
|
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-78671.rs:2:10
|
LL | trait CollectionFamily {
| ---------------- this trait cannot be made into an object...
| ---------------- this trait is not dyn compatible...
LL | type Member<T>;
| ^^^^^^ ...because it contains the generic associated type `Member`
= help: consider moving `Member` to another trait
@@ -14,41 +14,37 @@ help: add missing lifetime argument
LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
| ++++
error[E0038]: the trait `MapLike` cannot be made into an object
error[E0038]: the trait `MapLike` is not dyn compatible
--> $DIR/issue-79422.rs:47:12
|
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:23:10
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
std::collections::BTreeMap<K, V>
Source
error[E0038]: the trait `MapLike` cannot be made into an object
error[E0038]: the trait `MapLike` is not dyn compatible
--> $DIR/issue-79422.rs:44:13
|
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:23:10
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
std::collections::BTreeMap<K, V>
Source
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont<'_> = (dyn RefCont<'_, u8> + 'static)>>`
error: aborting due to 3 previous errors
@@ -14,41 +14,37 @@ help: add missing lifetime argument
LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
| ++++
error[E0038]: the trait `MapLike` cannot be made into an object
error[E0038]: the trait `MapLike` is not dyn compatible
--> $DIR/issue-79422.rs:41:12
|
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:18:10
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
std::collections::BTreeMap<K, V>
Source
error[E0038]: the trait `MapLike` cannot be made into an object
error[E0038]: the trait `MapLike` is not dyn compatible
--> $DIR/issue-79422.rs:39:13
|
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:18:10
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
std::collections::BTreeMap<K, V>
Source
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont<'_> = (dyn RefCont<'_, u8> + 'static)>>`
error: aborting due to 3 previous errors
@@ -12,7 +12,7 @@ fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
//~^ ERROR missing generics for associated type
//~| ERROR missing generics for associated type
//~| ERROR missing generics for associated type
//~| ERROR the trait `X` cannot be made into an object
//~| ERROR the trait `X` is not dyn compatible
fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {}
//~^ ERROR struct takes 3 lifetime arguments but 2 lifetime
@@ -48,17 +48,18 @@ help: add missing lifetime arguments
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'_, '_> = (&'c u32, &'d u32)>>) {}
| ++++++++
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/missing_lifetime_args.rs:11:26
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/missing_lifetime_args.rs:2:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a, 'b>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -10,7 +10,7 @@ fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR the trait `X` cannot be made into an object
//~| ERROR the trait `X` is not dyn compatible
};
fn main() {}
@@ -92,17 +92,18 @@ LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/trait-path-type-error-once-implemented.rs:6:23
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait
@@ -1,44 +1,47 @@
error[E0038]: the trait `StreamingIterator` cannot be made into an object
error[E0038]: the trait `StreamingIterator` is not dyn compatible
--> $DIR/trait-objects.rs:13:21
|
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/trait-objects.rs:7:10
|
LL | trait StreamingIterator {
| ----------------- this trait cannot be made into an object...
| ----------------- this trait is not dyn compatible...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait
error[E0038]: the trait `StreamingIterator` cannot be made into an object
error[E0038]: the trait `StreamingIterator` is not dyn compatible
--> $DIR/trait-objects.rs:15:7
|
LL | x.size_hint().0
| ^^^^^^^^^ `StreamingIterator` cannot be made into an object
| ^^^^^^^^^ `StreamingIterator` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/trait-objects.rs:7:10
|
LL | trait StreamingIterator {
| ----------------- this trait cannot be made into an object...
| ----------------- this trait is not dyn compatible...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait
error[E0038]: the trait `StreamingIterator` cannot be made into an object
error[E0038]: the trait `StreamingIterator` is not dyn compatible
--> $DIR/trait-objects.rs:15:5
|
LL | x.size_hint().0
| ^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
| ^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/trait-objects.rs:7:10
|
LL | trait StreamingIterator {
| ----------------- this trait cannot be made into an object...
| ----------------- this trait is not dyn compatible...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait

Some files were not shown because too many files have changed in this diff Show More