mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Rollup merge of #131475 - fmease:compiler-mv-obj-safe-dyn-compat-2, r=jieyouxu
Compiler & its UI tests: Rename remaining occurrences of "object safe" to "dyn compatible" Follow-up to #130826. Part of #130852. 1. 1st commit: Fix stupid oversights. Should've been part of #130826. 2. 2nd commit: Rename the unstable feature `object_safe_for_dispatch` to `dyn_compatible_for_dispatch`. Might not be worth the churn, you decide. 3. 3rd commit: Apply the renaming to all UI tests (contents and paths).
This commit is contained in:
commit
fa3dff3e24
@ -154,6 +154,10 @@ declare_features! (
|
||||
/// then removed. But there was no utility storing it separately, so now
|
||||
/// it's in this list.
|
||||
(removed, no_stack_check, "1.0.0", None, None),
|
||||
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible (object safe).
|
||||
/// Renamed to `dyn_compatible_for_dispatch`.
|
||||
(removed, object_safe_for_dispatch, "CURRENT_RUSTC_VERSION", Some(43561),
|
||||
Some("renamed to `dyn_compatible_for_dispatch`")),
|
||||
/// Allows using `#[on_unimplemented(..)]` on traits.
|
||||
/// (Moved to `rustc_attrs`.)
|
||||
(removed, on_unimplemented, "1.40.0", None, None),
|
||||
|
@ -259,6 +259,14 @@ declare_features! (
|
||||
(unstable, doc_notable_trait, "1.52.0", Some(45040)),
|
||||
/// Allows using the `may_dangle` attribute (RFC 1327).
|
||||
(unstable, dropck_eyepatch, "1.10.0", Some(34761)),
|
||||
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
|
||||
/// 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.
|
||||
///
|
||||
/// Renamed from `object_safe_for_dispatch`.
|
||||
///
|
||||
/// [^1]: Formerly known as "object safe".
|
||||
(unstable, dyn_compatible_for_dispatch, "CURRENT_RUSTC_VERSION", Some(43561)),
|
||||
/// Allows using the `#[fundamental]` attribute.
|
||||
(unstable, fundamental, "1.0.0", Some(29635)),
|
||||
/// Allows using `#[link_name="llvm.*"]`.
|
||||
@ -546,13 +554,6 @@ declare_features! (
|
||||
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
|
||||
/// Allows `for<T>` binders in where-clauses
|
||||
(incomplete, non_lifetime_binders, "1.69.0", Some(108185)),
|
||||
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible[^1].
|
||||
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
|
||||
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.
|
||||
///
|
||||
/// [^1]: Formerly known as "object safe".
|
||||
// FIXME(dyn_compat_renaming): Rename feature.
|
||||
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561)),
|
||||
/// Allows using enums in offset_of!
|
||||
(unstable, offset_of_enum, "1.75.0", Some(120141)),
|
||||
/// Allows using fields with slice type in offset_of!
|
||||
|
@ -199,7 +199,7 @@ fn check_object_overlap<'tcx>(
|
||||
for component_def_id in component_def_ids {
|
||||
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 'dyn_compatible_for_dispatch' feature this is an error
|
||||
// which will be reported by wfcheck. Ignore it here.
|
||||
// This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
|
||||
// With the feature enabled, the trait is not implemented automatically,
|
||||
|
@ -777,6 +777,7 @@ symbols! {
|
||||
dropck_eyepatch,
|
||||
dropck_parametricity,
|
||||
dylib,
|
||||
dyn_compatible_for_dispatch,
|
||||
dyn_metadata,
|
||||
dyn_star,
|
||||
dyn_trait,
|
||||
|
@ -1,12 +1,8 @@
|
||||
//! "Object safety" refers to the ability for a trait to be converted
|
||||
//! to an object. In general, traits may only be converted to an
|
||||
//! object if all of their methods meet certain criteria. In particular,
|
||||
//! they must:
|
||||
//! "Dyn-compatibility"[^1] refers to the ability for a trait to be converted
|
||||
//! to a trait object. In general, traits may only be converted to a trait
|
||||
//! object if certain criteria are met.
|
||||
//!
|
||||
//! - have a suitable receiver from which we can extract a vtable and coerce to a "thin" version
|
||||
//! that doesn't contain the vtable;
|
||||
//! - not reference the erased type `Self` except for in this receiver;
|
||||
//! - not have generic type parameters.
|
||||
//! [^1]: Formerly known as "object safety".
|
||||
|
||||
use std::iter;
|
||||
use std::ops::ControlFlow;
|
||||
@ -506,8 +502,8 @@ fn virtual_call_violations_for_method<'tcx>(
|
||||
|
||||
/// This code checks that `receiver_is_dispatchable` is correctly implemented.
|
||||
///
|
||||
/// This check is outlined from the object safety check to avoid cycles with
|
||||
/// layout computation, which relies on knowing whether methods are object safe.
|
||||
/// This check is outlined from the dyn-compatibility check to avoid cycles with
|
||||
/// layout computation, which relies on knowing whether methods are dyn-compatible.
|
||||
fn check_receiver_correct<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, method: ty::AssocItem) {
|
||||
if !is_vtable_safe_method(tcx, trait_def_id, method) {
|
||||
return;
|
||||
@ -643,8 +639,8 @@ fn object_ty_for_trait<'tcx>(
|
||||
/// contained by the trait object, because the object that needs to be coerced is behind
|
||||
/// a pointer.
|
||||
///
|
||||
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result
|
||||
/// in a new check that `Trait` is object safe, creating a cycle (until object_safe_for_dispatch
|
||||
/// In practice, we cannot use `dyn Trait` explicitly in the obligation because it would result in
|
||||
/// a new check that `Trait` is dyn-compatible, creating a cycle (until dyn_compatible_for_dispatch
|
||||
/// is stabilized, see tracking issue <https://github.com/rust-lang/rust/issues/43561>).
|
||||
/// Instead, we fudge a little by introducing a new type parameter `U` such that
|
||||
/// `Self: Unsize<U>` and `U: Trait + ?Sized`, and use `U` in place of `dyn Trait`.
|
||||
@ -678,7 +674,7 @@ fn receiver_is_dispatchable<'tcx>(
|
||||
|
||||
// the type `U` in the query
|
||||
// use a bogus type parameter to mimic a forall(U) query using u32::MAX for now.
|
||||
// FIXME(mikeyhew) this is a total hack. Once object_safe_for_dispatch is stabilized, we can
|
||||
// FIXME(mikeyhew) this is a total hack. Once dyn_compatible_for_dispatch is stabilized, we can
|
||||
// replace this with `dyn Trait`
|
||||
let unsized_self_ty: Ty<'tcx> =
|
||||
Ty::new_param(tcx, u32::MAX, Symbol::intern("RustaceansAreAwesome"));
|
||||
@ -865,7 +861,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_const(&mut self, ct: ty::Const<'tcx>) -> Self::Result {
|
||||
// Constants can only influence object safety if they are generic and reference `Self`.
|
||||
// Constants can only influence dyn-compatibility if they are generic and reference `Self`.
|
||||
// This is only possible for unevaluated constants, so we walk these here.
|
||||
self.tcx.expand_abstract_consts(ct).super_visit_with(self)
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
if let Some(principal) = data.principal() {
|
||||
if !self.infcx.tcx.features().object_safe_for_dispatch {
|
||||
if !self.infcx.tcx.features().dyn_compatible_for_dispatch {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
} else if self.tcx().is_dyn_compatible(principal.def_id()) {
|
||||
principal.with_self_ty(self.tcx(), self_ty)
|
||||
|
@ -829,7 +829,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
|
||||
// obligations that don't refer to Self and
|
||||
// checking those
|
||||
|
||||
let defer_to_coercion = tcx.features().object_safe_for_dispatch;
|
||||
let defer_to_coercion = tcx.features().dyn_compatible_for_dispatch;
|
||||
|
||||
if !defer_to_coercion {
|
||||
if let Some(principal) = data.principal_def_id() {
|
||||
|
@ -3172,10 +3172,6 @@ ui/nll/user-annotations/issue-55241.rs
|
||||
ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs
|
||||
ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs
|
||||
ui/numbers-arithmetic/issue-8460.rs
|
||||
ui/object-safety/issue-102762.rs
|
||||
ui/object-safety/issue-102933.rs
|
||||
ui/object-safety/issue-106247.rs
|
||||
ui/object-safety/issue-19538.rs
|
||||
ui/on-unimplemented/issue-104140.rs
|
||||
ui/or-patterns/issue-64879-trailing-before-guard.rs
|
||||
ui/or-patterns/issue-67514-irrefutable-param.rs
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ known-bug: #120241
|
||||
//@ edition:2021
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
#![feature(unsized_fn_params)]
|
||||
|
||||
fn guard(_s: Copy) -> bool {
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ known-bug: #120241
|
||||
//@ edition:2021
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
|
||||
trait B {
|
||||
fn f(a: A) -> A;
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ known-bug: #120482
|
||||
//@ edition:2021
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
|
||||
trait B {
|
||||
fn bar(&self, x: &Self);
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ known-bug: rust-lang/rust#125512
|
||||
//@ edition:2021
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
trait B {
|
||||
fn f(a: A) -> A;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//@ known-bug: rust-lang/rust#128176
|
||||
|
||||
#![feature(generic_const_exprs)]
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
trait X {
|
||||
type Y<const N: i16>;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@ known-bug: #130521
|
||||
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
struct Vtable(dyn Cap);
|
||||
|
||||
trait Cap<'a> {}
|
||||
|
13
tests/ui/allocator/dyn-compatible.rs
Normal file
13
tests/ui/allocator/dyn-compatible.rs
Normal file
@ -0,0 +1,13 @@
|
||||
//@ run-pass
|
||||
|
||||
// Check that `Allocator` is dyn-compatible, this allows for polymorphic allocators
|
||||
|
||||
#![feature(allocator_api)]
|
||||
|
||||
use std::alloc::{Allocator, System};
|
||||
|
||||
fn ensure_dyn_compatible(_: &dyn Allocator) {}
|
||||
|
||||
fn main() {
|
||||
ensure_dyn_compatible(&System);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
//@ run-pass
|
||||
|
||||
// Check that `Allocator` is object safe, this allows for polymorphic allocators
|
||||
|
||||
#![feature(allocator_api)]
|
||||
|
||||
use std::alloc::{Allocator, System};
|
||||
|
||||
fn ensure_object_safe(_: &dyn Allocator) {}
|
||||
|
||||
fn main() {
|
||||
ensure_object_safe(&System);
|
||||
}
|
@ -4,21 +4,21 @@ trait Tr1: Sized { type As1; }
|
||||
trait Tr2<'a>: Sized { type As2; }
|
||||
|
||||
trait ObjTr1 { fn foo() -> Self where Self: Tr1<As1: Copy>; }
|
||||
fn _assert_obj_safe_1(_: Box<dyn ObjTr1>) {}
|
||||
fn _assert_dyn_compat_1(_: Box<dyn ObjTr1>) {}
|
||||
|
||||
trait ObjTr2 { fn foo() -> Self where Self: Tr1<As1: 'static>; }
|
||||
fn _assert_obj_safe_2(_: Box<dyn ObjTr2>) {}
|
||||
fn _assert_dyn_compat_2(_: Box<dyn ObjTr2>) {}
|
||||
|
||||
trait ObjTr3 { fn foo() -> Self where Self: Tr1<As1: Into<u8> + 'static + Copy>; }
|
||||
fn _assert_obj_safe_3(_: Box<dyn ObjTr3>) {}
|
||||
fn _assert_dyn_compat_3(_: Box<dyn ObjTr3>) {}
|
||||
|
||||
trait ObjTr4 { fn foo() -> Self where Self: Tr1<As1: for<'a> Tr2<'a>>; }
|
||||
fn _assert_obj_safe_4(_: Box<dyn ObjTr4>) {}
|
||||
fn _assert_dyn_compat_4(_: Box<dyn ObjTr4>) {}
|
||||
|
||||
trait ObjTr5 { fn foo() -> Self where for<'a> Self: Tr1<As1: Tr2<'a>>; }
|
||||
fn _assert_obj_safe_5(_: Box<dyn ObjTr5>) {}
|
||||
fn _assert_dyn_compat_5(_: Box<dyn ObjTr5>) {}
|
||||
|
||||
trait ObjTr6 { fn foo() -> Self where Self: for<'a> Tr1<As1: Tr2<'a, As2: for<'b> Tr2<'b>>>; }
|
||||
fn _assert_obj_safe_6(_: Box<dyn ObjTr6>) {}
|
||||
fn _assert_dyn_compat_6(_: Box<dyn ObjTr6>) {}
|
||||
|
||||
fn main() {}
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:9:12
|
||||
--> $DIR/dyn-compatibility.rs:9:12
|
||||
|
|
||||
LL | let x: &dyn Foo = todo!();
|
||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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/dyn-compatibility.rs:5:14
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,10 +1,10 @@
|
||||
// Test that we give suitable error messages when the user attempts to
|
||||
// impl a trait `Trait` for its own object type.
|
||||
|
||||
// If the trait is not object-safe, we give a more tailored message
|
||||
// If the trait is dyn-incompatible, we give a more tailored message
|
||||
// because we're such schnuckels:
|
||||
trait NotObjectSafe { fn eq(&self, other: Self); }
|
||||
impl NotObjectSafe for dyn NotObjectSafe { }
|
||||
trait DynIncompatible { fn eq(&self, other: Self); }
|
||||
impl DynIncompatible for dyn DynIncompatible { }
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0046
|
||||
|
@ -0,0 +1,27 @@
|
||||
error[E0038]: the trait `DynIncompatible` cannot be made into an object
|
||||
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:26
|
||||
|
|
||||
LL | impl DynIncompatible for dyn DynIncompatible { }
|
||||
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` cannot be made into an object
|
||||
|
|
||||
note: for a 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-dyn-compatible.rs:6:45
|
||||
|
|
||||
LL | trait DynIncompatible { fn eq(&self, other: Self); }
|
||||
| --------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
= help: consider moving `eq` to another trait
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `eq`
|
||||
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:1
|
||||
|
|
||||
LL | trait DynIncompatible { fn eq(&self, other: Self); }
|
||||
| -------------------------- `eq` from trait
|
||||
LL | impl DynIncompatible for dyn DynIncompatible { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0046.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
@ -1,27 +0,0 @@
|
||||
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
|
||||
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:24
|
||||
|
|
||||
LL | impl NotObjectSafe for dyn NotObjectSafe { }
|
||||
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
||||
|
|
||||
note: for a 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
|
||||
|
|
||||
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
|
||||
| ------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
= help: consider moving `eq` to another trait
|
||||
|
||||
error[E0046]: not all trait items implemented, missing: `eq`
|
||||
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:1
|
||||
|
|
||||
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
|
||||
| -------------------------- `eq` from trait
|
||||
LL | impl NotObjectSafe for dyn NotObjectSafe { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0046.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
@ -1,7 +1,7 @@
|
||||
// Check that unsafe trait object do not implement themselves
|
||||
// automatically
|
||||
|
||||
#![feature(object_safe_for_dispatch)]
|
||||
#![feature(dyn_compatible_for_dispatch)]
|
||||
|
||||
trait Trait: Sized {
|
||||
fn call(&self);
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
|
||||
--> $DIR/const_param_ty_object_safety.rs:6:12
|
||||
--> $DIR/const_param_ty_dyn_compatibility.rs:6:12
|
||||
|
|
||||
LL | fn foo(a: &dyn ConstParamTy_) {}
|
||||
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
|
||||
@ -14,7 +14,7 @@ LL | fn foo(a: &impl ConstParamTy_) {}
|
||||
| ~~~~
|
||||
|
||||
error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
|
||||
--> $DIR/const_param_ty_object_safety.rs:9:12
|
||||
--> $DIR/const_param_ty_dyn_compatibility.rs:9:12
|
||||
|
|
||||
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-err-ret.rs:17:16
|
||||
--> $DIR/dyn-compatibility-err-ret.rs:17:16
|
||||
|
|
||||
LL | fn use_dyn(v: &dyn Foo) {
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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/dyn-compatibility-err-ret.rs:8:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -17,13 +17,13 @@ LL | fn test(&self) -> [u8; bar::<Self>()];
|
||||
= help: only type `()` implements the trait, consider using it directly instead
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-err-ret.rs:18:5
|
||||
--> $DIR/dyn-compatibility-err-ret.rs:18:5
|
||||
|
|
||||
LL | v.test();
|
||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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/dyn-compatibility-err-ret.rs:8:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-err-where-bounds.rs:15:16
|
||||
--> $DIR/dyn-compatibility-err-where-bounds.rs:15:16
|
||||
|
|
||||
LL | fn use_dyn(v: &dyn Foo) {
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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/dyn-compatibility-err-where-bounds.rs:8:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -15,13 +15,13 @@ LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
|
||||
= help: only type `()` implements the trait, consider using it directly instead
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-err-where-bounds.rs:17:5
|
||||
--> $DIR/dyn-compatibility-err-where-bounds.rs:17:5
|
||||
|
|
||||
LL | v.test();
|
||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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/dyn-compatibility-err-where-bounds.rs:8:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/object-safety-ok-infer-err.rs:19:5
|
||||
--> $DIR/dyn-compatibility-ok-infer-err.rs:19:5
|
||||
|
|
||||
LL | use_dyn(&());
|
||||
| ^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `use_dyn`
|
||||
|
|
||||
note: required by a const generic parameter in `use_dyn`
|
||||
--> $DIR/object-safety-ok-infer-err.rs:14:12
|
||||
--> $DIR/dyn-compatibility-ok-infer-err.rs:14:12
|
||||
|
|
||||
LL | fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized {
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `use_dyn`
|
||||
@ -15,7 +15,7 @@ LL | use_dyn::<N>(&());
|
||||
| +++++
|
||||
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/object-safety-ok-infer-err.rs:19:5
|
||||
--> $DIR/dyn-compatibility-ok-infer-err.rs:19:5
|
||||
|
|
||||
LL | use_dyn(&());
|
||||
| ^^^^^^^ --- type must be known at this point
|
||||
@ -23,7 +23,7 @@ LL | use_dyn(&());
|
||||
| cannot infer the value of the const parameter `N` declared on the function `use_dyn`
|
||||
|
|
||||
note: required for `()` to implement `Foo<_>`
|
||||
--> $DIR/object-safety-ok-infer-err.rs:8:22
|
||||
--> $DIR/dyn-compatibility-ok-infer-err.rs:8:22
|
||||
|
|
||||
LL | impl<const N: usize> Foo<N> for () {
|
||||
| -------------- ^^^^^^ ^^
|
@ -1,5 +1,5 @@
|
||||
// Test for fixed unsoundness in #126079.
|
||||
// Enforces that the associated types that are object safe
|
||||
// Enforces that the associated types that are dyn-compatible.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-associated-consts.rs:12:31
|
||||
--> $DIR/associated-consts.rs:12:31
|
||||
|
|
||||
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-associated-consts.rs:9:11
|
||||
--> $DIR/associated-consts.rs:9:11
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -14,13 +14,13 @@ LL | const X: usize;
|
||||
= help: consider moving `X` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-associated-consts.rs:14:5
|
||||
--> $DIR/associated-consts.rs:14:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-associated-consts.rs:9:11
|
||||
--> $DIR/associated-consts.rs:9:11
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-associated-consts.rs:14:5
|
||||
--> $DIR/associated-consts.rs:14:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-associated-consts.rs:9:11
|
||||
--> $DIR/associated-consts.rs:9:11
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,9 +1,9 @@
|
||||
// Check that we correctly prevent users from making trait objects
|
||||
// from traits with associated consts.
|
||||
//
|
||||
//@ revisions: curr object_safe_for_dispatch
|
||||
//@ revisions: curr dyn_compatible_for_dispatch
|
||||
|
||||
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
||||
#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))]
|
||||
|
||||
trait Bar {
|
||||
const X: usize;
|
@ -1,4 +1,4 @@
|
||||
// Traits with bounds mentioning `Self` are not object safe
|
||||
// Traits with bounds mentioning `Self` are dyn-incompatible.
|
||||
|
||||
trait X {
|
||||
type U: PartialEq<Self>;
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `X` cannot be made into an object
|
||||
--> $DIR/object-safety-bounds.rs:7:15
|
||||
--> $DIR/bounds.rs:7:15
|
||||
|
|
||||
LL | fn f() -> Box<dyn X<U = u32>> {
|
||||
| ^^^^^^^^^^^^^^ `X` cannot be made into an object
|
||||
|
|
||||
note: for a 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-bounds.rs:4:13
|
||||
--> $DIR/bounds.rs:4:13
|
||||
|
|
||||
LL | trait X {
|
||||
| - this trait cannot be made into an object...
|
@ -1,4 +1,4 @@
|
||||
// Check that while a trait with by-value self is object-safe, we
|
||||
// Check that while a trait with by-value self is dyn-compatible, we
|
||||
// can't actually invoke it from an object (yet...?).
|
||||
|
||||
#![feature(rustc_attrs)]
|
@ -1,5 +1,5 @@
|
||||
error[E0161]: cannot move a value of type `dyn Bar`
|
||||
--> $DIR/object-safety-by-value-self-use.rs:15:5
|
||||
--> $DIR/by-value-self-use.rs:15:5
|
||||
|
|
||||
LL | t.bar()
|
||||
| ^ the size of `dyn Bar` cannot be statically determined
|
@ -1,4 +1,4 @@
|
||||
// Check that a trait with by-value self is considered object-safe.
|
||||
// Check that a trait with by-value self is considered dyn-compatible.
|
||||
|
||||
//@ build-pass (FIXME(62277): could be check-pass?)
|
||||
#![allow(dead_code)]
|
@ -1,4 +1,5 @@
|
||||
//@ check-pass
|
||||
// issue: rust-lang/rust#102933
|
||||
|
||||
use std::future::Future;
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:18:31
|
||||
--> $DIR/generics.rs:18:31
|
||||
|
|
||||
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -14,13 +14,13 @@ LL | fn bar<T>(&self, t: T);
|
||||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:25:40
|
||||
--> $DIR/generics.rs:25:40
|
||||
|
|
||||
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -29,13 +29,13 @@ LL | fn bar<T>(&self, t: T);
|
||||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:20:5
|
||||
--> $DIR/generics.rs:20:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -45,13 +45,13 @@ LL | fn bar<T>(&self, t: T);
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:27:10
|
||||
--> $DIR/generics.rs:27:10
|
||||
|
|
||||
LL | t as &dyn Bar
|
||||
| ^^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -60,13 +60,13 @@ LL | fn bar<T>(&self, t: T);
|
||||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:27:5
|
||||
--> $DIR/generics.rs:27:5
|
||||
|
|
||||
LL | t as &dyn Bar
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:20:5
|
||||
--> $DIR/generics.rs:20:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -15,13 +15,13 @@ LL | fn bar<T>(&self, t: T);
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-generics.rs:27:5
|
||||
--> $DIR/generics.rs:27:5
|
||||
|
|
||||
LL | t as &dyn Bar
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-generics.rs:10:8
|
||||
--> $DIR/generics.rs:10:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,9 +1,9 @@
|
||||
// Check that we correctly prevent users from making trait objects
|
||||
// from traits with generic methods, unless `where Self : Sized` is
|
||||
// present.
|
||||
//@ revisions: curr object_safe_for_dispatch
|
||||
//@ revisions: curr dyn_compatible_for_dispatch
|
||||
|
||||
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
||||
#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))]
|
||||
|
||||
|
||||
trait Bar {
|
||||
@ -18,14 +18,14 @@ trait Quux {
|
||||
fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//[curr]~^ ERROR E0038
|
||||
t
|
||||
//[object_safe_for_dispatch]~^ ERROR E0038
|
||||
//[dyn_compatible_for_dispatch]~^ ERROR E0038
|
||||
//[curr]~^^ ERROR E0038
|
||||
}
|
||||
|
||||
fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//[curr]~^ ERROR E0038
|
||||
t as &dyn Bar
|
||||
//[object_safe_for_dispatch]~^ ERROR E0038
|
||||
//[dyn_compatible_for_dispatch]~^ ERROR E0038
|
||||
//[curr]~^^ ERROR E0038
|
||||
//[curr]~| ERROR E0038
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
//@ check-pass
|
||||
// issue: rust-lang/rust#106247
|
||||
|
||||
pub trait Trait {
|
||||
fn method(&self) where Self: Sync;
|
@ -1,3 +1,5 @@
|
||||
// issue: rust-lang/rust#19538
|
||||
|
||||
trait Foo {
|
||||
fn foo<T>(&self, val: T);
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-19538.rs:17:15
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:15
|
||||
|
|
||||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-19538.rs:2:8
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
||||
|
|
||||
LL | fn foo<T>(&self, val: T);
|
||||
| ^^^ ...because method `foo` has generic type parameters
|
||||
@ -16,13 +16,13 @@ LL | trait Bar: Foo { }
|
||||
= help: only type `Thing` implements the trait, consider using it directly instead
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-19538.rs:17:30
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:30
|
||||
|
|
||||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-19538.rs:2:8
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
||||
|
|
||||
LL | fn foo<T>(&self, val: T);
|
||||
| ^^^ ...because method `foo` has generic type parameters
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Expr` cannot be made into an object
|
||||
--> $DIR/object-safety-issue-22040.rs:12:23
|
||||
--> $DIR/mentions-Self-in-super-predicates.rs:12:23
|
||||
|
|
||||
LL | elements: Vec<Box<dyn Expr + 'x>>,
|
||||
| ^^^^^^^^^^^^^ `Expr` cannot be made into an object
|
||||
|
|
||||
note: for a 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-issue-22040.rs:5:21
|
||||
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
||||
|
|
||||
LL | trait Expr: Debug + PartialEq {
|
||||
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
|
||||
@ -14,13 +14,13 @@ LL | trait Expr: Debug + PartialEq {
|
||||
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
|
||||
|
||||
error[E0038]: the trait `Expr` cannot be made into an object
|
||||
--> $DIR/object-safety-issue-22040.rs:38:16
|
||||
--> $DIR/mentions-Self-in-super-predicates.rs:38:16
|
||||
|
|
||||
LL | let a: Box<dyn Expr> = Box::new(SExpr::new());
|
||||
| ^^^^^^^^ `Expr` cannot be made into an object
|
||||
|
|
||||
note: for a 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-issue-22040.rs:5:21
|
||||
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
||||
|
|
||||
LL | trait Expr: Debug + PartialEq {
|
||||
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
|
||||
@ -29,13 +29,13 @@ LL | trait Expr: Debug + PartialEq {
|
||||
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
|
||||
|
||||
error[E0038]: the trait `Expr` cannot be made into an object
|
||||
--> $DIR/object-safety-issue-22040.rs:40:16
|
||||
--> $DIR/mentions-Self-in-super-predicates.rs:40:16
|
||||
|
|
||||
LL | let b: Box<dyn Expr> = Box::new(SExpr::new());
|
||||
| ^^^^^^^^ `Expr` cannot be made into an object
|
||||
|
|
||||
note: for a 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-issue-22040.rs:5:21
|
||||
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
||||
|
|
||||
LL | trait Expr: Debug + PartialEq {
|
||||
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-mentions-Self.rs:22:31
|
||||
--> $DIR/mentions-Self.rs:22:31
|
||||
|
|
||||
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-mentions-Self.rs:11:22
|
||||
--> $DIR/mentions-Self.rs:11:22
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -14,13 +14,13 @@ LL | fn bar(&self, x: &Self);
|
||||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Baz` cannot be made into an object
|
||||
--> $DIR/object-safety-mentions-Self.rs:28:31
|
||||
--> $DIR/mentions-Self.rs:28:31
|
||||
|
|
||||
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
|
||||
| ^^^^^^^ `Baz` cannot be made into an object
|
||||
|
|
||||
note: for a 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-mentions-Self.rs:15:22
|
||||
--> $DIR/mentions-Self.rs:15:22
|
||||
|
|
||||
LL | trait Baz {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -29,13 +29,13 @@ LL | fn baz(&self) -> Self;
|
||||
= help: consider moving `baz` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-mentions-Self.rs:24:5
|
||||
--> $DIR/mentions-Self.rs:24:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-mentions-Self.rs:11:22
|
||||
--> $DIR/mentions-Self.rs:11:22
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -45,13 +45,13 @@ LL | fn bar(&self, x: &Self);
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Baz` cannot be made into an object
|
||||
--> $DIR/object-safety-mentions-Self.rs:30:5
|
||||
--> $DIR/mentions-Self.rs:30:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Baz` cannot be made into an object
|
||||
|
|
||||
note: for a 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-mentions-Self.rs:15:22
|
||||
--> $DIR/mentions-Self.rs:15:22
|
||||
|
|
||||
LL | trait Baz {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-mentions-Self.rs:24:5
|
||||
--> $DIR/mentions-Self.rs:24:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-mentions-Self.rs:11:22
|
||||
--> $DIR/mentions-Self.rs:11:22
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -15,13 +15,13 @@ LL | fn bar(&self, x: &Self);
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Baz` cannot be made into an object
|
||||
--> $DIR/object-safety-mentions-Self.rs:30:5
|
||||
--> $DIR/mentions-Self.rs:30:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Baz` cannot be made into an object
|
||||
|
|
||||
note: for a 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-mentions-Self.rs:15:22
|
||||
--> $DIR/mentions-Self.rs:15:22
|
||||
|
|
||||
LL | trait Baz {
|
||||
| --- this trait cannot be made into an object...
|
@ -2,9 +2,9 @@
|
||||
// form traits that make use of `Self` in an argument or return
|
||||
// position, unless `where Self : Sized` is present..
|
||||
//
|
||||
//@ revisions: curr object_safe_for_dispatch
|
||||
//@ revisions: curr dyn_compatible_for_dispatch
|
||||
|
||||
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
||||
#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))]
|
||||
|
||||
|
||||
trait Bar {
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-unsafe-missing-assoc-type.rs:5:16
|
||||
--> $DIR/missing-assoc-type.rs:5:16
|
||||
|
|
||||
LL | fn bar(x: &dyn Foo) {}
|
||||
| ^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-missing-assoc-type.rs:2:10
|
||||
--> $DIR/missing-assoc-type.rs:2:10
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -14,13 +14,13 @@ LL | type Bar<T>;
|
||||
= help: consider moving `Bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-unsafe-missing-assoc-type.rs:5:16
|
||||
--> $DIR/missing-assoc-type.rs:5:16
|
||||
|
|
||||
LL | fn bar(x: &dyn Foo) {}
|
||||
| ^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-missing-assoc-type.rs:2:10
|
||||
--> $DIR/missing-assoc-type.rs:2:10
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -30,13 +30,13 @@ LL | type Bar<T>;
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-unsafe-missing-assoc-type.rs:5:16
|
||||
--> $DIR/missing-assoc-type.rs:5:16
|
||||
|
|
||||
LL | fn bar(x: &dyn Foo) {}
|
||||
| ^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-missing-assoc-type.rs:2:10
|
||||
--> $DIR/missing-assoc-type.rs:2:10
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -46,13 +46,13 @@ LL | type Bar<T>;
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-unsafe-missing-assoc-type.rs:5:12
|
||||
--> $DIR/missing-assoc-type.rs:5:12
|
||||
|
|
||||
LL | fn bar(x: &dyn Foo) {}
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-missing-assoc-type.rs:2:10
|
||||
--> $DIR/missing-assoc-type.rs:2:10
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-no-static.rs:12:22
|
||||
--> $DIR/no-static.rs:12:22
|
||||
|
|
||||
LL | fn diverges() -> Box<dyn Foo> {
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-no-static.rs:9:8
|
||||
--> $DIR/no-static.rs:9:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -22,13 +22,13 @@ LL | fn foo() where Self: Sized {}
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-no-static.rs:22:12
|
||||
--> $DIR/no-static.rs:22:12
|
||||
|
|
||||
LL | let b: Box<dyn Foo> = Box::new(Bar);
|
||||
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-no-static.rs:9:8
|
||||
--> $DIR/no-static.rs:9:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -45,13 +45,13 @@ LL | fn foo() where Self: Sized {}
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-no-static.rs:22:27
|
||||
--> $DIR/no-static.rs:22:27
|
||||
|
|
||||
LL | let b: Box<dyn Foo> = Box::new(Bar);
|
||||
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-no-static.rs:9:8
|
||||
--> $DIR/no-static.rs:9:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety-no-static.rs:22:27
|
||||
--> $DIR/no-static.rs:22:27
|
||||
|
|
||||
LL | let b: Box<dyn Foo> = Box::new(Bar);
|
||||
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a 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-no-static.rs:9:8
|
||||
--> $DIR/no-static.rs:9:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
@ -1,9 +1,9 @@
|
||||
// Check that we correctly prevent users from making trait objects
|
||||
// from traits with static methods.
|
||||
//
|
||||
//@ revisions: curr object_safe_for_dispatch
|
||||
//@ revisions: curr dyn_compatible_for_dispatch
|
||||
|
||||
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
||||
#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))]
|
||||
|
||||
trait Foo {
|
||||
fn foo() {}
|
@ -1,4 +1,4 @@
|
||||
// Check that `Self` appearing in a phantom fn does not make a trait not object safe.
|
||||
// Check that `Self` appearing in a phantom fn does not make a trait dyn-incompatible.
|
||||
|
||||
//@ build-pass (FIXME(62277): could be check-pass?)
|
||||
#![allow(dead_code)]
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-sized-2.rs:14:31
|
||||
--> $DIR/sized-2.rs:14:31
|
||||
|
|
||||
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-sized-2.rs:9:18
|
||||
--> $DIR/sized-2.rs:9:18
|
||||
|
|
||||
LL | trait Bar
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -13,13 +13,13 @@ LL | where Self : Sized
|
||||
| ^^^^^ ...because it requires `Self: Sized`
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-sized-2.rs:16:5
|
||||
--> $DIR/sized-2.rs:16:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-sized-2.rs:9:18
|
||||
--> $DIR/sized-2.rs:9:18
|
||||
|
|
||||
LL | trait Bar
|
||||
| --- this trait cannot be made into an object...
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-sized-2.rs:16:5
|
||||
--> $DIR/sized-2.rs:16:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-sized-2.rs:9:18
|
||||
--> $DIR/sized-2.rs:9:18
|
||||
|
|
||||
LL | trait Bar
|
||||
| --- this trait cannot be made into an object...
|
@ -1,9 +1,9 @@
|
||||
// Check that we correctly prevent users from making trait objects
|
||||
// from traits where `Self : Sized`.
|
||||
//
|
||||
//@ revisions: curr object_safe_for_dispatch
|
||||
//@ revisions: curr dyn_compatible_for_dispatch
|
||||
|
||||
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
|
||||
#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))]
|
||||
|
||||
trait Bar
|
||||
where Self : Sized
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-sized.rs:12:32
|
||||
--> $DIR/sized.rs:12:32
|
||||
|
|
||||
LL | fn make_bar<T: Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-sized.rs:8:12
|
||||
--> $DIR/sized.rs:8:12
|
||||
|
|
||||
LL | trait Bar: Sized {
|
||||
| --- ^^^^^ ...because it requires `Self: Sized`
|
||||
@ -13,13 +13,13 @@ LL | trait Bar: Sized {
|
||||
| this trait cannot be made into an object...
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-sized.rs:14:5
|
||||
--> $DIR/sized.rs:14:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-sized.rs:8:12
|
||||
--> $DIR/sized.rs:8:12
|
||||
|
|
||||
LL | trait Bar: Sized {
|
||||
| --- ^^^^^ ...because it requires `Self: Sized`
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/object-safety-sized.rs:14:5
|
||||
--> $DIR/sized.rs:14:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` cannot be made into an object
|
||||
|
|
||||
note: for a 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-sized.rs:8:12
|
||||
--> $DIR/sized.rs:8:12
|
||||
|
|
||||
LL | trait Bar: Sized {
|
||||
| --- ^^^^^ ...because it requires `Self: Sized`
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user