mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Compiler: Rename "object safe" to "dyn compatible"
This commit is contained in:
parent
f5cd2c5888
commit
01a063f9df
@ -598,7 +598,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
// codegen'd / interpreted as virtual calls through the vtable.
|
// codegen'd / interpreted as virtual calls through the vtable.
|
||||||
ty::InstanceKind::Virtual(def_id, idx) => {
|
ty::InstanceKind::Virtual(def_id, idx) => {
|
||||||
let mut args = args.to_vec();
|
let mut args = args.to_vec();
|
||||||
// We have to implement all "object safe receivers". So we have to go search for a
|
// We have to implement all "dyn-compatible receivers". So we have to go search for a
|
||||||
// pointer or `dyn Trait` type, but it could be wrapped in newtypes. So recursively
|
// pointer or `dyn Trait` type, but it could be wrapped in newtypes. So recursively
|
||||||
// unwrap those newtypes until we are there.
|
// unwrap those newtypes until we are there.
|
||||||
// An `InPlace` does nothing here, we keep the original receiver intact. We can't
|
// An `InPlace` does nothing here, we keep the original receiver intact. We can't
|
||||||
|
@ -5,9 +5,9 @@ trait, written in type positions) but this was a bit too confusing, so we now
|
|||||||
write `dyn Trait`.
|
write `dyn Trait`.
|
||||||
|
|
||||||
Some traits are not allowed to be used as trait object types. The traits that
|
Some traits are not allowed to be used as trait object types. The traits that
|
||||||
are allowed to be used as trait object types are called "object-safe" traits.
|
are allowed to be used as trait object types are called "dyn-compatible"[^1]
|
||||||
Attempting to use a trait object type for a trait that is not object-safe will
|
traits. Attempting to use a trait object type for a trait that is not
|
||||||
trigger error E0038.
|
dyn-compatible will trigger error E0038.
|
||||||
|
|
||||||
Two general aspects of trait object types give rise to the restrictions:
|
Two general aspects of trait object types give rise to the restrictions:
|
||||||
|
|
||||||
@ -25,13 +25,16 @@ Two general aspects of trait object types give rise to the restrictions:
|
|||||||
objects with the same trait object type may point to vtables from different
|
objects with the same trait object type may point to vtables from different
|
||||||
implementations.
|
implementations.
|
||||||
|
|
||||||
The specific conditions that violate object-safety follow, most of which relate
|
The specific conditions that violate dyn-compatibility follow, most of which
|
||||||
to missing size information and vtable polymorphism arising from these aspects.
|
relate to missing size information and vtable polymorphism arising from these
|
||||||
|
aspects.
|
||||||
|
|
||||||
|
[^1]: Formerly known as "object-safe".
|
||||||
|
|
||||||
### The trait requires `Self: Sized`
|
### The trait requires `Self: Sized`
|
||||||
|
|
||||||
Traits that are declared as `Trait: Sized` or which otherwise inherit a
|
Traits that are declared as `Trait: Sized` or which otherwise inherit a
|
||||||
constraint of `Self:Sized` are not object-safe.
|
constraint of `Self:Sized` are not dyn-compatible.
|
||||||
|
|
||||||
The reasoning behind this is somewhat subtle. It derives from the fact that Rust
|
The reasoning behind this is somewhat subtle. It derives from the fact that Rust
|
||||||
requires (and defines) that every trait object type `dyn Trait` automatically
|
requires (and defines) that every trait object type `dyn Trait` automatically
|
||||||
@ -58,7 +61,7 @@ implement a sized trait like `Trait:Sized`. So, rather than allow an exception
|
|||||||
to the rule that `dyn Trait` always implements `Trait`, Rust chooses to prohibit
|
to the rule that `dyn Trait` always implements `Trait`, Rust chooses to prohibit
|
||||||
such a `dyn Trait` from existing at all.
|
such a `dyn Trait` from existing at all.
|
||||||
|
|
||||||
Only unsized traits are considered object-safe.
|
Only unsized traits are considered dyn-compatible.
|
||||||
|
|
||||||
Generally, `Self: Sized` is used to indicate that the trait should not be used
|
Generally, `Self: Sized` is used to indicate that the trait should not be used
|
||||||
as a trait object. If the trait comes from your own crate, consider removing
|
as a trait object. If the trait comes from your own crate, consider removing
|
||||||
@ -103,8 +106,8 @@ fn call_foo(x: Box<dyn Trait>) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If only some methods aren't object-safe, you can add a `where Self: Sized` bound
|
If only some methods aren't dyn-compatible, you can add a `where Self: Sized`
|
||||||
on them to mark them as explicitly unavailable to trait objects. The
|
bound on them to mark them as explicitly unavailable to trait objects. The
|
||||||
functionality will still be available to all other implementers, including
|
functionality will still be available to all other implementers, including
|
||||||
`Box<dyn Trait>` which is itself sized (assuming you `impl Trait for Box<dyn
|
`Box<dyn Trait>` which is itself sized (assuming you `impl Trait for Box<dyn
|
||||||
Trait>`).
|
Trait>`).
|
||||||
@ -117,7 +120,7 @@ trait Trait {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Now, `foo()` can no longer be called on a trait object, but you will now be
|
Now, `foo()` can no longer be called on a trait object, but you will now be
|
||||||
allowed to make a trait object, and that will be able to call any object-safe
|
allowed to make a trait object, and that will be able to call any dyn-compatible
|
||||||
methods. With such a bound, one can still call `foo()` on types implementing
|
methods. With such a bound, one can still call `foo()` on types implementing
|
||||||
that trait that aren't behind trait objects.
|
that trait that aren't behind trait objects.
|
||||||
|
|
||||||
@ -306,7 +309,7 @@ Here, the supertrait might have methods as follows:
|
|||||||
|
|
||||||
```
|
```
|
||||||
trait Super<A: ?Sized> {
|
trait Super<A: ?Sized> {
|
||||||
fn get_a(&self) -> &A; // note that this is object safe!
|
fn get_a(&self) -> &A; // note that this is dyn-compatible!
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -314,10 +317,10 @@ If the trait `Trait` was deriving from something like `Super<String>` or
|
|||||||
`Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type
|
`Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type
|
||||||
`get_a()` will definitely return an object of that type.
|
`get_a()` will definitely return an object of that type.
|
||||||
|
|
||||||
However, if it derives from `Super<Self>`, even though `Super` is object safe,
|
However, if it derives from `Super<Self>`, even though `Super` is
|
||||||
the method `get_a()` would return an object of unknown type when called on the
|
dyn-compatible, the method `get_a()` would return an object of unknown type when
|
||||||
function. `Self` type parameters let us make object safe traits no longer safe,
|
called on the function. `Self` type parameters let us make dyn-compatible traits
|
||||||
so they are forbidden when specifying supertraits.
|
no longer compatible, so they are forbidden when specifying supertraits.
|
||||||
|
|
||||||
There's no easy fix for this. Generally, code will need to be refactored so that
|
There's no easy fix for this. Generally, code will need to be refactored so that
|
||||||
you no longer need to derive from `Super<Self>`.
|
you no longer need to derive from `Super<Self>`.
|
||||||
|
@ -623,7 +623,7 @@ E0800: 0800,
|
|||||||
// E0314, // closure outlives stack frame
|
// E0314, // closure outlives stack frame
|
||||||
// E0315, // cannot invoke closure outside of its lifetime
|
// E0315, // cannot invoke closure outside of its lifetime
|
||||||
// E0319, // trait impls for defaulted traits allowed just for structs/enums
|
// E0319, // trait impls for defaulted traits allowed just for structs/enums
|
||||||
// E0372, // coherence not object safe
|
// E0372, // coherence not dyn-compatible
|
||||||
// E0385, // {} in an aliasable location
|
// E0385, // {} in an aliasable location
|
||||||
// E0402, // cannot use an outer type parameter in this context
|
// E0402, // cannot use an outer type parameter in this context
|
||||||
// E0406, // merged into 420
|
// E0406, // merged into 420
|
||||||
|
@ -548,9 +548,12 @@ declare_features! (
|
|||||||
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
|
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
|
||||||
/// Allows `for<T>` binders in where-clauses
|
/// Allows `for<T>` binders in where-clauses
|
||||||
(incomplete, non_lifetime_binders, "1.69.0", Some(108185)),
|
(incomplete, non_lifetime_binders, "1.69.0", Some(108185)),
|
||||||
/// Allows making `dyn Trait` well-formed even if `Trait` is not object safe.
|
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
|
||||||
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
|
/// 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.
|
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
|
||||||
|
///
|
||||||
|
/// [^1]: Formerly known as "object safe".
|
||||||
|
// FIXME(dyn_compat_renaming): Rename feature.
|
||||||
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
|
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
|
||||||
/// Allows using enums in offset_of!
|
/// Allows using enums in offset_of!
|
||||||
(unstable, offset_of_enum, "1.75.0", Some(120141)),
|
(unstable, offset_of_enum, "1.75.0", Some(120141)),
|
||||||
|
@ -558,7 +558,7 @@ hir_analysis_unrecognized_intrinsic_function =
|
|||||||
.help = if you're adding an intrinsic, be sure to update `check_intrinsic_type`
|
.help = if you're adding an intrinsic, be sure to update `check_intrinsic_type`
|
||||||
|
|
||||||
hir_analysis_unused_associated_type_bounds =
|
hir_analysis_unused_associated_type_bounds =
|
||||||
unnecessary associated type bound for not object safe associated type
|
unnecessary associated type bound for dyn-incompatible associated type
|
||||||
.note = this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`
|
.note = this associated type has a `where Self: Sized` bound, and while the associated type can be specified, it cannot be used because trait objects are never `Sized`
|
||||||
.suggestion = remove this bound
|
.suggestion = remove this bound
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ fn check_trait_item<'tcx>(
|
|||||||
hir::TraitItemKind::Type(_bounds, Some(ty)) => (None, ty.span),
|
hir::TraitItemKind::Type(_bounds, Some(ty)) => (None, ty.span),
|
||||||
_ => (None, trait_item.span),
|
_ => (None, trait_item.span),
|
||||||
};
|
};
|
||||||
check_object_unsafe_self_trait_by_name(tcx, trait_item);
|
check_dyn_incompatible_self_trait_by_name(tcx, trait_item);
|
||||||
let mut res = check_associated_item(tcx, def_id, span, method_sig);
|
let mut res = check_associated_item(tcx, def_id, span, method_sig);
|
||||||
|
|
||||||
if matches!(trait_item.kind, hir::TraitItemKind::Fn(..)) {
|
if matches!(trait_item.kind, hir::TraitItemKind::Fn(..)) {
|
||||||
@ -838,9 +838,10 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Detect when an object unsafe trait is referring to itself in one of its associated items.
|
/// Detect when a dyn-incompatible trait is referring to itself in one of its associated items.
|
||||||
/// When this is done, suggest using `Self` instead.
|
///
|
||||||
fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) {
|
/// In such cases, suggest using `Self` instead.
|
||||||
|
fn check_dyn_incompatible_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) {
|
||||||
let (trait_name, trait_def_id) =
|
let (trait_name, trait_def_id) =
|
||||||
match tcx.hir_node_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) {
|
match tcx.hir_node_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) {
|
||||||
hir::Node::Item(item) => match item.kind {
|
hir::Node::Item(item) => match item.kind {
|
||||||
@ -872,7 +873,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
if !trait_should_be_self.is_empty() {
|
if !trait_should_be_self.is_empty() {
|
||||||
if tcx.is_object_safe(trait_def_id) {
|
if tcx.is_dyn_compatible(trait_def_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let sugg = trait_should_be_self.iter().map(|span| (*span, "Self".to_string())).collect();
|
let sugg = trait_should_be_self.iter().map(|span| (*span, "Self".to_string())).collect();
|
||||||
|
@ -179,8 +179,8 @@ fn check_object_overlap<'tcx>(
|
|||||||
|
|
||||||
// check for overlap with the automatic `impl Trait for dyn Trait`
|
// check for overlap with the automatic `impl Trait for dyn Trait`
|
||||||
if let ty::Dynamic(data, ..) = trait_ref.self_ty().kind() {
|
if let ty::Dynamic(data, ..) = trait_ref.self_ty().kind() {
|
||||||
// This is something like impl Trait1 for Trait2. Illegal
|
// This is something like `impl Trait1 for Trait2`. Illegal if
|
||||||
// if Trait1 is a supertrait of Trait2 or Trait2 is not object safe.
|
// Trait1 is a supertrait of Trait2 or Trait2 is not dyn-compatible.
|
||||||
|
|
||||||
let component_def_ids = data.iter().flat_map(|predicate| {
|
let component_def_ids = data.iter().flat_map(|predicate| {
|
||||||
match predicate.skip_binder() {
|
match predicate.skip_binder() {
|
||||||
@ -193,7 +193,8 @@ fn check_object_overlap<'tcx>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
for component_def_id in component_def_ids {
|
for component_def_id in component_def_ids {
|
||||||
if !tcx.is_object_safe(component_def_id) {
|
if !tcx.is_dyn_compatible(component_def_id) {
|
||||||
|
// FIXME(dyn_compat_renaming): Rename test and update comment.
|
||||||
// Without the 'object_safe_for_dispatch' feature this is an error
|
// Without the 'object_safe_for_dispatch' feature this is an error
|
||||||
// which will be reported by wfcheck. Ignore it here.
|
// which will be reported by wfcheck. Ignore it here.
|
||||||
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
|
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
|
||||||
|
@ -109,16 +109,16 @@ pub(crate) fn orphan_check_impl(
|
|||||||
//
|
//
|
||||||
// auto trait AutoTrait {}
|
// auto trait AutoTrait {}
|
||||||
//
|
//
|
||||||
// trait ObjectSafeTrait {
|
// trait DynCompatibleTrait {
|
||||||
// fn f(&self) where Self: AutoTrait;
|
// fn f(&self) where Self: AutoTrait;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// We can allow f to be called on `dyn ObjectSafeTrait + AutoTrait`.
|
// We can allow f to be called on `dyn DynCompatibleTrait + AutoTrait`.
|
||||||
//
|
//
|
||||||
// If we didn't deny `impl AutoTrait for dyn Trait`, it would be unsound
|
// If we didn't deny `impl AutoTrait for dyn Trait`, it would be unsound
|
||||||
// for the ObjectSafeTrait shown above to be object safe because someone
|
// for the `DynCompatibleTrait` shown above to be dyn-compatible because someone
|
||||||
// could take some type implementing ObjectSafeTrait but not AutoTrait,
|
// could take some type implementing `DynCompatibleTrait` but not `AutoTrait`,
|
||||||
// unsize it to `dyn ObjectSafeTrait`, and call .f() which has no
|
// unsize it to `dyn DynCompatibleTrait`, and call `.f()` which has no
|
||||||
// concrete implementation (issue #50781).
|
// concrete implementation (issue #50781).
|
||||||
enum LocalImpl {
|
enum LocalImpl {
|
||||||
Allow,
|
Allow,
|
||||||
|
@ -11,8 +11,8 @@ use rustc_middle::ty::{
|
|||||||
self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable, Upcast,
|
self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable, Upcast,
|
||||||
};
|
};
|
||||||
use rustc_span::{ErrorGuaranteed, Span};
|
use rustc_span::{ErrorGuaranteed, Span};
|
||||||
use rustc_trait_selection::error_reporting::traits::report_object_safety_error;
|
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
|
||||||
use rustc_trait_selection::traits::{self, hir_ty_lowering_object_safety_violations};
|
use rustc_trait_selection::traits::{self, hir_ty_lowering_dyn_compatibility_violations};
|
||||||
use smallvec::{SmallVec, smallvec};
|
use smallvec::{SmallVec, smallvec};
|
||||||
use tracing::{debug, instrument};
|
use tracing::{debug, instrument};
|
||||||
|
|
||||||
@ -99,19 +99,19 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
return Ty::new_error(tcx, reported);
|
return Ty::new_error(tcx, reported);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that there are no gross object safety violations;
|
// Check that there are no gross dyn-compatibility violations;
|
||||||
// most importantly, that the supertraits don't contain `Self`,
|
// most importantly, that the supertraits don't contain `Self`,
|
||||||
// to avoid ICEs.
|
// to avoid ICEs.
|
||||||
for item in ®ular_traits {
|
for item in ®ular_traits {
|
||||||
let object_safety_violations =
|
let violations =
|
||||||
hir_ty_lowering_object_safety_violations(tcx, item.trait_ref().def_id());
|
hir_ty_lowering_dyn_compatibility_violations(tcx, item.trait_ref().def_id());
|
||||||
if !object_safety_violations.is_empty() {
|
if !violations.is_empty() {
|
||||||
let reported = report_object_safety_error(
|
let reported = report_dyn_incompatibility(
|
||||||
tcx,
|
tcx,
|
||||||
span,
|
span,
|
||||||
Some(hir_id),
|
Some(hir_id),
|
||||||
item.trait_ref().def_id(),
|
item.trait_ref().def_id(),
|
||||||
&object_safety_violations,
|
&violations,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
return Ty::new_error(tcx, reported);
|
return Ty::new_error(tcx, reported);
|
||||||
@ -275,7 +275,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
tcx.item_name(def_id),
|
tcx.item_name(def_id),
|
||||||
)
|
)
|
||||||
.with_note(
|
.with_note(
|
||||||
rustc_middle::traits::ObjectSafetyViolation::SupertraitSelf(smallvec![])
|
rustc_middle::traits::DynCompatibilityViolation::SupertraitSelf(
|
||||||
|
smallvec![],
|
||||||
|
)
|
||||||
.error_msg(),
|
.error_msg(),
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
@ -19,9 +19,9 @@ use rustc_session::parse::feature_err;
|
|||||||
use rustc_span::edit_distance::find_best_match_for_name;
|
use rustc_span::edit_distance::find_best_match_for_name;
|
||||||
use rustc_span::symbol::{Ident, kw, sym};
|
use rustc_span::symbol::{Ident, kw, sym};
|
||||||
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol};
|
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol};
|
||||||
use rustc_trait_selection::error_reporting::traits::report_object_safety_error;
|
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
FulfillmentError, TraitAliasExpansionInfo, object_safety_violations_for_assoc_item,
|
FulfillmentError, TraitAliasExpansionInfo, dyn_compatibility_violations_for_assoc_item,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
@ -739,7 +739,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
// Account for things like `dyn Foo + 'a`, like in tests `issue-22434.rs` and
|
// Account for things like `dyn Foo + 'a`, like in tests `issue-22434.rs` and
|
||||||
// `issue-22560.rs`.
|
// `issue-22560.rs`.
|
||||||
let mut trait_bound_spans: Vec<Span> = vec![];
|
let mut trait_bound_spans: Vec<Span> = vec![];
|
||||||
let mut object_safety_violations = false;
|
let mut dyn_compatibility_violations = false;
|
||||||
for (span, items) in &associated_types {
|
for (span, items) in &associated_types {
|
||||||
if !items.is_empty() {
|
if !items.is_empty() {
|
||||||
trait_bound_spans.push(*span);
|
trait_bound_spans.push(*span);
|
||||||
@ -750,14 +750,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
names_len += 1;
|
names_len += 1;
|
||||||
|
|
||||||
let violations =
|
let violations =
|
||||||
object_safety_violations_for_assoc_item(tcx, trait_def_id, *assoc_item);
|
dyn_compatibility_violations_for_assoc_item(tcx, trait_def_id, *assoc_item);
|
||||||
if !violations.is_empty() {
|
if !violations.is_empty() {
|
||||||
report_object_safety_error(tcx, *span, None, trait_def_id, &violations).emit();
|
report_dyn_incompatibility(tcx, *span, None, trait_def_id, &violations).emit();
|
||||||
object_safety_violations = true;
|
dyn_compatibility_violations = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if object_safety_violations {
|
if dyn_compatibility_violations {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
if self_ty.span.can_be_used_for_suggestions()
|
if self_ty.span.can_be_used_for_suggestions()
|
||||||
&& !self.maybe_suggest_impl_trait(self_ty, &mut diag)
|
&& !self.maybe_suggest_impl_trait(self_ty, &mut diag)
|
||||||
{
|
{
|
||||||
// FIXME: Only emit this suggestion if the trait is object safe.
|
// FIXME: Only emit this suggestion if the trait is dyn-compatible.
|
||||||
diag.multipart_suggestion_verbose(label, sugg, Applicability::MachineApplicable);
|
diag.multipart_suggestion_verbose(label, sugg, Applicability::MachineApplicable);
|
||||||
}
|
}
|
||||||
// Check if the impl trait that we are considering is an impl of a local trait.
|
// Check if the impl trait that we are considering is an impl of a local trait.
|
||||||
@ -89,7 +89,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
lint.primary_message("trait objects without an explicit `dyn` are deprecated");
|
lint.primary_message("trait objects without an explicit `dyn` are deprecated");
|
||||||
if self_ty.span.can_be_used_for_suggestions() {
|
if self_ty.span.can_be_used_for_suggestions() {
|
||||||
lint.multipart_suggestion_verbose(
|
lint.multipart_suggestion_verbose(
|
||||||
"if this is an object-safe trait, use `dyn`",
|
"if this is a dyn-compatible trait, use `dyn`",
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
@ -196,7 +196,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
let mut is_downgradable = true;
|
let mut is_downgradable = true;
|
||||||
|
|
||||||
// Check if trait object is safe for suggesting dynamic dispatch.
|
// Check if trait object is safe for suggesting dynamic dispatch.
|
||||||
let is_object_safe = match self_ty.kind {
|
let is_dyn_compatible = match self_ty.kind {
|
||||||
hir::TyKind::TraitObject(objects, ..) => {
|
hir::TyKind::TraitObject(objects, ..) => {
|
||||||
objects.iter().all(|(o, _)| match o.trait_ref.path.res {
|
objects.iter().all(|(o, _)| match o.trait_ref.path.res {
|
||||||
Res::Def(DefKind::Trait, id) => {
|
Res::Def(DefKind::Trait, id) => {
|
||||||
@ -204,7 +204,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
// For recursive traits, don't downgrade the error. (#119652)
|
// For recursive traits, don't downgrade the error. (#119652)
|
||||||
is_downgradable = false;
|
is_downgradable = false;
|
||||||
}
|
}
|
||||||
tcx.is_object_safe(id)
|
tcx.is_dyn_compatible(id)
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
@ -221,8 +221,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
if let hir::FnRetTy::Return(ty) = sig.decl.output
|
if let hir::FnRetTy::Return(ty) = sig.decl.output
|
||||||
&& ty.peel_refs().hir_id == self_ty.hir_id
|
&& ty.peel_refs().hir_id == self_ty.hir_id
|
||||||
{
|
{
|
||||||
let pre = if !is_object_safe {
|
let pre = if !is_dyn_compatible {
|
||||||
format!("`{trait_name}` is not object safe, ")
|
format!("`{trait_name}` is dyn-incompatible, ")
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
};
|
};
|
||||||
@ -234,7 +234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
diag.multipart_suggestion_verbose(msg, impl_sugg, Applicability::MachineApplicable);
|
diag.multipart_suggestion_verbose(msg, impl_sugg, Applicability::MachineApplicable);
|
||||||
|
|
||||||
// Suggest `Box<dyn Trait>` for return type
|
// Suggest `Box<dyn Trait>` for return type
|
||||||
if is_object_safe {
|
if is_dyn_compatible {
|
||||||
// If the return type is `&Trait`, we don't want
|
// If the return type is `&Trait`, we don't want
|
||||||
// the ampersand to be displayed in the `Box<dyn Trait>`
|
// the ampersand to be displayed in the `Box<dyn Trait>`
|
||||||
// suggestion.
|
// suggestion.
|
||||||
@ -253,7 +253,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
} else if is_downgradable {
|
} else if is_downgradable {
|
||||||
// We'll emit the object safety error already, with a structured suggestion.
|
// We'll emit the dyn-compatibility error already, with a structured suggestion.
|
||||||
diag.downgrade_to_delayed_bug();
|
diag.downgrade_to_delayed_bug();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -276,10 +276,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||||||
impl_sugg,
|
impl_sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
if !is_object_safe {
|
if !is_dyn_compatible {
|
||||||
diag.note(format!("`{trait_name}` it is not object safe, so it can't be `dyn`"));
|
diag.note(format!("`{trait_name}` it is dyn-incompatible, so it can't be `dyn`"));
|
||||||
if is_downgradable {
|
if is_downgradable {
|
||||||
// We'll emit the object safety error already, with a structured suggestion.
|
// We'll emit the dyn-compatibility error already, with a structured suggestion.
|
||||||
diag.downgrade_to_delayed_bug();
|
diag.downgrade_to_delayed_bug();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
mod bounds;
|
mod bounds;
|
||||||
mod cmse;
|
mod cmse;
|
||||||
|
mod dyn_compatibility;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod generics;
|
pub mod generics;
|
||||||
mod lint;
|
mod lint;
|
||||||
mod object_safety;
|
|
||||||
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||||||
return Err(TypeError::Mismatch);
|
return Err(TypeError::Mismatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object safety violations or miscellaneous.
|
// Dyn-compatibility violations or miscellaneous.
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.err_ctxt().report_selection_error(obligation.clone(), &obligation, &err);
|
self.err_ctxt().report_selection_error(obligation.clone(), &obligation, &err);
|
||||||
// Treat this like an obligation and follow through
|
// Treat this like an obligation and follow through
|
||||||
|
@ -757,7 +757,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// give us a `QPath::TypeRelative` with a trait object as
|
// give us a `QPath::TypeRelative` with a trait object as
|
||||||
// `qself`. In that case, we want to avoid registering a WF obligation
|
// `qself`. In that case, we want to avoid registering a WF obligation
|
||||||
// for `dyn MyTrait`, since we don't actually need the trait
|
// for `dyn MyTrait`, since we don't actually need the trait
|
||||||
// to be object-safe.
|
// to be dyn-compatible.
|
||||||
// We manually call `register_wf_obligation` in the success path
|
// We manually call `register_wf_obligation` in the success path
|
||||||
// below.
|
// below.
|
||||||
let ty = self.lowerer().lower_ty(qself);
|
let ty = self.lowerer().lower_ty(qself);
|
||||||
|
@ -50,7 +50,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
| ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..))
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..))
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::DynCompatible(..)
|
||||||
| ty::PredicateKind::NormalizesTo(..)
|
| ty::PredicateKind::NormalizesTo(..)
|
||||||
| ty::PredicateKind::AliasRelate(..)
|
| ty::PredicateKind::AliasRelate(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||||
|
@ -292,7 +292,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||||||
// distinct types (e.g., if `Self` appeared as an
|
// distinct types (e.g., if `Self` appeared as an
|
||||||
// argument type), but those cases have already
|
// argument type), but those cases have already
|
||||||
// been ruled out when we deemed the trait to be
|
// been ruled out when we deemed the trait to be
|
||||||
// "object safe".
|
// "dyn-compatible".
|
||||||
let original_poly_trait_ref = principal.with_self_ty(this.tcx, object_ty);
|
let original_poly_trait_ref = principal.with_self_ty(this.tcx, object_ty);
|
||||||
let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id);
|
let upcast_poly_trait_ref = this.upcast(original_poly_trait_ref, trait_def_id);
|
||||||
let upcast_trait_ref =
|
let upcast_trait_ref =
|
||||||
|
@ -779,8 +779,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// It is illegal to invoke a method on a trait instance that refers to
|
// It is illegal to invoke a method on a trait instance that refers to
|
||||||
// the `Self` type. An [`ObjectSafetyViolation::SupertraitSelf`] error
|
// the `Self` type. An [`DynCompatibilityViolation::SupertraitSelf`] error
|
||||||
// will be reported by `object_safety.rs` if the method refers to the
|
// will be reported by `dyn_compatibility.rs` if the method refers to the
|
||||||
// `Self` type anywhere other than the receiver. Here, we use a
|
// `Self` type anywhere other than the receiver. Here, we use a
|
||||||
// instantiation that replaces `Self` with the object type itself. Hence,
|
// instantiation that replaces `Self` with the object type itself. Hence,
|
||||||
// a `&self` method will wind up with an argument type like `&dyn Trait`.
|
// a `&self` method will wind up with an argument type like `&dyn Trait`.
|
||||||
|
@ -912,7 +912,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
|||||||
let traits = tcx.traits(LOCAL_CRATE);
|
let traits = tcx.traits(LOCAL_CRATE);
|
||||||
|
|
||||||
for &tr in traits {
|
for &tr in traits {
|
||||||
if !tcx.is_object_safe(tr) {
|
if !tcx.is_dyn_compatible(tr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ lint_mixed_script_confusables =
|
|||||||
.includes_note = the usage includes {$includes}
|
.includes_note = the usage includes {$includes}
|
||||||
.note = please recheck to make sure their usages are indeed what you want
|
.note = please recheck to make sure their usages are indeed what you want
|
||||||
|
|
||||||
lint_multiple_supertrait_upcastable = `{$ident}` is object-safe and has multiple supertraits
|
lint_multiple_supertrait_upcastable = `{$ident}` is dyn-compatible and has multiple supertraits
|
||||||
|
|
||||||
lint_named_argument_used_positionally = named argument `{$named_arg_name}` is not used by name
|
lint_named_argument_used_positionally = named argument `{$named_arg_name}` is not used by name
|
||||||
.label_named_arg = this named argument is referred to by position in formatting string
|
.label_named_arg = this named argument is referred to by position in formatting string
|
||||||
|
@ -4,7 +4,7 @@ use rustc_session::{declare_lint, declare_lint_pass};
|
|||||||
use crate::{LateContext, LateLintPass, LintContext};
|
use crate::{LateContext, LateLintPass, LintContext};
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `multiple_supertrait_upcastable` lint detects when an object-safe trait has multiple
|
/// The `multiple_supertrait_upcastable` lint detects when a dyn-compatible trait has multiple
|
||||||
/// supertraits.
|
/// supertraits.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
@ -28,7 +28,7 @@ declare_lint! {
|
|||||||
/// additional overhead is justified.
|
/// additional overhead is justified.
|
||||||
pub MULTIPLE_SUPERTRAIT_UPCASTABLE,
|
pub MULTIPLE_SUPERTRAIT_UPCASTABLE,
|
||||||
Allow,
|
Allow,
|
||||||
"detect when an object-safe trait has multiple supertraits",
|
"detect when a dyn-compatible trait has multiple supertraits",
|
||||||
@feature_gate = multiple_supertrait_upcastable;
|
@feature_gate = multiple_supertrait_upcastable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ declare_lint_pass!(MultipleSupertraitUpcastable => [MULTIPLE_SUPERTRAIT_UPCASTAB
|
|||||||
impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
|
impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
|
||||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||||
let def_id = item.owner_id.to_def_id();
|
let def_id = item.owner_id.to_def_id();
|
||||||
// NOTE(nbdd0121): use `object_safety_violations` instead of `is_object_safe` because
|
// NOTE(nbdd0121): use `object_safety_violations` instead of `is_dyn_compatible` because
|
||||||
// the latter will report `where_clause_object_safety` lint.
|
// the latter will report `where_clause_object_safety` lint.
|
||||||
if let hir::ItemKind::Trait(_, _, _, _, _) = item.kind
|
if let hir::ItemKind::Trait(_, _, _, _, _) = item.kind
|
||||||
&& cx.tcx.is_object_safe(def_id)
|
&& cx.tcx.is_dyn_compatible(def_id)
|
||||||
{
|
{
|
||||||
let direct_super_traits_iter = cx
|
let direct_super_traits_iter = cx
|
||||||
.tcx
|
.tcx
|
||||||
|
@ -83,7 +83,7 @@ macro_rules! arena_types {
|
|||||||
>,
|
>,
|
||||||
[] effective_visibilities: rustc_middle::middle::privacy::EffectiveVisibilities,
|
[] effective_visibilities: rustc_middle::middle::privacy::EffectiveVisibilities,
|
||||||
[] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
|
[] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
|
||||||
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
|
[] dyn_compatibility_violations: rustc_middle::traits::DynCompatibilityViolation,
|
||||||
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
|
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
|
||||||
[decode] attribute: rustc_ast::Attribute,
|
[decode] attribute: rustc_ast::Attribute,
|
||||||
[] name_set: rustc_data_structures::unord::UnordSet<rustc_span::symbol::Symbol>,
|
[] name_set: rustc_data_structures::unord::UnordSet<rustc_span::symbol::Symbol>,
|
||||||
|
@ -70,8 +70,8 @@ use crate::traits::query::{
|
|||||||
MethodAutoderefStepsResult, NoSolution, NormalizationResult, OutlivesBound,
|
MethodAutoderefStepsResult, NoSolution, NormalizationResult, OutlivesBound,
|
||||||
};
|
};
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause,
|
CodegenObligationError, DynCompatibilityViolation, EvaluationResult, ImplSource,
|
||||||
OverflowError, WellFormedLoc, specialization_graph,
|
ObligationCause, OverflowError, WellFormedLoc, specialization_graph,
|
||||||
};
|
};
|
||||||
use crate::ty::fast_reject::SimplifiedType;
|
use crate::ty::fast_reject::SimplifiedType;
|
||||||
use crate::ty::layout::ValidityRequirement;
|
use crate::ty::layout::ValidityRequirement;
|
||||||
@ -1338,11 +1338,11 @@ rustc_queries! {
|
|||||||
cache_on_disk_if { true }
|
cache_on_disk_if { true }
|
||||||
ensure_forwards_result_if_red
|
ensure_forwards_result_if_red
|
||||||
}
|
}
|
||||||
query object_safety_violations(trait_id: DefId) -> &'tcx [ObjectSafetyViolation] {
|
query dyn_compatibility_violations(trait_id: DefId) -> &'tcx [DynCompatibilityViolation] {
|
||||||
desc { |tcx| "determining object safety of trait `{}`", tcx.def_path_str(trait_id) }
|
desc { |tcx| "determining dyn-compatibility of trait `{}`", tcx.def_path_str(trait_id) }
|
||||||
}
|
}
|
||||||
query is_object_safe(trait_id: DefId) -> bool {
|
query is_dyn_compatible(trait_id: DefId) -> bool {
|
||||||
desc { |tcx| "checking if trait `{}` is object safe", tcx.def_path_str(trait_id) }
|
desc { |tcx| "checking if trait `{}` is dyn-compatible", tcx.def_path_str(trait_id) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the ParameterEnvironment for a given item; this environment
|
/// Gets the ParameterEnvironment for a given item; this environment
|
||||||
|
@ -556,8 +556,8 @@ pub enum SelectionError<'tcx> {
|
|||||||
/// (which for closures includes the "input" type params) and they
|
/// (which for closures includes the "input" type params) and they
|
||||||
/// didn't resolve. See `confirm_poly_trait_refs` for more.
|
/// didn't resolve. See `confirm_poly_trait_refs` for more.
|
||||||
SignatureMismatch(Box<SignatureMismatchData<'tcx>>),
|
SignatureMismatch(Box<SignatureMismatchData<'tcx>>),
|
||||||
/// The trait pointed by `DefId` is not object safe.
|
/// The trait pointed by `DefId` is dyn-incompatible.
|
||||||
TraitNotObjectSafe(DefId),
|
TraitDynIncompatible(DefId),
|
||||||
/// A given constant couldn't be evaluated.
|
/// A given constant couldn't be evaluated.
|
||||||
NotConstEvaluatable(NotConstEvaluatable),
|
NotConstEvaluatable(NotConstEvaluatable),
|
||||||
/// Exceeded the recursion depth during type projection.
|
/// Exceeded the recursion depth during type projection.
|
||||||
@ -690,7 +690,7 @@ pub struct ImplSourceUserDefinedData<'tcx, N> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
|
||||||
pub enum ObjectSafetyViolation {
|
pub enum DynCompatibilityViolation {
|
||||||
/// `Self: Sized` declared on the trait.
|
/// `Self: Sized` declared on the trait.
|
||||||
SizedSelf(SmallVec<[Span; 1]>),
|
SizedSelf(SmallVec<[Span; 1]>),
|
||||||
|
|
||||||
@ -711,11 +711,11 @@ pub enum ObjectSafetyViolation {
|
|||||||
GAT(Symbol, Span),
|
GAT(Symbol, Span),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectSafetyViolation {
|
impl DynCompatibilityViolation {
|
||||||
pub fn error_msg(&self) -> Cow<'static, str> {
|
pub fn error_msg(&self) -> Cow<'static, str> {
|
||||||
match self {
|
match self {
|
||||||
ObjectSafetyViolation::SizedSelf(_) => "it requires `Self: Sized`".into(),
|
DynCompatibilityViolation::SizedSelf(_) => "it requires `Self: Sized`".into(),
|
||||||
ObjectSafetyViolation::SupertraitSelf(ref spans) => {
|
DynCompatibilityViolation::SupertraitSelf(ref spans) => {
|
||||||
if spans.iter().any(|sp| *sp != DUMMY_SP) {
|
if spans.iter().any(|sp| *sp != DUMMY_SP) {
|
||||||
"it uses `Self` as a type parameter".into()
|
"it uses `Self` as a type parameter".into()
|
||||||
} else {
|
} else {
|
||||||
@ -723,81 +723,87 @@ impl ObjectSafetyViolation {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::SupertraitNonLifetimeBinder(_) => {
|
DynCompatibilityViolation::SupertraitNonLifetimeBinder(_) => {
|
||||||
"where clause cannot reference non-lifetime `for<...>` variables".into()
|
"where clause cannot reference non-lifetime `for<...>` variables".into()
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod(_), _) => {
|
DynCompatibilityViolation::Method(name, MethodViolationCode::StaticMethod(_), _) => {
|
||||||
format!("associated function `{name}` has no `self` parameter").into()
|
format!("associated function `{name}` has no `self` parameter").into()
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::Method(
|
DynCompatibilityViolation::Method(
|
||||||
name,
|
name,
|
||||||
MethodViolationCode::ReferencesSelfInput(_),
|
MethodViolationCode::ReferencesSelfInput(_),
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
) => format!("method `{name}` references the `Self` type in its parameters").into(),
|
) => format!("method `{name}` references the `Self` type in its parameters").into(),
|
||||||
ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelfInput(_), _) => {
|
DynCompatibilityViolation::Method(
|
||||||
format!("method `{name}` references the `Self` type in this parameter").into()
|
name,
|
||||||
}
|
MethodViolationCode::ReferencesSelfInput(_),
|
||||||
ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelfOutput, _) => {
|
_,
|
||||||
format!("method `{name}` references the `Self` type in its return type").into()
|
) => format!("method `{name}` references the `Self` type in this parameter").into(),
|
||||||
}
|
DynCompatibilityViolation::Method(
|
||||||
ObjectSafetyViolation::Method(
|
name,
|
||||||
|
MethodViolationCode::ReferencesSelfOutput,
|
||||||
|
_,
|
||||||
|
) => format!("method `{name}` references the `Self` type in its return type").into(),
|
||||||
|
DynCompatibilityViolation::Method(
|
||||||
name,
|
name,
|
||||||
MethodViolationCode::ReferencesImplTraitInTrait(_),
|
MethodViolationCode::ReferencesImplTraitInTrait(_),
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
format!("method `{name}` references an `impl Trait` type in its return type").into()
|
format!("method `{name}` references an `impl Trait` type in its return type").into()
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::Method(name, MethodViolationCode::AsyncFn, _) => {
|
DynCompatibilityViolation::Method(name, MethodViolationCode::AsyncFn, _) => {
|
||||||
format!("method `{name}` is `async`").into()
|
format!("method `{name}` is `async`").into()
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::Method(
|
DynCompatibilityViolation::Method(
|
||||||
name,
|
name,
|
||||||
MethodViolationCode::WhereClauseReferencesSelf,
|
MethodViolationCode::WhereClauseReferencesSelf,
|
||||||
_,
|
_,
|
||||||
) => format!("method `{name}` references the `Self` type in its `where` clause").into(),
|
) => format!("method `{name}` references the `Self` type in its `where` clause").into(),
|
||||||
ObjectSafetyViolation::Method(name, MethodViolationCode::Generic, _) => {
|
DynCompatibilityViolation::Method(name, MethodViolationCode::Generic, _) => {
|
||||||
format!("method `{name}` has generic type parameters").into()
|
format!("method `{name}` has generic type parameters").into()
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::Method(
|
DynCompatibilityViolation::Method(
|
||||||
name,
|
name,
|
||||||
MethodViolationCode::UndispatchableReceiver(_),
|
MethodViolationCode::UndispatchableReceiver(_),
|
||||||
_,
|
_,
|
||||||
) => format!("method `{name}`'s `self` parameter cannot be dispatched on").into(),
|
) => format!("method `{name}`'s `self` parameter cannot be dispatched on").into(),
|
||||||
ObjectSafetyViolation::AssocConst(name, DUMMY_SP) => {
|
DynCompatibilityViolation::AssocConst(name, DUMMY_SP) => {
|
||||||
format!("it contains associated `const` `{name}`").into()
|
format!("it contains associated `const` `{name}`").into()
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::AssocConst(..) => "it contains this associated `const`".into(),
|
DynCompatibilityViolation::AssocConst(..) => {
|
||||||
ObjectSafetyViolation::GAT(name, _) => {
|
"it contains this associated `const`".into()
|
||||||
|
}
|
||||||
|
DynCompatibilityViolation::GAT(name, _) => {
|
||||||
format!("it contains the generic associated type `{name}`").into()
|
format!("it contains the generic associated type `{name}`").into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn solution(&self) -> ObjectSafetyViolationSolution {
|
pub fn solution(&self) -> DynCompatibilityViolationSolution {
|
||||||
match self {
|
match self {
|
||||||
ObjectSafetyViolation::SizedSelf(_)
|
DynCompatibilityViolation::SizedSelf(_)
|
||||||
| ObjectSafetyViolation::SupertraitSelf(_)
|
| DynCompatibilityViolation::SupertraitSelf(_)
|
||||||
| ObjectSafetyViolation::SupertraitNonLifetimeBinder(..) => {
|
| DynCompatibilityViolation::SupertraitNonLifetimeBinder(..) => {
|
||||||
ObjectSafetyViolationSolution::None
|
DynCompatibilityViolationSolution::None
|
||||||
}
|
}
|
||||||
ObjectSafetyViolation::Method(
|
DynCompatibilityViolation::Method(
|
||||||
name,
|
name,
|
||||||
MethodViolationCode::StaticMethod(Some((add_self_sugg, make_sized_sugg))),
|
MethodViolationCode::StaticMethod(Some((add_self_sugg, make_sized_sugg))),
|
||||||
_,
|
_,
|
||||||
) => ObjectSafetyViolationSolution::AddSelfOrMakeSized {
|
) => DynCompatibilityViolationSolution::AddSelfOrMakeSized {
|
||||||
name: *name,
|
name: *name,
|
||||||
add_self_sugg: add_self_sugg.clone(),
|
add_self_sugg: add_self_sugg.clone(),
|
||||||
make_sized_sugg: make_sized_sugg.clone(),
|
make_sized_sugg: make_sized_sugg.clone(),
|
||||||
},
|
},
|
||||||
ObjectSafetyViolation::Method(
|
DynCompatibilityViolation::Method(
|
||||||
name,
|
name,
|
||||||
MethodViolationCode::UndispatchableReceiver(Some(span)),
|
MethodViolationCode::UndispatchableReceiver(Some(span)),
|
||||||
_,
|
_,
|
||||||
) => ObjectSafetyViolationSolution::ChangeToRefSelf(*name, *span),
|
) => DynCompatibilityViolationSolution::ChangeToRefSelf(*name, *span),
|
||||||
ObjectSafetyViolation::AssocConst(name, _)
|
DynCompatibilityViolation::AssocConst(name, _)
|
||||||
| ObjectSafetyViolation::GAT(name, _)
|
| DynCompatibilityViolation::GAT(name, _)
|
||||||
| ObjectSafetyViolation::Method(name, ..) => {
|
| DynCompatibilityViolation::Method(name, ..) => {
|
||||||
ObjectSafetyViolationSolution::MoveToAnotherTrait(*name)
|
DynCompatibilityViolationSolution::MoveToAnotherTrait(*name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -806,12 +812,12 @@ impl ObjectSafetyViolation {
|
|||||||
// When `span` comes from a separate crate, it'll be `DUMMY_SP`. Treat it as `None` so
|
// When `span` comes from a separate crate, it'll be `DUMMY_SP`. Treat it as `None` so
|
||||||
// diagnostics use a `note` instead of a `span_label`.
|
// diagnostics use a `note` instead of a `span_label`.
|
||||||
match self {
|
match self {
|
||||||
ObjectSafetyViolation::SupertraitSelf(spans)
|
DynCompatibilityViolation::SupertraitSelf(spans)
|
||||||
| ObjectSafetyViolation::SizedSelf(spans)
|
| DynCompatibilityViolation::SizedSelf(spans)
|
||||||
| ObjectSafetyViolation::SupertraitNonLifetimeBinder(spans) => spans.clone(),
|
| DynCompatibilityViolation::SupertraitNonLifetimeBinder(spans) => spans.clone(),
|
||||||
ObjectSafetyViolation::AssocConst(_, span)
|
DynCompatibilityViolation::AssocConst(_, span)
|
||||||
| ObjectSafetyViolation::GAT(_, span)
|
| DynCompatibilityViolation::GAT(_, span)
|
||||||
| ObjectSafetyViolation::Method(_, _, span)
|
| DynCompatibilityViolation::Method(_, _, span)
|
||||||
if *span != DUMMY_SP =>
|
if *span != DUMMY_SP =>
|
||||||
{
|
{
|
||||||
smallvec![*span]
|
smallvec![*span]
|
||||||
@ -822,7 +828,7 @@ impl ObjectSafetyViolation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub enum ObjectSafetyViolationSolution {
|
pub enum DynCompatibilityViolationSolution {
|
||||||
None,
|
None,
|
||||||
AddSelfOrMakeSized {
|
AddSelfOrMakeSized {
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
@ -833,11 +839,11 @@ pub enum ObjectSafetyViolationSolution {
|
|||||||
MoveToAnotherTrait(Symbol),
|
MoveToAnotherTrait(Symbol),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectSafetyViolationSolution {
|
impl DynCompatibilityViolationSolution {
|
||||||
pub fn add_to<G: EmissionGuarantee>(self, err: &mut Diag<'_, G>) {
|
pub fn add_to<G: EmissionGuarantee>(self, err: &mut Diag<'_, G>) {
|
||||||
match self {
|
match self {
|
||||||
ObjectSafetyViolationSolution::None => {}
|
DynCompatibilityViolationSolution::None => {}
|
||||||
ObjectSafetyViolationSolution::AddSelfOrMakeSized {
|
DynCompatibilityViolationSolution::AddSelfOrMakeSized {
|
||||||
name,
|
name,
|
||||||
add_self_sugg,
|
add_self_sugg,
|
||||||
make_sized_sugg,
|
make_sized_sugg,
|
||||||
@ -860,7 +866,7 @@ impl ObjectSafetyViolationSolution {
|
|||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ObjectSafetyViolationSolution::ChangeToRefSelf(name, span) => {
|
DynCompatibilityViolationSolution::ChangeToRefSelf(name, span) => {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
span,
|
span,
|
||||||
format!("consider changing method `{name}`'s `self` parameter to be `&self`"),
|
format!("consider changing method `{name}`'s `self` parameter to be `&self`"),
|
||||||
@ -868,14 +874,14 @@ impl ObjectSafetyViolationSolution {
|
|||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ObjectSafetyViolationSolution::MoveToAnotherTrait(name) => {
|
DynCompatibilityViolationSolution::MoveToAnotherTrait(name) => {
|
||||||
err.help(format!("consider moving `{name}` to another trait"));
|
err.help(format!("consider moving `{name}` to another trait"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reasons a method might not be object-safe.
|
/// Reasons a method might not be dyn-compatible.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
|
||||||
pub enum MethodViolationCode {
|
pub enum MethodViolationCode {
|
||||||
/// e.g., `fn foo()`
|
/// e.g., `fn foo()`
|
||||||
|
@ -527,8 +527,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||||||
self.trait_is_alias(trait_def_id)
|
self.trait_is_alias(trait_def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trait_is_object_safe(self, trait_def_id: DefId) -> bool {
|
fn trait_is_dyn_compatible(self, trait_def_id: DefId) -> bool {
|
||||||
self.is_object_safe(trait_def_id)
|
self.is_dyn_compatible(trait_def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trait_is_fundamental(self, def_id: DefId) -> bool {
|
fn trait_is_fundamental(self, def_id: DefId) -> bool {
|
||||||
|
@ -301,7 +301,7 @@ impl FlagComputation {
|
|||||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
|
||||||
self.add_args(slice::from_ref(&arg));
|
self.add_args(slice::from_ref(&arg));
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ObjectSafe(_def_id) => {}
|
ty::PredicateKind::DynCompatible(_def_id) => {}
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(uv)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(uv)) => {
|
||||||
self.add_const(uv);
|
self.add_const(uv);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ pub enum ReifyReason {
|
|||||||
/// * A vtable entry is directly converted to a function call (e.g. creating a fn ptr from a
|
/// * A vtable entry is directly converted to a function call (e.g. creating a fn ptr from a
|
||||||
/// method on a `dyn` object).
|
/// method on a `dyn` object).
|
||||||
/// * A function with `#[track_caller]` is converted to a function pointer
|
/// * A function with `#[track_caller]` is converted to a function pointer
|
||||||
/// * If KCFI is enabled, creating a function pointer from a method on an object-safe trait.
|
/// * If KCFI is enabled, creating a function pointer from a method on a dyn-compatible trait.
|
||||||
/// This includes the case of converting `::call`-like methods on closure-likes to function
|
/// This includes the case of converting `::call`-like methods on closure-likes to function
|
||||||
/// pointers.
|
/// pointers.
|
||||||
FnPtr,
|
FnPtr,
|
||||||
|
@ -36,7 +36,7 @@ pub type PolyProjectionPredicate<'tcx> = ty::Binder<'tcx, ProjectionPredicate<'t
|
|||||||
|
|
||||||
/// A statement that can be proven by a trait solver. This includes things that may
|
/// A statement that can be proven by a trait solver. This includes things that may
|
||||||
/// show up in where clauses, such as trait predicates and projection predicates,
|
/// show up in where clauses, such as trait predicates and projection predicates,
|
||||||
/// and also things that are emitted as part of type checking such as `ObjectSafe`
|
/// and also things that are emitted as part of type checking such as `DynCompatible`
|
||||||
/// predicate which is emitted when a type is coerced to a trait object.
|
/// predicate which is emitted when a type is coerced to a trait object.
|
||||||
///
|
///
|
||||||
/// Use this rather than `PredicateKind`, whenever possible.
|
/// Use this rather than `PredicateKind`, whenever possible.
|
||||||
@ -147,7 +147,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||||||
| PredicateKind::Clause(ClauseKind::TypeOutlives(_))
|
| PredicateKind::Clause(ClauseKind::TypeOutlives(_))
|
||||||
| PredicateKind::Clause(ClauseKind::Projection(_))
|
| PredicateKind::Clause(ClauseKind::Projection(_))
|
||||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||||
| PredicateKind::ObjectSafe(_)
|
| PredicateKind::DynCompatible(_)
|
||||||
| PredicateKind::Subtype(_)
|
| PredicateKind::Subtype(_)
|
||||||
| PredicateKind::Coerce(_)
|
| PredicateKind::Coerce(_)
|
||||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
|
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
|
||||||
@ -647,7 +647,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||||||
| PredicateKind::Coerce(..)
|
| PredicateKind::Coerce(..)
|
||||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||||
| PredicateKind::ObjectSafe(..)
|
| PredicateKind::DynCompatible(..)
|
||||||
| PredicateKind::Clause(ClauseKind::TypeOutlives(..))
|
| PredicateKind::Clause(ClauseKind::TypeOutlives(..))
|
||||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||||
| PredicateKind::ConstEquate(..)
|
| PredicateKind::ConstEquate(..)
|
||||||
@ -667,7 +667,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||||||
| PredicateKind::Coerce(..)
|
| PredicateKind::Coerce(..)
|
||||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||||
| PredicateKind::ObjectSafe(..)
|
| PredicateKind::DynCompatible(..)
|
||||||
| PredicateKind::Clause(ClauseKind::TypeOutlives(..))
|
| PredicateKind::Clause(ClauseKind::TypeOutlives(..))
|
||||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||||
| PredicateKind::ConstEquate(..)
|
| PredicateKind::ConstEquate(..)
|
||||||
|
@ -3088,8 +3088,8 @@ define_print! {
|
|||||||
}
|
}
|
||||||
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
||||||
ty::PredicateKind::Coerce(predicate) => p!(print(predicate)),
|
ty::PredicateKind::Coerce(predicate) => p!(print(predicate)),
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::DynCompatible(trait_def_id) => {
|
||||||
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe")
|
p!("the trait `", print_def_path(trait_def_id, &[]), "` is dyn-compatible")
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||||
p!("the constant `", print(c1), "` equals `", print(c2), "`")
|
p!("the constant `", print(c1), "` equals `", print(c2), "`")
|
||||||
|
@ -1602,7 +1602,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
|||||||
/// `Other`.
|
/// `Other`.
|
||||||
/// This is mainly used to require the arbitrary_self_types feature
|
/// This is mainly used to require the arbitrary_self_types feature
|
||||||
/// in the case of `Other`, to improve error messages in the common cases,
|
/// in the case of `Other`, to improve error messages in the common cases,
|
||||||
/// and to make `Other` non-object-safe.
|
/// and to make `Other` dyn-incompatible.
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
///
|
///
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
//! #### Unsizing Casts
|
//! #### Unsizing Casts
|
||||||
//! A subtle way of introducing use edges is by casting to a trait object.
|
//! A subtle way of introducing use edges is by casting to a trait object.
|
||||||
//! Since the resulting fat-pointer contains a reference to a vtable, we need to
|
//! Since the resulting fat-pointer contains a reference to a vtable, we need to
|
||||||
//! instantiate all object-safe methods of the trait, as we need to store
|
//! instantiate all dyn-compatible methods of the trait, as we need to store
|
||||||
//! pointers to these functions even if they never get called anywhere. This can
|
//! pointers to these functions even if they never get called anywhere. This can
|
||||||
//! be seen as a special case of taking a function reference.
|
//! be seen as a special case of taking a function reference.
|
||||||
//!
|
//!
|
||||||
|
@ -639,8 +639,8 @@ where
|
|||||||
ty::Dynamic(bounds, ..) => bounds,
|
ty::Dynamic(bounds, ..) => bounds,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Do not consider built-in object impls for non-object-safe types.
|
// Do not consider built-in object impls for dyn-incompatible types.
|
||||||
if bounds.principal_def_id().is_some_and(|def_id| !cx.trait_is_object_safe(def_id)) {
|
if bounds.principal_def_id().is_some_and(|def_id| !cx.trait_is_dyn_compatible(def_id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,8 +423,8 @@ where
|
|||||||
ty::PredicateKind::Coerce(predicate) => {
|
ty::PredicateKind::Coerce(predicate) => {
|
||||||
self.compute_coerce_goal(Goal { param_env, predicate })
|
self.compute_coerce_goal(Goal { param_env, predicate })
|
||||||
}
|
}
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::DynCompatible(trait_def_id) => {
|
||||||
self.compute_object_safe_goal(trait_def_id)
|
self.compute_dyn_compatible_goal(trait_def_id)
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
|
||||||
self.compute_well_formed_goal(Goal { param_env, predicate: arg })
|
self.compute_well_formed_goal(Goal { param_env, predicate: arg })
|
||||||
|
@ -111,8 +111,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_object_safe_goal(&mut self, trait_def_id: I::DefId) -> QueryResult<I> {
|
fn compute_dyn_compatible_goal(&mut self, trait_def_id: I::DefId) -> QueryResult<I> {
|
||||||
if self.cx().trait_is_object_safe(trait_def_id) {
|
if self.cx().trait_is_dyn_compatible(trait_def_id) {
|
||||||
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||||
} else {
|
} else {
|
||||||
Err(NoSolution)
|
Err(NoSolution)
|
||||||
|
@ -832,8 +832,8 @@ where
|
|||||||
let cx = self.cx();
|
let cx = self.cx();
|
||||||
let Goal { predicate: (a_ty, _), .. } = goal;
|
let Goal { predicate: (a_ty, _), .. } = goal;
|
||||||
|
|
||||||
// Can only unsize to an object-safe trait.
|
// Can only unsize to an dyn-compatible trait.
|
||||||
if b_data.principal_def_id().is_some_and(|def_id| !cx.trait_is_object_safe(def_id)) {
|
if b_data.principal_def_id().is_some_and(|def_id| !cx.trait_is_dyn_compatible(def_id)) {
|
||||||
return Err(NoSolution);
|
return Err(NoSolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ fn implemented_method<'tcx>(
|
|||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let vtable_possible =
|
let vtable_possible = traits::is_vtable_safe_method(tcx, trait_id, trait_method)
|
||||||
traits::is_vtable_safe_method(tcx, trait_id, trait_method) && tcx.is_object_safe(trait_id);
|
&& tcx.is_dyn_compatible(trait_id);
|
||||||
vtable_possible.then_some((trait_ref, method_id, ancestor))
|
vtable_possible.then_some((trait_ref, method_id, ancestor))
|
||||||
}
|
}
|
||||||
|
@ -632,8 +632,8 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
|
|||||||
PredicateKind::Clause(clause_kind) => {
|
PredicateKind::Clause(clause_kind) => {
|
||||||
stable_mir::ty::PredicateKind::Clause(clause_kind.stable(tables))
|
stable_mir::ty::PredicateKind::Clause(clause_kind.stable(tables))
|
||||||
}
|
}
|
||||||
PredicateKind::ObjectSafe(did) => {
|
PredicateKind::DynCompatible(did) => {
|
||||||
stable_mir::ty::PredicateKind::ObjectSafe(tables.trait_def(*did))
|
stable_mir::ty::PredicateKind::DynCompatible(tables.trait_def(*did))
|
||||||
}
|
}
|
||||||
PredicateKind::Subtype(subtype_predicate) => {
|
PredicateKind::Subtype(subtype_predicate) => {
|
||||||
stable_mir::ty::PredicateKind::SubType(subtype_predicate.stable(tables))
|
stable_mir::ty::PredicateKind::SubType(subtype_predicate.stable(tables))
|
||||||
|
@ -37,7 +37,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::error_reporting::TypeErrCtxt;
|
use crate::error_reporting::TypeErrCtxt;
|
||||||
use crate::error_reporting::infer::TyCategory;
|
use crate::error_reporting::infer::TyCategory;
|
||||||
use crate::error_reporting::traits::report_object_safety_error;
|
use crate::error_reporting::traits::report_dyn_incompatibility;
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
|
AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
|
||||||
};
|
};
|
||||||
@ -46,7 +46,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
|||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
MismatchedProjectionTypes, NormalizeExt, Obligation, ObligationCause, ObligationCauseCode,
|
MismatchedProjectionTypes, NormalizeExt, Obligation, ObligationCause, ObligationCauseCode,
|
||||||
ObligationCtxt, Overflow, PredicateObligation, SelectionError, SignatureMismatch,
|
ObligationCtxt, Overflow, PredicateObligation, SelectionError, SignatureMismatch,
|
||||||
TraitNotObjectSafe, elaborate,
|
TraitDynIncompatible, elaborate,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
@ -547,9 +547,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::DynCompatible(trait_def_id) => {
|
||||||
let violations = self.tcx.object_safety_violations(trait_def_id);
|
let violations = self.tcx.dyn_compatibility_violations(trait_def_id);
|
||||||
report_object_safety_error(self.tcx, span, None, trait_def_id, violations)
|
report_dyn_incompatibility(self.tcx, span, None, trait_def_id, violations)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => {
|
||||||
@ -624,9 +624,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
def_id,
|
def_id,
|
||||||
),
|
),
|
||||||
|
|
||||||
TraitNotObjectSafe(did) => {
|
TraitDynIncompatible(did) => {
|
||||||
let violations = self.tcx.object_safety_violations(did);
|
let violations = self.tcx.dyn_compatibility_violations(did);
|
||||||
report_object_safety_error(self.tcx, span, None, did, violations)
|
report_dyn_incompatibility(self.tcx, span, None, did, violations)
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectionError::NotConstEvaluatable(NotConstEvaluatable::MentionsInfer) => {
|
SelectionError::NotConstEvaluatable(NotConstEvaluatable::MentionsInfer) => {
|
||||||
|
@ -12,8 +12,8 @@ use rustc_hir::def_id::{DefId, LocalDefId};
|
|||||||
use rustc_hir::intravisit::Visitor;
|
use rustc_hir::intravisit::Visitor;
|
||||||
use rustc_hir::{self as hir, LangItem};
|
use rustc_hir::{self as hir, LangItem};
|
||||||
use rustc_infer::traits::{
|
use rustc_infer::traits::{
|
||||||
ObjectSafetyViolation, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation,
|
DynCompatibilityViolation, Obligation, ObligationCause, ObligationCauseCode,
|
||||||
SelectionError,
|
PredicateObligation, SelectionError,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
|
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
@ -406,12 +406,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_object_safety_error<'tcx>(
|
pub fn report_dyn_incompatibility<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
hir_id: Option<hir::HirId>,
|
hir_id: Option<hir::HirId>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
violations: &[ObjectSafetyViolation],
|
violations: &[DynCompatibilityViolation],
|
||||||
) -> Diag<'tcx> {
|
) -> Diag<'tcx> {
|
||||||
let trait_str = tcx.def_path_str(trait_def_id);
|
let trait_str = tcx.def_path_str(trait_def_id);
|
||||||
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {
|
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {
|
||||||
@ -449,12 +449,12 @@ pub fn report_object_safety_error<'tcx>(
|
|||||||
let mut multi_span = vec![];
|
let mut multi_span = vec![];
|
||||||
let mut messages = vec![];
|
let mut messages = vec![];
|
||||||
for violation in violations {
|
for violation in violations {
|
||||||
if let ObjectSafetyViolation::SizedSelf(sp) = &violation
|
if let DynCompatibilityViolation::SizedSelf(sp) = &violation
|
||||||
&& !sp.is_empty()
|
&& !sp.is_empty()
|
||||||
{
|
{
|
||||||
// Do not report `SizedSelf` without spans pointing at `SizedSelf` obligations
|
// Do not report `SizedSelf` without spans pointing at `SizedSelf` obligations
|
||||||
// with a `Span`.
|
// with a `Span`.
|
||||||
reported_violations.insert(ObjectSafetyViolation::SizedSelf(vec![].into()));
|
reported_violations.insert(DynCompatibilityViolation::SizedSelf(vec![].into()));
|
||||||
}
|
}
|
||||||
if reported_violations.insert(violation.clone()) {
|
if reported_violations.insert(violation.clone()) {
|
||||||
let spans = violation.spans();
|
let spans = violation.spans();
|
||||||
@ -481,9 +481,10 @@ pub fn report_object_safety_error<'tcx>(
|
|||||||
for (span, msg) in iter::zip(multi_span, messages) {
|
for (span, msg) in iter::zip(multi_span, messages) {
|
||||||
note_span.push_span_label(span, msg);
|
note_span.push_span_label(span, msg);
|
||||||
}
|
}
|
||||||
|
// FIXME(dyn_compat_renaming): Update the URL.
|
||||||
err.span_note(
|
err.span_note(
|
||||||
note_span,
|
note_span,
|
||||||
"for a trait to be \"object safe\" it needs to allow building a vtable to allow the call \
|
"for a trait to be \"dyn-compatible\" it needs to allow building a vtable to allow the call \
|
||||||
to be resolvable dynamically; for more information visit \
|
to be resolvable dynamically; for more information visit \
|
||||||
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
|
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
|
||||||
);
|
);
|
||||||
|
@ -275,7 +275,7 @@ fn fulfillment_error_for_no_solution<'tcx>(
|
|||||||
FulfillmentErrorCode::Subtype(expected_found, TypeError::Sorts(expected_found))
|
FulfillmentErrorCode::Subtype(expected_found, TypeError::Sorts(expected_found))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Clause(_)
|
ty::PredicateKind::Clause(_)
|
||||||
| ty::PredicateKind::ObjectSafe(_)
|
| ty::PredicateKind::DynCompatible(_)
|
||||||
| ty::PredicateKind::Ambiguous => {
|
| ty::PredicateKind::Ambiguous => {
|
||||||
FulfillmentErrorCode::Select(SelectionError::Unimplemented)
|
FulfillmentErrorCode::Select(SelectionError::Unimplemented)
|
||||||
}
|
}
|
||||||
|
@ -802,7 +802,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
|
||||||
| ty::PredicateKind::NormalizesTo(..)
|
| ty::PredicateKind::NormalizesTo(..)
|
||||||
| ty::PredicateKind::AliasRelate(..)
|
| ty::PredicateKind::AliasRelate(..)
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::DynCompatible(..)
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
// FIXME(generic_const_exprs): you can absolutely add this as a where clauses
|
// FIXME(generic_const_exprs): you can absolutely add this as a where clauses
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||||
|
@ -28,43 +28,43 @@ use tracing::{debug, instrument};
|
|||||||
|
|
||||||
use super::elaborate;
|
use super::elaborate;
|
||||||
use crate::infer::TyCtxtInferExt;
|
use crate::infer::TyCtxtInferExt;
|
||||||
pub use crate::traits::ObjectSafetyViolation;
|
pub use crate::traits::DynCompatibilityViolation;
|
||||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||||
use crate::traits::{MethodViolationCode, Obligation, ObligationCause, util};
|
use crate::traits::{MethodViolationCode, Obligation, ObligationCause, util};
|
||||||
|
|
||||||
/// Returns the object safety violations that affect HIR ty lowering.
|
/// Returns the dyn-compatibility violations that affect HIR ty lowering.
|
||||||
///
|
///
|
||||||
/// Currently that is `Self` in supertraits. This is needed
|
/// Currently that is `Self` in supertraits. This is needed
|
||||||
/// because `object_safety_violations` can't be used during
|
/// because `dyn_compatibility_violations` can't be used during
|
||||||
/// type collection.
|
/// type collection.
|
||||||
#[instrument(level = "debug", skip(tcx))]
|
#[instrument(level = "debug", skip(tcx), ret)]
|
||||||
pub fn hir_ty_lowering_object_safety_violations(
|
pub fn hir_ty_lowering_dyn_compatibility_violations(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
) -> Vec<ObjectSafetyViolation> {
|
) -> Vec<DynCompatibilityViolation> {
|
||||||
debug_assert!(tcx.generics_of(trait_def_id).has_self);
|
debug_assert!(tcx.generics_of(trait_def_id).has_self);
|
||||||
let violations = tcx
|
tcx.supertrait_def_ids(trait_def_id)
|
||||||
.supertrait_def_ids(trait_def_id)
|
|
||||||
.map(|def_id| predicates_reference_self(tcx, def_id, true))
|
.map(|def_id| predicates_reference_self(tcx, def_id, true))
|
||||||
.filter(|spans| !spans.is_empty())
|
.filter(|spans| !spans.is_empty())
|
||||||
.map(ObjectSafetyViolation::SupertraitSelf)
|
.map(DynCompatibilityViolation::SupertraitSelf)
|
||||||
.collect();
|
.collect()
|
||||||
debug!(?violations);
|
|
||||||
violations
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_safety_violations(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &'_ [ObjectSafetyViolation] {
|
fn dyn_compatibility_violations(
|
||||||
|
tcx: TyCtxt<'_>,
|
||||||
|
trait_def_id: DefId,
|
||||||
|
) -> &'_ [DynCompatibilityViolation] {
|
||||||
debug_assert!(tcx.generics_of(trait_def_id).has_self);
|
debug_assert!(tcx.generics_of(trait_def_id).has_self);
|
||||||
debug!("object_safety_violations: {:?}", trait_def_id);
|
debug!("dyn_compatibility_violations: {:?}", trait_def_id);
|
||||||
|
|
||||||
tcx.arena.alloc_from_iter(
|
tcx.arena.alloc_from_iter(
|
||||||
tcx.supertrait_def_ids(trait_def_id)
|
tcx.supertrait_def_ids(trait_def_id)
|
||||||
.flat_map(|def_id| object_safety_violations_for_trait(tcx, def_id)),
|
.flat_map(|def_id| dyn_compatibility_violations_for_trait(tcx, def_id)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_object_safe(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
|
fn is_dyn_compatible(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
|
||||||
tcx.object_safety_violations(trait_def_id).is_empty()
|
tcx.dyn_compatibility_violations(trait_def_id).is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// We say a method is *vtable safe* if it can be invoked on a trait
|
/// We say a method is *vtable safe* if it can be invoked on a trait
|
||||||
@ -82,34 +82,35 @@ pub fn is_vtable_safe_method(tcx: TyCtxt<'_>, trait_def_id: DefId, method: ty::A
|
|||||||
virtual_call_violations_for_method(tcx, trait_def_id, method).is_empty()
|
virtual_call_violations_for_method(tcx, trait_def_id, method).is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_safety_violations_for_trait(
|
#[instrument(level = "debug", skip(tcx), ret)]
|
||||||
|
fn dyn_compatibility_violations_for_trait(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
) -> Vec<ObjectSafetyViolation> {
|
) -> Vec<DynCompatibilityViolation> {
|
||||||
// Check assoc items for violations.
|
// Check assoc items for violations.
|
||||||
let mut violations: Vec<_> = tcx
|
let mut violations: Vec<_> = tcx
|
||||||
.associated_items(trait_def_id)
|
.associated_items(trait_def_id)
|
||||||
.in_definition_order()
|
.in_definition_order()
|
||||||
.flat_map(|&item| object_safety_violations_for_assoc_item(tcx, trait_def_id, item))
|
.flat_map(|&item| dyn_compatibility_violations_for_assoc_item(tcx, trait_def_id, item))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Check the trait itself.
|
// Check the trait itself.
|
||||||
if trait_has_sized_self(tcx, trait_def_id) {
|
if trait_has_sized_self(tcx, trait_def_id) {
|
||||||
// We don't want to include the requirement from `Sized` itself to be `Sized` in the list.
|
// We don't want to include the requirement from `Sized` itself to be `Sized` in the list.
|
||||||
let spans = get_sized_bounds(tcx, trait_def_id);
|
let spans = get_sized_bounds(tcx, trait_def_id);
|
||||||
violations.push(ObjectSafetyViolation::SizedSelf(spans));
|
violations.push(DynCompatibilityViolation::SizedSelf(spans));
|
||||||
}
|
}
|
||||||
let spans = predicates_reference_self(tcx, trait_def_id, false);
|
let spans = predicates_reference_self(tcx, trait_def_id, false);
|
||||||
if !spans.is_empty() {
|
if !spans.is_empty() {
|
||||||
violations.push(ObjectSafetyViolation::SupertraitSelf(spans));
|
violations.push(DynCompatibilityViolation::SupertraitSelf(spans));
|
||||||
}
|
}
|
||||||
let spans = bounds_reference_self(tcx, trait_def_id);
|
let spans = bounds_reference_self(tcx, trait_def_id);
|
||||||
if !spans.is_empty() {
|
if !spans.is_empty() {
|
||||||
violations.push(ObjectSafetyViolation::SupertraitSelf(spans));
|
violations.push(DynCompatibilityViolation::SupertraitSelf(spans));
|
||||||
}
|
}
|
||||||
let spans = super_predicates_have_non_lifetime_binders(tcx, trait_def_id);
|
let spans = super_predicates_have_non_lifetime_binders(tcx, trait_def_id);
|
||||||
if !spans.is_empty() {
|
if !spans.is_empty() {
|
||||||
violations.push(ObjectSafetyViolation::SupertraitNonLifetimeBinder(spans));
|
violations.push(DynCompatibilityViolation::SupertraitNonLifetimeBinder(spans));
|
||||||
}
|
}
|
||||||
|
|
||||||
if violations.is_empty() {
|
if violations.is_empty() {
|
||||||
@ -120,11 +121,6 @@ fn object_safety_violations_for_trait(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!(
|
|
||||||
"object_safety_violations_for_trait(trait_def_id={:?}) = {:?}",
|
|
||||||
trait_def_id, violations
|
|
||||||
);
|
|
||||||
|
|
||||||
violations
|
violations
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,13 +292,13 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `Some(_)` if this item makes the containing trait not object safe.
|
/// Returns `Some(_)` if this item makes the containing trait dyn-incompatible.
|
||||||
#[instrument(level = "debug", skip(tcx), ret)]
|
#[instrument(level = "debug", skip(tcx), ret)]
|
||||||
pub fn object_safety_violations_for_assoc_item(
|
pub fn dyn_compatibility_violations_for_assoc_item(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
item: ty::AssocItem,
|
item: ty::AssocItem,
|
||||||
) -> Vec<ObjectSafetyViolation> {
|
) -> Vec<DynCompatibilityViolation> {
|
||||||
// Any item that has a `Self : Sized` requisite is otherwise
|
// Any item that has a `Self : Sized` requisite is otherwise
|
||||||
// exempt from the regulations.
|
// exempt from the regulations.
|
||||||
if tcx.generics_require_sized_self(item.def_id) {
|
if tcx.generics_require_sized_self(item.def_id) {
|
||||||
@ -310,10 +306,10 @@ pub fn object_safety_violations_for_assoc_item(
|
|||||||
}
|
}
|
||||||
|
|
||||||
match item.kind {
|
match item.kind {
|
||||||
// Associated consts are never object safe, as they can't have `where` bounds yet at all,
|
// Associated consts are never dyn-compatible, as they can't have `where` bounds yet at all,
|
||||||
// and associated const bounds in trait objects aren't a thing yet either.
|
// and associated const bounds in trait objects aren't a thing yet either.
|
||||||
ty::AssocKind::Const => {
|
ty::AssocKind::Const => {
|
||||||
vec![ObjectSafetyViolation::AssocConst(item.name, item.ident(tcx).span)]
|
vec![DynCompatibilityViolation::AssocConst(item.name, item.ident(tcx).span)]
|
||||||
}
|
}
|
||||||
ty::AssocKind::Fn => virtual_call_violations_for_method(tcx, trait_def_id, item)
|
ty::AssocKind::Fn => virtual_call_violations_for_method(tcx, trait_def_id, item)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -330,16 +326,16 @@ pub fn object_safety_violations_for_assoc_item(
|
|||||||
_ => item.ident(tcx).span,
|
_ => item.ident(tcx).span,
|
||||||
};
|
};
|
||||||
|
|
||||||
ObjectSafetyViolation::Method(item.name, v, span)
|
DynCompatibilityViolation::Method(item.name, v, span)
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
// Associated types can only be object safe if they have `Self: Sized` bounds.
|
// Associated types can only be dyn-compatible if they have `Self: Sized` bounds.
|
||||||
ty::AssocKind::Type => {
|
ty::AssocKind::Type => {
|
||||||
if !tcx.features().generic_associated_types_extended
|
if !tcx.features().generic_associated_types_extended
|
||||||
&& !tcx.generics_of(item.def_id).is_own_empty()
|
&& !tcx.generics_of(item.def_id).is_own_empty()
|
||||||
&& !item.is_impl_trait_in_trait()
|
&& !item.is_impl_trait_in_trait()
|
||||||
{
|
{
|
||||||
vec![ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span)]
|
vec![DynCompatibilityViolation::GAT(item.name, item.ident(tcx).span)]
|
||||||
} else {
|
} else {
|
||||||
// We will permit associated types if they are explicitly mentioned in the trait object.
|
// We will permit associated types if they are explicitly mentioned in the trait object.
|
||||||
// We can't check this here, as here we only check if it is guaranteed to not be possible.
|
// We can't check this here, as here we only check if it is guaranteed to not be possible.
|
||||||
@ -351,8 +347,8 @@ pub fn object_safety_violations_for_assoc_item(
|
|||||||
|
|
||||||
/// Returns `Some(_)` if this method cannot be called on a trait
|
/// Returns `Some(_)` if this method cannot be called on a trait
|
||||||
/// object; this does not necessarily imply that the enclosing trait
|
/// object; this does not necessarily imply that the enclosing trait
|
||||||
/// is not object safe, because the method might have a where clause
|
/// is dyn-incompatible, because the method might have a where clause
|
||||||
/// `Self:Sized`.
|
/// `Self: Sized`.
|
||||||
fn virtual_call_violations_for_method<'tcx>(
|
fn virtual_call_violations_for_method<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
@ -932,8 +928,8 @@ fn contains_illegal_impl_trait_in_trait<'tcx>(
|
|||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
object_safety_violations,
|
dyn_compatibility_violations,
|
||||||
is_object_safe,
|
is_dyn_compatible,
|
||||||
generics_require_sized_self,
|
generics_require_sized_self,
|
||||||
..*providers
|
..*providers
|
||||||
};
|
};
|
@ -363,7 +363,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
|||||||
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
|
| ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(_))
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(..))
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
|
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
|
||||||
| ty::PredicateKind::ObjectSafe(_)
|
| ty::PredicateKind::DynCompatible(_)
|
||||||
| ty::PredicateKind::Subtype(_)
|
| ty::PredicateKind::Subtype(_)
|
||||||
| ty::PredicateKind::Coerce(_)
|
| ty::PredicateKind::Coerce(_)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||||
@ -418,8 +418,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::DynCompatible(trait_def_id) => {
|
||||||
if !self.selcx.tcx().is_object_safe(trait_def_id) {
|
if !self.selcx.tcx().is_dyn_compatible(trait_def_id) {
|
||||||
ProcessResult::Error(FulfillmentErrorCode::Select(Unimplemented))
|
ProcessResult::Error(FulfillmentErrorCode::Select(Unimplemented))
|
||||||
} else {
|
} else {
|
||||||
ProcessResult::Changed(vec![])
|
ProcessResult::Changed(vec![])
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
pub mod auto_trait;
|
pub mod auto_trait;
|
||||||
pub(crate) mod coherence;
|
pub(crate) mod coherence;
|
||||||
pub mod const_evaluatable;
|
pub mod const_evaluatable;
|
||||||
|
mod dyn_compatibility;
|
||||||
mod engine;
|
mod engine;
|
||||||
mod fulfill;
|
mod fulfill;
|
||||||
pub mod misc;
|
pub mod misc;
|
||||||
pub mod normalize;
|
pub mod normalize;
|
||||||
mod object_safety;
|
|
||||||
pub mod outlives_bounds;
|
pub mod outlives_bounds;
|
||||||
pub mod project;
|
pub mod project;
|
||||||
pub mod query;
|
pub mod query;
|
||||||
@ -43,13 +43,13 @@ pub use self::coherence::{
|
|||||||
InCrate, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams,
|
InCrate, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams,
|
||||||
add_placeholder_note, orphan_check_trait_ref, overlapping_impls,
|
add_placeholder_note, orphan_check_trait_ref, overlapping_impls,
|
||||||
};
|
};
|
||||||
|
pub use self::dyn_compatibility::{
|
||||||
|
DynCompatibilityViolation, dyn_compatibility_violations_for_assoc_item,
|
||||||
|
hir_ty_lowering_dyn_compatibility_violations, is_vtable_safe_method,
|
||||||
|
};
|
||||||
pub use self::engine::{ObligationCtxt, TraitEngineExt};
|
pub use self::engine::{ObligationCtxt, TraitEngineExt};
|
||||||
pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation};
|
pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation};
|
||||||
pub use self::normalize::NormalizeExt;
|
pub use self::normalize::NormalizeExt;
|
||||||
pub use self::object_safety::{
|
|
||||||
ObjectSafetyViolation, hir_ty_lowering_object_safety_violations, is_vtable_safe_method,
|
|
||||||
object_safety_violations_for_assoc_item,
|
|
||||||
};
|
|
||||||
pub use self::project::{normalize_inherent_projection, normalize_projection_ty};
|
pub use self::project::{normalize_inherent_projection, normalize_projection_ty};
|
||||||
pub use self::select::{
|
pub use self::select::{
|
||||||
EvaluationCache, EvaluationResult, IntercrateAmbiguityCause, OverflowError, SelectionCache,
|
EvaluationCache, EvaluationResult, IntercrateAmbiguityCause, OverflowError, SelectionCache,
|
||||||
@ -593,7 +593,7 @@ fn is_impossible_associated_item(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
object_safety::provide(providers);
|
dyn_compatibility::provide(providers);
|
||||||
vtable::provide(providers);
|
vtable::provide(providers);
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
specialization_graph_of: specialize::specialization_graph_provider,
|
specialization_graph_of: specialize::specialization_graph_provider,
|
||||||
|
@ -113,7 +113,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
|
|||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(..))
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::DynCompatible(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Ambiguous
|
| ty::PredicateKind::Ambiguous
|
||||||
@ -217,7 +217,7 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>(
|
|||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::Projection(..))
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::DynCompatible(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||||
| ty::PredicateKind::ConstEquate(..)
|
| ty::PredicateKind::ConstEquate(..)
|
||||||
| ty::PredicateKind::Ambiguous
|
| ty::PredicateKind::Ambiguous
|
||||||
|
@ -883,7 +883,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
if let Some(principal) = data.principal() {
|
if let Some(principal) = data.principal() {
|
||||||
if !self.infcx.tcx.features().object_safe_for_dispatch {
|
if !self.infcx.tcx.features().object_safe_for_dispatch {
|
||||||
principal.with_self_ty(self.tcx(), self_ty)
|
principal.with_self_ty(self.tcx(), self_ty)
|
||||||
} else if self.tcx().is_object_safe(principal.def_id()) {
|
} else if self.tcx().is_dyn_compatible(principal.def_id()) {
|
||||||
principal.with_self_ty(self.tcx(), self_ty)
|
principal.with_self_ty(self.tcx(), self_ty)
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,7 @@ use crate::traits::util::{self, closure_trait_ref_and_return_type};
|
|||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
ImplDerivedCause, ImplSource, ImplSourceUserDefinedData, Normalized, Obligation,
|
ImplDerivedCause, ImplSource, ImplSourceUserDefinedData, Normalized, Obligation,
|
||||||
ObligationCause, PolyTraitObligation, PredicateObligation, Selection, SelectionError,
|
ObligationCause, PolyTraitObligation, PredicateObligation, Selection, SelectionError,
|
||||||
SignatureMismatch, TraitNotObjectSafe, TraitObligation, Unimplemented,
|
SignatureMismatch, TraitDynIncompatible, TraitObligation, Unimplemented,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
@ -630,7 +630,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
"GATs in trait object shouldn't have been considered",
|
"GATs in trait object shouldn't have been considered",
|
||||||
);
|
);
|
||||||
return Err(SelectionError::TraitNotObjectSafe(trait_predicate.trait_ref.def_id));
|
return Err(SelectionError::TraitDynIncompatible(trait_predicate.trait_ref.def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This maybe belongs in wf, but that can't (doesn't) handle
|
// This maybe belongs in wf, but that can't (doesn't) handle
|
||||||
@ -1187,11 +1187,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
|
ImplSource::Builtin(BuiltinImplSource::Misc, obligations)
|
||||||
}
|
}
|
||||||
|
|
||||||
// `T` -> `Trait`
|
// `T` -> `dyn Trait`
|
||||||
(_, &ty::Dynamic(data, r, ty::Dyn)) => {
|
(_, &ty::Dynamic(data, r, ty::Dyn)) => {
|
||||||
let mut object_dids = data.auto_traits().chain(data.principal_def_id());
|
let mut object_dids = data.auto_traits().chain(data.principal_def_id());
|
||||||
if let Some(did) = object_dids.find(|did| !tcx.is_object_safe(*did)) {
|
if let Some(did) = object_dids.find(|did| !tcx.is_dyn_compatible(*did)) {
|
||||||
return Err(TraitNotObjectSafe(did));
|
return Err(TraitDynIncompatible(did));
|
||||||
}
|
}
|
||||||
|
|
||||||
let predicate_to_obligation = |predicate| {
|
let predicate_to_obligation = |predicate| {
|
||||||
|
@ -772,8 +772,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
Ok(EvaluatedToOkModuloRegions)
|
Ok(EvaluatedToOkModuloRegions)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
ty::PredicateKind::DynCompatible(trait_def_id) => {
|
||||||
if self.tcx().is_object_safe(trait_def_id) {
|
if self.tcx().is_dyn_compatible(trait_def_id) {
|
||||||
Ok(EvaluatedToOk)
|
Ok(EvaluatedToOk)
|
||||||
} else {
|
} else {
|
||||||
Ok(EvaluatedToErr)
|
Ok(EvaluatedToErr)
|
||||||
|
@ -838,7 +838,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
|
|||||||
self.cause(ObligationCauseCode::WellFormed(None)),
|
self.cause(ObligationCauseCode::WellFormed(None)),
|
||||||
self.recursion_depth,
|
self.recursion_depth,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)),
|
ty::Binder::dummy(ty::PredicateKind::DynCompatible(principal)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ fn not_outlives_predicate(p: ty::Predicate<'_>) -> bool {
|
|||||||
| ty::PredicateKind::NormalizesTo(..)
|
| ty::PredicateKind::NormalizesTo(..)
|
||||||
| ty::PredicateKind::AliasRelate(..)
|
| ty::PredicateKind::AliasRelate(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(..))
|
||||||
| ty::PredicateKind::ObjectSafe(..)
|
| ty::PredicateKind::DynCompatible(..)
|
||||||
| ty::PredicateKind::Subtype(..)
|
| ty::PredicateKind::Subtype(..)
|
||||||
| ty::PredicateKind::Coerce(..)
|
| ty::PredicateKind::Coerce(..)
|
||||||
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
|
||||||
|
@ -255,7 +255,7 @@ pub trait Interner:
|
|||||||
|
|
||||||
fn trait_is_alias(self, trait_def_id: Self::DefId) -> bool;
|
fn trait_is_alias(self, trait_def_id: Self::DefId) -> bool;
|
||||||
|
|
||||||
fn trait_is_object_safe(self, trait_def_id: Self::DefId) -> bool;
|
fn trait_is_dyn_compatible(self, trait_def_id: Self::DefId) -> bool;
|
||||||
|
|
||||||
fn trait_is_fundamental(self, def_id: Self::DefId) -> bool;
|
fn trait_is_fundamental(self, def_id: Self::DefId) -> bool;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ pub enum PredicateKind<I: Interner> {
|
|||||||
/// Prove a clause
|
/// Prove a clause
|
||||||
Clause(ClauseKind<I>),
|
Clause(ClauseKind<I>),
|
||||||
|
|
||||||
/// Trait must be object-safe.
|
/// Trait must be dyn-compatible.
|
||||||
ObjectSafe(I::DefId),
|
DynCompatible(I::DefId),
|
||||||
|
|
||||||
/// `T1 <: T2`
|
/// `T1 <: T2`
|
||||||
///
|
///
|
||||||
@ -128,8 +128,8 @@ impl<I: Interner> fmt::Debug for PredicateKind<I> {
|
|||||||
PredicateKind::Clause(a) => a.fmt(f),
|
PredicateKind::Clause(a) => a.fmt(f),
|
||||||
PredicateKind::Subtype(pair) => pair.fmt(f),
|
PredicateKind::Subtype(pair) => pair.fmt(f),
|
||||||
PredicateKind::Coerce(pair) => pair.fmt(f),
|
PredicateKind::Coerce(pair) => pair.fmt(f),
|
||||||
PredicateKind::ObjectSafe(trait_def_id) => {
|
PredicateKind::DynCompatible(trait_def_id) => {
|
||||||
write!(f, "ObjectSafe({trait_def_id:?})")
|
write!(f, "DynCompatible({trait_def_id:?})")
|
||||||
}
|
}
|
||||||
PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({c1:?}, {c2:?})"),
|
PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({c1:?}, {c2:?})"),
|
||||||
PredicateKind::Ambiguous => write!(f, "Ambiguous"),
|
PredicateKind::Ambiguous => write!(f, "Ambiguous"),
|
||||||
|
@ -1420,7 +1420,7 @@ pub struct GenericPredicates {
|
|||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||||
pub enum PredicateKind {
|
pub enum PredicateKind {
|
||||||
Clause(ClauseKind),
|
Clause(ClauseKind),
|
||||||
ObjectSafe(TraitDef),
|
DynCompatible(TraitDef),
|
||||||
SubType(SubtypePredicate),
|
SubType(SubtypePredicate),
|
||||||
Coerce(CoercePredicate),
|
Coerce(CoercePredicate),
|
||||||
ConstEquate(TyConst, TyConst),
|
ConstEquate(TyConst, TyConst),
|
||||||
|
@ -1444,7 +1444,7 @@ impl Trait {
|
|||||||
tcx.trait_def(self.def_id).safety
|
tcx.trait_def(self.def_id).safety
|
||||||
}
|
}
|
||||||
pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool {
|
pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool {
|
||||||
tcx.is_object_safe(self.def_id)
|
tcx.is_dyn_compatible(self.def_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -300,7 +300,7 @@ error[E0038]: the trait `SVec` cannot be made into an object
|
|||||||
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-105742.rs:14:17
|
--> $DIR/issue-105742.rs:14:17
|
||||||
|
|
|
|
||||||
LL | pub trait SVec: Index<
|
LL | pub trait SVec: Index<
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | impl dyn Trait {
|
LL | impl dyn Trait {
|
||||||
| ^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/associated-const-in-trait.rs:4:11
|
--> $DIR/associated-const-in-trait.rs:4:11
|
||||||
|
|
|
|
||||||
LL | trait Trait {
|
LL | trait Trait {
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | const fn n() -> usize { Self::N }
|
LL | const fn n() -> usize { Self::N }
|
||||||
| ^^^^ `Trait` cannot be made into an object
|
| ^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/associated-const-in-trait.rs:4:11
|
--> $DIR/associated-const-in-trait.rs:4:11
|
||||||
|
|
|
|
||||||
LL | trait Trait {
|
LL | trait Trait {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||||||
LL | impl dyn Bar {}
|
LL | impl dyn Bar {}
|
||||||
| ^^^^^^^ `Bar` cannot be made into an object
|
| ^^^^^^^ `Bar` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-48027.rs:2:11
|
--> $DIR/issue-48027.rs:2:11
|
||||||
|
|
|
|
||||||
LL | trait Bar {
|
LL | trait Bar {
|
||||||
|
@ -5,7 +5,7 @@ LL | fn f(_: impl Trait<T = Copy>) {}
|
|||||||
| ^^^^^^^^ `Copy` cannot be made into an object
|
| ^^^^^^^^ `Copy` cannot be made into an object
|
||||||
|
|
|
|
||||||
= note: the trait cannot be made into an object because it requires `Self: Sized`
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
|
||||||
= note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
|
||||||
error[E0225]: only auto traits can be used as additional traits in a trait object
|
error[E0225]: only auto traits can be used as additional traits in a trait object
|
||||||
--> $DIR/suggest-assoc-ty-bound-on-eq-bound.rs:10:42
|
--> $DIR/suggest-assoc-ty-bound-on-eq-bound.rs:10:42
|
||||||
@ -24,7 +24,7 @@ error[E0038]: the trait `Eq` cannot be made into an object
|
|||||||
LL | fn g(_: impl Trait<T = std::fmt::Debug + Eq>) {}
|
LL | fn g(_: impl Trait<T = std::fmt::Debug + Eq>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `Eq` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^ `Eq` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
--> $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 cannot be made into an object because it uses `Self` as a type parameter
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object
|
|||||||
LL | fn foo(x: &dyn async Fn()) {}
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $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`
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture`
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object
|
|||||||
LL | fn foo(x: &dyn async Fn()) {}
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $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`
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture`
|
||||||
@ -35,7 +35,7 @@ error[E0038]: the trait `AsyncFnMut` cannot be made into an object
|
|||||||
LL | fn foo(x: &dyn async Fn()) {}
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
| ^^^^^^^^^^ `AsyncFnMut` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $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`
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture`
|
||||||
@ -51,7 +51,7 @@ error[E0038]: the trait `AsyncFn` cannot be made into an object
|
|||||||
LL | fn foo(x: &dyn async Fn()) {}
|
LL | fn foo(x: &dyn async Fn()) {}
|
||||||
| ^^^^^^^^^^^^^^ `AsyncFn` cannot be made into an object
|
| ^^^^^^^^^^^^^^ `AsyncFn` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $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`
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture`
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let x: &dyn Foo = todo!();
|
LL | let x: &dyn Foo = todo!();
|
||||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety.rs:5:14
|
--> $DIR/object-safety.rs:5:14
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | async fn foo(self: &dyn Foo) {
|
LL | async fn foo(self: &dyn Foo) {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/inference_var_self_argument.rs:5:14
|
--> $DIR/inference_var_self_argument.rs:5:14
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
|
|||||||
LL | impl NotObjectSafe for dyn NotObjectSafe { }
|
LL | impl NotObjectSafe for dyn NotObjectSafe { }
|
||||||
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:6:43
|
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:6:43
|
||||||
|
|
|
|
||||||
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `ConstParamTy_` cannot be made into an object
|
|||||||
LL | fn foo(a: &dyn ConstParamTy_) {}
|
LL | fn foo(a: &dyn ConstParamTy_) {}
|
||||||
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
--> $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 cannot be made into an object because it uses `Self` as a type parameter
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
|
|||||||
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
|
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
--> $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 cannot be made into an object because it uses `Self` as a type parameter
|
||||||
|
@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-102768.rs:5:10
|
--> $DIR/issue-102768.rs:5:10
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | fn use_dyn(v: &dyn Foo) {
|
LL | fn use_dyn(v: &dyn Foo) {
|
||||||
| ^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety-err-ret.rs:8:8
|
--> $DIR/object-safety-err-ret.rs:8:8
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -22,7 +22,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | v.test();
|
LL | v.test();
|
||||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety-err-ret.rs:8:8
|
--> $DIR/object-safety-err-ret.rs:8:8
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | fn use_dyn(v: &dyn Foo) {
|
LL | fn use_dyn(v: &dyn Foo) {
|
||||||
| ^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety-err-where-bounds.rs:8:8
|
--> $DIR/object-safety-err-where-bounds.rs:8:8
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -20,7 +20,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | v.test();
|
LL | v.test();
|
||||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety-err-where-bounds.rs:8:8
|
--> $DIR/object-safety-err-where-bounds.rs:8:8
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
|
@ -24,7 +24,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
| ^^^^^ `Trait` cannot be made into an object
|
| ^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/not_wf_param_in_rpitit.rs:11:14
|
--> $DIR/not_wf_param_in_rpitit.rs:11:14
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
@ -47,7 +47,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/not_wf_param_in_rpitit.rs:11:14
|
--> $DIR/not_wf_param_in_rpitit.rs:11:14
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
@ -78,7 +78,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/not_wf_param_in_rpitit.rs:11:14
|
--> $DIR/not_wf_param_in_rpitit.rs:11:14
|
||||||
|
|
|
|
||||||
LL | trait Trait<const N: Trait = bar> {
|
LL | trait Trait<const N: Trait = bar> {
|
||||||
|
@ -12,7 +12,7 @@ const REF_INTERIOR_MUT: &usize = {
|
|||||||
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
//~| HELP if this is an object-safe trait, use `dyn`
|
//~| HELP if this is a dyn-compatible trait, use `dyn`
|
||||||
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
unsafe { &*(&FOO as *const _ as *const usize) }
|
unsafe { &*(&FOO as *const _ as *const usize) }
|
||||||
|
@ -18,7 +18,7 @@ LL | static FOO: Sync = AtomicUsize::new(0);
|
|||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: `#[warn(bare_trait_objects)]` on by default
|
= note: `#[warn(bare_trait_objects)]` on by default
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | static FOO: dyn Sync = AtomicUsize::new(0);
|
LL | static FOO: dyn Sync = AtomicUsize::new(0);
|
||||||
| +++
|
| +++
|
||||||
|
@ -182,7 +182,7 @@ LL | type H = Fn(u8) -> (u8)::Output;
|
|||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: `#[warn(bare_trait_objects)]` on by default
|
= note: `#[warn(bare_trait_objects)]` on by default
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | type H = <dyn Fn(u8) -> (u8)>::Output;
|
LL | type H = <dyn Fn(u8) -> (u8)>::Output;
|
||||||
| ++++ +
|
| ++++ +
|
||||||
|
@ -27,7 +27,7 @@ LL | let _: &Copy + 'static;
|
|||||||
| ^^^^^ `Copy` cannot be made into an object
|
| ^^^^^ `Copy` cannot be made into an object
|
||||||
|
|
|
|
||||||
= note: the trait cannot be made into an object because it requires `Self: Sized`
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
|
||||||
= note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ note: the lint level is defined here
|
|||||||
|
|
|
|
||||||
LL | #[deny(bare_trait_objects)]
|
LL | #[deny(bare_trait_objects)]
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
|
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
|
||||||
| +++
|
| +++
|
||||||
@ -24,7 +24,7 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
|||||||
|
|
|
|
||||||
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
|
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
|
||||||
| +++
|
| +++
|
||||||
@ -37,7 +37,7 @@ LL | let _x: &SomeTrait = todo!();
|
|||||||
|
|
|
|
||||||
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | let _x: &dyn SomeTrait = todo!();
|
LL | let _x: &dyn SomeTrait = todo!();
|
||||||
| +++
|
| +++
|
||||||
|
@ -11,7 +11,7 @@ note: the lint level is defined here
|
|||||||
|
|
|
|
||||||
LL | #![deny(bare_trait_objects)]
|
LL | #![deny(bare_trait_objects)]
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | <dyn fmt::Debug>::fmt(self, f)
|
LL | <dyn fmt::Debug>::fmt(self, f)
|
||||||
| +++
|
| +++
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | fn call_foo(x: Box<dyn Trait>) {
|
LL | fn call_foo(x: Box<dyn Trait>) {
|
||||||
| ^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/E0038.rs:2:22
|
--> $DIR/E0038.rs:2:22
|
||||||
|
|
|
|
||||||
LL | trait Trait {
|
LL | trait Trait {
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | let y = x.foo();
|
LL | let y = x.foo();
|
||||||
| ^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/E0038.rs:2:22
|
--> $DIR/E0038.rs:2:22
|
||||||
|
|
|
|
||||||
LL | trait Trait {
|
LL | trait Trait {
|
||||||
|
@ -7,7 +7,7 @@ LL | let _ = MyIterator::next;
|
|||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: `#[warn(bare_trait_objects)]` on by default
|
= note: `#[warn(bare_trait_objects)]` on by default
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | let _ = <dyn MyIterator>::next;
|
LL | let _ = <dyn MyIterator>::next;
|
||||||
| ++++ +
|
| ++++ +
|
||||||
|
@ -7,7 +7,7 @@ LL | fn ptr(self: Ptr<Self>);
|
|||||||
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
|
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
|
||||||
| ^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18
|
||||||
|
|
|
|
||||||
LL | trait Trait {
|
LL | trait Trait {
|
||||||
@ -25,7 +25,7 @@ LL | fn ptr(self: Ptr<Self>);
|
|||||||
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
|
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
|
||||||
| ^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18
|
||||||
|
|
|
|
||||||
LL | trait Trait {
|
LL | trait Trait {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
|
|||||||
LL | fn takes_non_object_safe_ref<T>(obj: &dyn NonObjectSafe1) {
|
LL | fn takes_non_object_safe_ref<T>(obj: &dyn NonObjectSafe1) {
|
||||||
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23
|
--> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23
|
||||||
|
|
|
|
||||||
LL | trait NonObjectSafe1: Sized {}
|
LL | trait NonObjectSafe1: Sized {}
|
||||||
@ -18,7 +18,7 @@ error[E0038]: the trait `NonObjectSafe2` cannot be made into an object
|
|||||||
LL | fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 {
|
LL | fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 {
|
||||||
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe2` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe2` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/feature-gate-object_safe_for_dispatch.rs:7:8
|
--> $DIR/feature-gate-object_safe_for_dispatch.rs:7:8
|
||||||
|
|
|
|
||||||
LL | trait NonObjectSafe2 {
|
LL | trait NonObjectSafe2 {
|
||||||
@ -40,7 +40,7 @@ error[E0038]: the trait `NonObjectSafe3` cannot be made into an object
|
|||||||
LL | fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) {
|
LL | fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) {
|
||||||
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8
|
--> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8
|
||||||
|
|
|
|
||||||
LL | trait NonObjectSafe3 {
|
LL | trait NonObjectSafe3 {
|
||||||
@ -55,7 +55,7 @@ error[E0038]: the trait `NonObjectSafe4` cannot be made into an object
|
|||||||
LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
|
LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
|
||||||
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22
|
--> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22
|
||||||
|
|
|
|
||||||
LL | trait NonObjectSafe4 {
|
LL | trait NonObjectSafe4 {
|
||||||
@ -70,7 +70,7 @@ error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
|
|||||||
LL | impl Trait for dyn NonObjectSafe1 {}
|
LL | impl Trait for dyn NonObjectSafe1 {}
|
||||||
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23
|
--> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23
|
||||||
|
|
|
|
||||||
LL | trait NonObjectSafe1: Sized {}
|
LL | trait NonObjectSafe1: Sized {}
|
||||||
|
@ -42,7 +42,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:2:8
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
|
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/gat-in-trait-path.rs:10:10
|
--> $DIR/gat-in-trait-path.rs:10:10
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -22,7 +22,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | f(Box::new(foo));
|
LL | f(Box::new(foo));
|
||||||
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/gat-in-trait-path.rs:10:10
|
--> $DIR/gat-in-trait-path.rs:10:10
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -40,7 +40,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | f(Box::new(foo));
|
LL | f(Box::new(foo));
|
||||||
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/gat-in-trait-path.rs:10:10
|
--> $DIR/gat-in-trait-path.rs:10:10
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
|
@ -129,7 +129,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
@ -194,7 +194,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
|
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-67510-pass.rs:9:10
|
--> $DIR/issue-67510-pass.rs:9:10
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -35,7 +35,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
|
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-67510.rs:2:10
|
--> $DIR/issue-67510.rs:2:10
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -54,7 +54,7 @@ error[E0038]: the trait `Provider` cannot be made into an object
|
|||||||
LL | inner: Box<dyn Provider<A = B>>,
|
LL | inner: Box<dyn Provider<A = B>>,
|
||||||
| ^^^^^^^^^^^^^^^^^^^ `Provider` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^ `Provider` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-71176.rs:2:10
|
--> $DIR/issue-71176.rs:2:10
|
||||||
|
|
|
|
||||||
LL | trait Provider {
|
LL | trait Provider {
|
||||||
@ -70,7 +70,7 @@ error[E0038]: the trait `Provider` cannot be made into an object
|
|||||||
LL | inner: Box::new(()),
|
LL | inner: Box::new(()),
|
||||||
| ^^^^^^^^^^^^ `Provider` cannot be made into an object
|
| ^^^^^^^^^^^^ `Provider` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-71176.rs:2:10
|
--> $DIR/issue-71176.rs:2:10
|
||||||
|
|
|
|
||||||
LL | trait Provider {
|
LL | trait Provider {
|
||||||
|
@ -20,7 +20,7 @@ error[E0038]: the trait `SuperTrait` cannot be made into an object
|
|||||||
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-76535.rs:9:10
|
--> $DIR/issue-76535.rs:9:10
|
||||||
|
|
|
|
||||||
LL | pub trait SuperTrait {
|
LL | pub trait SuperTrait {
|
||||||
@ -37,7 +37,7 @@ error[E0038]: the trait `SuperTrait` cannot be made into an object
|
|||||||
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-76535.rs:9:10
|
--> $DIR/issue-76535.rs:9:10
|
||||||
|
|
|
|
||||||
LL | pub trait SuperTrait {
|
LL | pub trait SuperTrait {
|
||||||
|
@ -20,7 +20,7 @@ error[E0038]: the trait `CollectionFamily` cannot be made into an object
|
|||||||
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
|
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-78671.rs:7:10
|
--> $DIR/issue-78671.rs:7:10
|
||||||
|
|
|
|
||||||
LL | trait CollectionFamily {
|
LL | trait CollectionFamily {
|
||||||
|
@ -20,7 +20,7 @@ error[E0038]: the trait `MapLike` cannot be made into an object
|
|||||||
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
|
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-79422.rs:23:10
|
--> $DIR/issue-79422.rs:23:10
|
||||||
|
|
|
|
||||||
LL | trait MapLike<K, V> {
|
LL | trait MapLike<K, V> {
|
||||||
@ -38,7 +38,7 @@ error[E0038]: the trait `MapLike` cannot be made into an object
|
|||||||
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
|
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-79422.rs:23:10
|
--> $DIR/issue-79422.rs:23:10
|
||||||
|
|
|
|
||||||
LL | trait MapLike<K, V> {
|
LL | trait MapLike<K, V> {
|
||||||
|
@ -54,7 +54,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
|
LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/missing_lifetime_args.rs:2:10
|
--> $DIR/missing_lifetime_args.rs:2:10
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -98,7 +98,7 @@ error[E0038]: the trait `X` cannot be made into an object
|
|||||||
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; 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
|
--> $DIR/trait-path-type-error-once-implemented.rs:2:10
|
||||||
|
|
|
|
||||||
LL | trait X {
|
LL | trait X {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object
|
|||||||
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
|
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/trait-objects.rs:7:10
|
--> $DIR/trait-objects.rs:7:10
|
||||||
|
|
|
|
||||||
LL | trait StreamingIterator {
|
LL | trait StreamingIterator {
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object
|
|||||||
LL | x.size_hint().0
|
LL | x.size_hint().0
|
||||||
| ^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
| ^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/trait-objects.rs:7:10
|
--> $DIR/trait-objects.rs:7:10
|
||||||
|
|
|
|
||||||
LL | trait StreamingIterator {
|
LL | trait StreamingIterator {
|
||||||
@ -34,7 +34,7 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object
|
|||||||
LL | x.size_hint().0
|
LL | x.size_hint().0
|
||||||
| ^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
| ^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/trait-objects.rs:7:10
|
--> $DIR/trait-objects.rs:7:10
|
||||||
|
|
|
|
||||||
LL | trait StreamingIterator {
|
LL | trait StreamingIterator {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let x: &dyn Foo = &();
|
LL | let x: &dyn Foo = &();
|
||||||
| ^^^ `Foo` cannot be made into an object
|
| ^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/span-bug-issue-121597.rs:4:12
|
--> $DIR/span-bug-issue-121597.rs:4:12
|
||||||
|
|
|
|
||||||
LL | trait Foo: for<T> Bar<T> {}
|
LL | trait Foo: for<T> Bar<T> {}
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let x: &dyn Foo = &();
|
LL | let x: &dyn Foo = &();
|
||||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/span-bug-issue-121597.rs:4:12
|
--> $DIR/span-bug-issue-121597.rs:4:12
|
||||||
|
|
|
|
||||||
LL | trait Foo: for<T> Bar<T> {}
|
LL | trait Foo: for<T> Bar<T> {}
|
||||||
|
@ -7,7 +7,7 @@ LL | fn ice() -> impl AsRef<Fn(&())> {
|
|||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: `#[warn(bare_trait_objects)]` on by default
|
= note: `#[warn(bare_trait_objects)]` on by default
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
||||||
| +++
|
| +++
|
||||||
@ -21,7 +21,7 @@ LL | fn ice() -> impl AsRef<Fn(&())> {
|
|||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
||||||
| +++
|
| +++
|
||||||
|
@ -14,7 +14,7 @@ error[E0038]: the trait `MyTrait` cannot be made into an object
|
|||||||
LL | MyTrait::foo(&self)
|
LL | MyTrait::foo(&self)
|
||||||
| ^^^^^^^^^^^^ `MyTrait` cannot be made into an object
|
| ^^^^^^^^^^^^ `MyTrait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
||||||
|
|
|
|
||||||
LL | trait MyTrait {
|
LL | trait MyTrait {
|
||||||
@ -38,7 +38,7 @@ error[E0038]: the trait `MyTrait` cannot be made into an object
|
|||||||
LL | impl dyn MyTrait {
|
LL | impl dyn MyTrait {
|
||||||
| ^^^^^^^^^^^ `MyTrait` cannot be made into an object
|
| ^^^^^^^^^^^ `MyTrait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
||||||
|
|
|
|
||||||
LL | trait MyTrait {
|
LL | trait MyTrait {
|
||||||
@ -54,7 +54,7 @@ error[E0038]: the trait `MyTrait` cannot be made into an object
|
|||||||
LL | fn other(&self) -> impl Marker {
|
LL | fn other(&self) -> impl Marker {
|
||||||
| ^^^^ `MyTrait` cannot be made into an object
|
| ^^^^ `MyTrait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
||||||
|
|
|
|
||||||
LL | trait MyTrait {
|
LL | trait MyTrait {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let _: &dyn rpitit::Foo = todo!();
|
LL | let _: &dyn rpitit::Foo = todo!();
|
||||||
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/auxiliary/rpitit.rs:4:21
|
--> $DIR/auxiliary/rpitit.rs:4:21
|
||||||
|
|
|
|
||||||
LL | fn bar(self) -> impl Deref<Target = impl Sized>;
|
LL | fn bar(self) -> impl Deref<Target = impl Sized>;
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||||
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety.rs:4:22
|
--> $DIR/object-safety.rs:4:22
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -20,7 +20,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let s = i.baz();
|
LL | let s = i.baz();
|
||||||
| ^^^ `Foo` cannot be made into an object
|
| ^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety.rs:4:22
|
--> $DIR/object-safety.rs:4:22
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -36,7 +36,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let s = i.baz();
|
LL | let s = i.baz();
|
||||||
| ^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety.rs:4:22
|
--> $DIR/object-safety.rs:4:22
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
@ -52,7 +52,7 @@ error[E0038]: the trait `Foo` cannot be made into an object
|
|||||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||||
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-safety.rs:4:22
|
--> $DIR/object-safety.rs:4:22
|
||||||
|
|
|
|
||||||
LL | trait Foo {
|
LL | trait Foo {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
|
|||||||
LL | fn car() -> dyn NotObjectSafe {
|
LL | fn car() -> dyn NotObjectSafe {
|
||||||
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
||||||
|
|
|
|
||||||
LL | trait NotObjectSafe {
|
LL | trait NotObjectSafe {
|
||||||
@ -29,7 +29,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
|
|||||||
LL | fn cat() -> Box<dyn NotObjectSafe> {
|
LL | fn cat() -> Box<dyn NotObjectSafe> {
|
||||||
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
||||||
|
|
|
|
||||||
LL | trait NotObjectSafe {
|
LL | trait NotObjectSafe {
|
||||||
@ -71,7 +71,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
|
|||||||
LL | return Box::new(A);
|
LL | return Box::new(A);
|
||||||
| ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
| ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
||||||
|
|
|
|
||||||
LL | trait NotObjectSafe {
|
LL | trait NotObjectSafe {
|
||||||
@ -97,7 +97,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
|
|||||||
LL | Box::new(B)
|
LL | Box::new(B)
|
||||||
| ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
| ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
|
||||||
|
|
|
|
||||||
LL | trait NotObjectSafe {
|
LL | trait NotObjectSafe {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||||||
LL | fn foo(b: &dyn Bar) {
|
LL | fn foo(b: &dyn Bar) {
|
||||||
| ^^^^^^^ `Bar` cannot be made into an object
|
| ^^^^^^^ `Bar` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-18959.rs:1:20
|
--> $DIR/issue-18959.rs:1:20
|
||||||
|
|
|
|
||||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||||
@ -19,7 +19,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||||||
LL | b.foo(&0)
|
LL | b.foo(&0)
|
||||||
| ^^^^^^^^^ `Bar` cannot be made into an object
|
| ^^^^^^^^^ `Bar` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-18959.rs:1:20
|
--> $DIR/issue-18959.rs:1:20
|
||||||
|
|
|
|
||||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||||
@ -34,7 +34,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||||||
LL | let test: &dyn Bar = &mut thing;
|
LL | let test: &dyn Bar = &mut thing;
|
||||||
| ^^^^^^^^ `Bar` cannot be made into an object
|
| ^^^^^^^^ `Bar` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-18959.rs:1:20
|
--> $DIR/issue-18959.rs:1:20
|
||||||
|
|
|
|
||||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||||
@ -49,7 +49,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||||||
LL | let test: &dyn Bar = &mut thing;
|
LL | let test: &dyn Bar = &mut thing;
|
||||||
| ^^^^^^^^^^ `Bar` cannot be made into an object
|
| ^^^^^^^^^^ `Bar` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-18959.rs:1:20
|
--> $DIR/issue-18959.rs:1:20
|
||||||
|
|
|
|
||||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||||
@ -65,7 +65,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||||||
LL | foo(test);
|
LL | foo(test);
|
||||||
| ^^^^ `Bar` cannot be made into an object
|
| ^^^^ `Bar` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-18959.rs:1:20
|
--> $DIR/issue-18959.rs:1:20
|
||||||
|
|
|
|
||||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Qiz` cannot be made into an object
|
|||||||
LL | foos: &'static [&'static (dyn Qiz + 'static)]
|
LL | foos: &'static [&'static (dyn Qiz + 'static)]
|
||||||
| ^^^^^^^^^^^^^^^^^ `Qiz` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^ `Qiz` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-19380.rs:2:6
|
--> $DIR/issue-19380.rs:2:6
|
||||||
|
|
|
|
||||||
LL | trait Qiz {
|
LL | trait Qiz {
|
||||||
@ -27,7 +27,7 @@ error[E0038]: the trait `Qiz` cannot be made into an object
|
|||||||
LL | const BAR : Bar = Bar { foos: &[&FOO]};
|
LL | const BAR : Bar = Bar { foos: &[&FOO]};
|
||||||
| ^^^^ `Qiz` cannot be made into an object
|
| ^^^^ `Qiz` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-19380.rs:2:6
|
--> $DIR/issue-19380.rs:2:6
|
||||||
|
|
|
|
||||||
LL | trait Qiz {
|
LL | trait Qiz {
|
||||||
@ -51,7 +51,7 @@ error[E0038]: the trait `Qiz` cannot be made into an object
|
|||||||
LL | const BAR : Bar = Bar { foos: &[&FOO]};
|
LL | const BAR : Bar = Bar { foos: &[&FOO]};
|
||||||
| ^^^^^^^ `Qiz` cannot be made into an object
|
| ^^^^^^^ `Qiz` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-19380.rs:2:6
|
--> $DIR/issue-19380.rs:2:6
|
||||||
|
|
|
|
||||||
LL | trait Qiz {
|
LL | trait Qiz {
|
||||||
|
@ -4,7 +4,7 @@ error[E0038]: the trait `Map` cannot be made into an object
|
|||||||
LL | as &dyn Map<Key=u32,MapValue=u32>;
|
LL | as &dyn Map<Key=u32,MapValue=u32>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Map` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Map` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-26056.rs:9:12
|
--> $DIR/issue-26056.rs:9:12
|
||||||
|
|
|
|
||||||
LL | trait Map: MapLookup<<Self as Map>::Key> {
|
LL | trait Map: MapLookup<<Self as Map>::Key> {
|
||||||
|
@ -7,7 +7,7 @@ LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
|
|||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
= note: `#[warn(bare_trait_objects)]` on by default
|
= note: `#[warn(bare_trait_objects)]` on by default
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | let x: u8 = <dyn BitXor>::bitor(0 as u8, 0 as u8);
|
LL | let x: u8 = <dyn BitXor>::bitor(0 as u8, 0 as u8);
|
||||||
| ++++ +
|
| ++++ +
|
||||||
@ -35,7 +35,7 @@ LL | let g = BitXor::bitor;
|
|||||||
|
|
|
|
||||||
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
help: if this is an object-safe trait, use `dyn`
|
help: if this is a dyn-compatible trait, use `dyn`
|
||||||
|
|
|
|
||||||
LL | let g = <dyn BitXor>::bitor;
|
LL | let g = <dyn BitXor>::bitor;
|
||||||
| ++++ +
|
| ++++ +
|
||||||
|
@ -23,7 +23,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
|
|||||||
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
|
||||||
| ^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
| ^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
|
||||||
|
|
|
|
||||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <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 to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||||
--> $DIR/issue-34373.rs:4:8
|
--> $DIR/issue-34373.rs:4:8
|
||||||
|
|
|
|
||||||
LL | trait Trait<T> {
|
LL | trait Trait<T> {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user