Auto merge of #135893 - matthiaskrgr:rollup-2qqo647, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #133372 (Refactor dyn-compatibility error and suggestions)
 - #134396 (AIX: use align 8 for byval parameter)
 - #135156 (Make our `DIFlags` match `LLVMDIFlags` in the LLVM-C API)
 - #135816 (Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors)
 - #135823 (make UI tests that use `--test` work on panic=abort targets)
 - #135850 (Update the `wasm-component-ld` tool)
 - #135858 (rustdoc: Finalize dyn compatibility renaming)
 - #135866 (Don't pick `T: FnPtr` nested goals as the leaf goal in diagnostics for new solver)
 - #135874 (Enforce that all spans are lowered in ast lowering)
 - #135875 (Remove `Copy` bound from `enter_forall`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-22 19:33:19 +00:00
commit 649b995a9f
244 changed files with 2149 additions and 1469 deletions

View file

@ -1525,7 +1525,6 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
"serde",
]
[[package]]
@ -1535,6 +1534,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
dependencies = [
"foldhash",
"serde",
]
[[package]]
@ -5880,9 +5880,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi-preview1-component-adapter-provider"
version = "24.0.1"
version = "29.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f76d9fa52234153eeb40b088de91a8c13dc28a912cf6f31cd89ca4bac9024e0"
checksum = "dcd9f21bbde82ba59e415a8725e6ad0d0d7e9e460b1a3ccbca5bdee952c1a324"
[[package]]
name = "wasm-bindgen"
@ -5944,9 +5944,9 @@ dependencies = [
[[package]]
name = "wasm-component-ld"
version = "0.5.11"
version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2b05c3820968b335f10e703218459e4fd2cc91fdfc8f7936a993f1aacaa0938"
checksum = "580305a8e3f1b7a79859a8db897de643533b2851c5eb080fe5800233f16dec88"
dependencies = [
"anyhow",
"clap",
@ -5954,7 +5954,7 @@ dependencies = [
"libc",
"tempfile",
"wasi-preview1-component-adapter-provider",
"wasmparser 0.219.1",
"wasmparser 0.223.0",
"wat",
"windows-sys 0.59.0",
"winsplit",
@ -5991,9 +5991,9 @@ dependencies = [
[[package]]
name = "wasm-metadata"
version = "0.219.1"
version = "0.223.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af5a8e37a5e996861e1813f8de30911c47609c9ff51a7284f7dbd754dc3a9f3"
checksum = "5c730c3379d3d20e5a0245b0724b924483e853588ca8fba547c1e21f19e7d735"
dependencies = [
"anyhow",
"indexmap",
@ -6001,8 +6001,9 @@ dependencies = [
"serde_derive",
"serde_json",
"spdx",
"wasm-encoder 0.219.1",
"wasmparser 0.219.1",
"url",
"wasm-encoder 0.223.0",
"wasmparser 0.223.0",
]
[[package]]
@ -6011,12 +6012,8 @@ version = "0.219.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5"
dependencies = [
"ahash",
"bitflags",
"hashbrown 0.14.5",
"indexmap",
"semver",
"serde",
]
[[package]]
@ -6035,8 +6032,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5a99faceb1a5a84dd6084ec4bfa4b2ab153b5793b43fd8f58b89232634afc35"
dependencies = [
"bitflags",
"hashbrown 0.15.2",
"indexmap",
"semver",
"serde",
]
[[package]]
@ -6476,9 +6475,9 @@ checksum = "3ab703352da6a72f35c39a533526393725640575bb211f61987a2748323ad956"
[[package]]
name = "wit-component"
version = "0.219.1"
version = "0.223.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad1673163c0cb14a6a19ddbf44dd4efe6f015ec1ebb8156710ac32501f19fba2"
checksum = "c10ed2aeee4c8ec5715875f62f4a3de3608d6987165c116810d8c2908aa9d93b"
dependencies = [
"anyhow",
"bitflags",
@ -6487,17 +6486,17 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"wasm-encoder 0.219.1",
"wasm-encoder 0.223.0",
"wasm-metadata",
"wasmparser 0.219.1",
"wasmparser 0.223.0",
"wit-parser",
]
[[package]]
name = "wit-parser"
version = "0.219.1"
version = "0.223.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a86f669283257e8e424b9a4fc3518e3ade0b95deb9fbc0f93a1876be3eda598"
checksum = "92772f4dcacb804b275981eea1d920b12b377993b53307f1e33d87404e080281"
dependencies = [
"anyhow",
"id-arena",
@ -6508,7 +6507,7 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser 0.219.1",
"wasmparser 0.223.0",
]
[[package]]

View file

@ -2159,7 +2159,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let path = hir::ExprKind::Path(hir::QPath::TypeRelative(
self.arena.alloc(self.ty(span, hir::TyKind::Path(qpath))),
self.arena.alloc(hir::PathSegment::new(
Ident::new(name, span),
Ident::new(name, self.lower_span(span)),
self.next_id(),
Res::Err,
)),

View file

@ -78,24 +78,31 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
// Make sure that the DepNode of some node coincides with the HirId
// owner of that node.
if cfg!(debug_assertions) && hir_id.owner != self.owner {
span_bug!(
span,
"inconsistent HirId at `{:?}` for `{:?}`: \
if cfg!(debug_assertions) {
if hir_id.owner != self.owner {
span_bug!(
span,
"inconsistent HirId at `{:?}` for `{node:?}`: \
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
self.tcx.sess.source_map().span_to_diagnostic_string(span),
node,
self.tcx
.definitions_untracked()
.def_path(self.owner.def_id)
.to_string_no_crate_verbose(),
self.owner,
self.tcx
.definitions_untracked()
.def_path(hir_id.owner.def_id)
.to_string_no_crate_verbose(),
hir_id.owner,
)
self.tcx.sess.source_map().span_to_diagnostic_string(span),
self.tcx
.definitions_untracked()
.def_path(self.owner.def_id)
.to_string_no_crate_verbose(),
self.owner,
self.tcx
.definitions_untracked()
.def_path(hir_id.owner.def_id)
.to_string_no_crate_verbose(),
hir_id.owner,
)
}
if self.tcx.sess.opts.incremental.is_some()
&& span.parent().is_none()
&& !span.is_dummy()
{
span_bug!(span, "span without a parent: {:#?}, {node:?}", span.data())
}
}
self.nodes[hir_id.local_id] = ParentedNode { parent: self.parent_node, node };

View file

@ -1092,6 +1092,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// this as a special case.
return self.lower_fn_body(decl, |this| {
if attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic) {
let span = this.lower_span(span);
let empty_block = hir::Block {
hir_id: this.next_id(),
stmts: &[],

View file

@ -375,24 +375,24 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
expr: &Expr,
allow_paths: bool,
) -> &'hir hir::PatExpr<'hir> {
let span = self.lower_span(expr.span);
let err = |guar| hir::PatExprKind::Lit {
lit: self.arena.alloc(respan(self.lower_span(expr.span), LitKind::Err(guar))),
lit: self.arena.alloc(respan(span, LitKind::Err(guar))),
negated: false,
};
let kind = match &expr.kind {
ExprKind::Lit(lit) => {
hir::PatExprKind::Lit { lit: self.lower_lit(lit, expr.span), negated: false }
hir::PatExprKind::Lit { lit: self.lower_lit(lit, span), negated: false }
}
ExprKind::ConstBlock(c) => hir::PatExprKind::ConstBlock(self.lower_const_block(c)),
ExprKind::IncludedBytes(bytes) => hir::PatExprKind::Lit {
lit: self.arena.alloc(respan(
self.lower_span(expr.span),
LitKind::ByteStr(Arc::clone(bytes), StrStyle::Cooked),
)),
lit: self
.arena
.alloc(respan(span, LitKind::ByteStr(Arc::clone(bytes), StrStyle::Cooked))),
negated: false,
},
ExprKind::Err(guar) => err(*guar),
ExprKind::Dummy => span_bug!(expr.span, "lowered ExprKind::Dummy"),
ExprKind::Dummy => span_bug!(span, "lowered ExprKind::Dummy"),
ExprKind::Path(qself, path) if allow_paths => hir::PatExprKind::Path(self.lower_qpath(
expr.id,
qself,
@ -403,21 +403,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
None,
)),
ExprKind::Unary(UnOp::Neg, inner) if let ExprKind::Lit(lit) = &inner.kind => {
hir::PatExprKind::Lit { lit: self.lower_lit(lit, expr.span), negated: true }
hir::PatExprKind::Lit { lit: self.lower_lit(lit, span), negated: true }
}
_ => {
let pattern_from_macro = expr.is_approximately_pattern();
let guar = self.dcx().emit_err(ArbitraryExpressionInPattern {
span: expr.span,
span,
pattern_from_macro_note: pattern_from_macro,
});
err(guar)
}
};
self.arena.alloc(hir::PatExpr {
hir_id: self.lower_node_id(expr.id),
span: expr.span,
kind,
})
self.arena.alloc(hir::PatExpr { hir_id: self.lower_node_id(expr.id), span, kind })
}
}

View file

@ -185,7 +185,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
CustomTypeOp::new(
|ocx| {
let structurally_normalize = |ty| {
ocx.structurally_normalize(
ocx.structurally_normalize_ty(
&ObligationCause::misc(
location.to_locations().span(body),
body.source.def_id().expect_local(),
@ -230,7 +230,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
ConstraintCategory::Boring,
CustomTypeOp::new(
|ocx| {
ocx.structurally_normalize(
ocx.structurally_normalize_ty(
&ObligationCause::misc(
location.to_locations().span(body),
body.source.def_id().expect_local(),

View file

@ -9,6 +9,8 @@ test = false
[dependencies]
# tidy-alphabetical-start
bitflags = "2.4.1"
# To avoid duplicate dependencies, this should match the version of gimli used
# by `rustc_codegen_ssa` via its `thorin-dwp` dependency.
gimli = "0.30"
itertools = "0.12"
libc = "0.2"

View file

@ -741,8 +741,11 @@ pub mod debuginfo {
pub type DIEnumerator = DIDescriptor;
pub type DITemplateTypeParameter = DIDescriptor;
// These values **must** match with LLVMRustDIFlags!!
bitflags! {
/// Must match the layout of `LLVMDIFlags` in the LLVM-C API.
///
/// Each value declared here must also be covered by the static
/// assertions in `RustWrapper.cpp` used by `fromRust(LLVMDIFlags)`.
#[repr(transparent)]
#[derive(Clone, Copy, Default)]
pub struct DIFlags: u32 {
@ -752,7 +755,7 @@ pub mod debuginfo {
const FlagPublic = 3;
const FlagFwdDecl = (1 << 2);
const FlagAppleBlock = (1 << 3);
const FlagBlockByrefStruct = (1 << 4);
const FlagReservedBit4 = (1 << 4);
const FlagVirtual = (1 << 5);
const FlagArtificial = (1 << 6);
const FlagExplicit = (1 << 7);
@ -763,10 +766,21 @@ pub mod debuginfo {
const FlagStaticMember = (1 << 12);
const FlagLValueReference = (1 << 13);
const FlagRValueReference = (1 << 14);
const FlagExternalTypeRef = (1 << 15);
const FlagReserved = (1 << 15);
const FlagSingleInheritance = (1 << 16);
const FlagMultipleInheritance = (2 << 16);
const FlagVirtualInheritance = (3 << 16);
const FlagIntroducedVirtual = (1 << 18);
const FlagBitField = (1 << 19);
const FlagNoReturn = (1 << 20);
// The bit at (1 << 21) is unused, but was `LLVMDIFlagMainSubprogram`.
const FlagTypePassByValue = (1 << 22);
const FlagTypePassByReference = (1 << 23);
const FlagEnumClass = (1 << 24);
const FlagThunk = (1 << 25);
const FlagNonTrivial = (1 << 26);
const FlagBigEndian = (1 << 27);
const FlagLittleEndian = (1 << 28);
}
}

View file

@ -264,15 +264,15 @@ trait Foo {
### Trait contains associated constants
Just like static functions, associated constants aren't stored on the method
table. If the trait or any subtrait contain an associated constant, they cannot
be made into an object.
table. If the trait or any subtrait contain an associated constant, they are not
dyn compatible.
```compile_fail,E0038
trait Foo {
const X: i32;
}
impl Foo {}
impl dyn Foo {}
```
A simple workaround is to use a helper method instead:

View file

@ -163,7 +163,7 @@ declare_features! (
/// then removed. But there was no utility storing it separately, so now
/// it's in this list.
(removed, no_stack_check, "1.0.0", None, None),
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn-compatible (object safe).
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible (object safe).
/// Renamed to `dyn_compatible_for_dispatch`.
(removed, object_safe_for_dispatch, "1.83.0", Some(43561),
Some("renamed to `dyn_compatible_for_dispatch`")),

View file

@ -272,7 +272,7 @@ 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].
/// 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.
///

View file

@ -86,7 +86,7 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
if self.infcx.next_trait_solver()
&& let ty::Alias(..) = ty.kind()
{
let (normalized_ty, obligations) = self.structurally_normalize(ty)?;
let (normalized_ty, obligations) = self.structurally_normalize_ty(ty)?;
self.state.obligations.extend(obligations);
(AutoderefKind::Builtin, normalized_ty)
} else {
@ -166,7 +166,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
}
let (normalized_ty, obligations) =
self.structurally_normalize(Ty::new_projection(tcx, trait_target_def_id, [ty]))?;
self.structurally_normalize_ty(Ty::new_projection(tcx, trait_target_def_id, [ty]))?;
debug!("overloaded_deref_ty({:?}) = ({:?}, {:?})", ty, normalized_ty, obligations);
self.state.obligations.extend(obligations);
@ -174,12 +174,12 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
}
#[instrument(level = "debug", skip(self), ret)]
pub fn structurally_normalize(
pub fn structurally_normalize_ty(
&self,
ty: Ty<'tcx>,
) -> Option<(Ty<'tcx>, PredicateObligations<'tcx>)> {
let ocx = ObligationCtxt::new(self.infcx);
let Ok(normalized_ty) = ocx.structurally_normalize(
let Ok(normalized_ty) = ocx.structurally_normalize_ty(
&traits::ObligationCause::misc(self.span, self.body_id),
self.param_env,
ty,

View file

@ -185,7 +185,7 @@ fn check_object_overlap<'tcx>(
// check for overlap with the automatic `impl Trait for dyn Trait`
if let ty::Dynamic(data, ..) = trait_ref.self_ty().kind() {
// This is something like `impl Trait1 for Trait2`. Illegal if
// Trait1 is a supertrait of Trait2 or Trait2 is not dyn-compatible.
// Trait1 is a supertrait of Trait2 or Trait2 is not dyn compatible.
let component_def_ids = data.iter().flat_map(|predicate| {
match predicate.skip_binder() {

View file

@ -320,7 +320,7 @@ fn orphan_check<'tcx>(
}
let ty = if infcx.next_trait_solver() {
ocx.structurally_normalize(
ocx.structurally_normalize_ty(
&cause,
ty::ParamEnv::empty(),
infcx.resolve_vars_if_possible(ty),

View file

@ -1124,7 +1124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if self.next_trait_solver()
&& let ty::Alias(..) = ty.kind()
{
ocx.structurally_normalize(&cause, self.param_env, ty)
ocx.structurally_normalize_ty(&cause, self.param_env, ty)
} else {
Ok(ty)
}

View file

@ -1433,7 +1433,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// in a reentrant borrow, causing an ICE.
let result = self
.at(&self.misc(sp), self.param_env)
.structurally_normalize(ty, &mut **self.fulfillment_cx.borrow_mut());
.structurally_normalize_ty(ty, &mut **self.fulfillment_cx.borrow_mut());
match result {
Ok(normalized_ty) => normalized_ty,
Err(errors) => {

View file

@ -114,7 +114,7 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
)
}
fn enter_forall<T: TypeFoldable<TyCtxt<'tcx>> + Copy, U>(
fn enter_forall<T: TypeFoldable<TyCtxt<'tcx>>, U>(
&self,
value: ty::Binder<'tcx, T>,
f: impl FnOnce(T) -> U,

View file

@ -24,9 +24,9 @@ impl<'tcx> InferCtxt<'tcx> {
#[instrument(level = "debug", skip(self), ret)]
pub fn enter_forall_and_leak_universe<T>(&self, binder: ty::Binder<'tcx, T>) -> T
where
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
T: TypeFoldable<TyCtxt<'tcx>>,
{
if let Some(inner) = binder.no_bound_vars() {
if let Some(inner) = binder.clone().no_bound_vars() {
return inner;
}
@ -71,7 +71,7 @@ impl<'tcx> InferCtxt<'tcx> {
#[instrument(level = "debug", skip(self, f))]
pub fn enter_forall<T, U>(&self, forall: ty::Binder<'tcx, T>, f: impl FnOnce(T) -> U) -> U
where
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
T: TypeFoldable<TyCtxt<'tcx>>,
{
// FIXME: currently we do nothing to prevent placeholders with the new universe being
// used after exiting `f`. For example region subtyping can result in outlives constraints

View file

@ -2,6 +2,7 @@
#include "llvm-c/Analysis.h"
#include "llvm-c/Core.h"
#include "llvm-c/DebugInfo.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
@ -676,120 +677,73 @@ template <typename DIT> DIT *unwrapDIPtr(LLVMMetadataRef Ref) {
#define DIArray DINodeArray
#define unwrapDI unwrapDIPtr
// These values **must** match debuginfo::DIFlags! They also *happen*
// to match LLVM, but that isn't required as we do giant sets of
// matching below. The value shouldn't be directly passed to LLVM.
enum class LLVMRustDIFlags : uint32_t {
FlagZero = 0,
FlagPrivate = 1,
FlagProtected = 2,
FlagPublic = 3,
FlagFwdDecl = (1 << 2),
FlagAppleBlock = (1 << 3),
FlagBlockByrefStruct = (1 << 4),
FlagVirtual = (1 << 5),
FlagArtificial = (1 << 6),
FlagExplicit = (1 << 7),
FlagPrototyped = (1 << 8),
FlagObjcClassComplete = (1 << 9),
FlagObjectPointer = (1 << 10),
FlagVector = (1 << 11),
FlagStaticMember = (1 << 12),
FlagLValueReference = (1 << 13),
FlagRValueReference = (1 << 14),
FlagExternalTypeRef = (1 << 15),
FlagIntroducedVirtual = (1 << 18),
FlagBitField = (1 << 19),
FlagNoReturn = (1 << 20),
// Do not add values that are not supported by the minimum LLVM
// version we support! see llvm/include/llvm/IR/DebugInfoFlags.def
};
// FIXME(Zalathar): This is a temporary typedef to avoid churning dozens of
// bindings that are going to be deleted and replaced with their LLVM-C
// equivalents, as part of #134009. After that happens, the remaining bindings
// can be adjusted to use `LLVMDIFlags` instead of relying on this typedef.
typedef LLVMDIFlags LLVMRustDIFlags;
inline LLVMRustDIFlags operator&(LLVMRustDIFlags A, LLVMRustDIFlags B) {
return static_cast<LLVMRustDIFlags>(static_cast<uint32_t>(A) &
static_cast<uint32_t>(B));
}
// Statically assert that `LLVMDIFlags` (C) and `DIFlags` (C++) have the same
// layout, at least for the flags we know about. This isn't guaranteed, but is
// likely to remain true, and as long as it is true it makes conversions easy.
#define ASSERT_DIFLAG_VALUE(FLAG, VALUE) \
static_assert((LLVMDI##FLAG == (VALUE)) && (DINode::DIFlags::FLAG == (VALUE)))
ASSERT_DIFLAG_VALUE(FlagZero, 0);
ASSERT_DIFLAG_VALUE(FlagPrivate, 1);
ASSERT_DIFLAG_VALUE(FlagProtected, 2);
ASSERT_DIFLAG_VALUE(FlagPublic, 3);
// Bit (1 << 1) is part of the private/protected/public values above.
ASSERT_DIFLAG_VALUE(FlagFwdDecl, 1 << 2);
ASSERT_DIFLAG_VALUE(FlagAppleBlock, 1 << 3);
ASSERT_DIFLAG_VALUE(FlagReservedBit4, 1 << 4);
ASSERT_DIFLAG_VALUE(FlagVirtual, 1 << 5);
ASSERT_DIFLAG_VALUE(FlagArtificial, 1 << 6);
ASSERT_DIFLAG_VALUE(FlagExplicit, 1 << 7);
ASSERT_DIFLAG_VALUE(FlagPrototyped, 1 << 8);
ASSERT_DIFLAG_VALUE(FlagObjcClassComplete, 1 << 9);
ASSERT_DIFLAG_VALUE(FlagObjectPointer, 1 << 10);
ASSERT_DIFLAG_VALUE(FlagVector, 1 << 11);
ASSERT_DIFLAG_VALUE(FlagStaticMember, 1 << 12);
ASSERT_DIFLAG_VALUE(FlagLValueReference, 1 << 13);
ASSERT_DIFLAG_VALUE(FlagRValueReference, 1 << 14);
// Bit (1 << 15) has been recycled, but the C API value hasn't been renamed.
static_assert((LLVMDIFlagReserved == (1 << 15)) &&
(DINode::DIFlags::FlagExportSymbols == (1 << 15)));
ASSERT_DIFLAG_VALUE(FlagSingleInheritance, 1 << 16);
ASSERT_DIFLAG_VALUE(FlagMultipleInheritance, 2 << 16);
ASSERT_DIFLAG_VALUE(FlagVirtualInheritance, 3 << 16);
// Bit (1 << 17) is part of the inheritance values above.
ASSERT_DIFLAG_VALUE(FlagIntroducedVirtual, 1 << 18);
ASSERT_DIFLAG_VALUE(FlagBitField, 1 << 19);
ASSERT_DIFLAG_VALUE(FlagNoReturn, 1 << 20);
// Bit (1 << 21) is unused, but was `LLVMDIFlagMainSubprogram`.
ASSERT_DIFLAG_VALUE(FlagTypePassByValue, 1 << 22);
ASSERT_DIFLAG_VALUE(FlagTypePassByReference, 1 << 23);
ASSERT_DIFLAG_VALUE(FlagEnumClass, 1 << 24);
ASSERT_DIFLAG_VALUE(FlagThunk, 1 << 25);
ASSERT_DIFLAG_VALUE(FlagNonTrivial, 1 << 26);
ASSERT_DIFLAG_VALUE(FlagBigEndian, 1 << 27);
ASSERT_DIFLAG_VALUE(FlagLittleEndian, 1 << 28);
ASSERT_DIFLAG_VALUE(FlagIndirectVirtualBase, (1 << 2) | (1 << 5));
#undef ASSERT_DIFLAG_VALUE
inline LLVMRustDIFlags operator|(LLVMRustDIFlags A, LLVMRustDIFlags B) {
return static_cast<LLVMRustDIFlags>(static_cast<uint32_t>(A) |
static_cast<uint32_t>(B));
}
inline LLVMRustDIFlags &operator|=(LLVMRustDIFlags &A, LLVMRustDIFlags B) {
return A = A | B;
}
inline bool isSet(LLVMRustDIFlags F) { return F != LLVMRustDIFlags::FlagZero; }
inline LLVMRustDIFlags visibility(LLVMRustDIFlags F) {
return static_cast<LLVMRustDIFlags>(static_cast<uint32_t>(F) & 0x3);
}
static DINode::DIFlags fromRust(LLVMRustDIFlags Flags) {
DINode::DIFlags Result = DINode::DIFlags::FlagZero;
switch (visibility(Flags)) {
case LLVMRustDIFlags::FlagPrivate:
Result |= DINode::DIFlags::FlagPrivate;
break;
case LLVMRustDIFlags::FlagProtected:
Result |= DINode::DIFlags::FlagProtected;
break;
case LLVMRustDIFlags::FlagPublic:
Result |= DINode::DIFlags::FlagPublic;
break;
default:
// The rest are handled below
break;
// There are two potential ways to convert `LLVMDIFlags` to `DIFlags`:
// - Check and copy every individual bit/subvalue from input to output.
// - Statically assert that both have the same layout, and cast.
// As long as the static assertions succeed, a cast is easier and faster.
// In the (hopefully) unlikely event that the assertions do fail someday, and
// LLVM doesn't expose its own conversion function, we'll have to switch over
// to copying each bit/subvalue.
static DINode::DIFlags fromRust(LLVMDIFlags Flags) {
// Check that all set bits are covered by the static assertions above.
const unsigned UNKNOWN_BITS = (1 << 31) | (1 << 30) | (1 << 29) | (1 << 21);
if (Flags & UNKNOWN_BITS) {
report_fatal_error("bad LLVMDIFlags");
}
if (isSet(Flags & LLVMRustDIFlags::FlagFwdDecl)) {
Result |= DINode::DIFlags::FlagFwdDecl;
}
if (isSet(Flags & LLVMRustDIFlags::FlagAppleBlock)) {
Result |= DINode::DIFlags::FlagAppleBlock;
}
if (isSet(Flags & LLVMRustDIFlags::FlagVirtual)) {
Result |= DINode::DIFlags::FlagVirtual;
}
if (isSet(Flags & LLVMRustDIFlags::FlagArtificial)) {
Result |= DINode::DIFlags::FlagArtificial;
}
if (isSet(Flags & LLVMRustDIFlags::FlagExplicit)) {
Result |= DINode::DIFlags::FlagExplicit;
}
if (isSet(Flags & LLVMRustDIFlags::FlagPrototyped)) {
Result |= DINode::DIFlags::FlagPrototyped;
}
if (isSet(Flags & LLVMRustDIFlags::FlagObjcClassComplete)) {
Result |= DINode::DIFlags::FlagObjcClassComplete;
}
if (isSet(Flags & LLVMRustDIFlags::FlagObjectPointer)) {
Result |= DINode::DIFlags::FlagObjectPointer;
}
if (isSet(Flags & LLVMRustDIFlags::FlagVector)) {
Result |= DINode::DIFlags::FlagVector;
}
if (isSet(Flags & LLVMRustDIFlags::FlagStaticMember)) {
Result |= DINode::DIFlags::FlagStaticMember;
}
if (isSet(Flags & LLVMRustDIFlags::FlagLValueReference)) {
Result |= DINode::DIFlags::FlagLValueReference;
}
if (isSet(Flags & LLVMRustDIFlags::FlagRValueReference)) {
Result |= DINode::DIFlags::FlagRValueReference;
}
if (isSet(Flags & LLVMRustDIFlags::FlagIntroducedVirtual)) {
Result |= DINode::DIFlags::FlagIntroducedVirtual;
}
if (isSet(Flags & LLVMRustDIFlags::FlagBitField)) {
Result |= DINode::DIFlags::FlagBitField;
}
if (isSet(Flags & LLVMRustDIFlags::FlagNoReturn)) {
Result |= DINode::DIFlags::FlagNoReturn;
}
return Result;
// As long as the static assertions are satisfied and no unknown bits are
// present, we can convert from `LLVMDIFlags` to `DIFlags` with a cast.
return static_cast<DINode::DIFlags>(Flags);
}
// These values **must** match debuginfo::DISPFlags! They also *happen*

View file

@ -277,23 +277,7 @@ where
param_env: I::ParamEnv,
ty: I::Ty,
) -> Result<I::Ty, NoSolution> {
if let ty::Alias(..) = ty.kind() {
let normalized_ty = self.next_ty_infer();
let alias_relate_goal = Goal::new(
self.cx(),
param_env,
ty::PredicateKind::AliasRelate(
ty.into(),
normalized_ty.into(),
ty::AliasRelationDirection::Equate,
),
);
self.add_goal(GoalSource::Misc, alias_relate_goal);
self.try_evaluate_added_goals()?;
Ok(self.resolve_vars_if_possible(normalized_ty))
} else {
Ok(ty)
}
self.structurally_normalize_term(param_env, ty.into()).map(|term| term.expect_ty())
}
/// Normalize a const for when it is structurally matched on, or more likely
@ -308,22 +292,34 @@ where
param_env: I::ParamEnv,
ct: I::Const,
) -> Result<I::Const, NoSolution> {
if let ty::ConstKind::Unevaluated(..) = ct.kind() {
let normalized_ct = self.next_const_infer();
self.structurally_normalize_term(param_env, ct.into()).map(|term| term.expect_const())
}
/// Normalize a term for when it is structurally matched on.
///
/// This function is necessary in nearly all cases before matching on a ty/const.
/// Not doing so is likely to be incomplete and therefore unsound during coherence.
fn structurally_normalize_term(
&mut self,
param_env: I::ParamEnv,
term: I::Term,
) -> Result<I::Term, NoSolution> {
if let Some(_) = term.to_alias_term() {
let normalized_term = self.next_term_infer_of_kind(term);
let alias_relate_goal = Goal::new(
self.cx(),
param_env,
ty::PredicateKind::AliasRelate(
ct.into(),
normalized_ct.into(),
term,
normalized_term,
ty::AliasRelationDirection::Equate,
),
);
self.add_goal(GoalSource::Misc, alias_relate_goal);
self.try_evaluate_added_goals()?;
Ok(self.resolve_vars_if_possible(normalized_ct))
Ok(self.resolve_vars_if_possible(normalized_term))
} else {
Ok(ct)
Ok(term)
}
}

View file

@ -58,8 +58,10 @@ where
// The AIX ABI expect byval for aggregates
// See https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/Targets/PPC.cpp.
// The incoming parameter is represented as a pointer in the IR,
// the alignment is associated with the size of the register. (align 8 for 64bit)
if !is_ret && abi == AIX {
arg.pass_by_stack_offset(None);
arg.pass_by_stack_offset(Some(Align::from_bytes(8).unwrap()));
return;
}

View file

@ -1338,20 +1338,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let derive_better_type_error =
|alias_term: ty::AliasTerm<'tcx>, expected_term: ty::Term<'tcx>| {
let ocx = ObligationCtxt::new(self);
let normalized_term = match expected_term.unpack() {
ty::TermKind::Ty(_) => self.next_ty_var(DUMMY_SP).into(),
ty::TermKind::Const(_) => self.next_const_var(DUMMY_SP).into(),
};
ocx.register_obligation(Obligation::new(
self.tcx,
ObligationCause::dummy(),
let Ok(normalized_term) = ocx.structurally_normalize_term(
&ObligationCause::dummy(),
obligation.param_env,
ty::PredicateKind::NormalizesTo(ty::NormalizesTo {
alias: alias_term,
term: normalized_term,
}),
));
let _ = ocx.select_where_possible();
alias_term.to_term(self.tcx),
) else {
return None;
};
if let Err(terr) = ocx.eq(
&ObligationCause::dummy(),
obligation.param_env,

View file

@ -433,34 +433,19 @@ pub fn report_dyn_incompatibility<'tcx>(
hir::Node::Item(item) => Some(item.ident.span),
_ => None,
});
let mut err = struct_span_code_err!(
tcx.dcx(),
span,
E0038,
"the {} `{}` cannot be made into an object",
"the {} `{}` is not dyn compatible",
tcx.def_descr(trait_def_id),
trait_str
);
err.span_label(span, format!("`{trait_str}` cannot be made into an object"));
err.span_label(span, format!("`{trait_str}` is not dyn compatible"));
attempt_dyn_to_impl_suggestion(tcx, hir_id, &mut err);
if let Some(hir_id) = hir_id
&& let hir::Node::Ty(ty) = tcx.hir_node(hir_id)
&& let hir::TyKind::TraitObject([trait_ref, ..], ..) = ty.kind
{
let mut hir_id = hir_id;
while let hir::Node::Ty(ty) = tcx.parent_hir_node(hir_id) {
hir_id = ty.hir_id;
}
if tcx.parent_hir_node(hir_id).fn_sig().is_some() {
// Do not suggest `impl Trait` when dealing with things like super-traits.
err.span_suggestion_verbose(
ty.span.until(trait_ref.span),
"consider using an opaque type instead",
"impl ",
Applicability::MaybeIncorrect,
);
}
}
let mut reported_violations = FxIndexSet::default();
let mut multi_span = vec![];
let mut messages = vec![];
@ -475,7 +460,7 @@ pub fn report_dyn_incompatibility<'tcx>(
if reported_violations.insert(violation.clone()) {
let spans = violation.spans();
let msg = if trait_span.is_none() || spans.is_empty() {
format!("the trait cannot be made into an object because {}", violation.error_msg())
format!("the trait is not dyn compatible because {}", violation.error_msg())
} else {
format!("...because {}", violation.error_msg())
};
@ -492,7 +477,7 @@ pub fn report_dyn_incompatibility<'tcx>(
let has_multi_span = !multi_span.is_empty();
let mut note_span = MultiSpan::from_spans(multi_span.clone());
if let (Some(trait_span), true) = (trait_span, has_multi_span) {
note_span.push_span_label(trait_span, "this trait cannot be made into an object...");
note_span.push_span_label(trait_span, "this trait is not dyn compatible...");
}
for (span, msg) in iter::zip(multi_span, messages) {
note_span.push_span_label(span, msg);
@ -500,16 +485,12 @@ pub fn report_dyn_incompatibility<'tcx>(
// FIXME(dyn_compat_renaming): Update the URL.
err.span_note(
note_span,
"for a trait to be \"dyn-compatible\" it needs to allow building a vtable to allow the call \
to be resolvable dynamically; for more information visit \
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
"for a trait to be dyn compatible it needs to allow building a vtable\n\
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
);
// Only provide the help if its a local trait, otherwise it's not actionable.
if trait_span.is_some() {
let mut reported_violations: Vec<_> = reported_violations.into_iter().collect();
reported_violations.sort();
let mut potential_solutions: Vec<_> =
reported_violations.into_iter().map(|violation| violation.solution()).collect();
potential_solutions.sort();
@ -520,68 +501,116 @@ pub fn report_dyn_incompatibility<'tcx>(
}
}
let impls_of = tcx.trait_impls_of(trait_def_id);
let impls = if impls_of.blanket_impls().is_empty() {
impls_of
.non_blanket_impls()
.values()
.flatten()
.filter(|def_id| {
!matches!(tcx.type_of(*def_id).instantiate_identity().kind(), ty::Dynamic(..))
})
.collect::<Vec<_>>()
} else {
vec![]
};
let externally_visible = if !impls.is_empty()
&& let Some(def_id) = trait_def_id.as_local()
// We may be executing this during typeck, which would result in cycle
// if we used effective_visibilities query, which looks into opaque types
// (and therefore calls typeck).
&& tcx.resolutions(()).effective_visibilities.is_exported(def_id)
{
true
} else {
false
};
match &impls[..] {
[] => {}
_ if impls.len() > 9 => {}
[only] if externally_visible => {
err.help(with_no_trimmed_paths!(format!(
"only type `{}` is seen to implement the trait in this crate, consider using it \
directly instead",
tcx.type_of(*only).instantiate_identity(),
)));
}
[only] => {
err.help(with_no_trimmed_paths!(format!(
"only type `{}` implements the trait, consider using it directly instead",
tcx.type_of(*only).instantiate_identity(),
)));
}
impls => {
let types = impls
.iter()
.map(|t| {
with_no_trimmed_paths!(format!(" {}", tcx.type_of(*t).instantiate_identity(),))
})
.collect::<Vec<_>>();
err.help(format!(
"the following types implement the trait, consider defining an enum where each \
variant holds one of these types, implementing `{}` for this new enum and using \
it instead:\n{}",
trait_str,
types.join("\n"),
));
}
}
if externally_visible {
err.note(format!(
"`{trait_str}` can be implemented in other crates; if you want to support your users \
passing their own types here, you can't refer to a specific type",
));
}
attempt_dyn_to_enum_suggestion(tcx, trait_def_id, &*trait_str, &mut err);
err
}
/// Attempt to suggest converting the `dyn Trait` argument to an enumeration
/// over the types that implement `Trait`.
fn attempt_dyn_to_enum_suggestion(
tcx: TyCtxt<'_>,
trait_def_id: DefId,
trait_str: &str,
err: &mut Diag<'_>,
) {
let impls_of = tcx.trait_impls_of(trait_def_id);
if !impls_of.blanket_impls().is_empty() {
return;
}
let concrete_impls: Option<Vec<Ty<'_>>> = impls_of
.non_blanket_impls()
.values()
.flatten()
.map(|impl_id| {
// Don't suggest conversion to enum if the impl types have type parameters.
// It's unlikely the user wants to define a generic enum.
let Some(impl_type) = tcx.type_of(*impl_id).no_bound_vars() else { return None };
// Obviously unsized impl types won't be usable in an enum.
// Note: this doesn't use `Ty::is_trivially_sized` because that function
// defaults to assuming that things are *not* sized, whereas we want to
// fall back to assuming that things may be sized.
match impl_type.kind() {
ty::Str | ty::Slice(_) | ty::Dynamic(_, _, ty::DynKind::Dyn) => {
return None;
}
_ => {}
}
Some(impl_type)
})
.collect();
let Some(concrete_impls) = concrete_impls else { return };
const MAX_IMPLS_TO_SUGGEST_CONVERTING_TO_ENUM: usize = 9;
if concrete_impls.is_empty() || concrete_impls.len() > MAX_IMPLS_TO_SUGGEST_CONVERTING_TO_ENUM {
return;
}
let externally_visible = if let Some(def_id) = trait_def_id.as_local() {
// We may be executing this during typeck, which would result in cycle
// if we used effective_visibilities query, which looks into opaque types
// (and therefore calls typeck).
tcx.resolutions(()).effective_visibilities.is_exported(def_id)
} else {
false
};
if let [only_impl] = &concrete_impls[..] {
let within = if externally_visible { " within this crate" } else { "" };
err.help(with_no_trimmed_paths!(format!(
"only type `{only_impl}` implements `{trait_str}`{within}; \
consider using it directly instead."
)));
} else {
let types = concrete_impls
.iter()
.map(|t| with_no_trimmed_paths!(format!(" {}", t)))
.collect::<Vec<String>>()
.join("\n");
err.help(format!(
"the following types implement `{trait_str}`:\n\
{types}\n\
consider defining an enum where each variant holds one of these types,\n\
implementing `{trait_str}` for this new enum and using it instead",
));
}
if externally_visible {
err.note(format!(
"`{trait_str}` may be implemented in other crates; if you want to support your users \
passing their own types here, you can't refer to a specific type",
));
}
}
/// Attempt to suggest that a `dyn Trait` argument or return type be converted
/// to use `impl Trait`.
fn attempt_dyn_to_impl_suggestion(tcx: TyCtxt<'_>, hir_id: Option<hir::HirId>, err: &mut Diag<'_>) {
let Some(hir_id) = hir_id else { return };
let hir::Node::Ty(ty) = tcx.hir_node(hir_id) else { return };
let hir::TyKind::TraitObject([trait_ref, ..], ..) = ty.kind else { return };
// Only suggest converting `dyn` to `impl` if we're in a function signature.
// This ensures that we don't suggest converting e.g.
// `type Alias = Box<dyn DynIncompatibleTrait>;` to
// `type Alias = Box<impl DynIncompatibleTrait>;`
let Some((_id, first_non_type_parent_node)) =
tcx.hir().parent_iter(hir_id).find(|(_id, node)| !matches!(node, hir::Node::Ty(_)))
else {
return;
};
if first_non_type_parent_node.fn_sig().is_none() {
return;
}
err.span_suggestion_verbose(
ty.span.until(trait_ref.span),
"consider using an opaque type instead",
"impl ",
Applicability::MaybeIncorrect,
);
}

View file

@ -513,8 +513,27 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
_ => ChildMode::PassThrough,
};
let nested_goals = candidate.instantiate_nested_goals(self.span());
// If the candidate requires some `T: FnPtr` bound which does not hold should not be treated as
// an actual candidate, instead we should treat them as if the impl was never considered to
// have potentially applied. As if `impl<A, R> Trait for for<..> fn(..A) -> R` was written
// instead of `impl<T: FnPtr> Trait for T`.
//
// We do this as a separate loop so that we do not choose to tell the user about some nested
// goal before we encounter a `T: FnPtr` nested goal.
for nested_goal in &nested_goals {
if let Some(fn_ptr_trait) = tcx.lang_items().fn_ptr_trait()
&& let Some(poly_trait_pred) = nested_goal.goal().predicate.as_trait_clause()
&& poly_trait_pred.def_id() == fn_ptr_trait
&& let Err(NoSolution) = nested_goal.result()
{
return ControlFlow::Break(self.obligation.clone());
}
}
let mut impl_where_bound_count = 0;
for nested_goal in candidate.instantiate_nested_goals(self.span()) {
for nested_goal in nested_goals {
trace!(nested_goal = ?(nested_goal.goal(), nested_goal.source(), nested_goal.result()));
let make_obligation = |cause| Obligation {
@ -605,7 +624,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
}
}
#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
enum ChildMode<'tcx> {
// Try to derive an `ObligationCause::{ImplDerived,BuiltinDerived}`,
// and skip all `GoalSource::Misc`, which represent useless obligations

View file

@ -709,7 +709,7 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
if matches!(ty.kind(), ty::Alias(..)) {
let ocx = ObligationCtxt::new(infcx);
ty = ocx
.structurally_normalize(&ObligationCause::dummy(), param_env, ty)
.structurally_normalize_ty(&ObligationCause::dummy(), param_env, ty)
.map_err(|_| ())?;
if !ocx.select_where_possible().is_empty() {
return Err(());

View file

@ -53,7 +53,6 @@ fn dyn_compatibility_violations(
) -> &'_ [DynCompatibilityViolation] {
debug_assert!(tcx.generics_of(trait_def_id).has_self);
debug!("dyn_compatibility_violations: {:?}", trait_def_id);
tcx.arena.alloc_from_iter(
elaborate::supertrait_def_ids(tcx, trait_def_id)
.flat_map(|def_id| dyn_compatibility_violations_for_trait(tcx, def_id)),

View file

@ -319,7 +319,7 @@ where
self.infcx.at(cause, param_env).deeply_normalize(value, &mut **self.engine.borrow_mut())
}
pub fn structurally_normalize(
pub fn structurally_normalize_ty(
&self,
cause: &ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
@ -327,7 +327,7 @@ where
) -> Result<Ty<'tcx>, Vec<E>> {
self.infcx
.at(cause, param_env)
.structurally_normalize(value, &mut **self.engine.borrow_mut())
.structurally_normalize_ty(value, &mut **self.engine.borrow_mut())
}
pub fn structurally_normalize_const(
@ -340,4 +340,15 @@ where
.at(cause, param_env)
.structurally_normalize_const(value, &mut **self.engine.borrow_mut())
}
pub fn structurally_normalize_term(
&self,
cause: &ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
value: ty::Term<'tcx>,
) -> Result<ty::Term<'tcx>, Vec<E>> {
self.infcx
.at(cause, param_env)
.structurally_normalize_term(value, &mut **self.engine.borrow_mut())
}
}

View file

@ -7,44 +7,12 @@ use crate::traits::{NormalizeExt, Obligation};
#[extension(pub trait StructurallyNormalizeExt<'tcx>)]
impl<'tcx> At<'_, 'tcx> {
fn structurally_normalize<E: 'tcx>(
fn structurally_normalize_ty<E: 'tcx>(
&self,
ty: Ty<'tcx>,
fulfill_cx: &mut dyn TraitEngine<'tcx, E>,
) -> Result<Ty<'tcx>, Vec<E>> {
assert!(!ty.is_ty_var(), "should have resolved vars before calling");
if self.infcx.next_trait_solver() {
let ty::Alias(..) = *ty.kind() else {
return Ok(ty);
};
let new_infer_ty = self.infcx.next_ty_var(self.cause.span);
// We simply emit an `alias-eq` goal here, since that will take care of
// normalizing the LHS of the projection until it is a rigid projection
// (or a not-yet-defined opaque in scope).
let obligation = Obligation::new(
self.infcx.tcx,
self.cause.clone(),
self.param_env,
ty::PredicateKind::AliasRelate(
ty.into(),
new_infer_ty.into(),
ty::AliasRelationDirection::Equate,
),
);
fulfill_cx.register_predicate_obligation(self.infcx, obligation);
let errors = fulfill_cx.select_where_possible(self.infcx);
if !errors.is_empty() {
return Err(errors);
}
Ok(self.infcx.resolve_vars_if_possible(new_infer_ty))
} else {
Ok(self.normalize(ty).into_value_registering_obligations(self.infcx, fulfill_cx))
}
self.structurally_normalize_term(ty.into(), fulfill_cx).map(|term| term.expect_type())
}
fn structurally_normalize_const<E: 'tcx>(
@ -52,14 +20,29 @@ impl<'tcx> At<'_, 'tcx> {
ct: ty::Const<'tcx>,
fulfill_cx: &mut dyn TraitEngine<'tcx, E>,
) -> Result<ty::Const<'tcx>, Vec<E>> {
assert!(!ct.is_ct_infer(), "should have resolved vars before calling");
if self.infcx.tcx.features().generic_const_exprs() {
return Ok(super::evaluate_const(&self.infcx, ct, self.param_env));
}
self.structurally_normalize_term(ct.into(), fulfill_cx).map(|term| term.expect_const())
}
fn structurally_normalize_term<E: 'tcx>(
&self,
term: ty::Term<'tcx>,
fulfill_cx: &mut dyn TraitEngine<'tcx, E>,
) -> Result<ty::Term<'tcx>, Vec<E>> {
assert!(!term.is_infer(), "should have resolved vars before calling");
if self.infcx.next_trait_solver() {
let ty::ConstKind::Unevaluated(..) = ct.kind() else {
return Ok(ct);
};
if let None = term.to_alias_term() {
return Ok(term);
}
let new_infer_ct = self.infcx.next_const_var(self.cause.span);
let new_infer = match term.unpack() {
ty::TermKind::Ty(_) => self.infcx.next_ty_var(self.cause.span).into(),
ty::TermKind::Const(_) => self.infcx.next_const_var(self.cause.span).into(),
};
// We simply emit an `alias-eq` goal here, since that will take care of
// normalizing the LHS of the projection until it is a rigid projection
@ -68,11 +51,7 @@ impl<'tcx> At<'_, 'tcx> {
self.infcx.tcx,
self.cause.clone(),
self.param_env,
ty::PredicateKind::AliasRelate(
ct.into(),
new_infer_ct.into(),
ty::AliasRelationDirection::Equate,
),
ty::PredicateKind::AliasRelate(term, new_infer, ty::AliasRelationDirection::Equate),
);
fulfill_cx.register_predicate_obligation(self.infcx, obligation);
@ -81,11 +60,9 @@ impl<'tcx> At<'_, 'tcx> {
return Err(errors);
}
Ok(self.infcx.resolve_vars_if_possible(new_infer_ct))
} else if self.infcx.tcx.features().generic_const_exprs() {
Ok(super::evaluate_const(&self.infcx, ct, self.param_env))
Ok(self.infcx.resolve_vars_if_possible(new_infer))
} else {
Ok(self.normalize(ct).into_value_registering_obligations(self.infcx, fulfill_cx))
Ok(self.normalize(term).into_value_registering_obligations(self.infcx, fulfill_cx))
}
}
}

View file

@ -914,7 +914,6 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
let mut extern_crates = FxIndexSet::default();
if !t.is_dyn_compatible(cx.tcx()) {
// FIXME(dyn_compat_renaming): Update the URL once the Reference is updated.
write_section_heading(
w,
"Dyn Compatibility",
@ -922,7 +921,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
None,
format!(
"<div class=\"dyn-compatibility-info\"><p>This trait is <b>not</b> \
<a href=\"{base}/reference/items/traits.html#object-safety\">dyn compatible</a>.</p>\
<a href=\"{base}/reference/items/traits.html#dyn-compatibility\">dyn compatible</a>.</p>\
<p><i>In older versions of Rust, dyn compatibility was called \"object safety\", \
so this trait is not object safe.</i></p></div>",
base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL

View file

@ -17,7 +17,7 @@ use ignore::Walk;
const ENTRY_LIMIT: u32 = 901;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: u32 = 1663;
const ISSUES_ENTRY_LIMIT: u32 = 1664;
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files

View file

@ -10,4 +10,4 @@ name = "wasm-component-ld"
path = "src/main.rs"
[dependencies]
wasm-component-ld = "0.5.11"
wasm-component-ld = "0.5.12"

View file

@ -8,4 +8,4 @@ fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR trait `X` cannot be made into an object
//~| ERROR trait `X` is not dyn compatible

View file

@ -92,17 +92,18 @@ LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/invalid_const_in_lifetime_position.rs:4:20
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait

View file

@ -5,8 +5,8 @@ use std::ops::Index;
pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| the trait `SVec` cannot be made into an object
//~| `SVec` cannot be made into an object
//~| the trait `SVec` is not dyn compatible
//~| `SVec` is not dyn compatible
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
let _ = s;

View file

@ -294,19 +294,20 @@ help: add missing generic argument
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0038]: the trait `SVec` cannot be made into an object
error[E0038]: the trait `SVec` is not dyn compatible
--> $DIR/ice-generic-type-alias-105742.rs:5:35
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/ice-generic-type-alias-105742.rs:15:17
|
LL | pub trait SVec: Index<
| ____________----__^
| | |
| | this trait cannot be made into an object...
| | this trait is not dyn compatible...
LL | | <Self as SVec>::Item,
... |
LL | |/ Output = <Index<<Self as SVec>::Item,

View file

@ -26,7 +26,7 @@ pub trait Foo {
}
//@ has foo/trait.DynCompatible.html
//@ !has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' ''
//@ !has - '//div[@class="sidebar-elems"]//h3/a[@href="#dyn-compatibility"]' ''
pub trait DynCompatible {
fn access(&self);
}

View file

@ -5,9 +5,9 @@ trait Trait {
}
impl dyn Trait {
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
//~^ ERROR the trait `Trait` is not dyn compatible [E0038]
const fn n() -> usize { Self::N }
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
//~^ ERROR the trait `Trait` is not dyn compatible [E0038]
}
fn main() {}

View file

@ -1,29 +1,31 @@
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/associated-const-in-trait.rs:7:6
|
LL | impl dyn Trait {
| ^^^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-const-in-trait.rs:4:11
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/associated-const-in-trait.rs:9:29
|
LL | const fn n() -> usize { Self::N }
| ^^^^ `Trait` cannot be made into an object
| ^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-const-in-trait.rs:4:11
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait

View file

@ -3,6 +3,6 @@ trait Bar {
fn return_n(&self) -> [u8; Bar::X]; //~ ERROR: E0790
}
impl dyn Bar {} //~ ERROR: the trait `Bar` cannot be made into an object
impl dyn Bar {} //~ ERROR: the trait `Bar` is not dyn compatible
fn main() {}

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/issue-48027.rs:6:6
|
LL | impl dyn Bar {}
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-48027.rs:2:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait

View file

@ -1,5 +1,5 @@
error[E0271]: expected `{async closure@is-not-fn.rs:5:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:5:23: 5:25}`
--> $DIR/is-not-fn.rs:5:14
error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
--> $DIR/is-not-fn.rs:8:14
|
LL | needs_fn(async || {});
| -------- ^^^^^^^^^^^ expected `()`, found `async` closure body
@ -7,9 +7,9 @@ LL | needs_fn(async || {});
| required by a bound introduced by this call
|
= note: expected unit type `()`
found `async` closure body `{async closure body@$DIR/is-not-fn.rs:5:23: 5:25}`
found `async` closure body `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
note: required by a bound in `needs_fn`
--> $DIR/is-not-fn.rs:4:25
--> $DIR/is-not-fn.rs:7:25
|
LL | fn needs_fn(x: impl FnOnce()) {}
| ^^^^^^^^ required by this bound in `needs_fn`

View file

@ -0,0 +1,19 @@
error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
--> $DIR/is-not-fn.rs:8:14
|
LL | needs_fn(async || {});
| -------- ^^^^^^^^^^^ expected `()`, found `async` closure body
| |
| required by a bound introduced by this call
|
= note: expected unit type `()`
found `async` closure body `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}`
note: required by a bound in `needs_fn`
--> $DIR/is-not-fn.rs:7:25
|
LL | fn needs_fn(x: impl FnOnce()) {}
| ^^^^^^^^ required by this bound in `needs_fn`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.

View file

@ -1,7 +1,10 @@
//@ edition:2021
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
fn main() {
fn needs_fn(x: impl FnOnce()) {}
needs_fn(async || {});
//~^ ERROR expected `{async closure@is-not-fn.rs:5:14}` to be a closure that returns `()`
//~^ ERROR expected `{async closure@is-not-fn.rs:8:14}` to be a closure that returns `()`
}

View file

@ -1,6 +1,6 @@
//@ edition:2018
fn foo(x: &dyn AsyncFn()) {}
//~^ ERROR the trait `AsyncFnMut` cannot be made into an object
//~^ ERROR the trait `AsyncFnMut` is not dyn compatible
fn main() {}

View file

@ -1,17 +1,14 @@
error[E0038]: the trait `AsyncFnMut` cannot be made into an object
error[E0038]: the trait `AsyncFnMut` is not dyn compatible
--> $DIR/dyn-pos.rs:3:16
|
LL | fn foo(x: &dyn AsyncFn()) {}
| ^^^^^^^^^ `AsyncFnMut` cannot be made into an object
| ^^^^^^^^^ `AsyncFnMut` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $SRC_DIR/core/src/ops/async_function.rs:LL:COL
|
= note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture`
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead:
&F
&mut F
std::boxed::Box<F, A>
= note: the trait is not dyn compatible because it contains the generic associated type `CallRefFuture`
error: aborting due to 1 previous error

View file

@ -7,5 +7,5 @@ trait Foo {
fn main() {
let x: &dyn Foo = todo!();
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
}

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility.rs:9:12
|
LL | let x: &dyn Foo = todo!();
| ^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility.rs:5:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn foo(&self);
| ^^^ ...because method `foo` is `async`
= help: consider moving `foo` to another trait

View file

@ -3,7 +3,7 @@
trait Foo {
async fn foo(self: &dyn Foo) {
//~^ ERROR: `Foo` cannot be made into an object
//~^ ERROR: `Foo` is not dyn compatible
//~| ERROR invalid `self` parameter type: `&dyn Foo`
todo!()
}

View file

@ -7,17 +7,18 @@ LL | async fn foo(self: &dyn Foo) {
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/inference_var_self_argument.rs:5:5
|
LL | async fn foo(self: &dyn Foo) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/inference_var_self_argument.rs:5:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn foo(self: &dyn Foo) {
| ^^^ ...because method `foo` is `async`
= help: consider moving `foo` to another trait

View file

@ -1,16 +1,17 @@
error[E0038]: the trait `DynIncompatible` cannot be made into an object
error[E0038]: the trait `DynIncompatible` is not dyn compatible
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:26
|
LL | impl DynIncompatible for dyn DynIncompatible { }
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:6:45
|
LL | trait DynIncompatible { fn eq(&self, other: Self); }
| --------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
= help: consider moving `eq` to another trait
error[E0046]: not all trait items implemented, missing: `eq`

View file

@ -1,28 +1,30 @@
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
error[E0038]: the trait `ConstParamTy_` is not dyn compatible
--> $DIR/const_param_ty_dyn_compatibility.rs:6:16
|
LL | fn foo(a: &dyn ConstParamTy_) {}
| ^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
| ^^^^^^^^^^^^^ `ConstParamTy_` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn foo(a: &impl ConstParamTy_) {}
| ~~~~
error[E0038]: the trait `UnsizedConstParamTy` cannot be made into an object
error[E0038]: the trait `UnsizedConstParamTy` is not dyn compatible
--> $DIR/const_param_ty_dyn_compatibility.rs:9:16
|
LL | fn bar(a: &dyn UnsizedConstParamTy) {}
| ^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^ `UnsizedConstParamTy` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn bar(a: &impl UnsizedConstParamTy) {}

View file

@ -14,8 +14,8 @@ impl Foo for () {
}
}
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` cannot be made into an object
v.test(); //~ERROR the trait `Foo` cannot be made into an object
fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` is not dyn compatible
v.test(); //~ERROR the trait `Foo` is not dyn compatible
}
fn main() {}

View file

@ -1,38 +1,40 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-ret.rs:17:16
|
LL | fn use_dyn(v: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-ret.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
| |
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-ret.rs:18:5
|
LL | v.test();
| ^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-ret.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
| |
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error: aborting due to 2 previous errors

View file

@ -13,9 +13,9 @@ impl Foo for () {
}
fn use_dyn(v: &dyn Foo) {
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
v.test();
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
}
fn main() {}

View file

@ -1,34 +1,36 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-where-bounds.rs:15:16
|
LL | fn use_dyn(v: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/dyn-compatibility-err-where-bounds.rs:17:5
|
LL | v.test();
| ^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/dyn-compatibility-err-where-bounds.rs:8:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead
= help: only type `()` implements `Foo`; consider using it directly instead.
error: aborting due to 2 previous errors

View file

@ -13,7 +13,7 @@ const _: () = {
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
//~| ERROR `X` cannot be made into an object
//~| ERROR `X` is not dyn compatible
};
fn main() {}

View file

@ -92,17 +92,18 @@ LL | type Y<'a>;
| ^
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/issue-102768.rs:9:24
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-102768.rs:5:10
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait

View file

@ -2,6 +2,6 @@
fn main() {
let _: &Copy + 'static; //~ ERROR expected a path
//~^ ERROR cannot be made into an object
//~^ ERROR is not dyn compatible
let _: &'static Copy + 'static; //~ ERROR expected a path
}

View file

@ -20,14 +20,15 @@ help: try adding parentheses
LL | let _: &'static (Copy + 'static);
| + +
error[E0038]: the trait `Copy` cannot be made into an object
error[E0038]: the trait `Copy` is not dyn compatible
--> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12
|
LL | let _: &Copy + 'static;
| ^^^^^ `Copy` cannot be made into an object
| ^^^^^ `Copy` is not dyn compatible
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
= note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
= note: the trait is not dyn compatible because it requires `Self: Sized`
= note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
error: aborting due to 3 previous errors

View file

@ -5,8 +5,8 @@ use std::marker::PhantomData;
fn transmute<T, U>(t: T) -> U {
(&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
//~^ ERROR the trait `Foo` cannot be made into an object
//~| ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
}
struct ActuallySuper;
@ -19,7 +19,7 @@ trait Dyn {
type Out;
}
impl<T, U> Dyn for dyn Foo<T, U> + '_ {
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
type Out = U;
}
impl<S: Dyn<Out = U> + ?Sized, U> Super<NotActuallySuper> for S {

View file

@ -1,53 +1,53 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:21:20
|
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {
| ^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait
= help: only type `std::marker::PhantomData<T>` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:7:27
|
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
| ^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait
= help: only type `std::marker::PhantomData<T>` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:7:6
|
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
| ^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
...
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait
= help: only type `std::marker::PhantomData<T>` implements the trait, consider using it directly instead
= note: required for the cast from `&PhantomData<T>` to `&dyn Foo<T, U>`
error: aborting due to 3 previous errors

View file

@ -1,29 +1,31 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/associated-consts.rs:12:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/associated-consts.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/associated-consts.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait

View file

@ -26,14 +26,15 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | fn id<F>(f: dyn Copy) -> usize {
| +++
error[E0038]: the trait `Copy` cannot be made into an object
error[E0038]: the trait `Copy` is not dyn compatible
--> $DIR/avoid-ice-on-warning-2.rs:4:13
|
LL | fn id<F>(f: Copy) -> usize {
| ^^^^ `Copy` cannot be made into an object
| ^^^^ `Copy` is not dyn compatible
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
= note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
= note: the trait is not dyn compatible because it requires `Self: Sized`
= note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
error[E0618]: expected function, found `(dyn Copy + 'static)`
--> $DIR/avoid-ice-on-warning-2.rs:12:5

View file

@ -3,7 +3,7 @@
//@[new] edition:2021
fn id<F>(f: Copy) -> usize {
//[new]~^ ERROR expected a type, found a trait
//[old]~^^ ERROR the trait `Copy` cannot be made into an object
//[old]~^^ ERROR the trait `Copy` is not dyn compatible
//[old]~| ERROR the size for values of type `(dyn Copy + 'static)`
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!

View file

@ -65,19 +65,20 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | trait B { fn f(a: dyn A) -> A; }
| +++
error[E0038]: the trait `A` cannot be made into an object
error[E0038]: the trait `A` is not dyn compatible
--> $DIR/avoid-ice-on-warning-3.rs:4:19
|
LL | trait B { fn f(a: A) -> A; }
| ^ `A` cannot be made into an object
| ^ `A` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/avoid-ice-on-warning-3.rs:14:14
|
LL | trait A { fn g(b: B) -> B; }
| - ^ ...because associated function `g` has no `self` parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
help: consider turning `g` into a method by giving it a `&self` argument
|
LL | trait A { fn g(&self, b: B) -> B; }
@ -101,19 +102,20 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | trait A { fn g(b: dyn B) -> B; }
| +++
error[E0038]: the trait `B` cannot be made into an object
error[E0038]: the trait `B` is not dyn compatible
--> $DIR/avoid-ice-on-warning-3.rs:14:19
|
LL | trait A { fn g(b: B) -> B; }
| ^ `B` cannot be made into an object
| ^ `B` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/avoid-ice-on-warning-3.rs:4:14
|
LL | trait B { fn f(a: A) -> A; }
| - ^ ...because associated function `f` has no `self` parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
help: consider turning `f` into a method by giving it a `&self` argument
|
LL | trait B { fn f(&self, a: A) -> A; }

View file

@ -4,7 +4,7 @@
trait B { fn f(a: A) -> A; }
//[new]~^ ERROR expected a type, found a trait
//[new]~| ERROR expected a type, found a trait
//[old]~^^^ ERROR the trait `A` cannot be made into an object
//[old]~^^^ ERROR the trait `A` is not dyn compatible
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
@ -14,7 +14,7 @@ trait B { fn f(a: A) -> A; }
trait A { fn g(b: B) -> B; }
//[new]~^ ERROR expected a type, found a trait
//[new]~| ERROR expected a type, found a trait
//[old]~^^^ ERROR the trait `B` cannot be made into an object
//[old]~^^^ ERROR the trait `B` is not dyn compatible
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated
//[old]~| WARN trait objects without an explicit `dyn` are deprecated

View file

@ -5,7 +5,7 @@
#![deny(bare_trait_objects)]
fn ord_prefer_dot(s: String) -> impl Ord {
//[new]~^ ERROR expected a type, found a trait
//[old]~^^ ERROR the trait `Ord` cannot be made into an object
//[old]~^^ ERROR the trait `Ord` is not dyn compatible
//[old]~| ERROR trait objects without an explicit `dyn` are deprecated
//[old]~| WARNING this is accepted in the current edition (Rust 2015)
(s.starts_with("."), s)

View file

@ -16,19 +16,20 @@ help: if this is a dyn-compatible trait, use `dyn`
LL | fn ord_prefer_dot(s: String) -> dyn Ord {
| +++
error[E0038]: the trait `Ord` cannot be made into an object
error[E0038]: the trait `Ord` is not dyn compatible
--> $DIR/bare-trait-dont-suggest-dyn.rs:6:33
|
LL | fn ord_prefer_dot(s: String) -> Ord {
| ^^^ `Ord` cannot be made into an object
| ^^^ `Ord` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
::: $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
= note: the trait is not dyn compatible because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn ord_prefer_dot(s: String) -> impl Ord {

View file

@ -5,7 +5,7 @@
#![deny(bare_trait_objects)]
fn ord_prefer_dot(s: String) -> Ord {
//[new]~^ ERROR expected a type, found a trait
//[old]~^^ ERROR the trait `Ord` cannot be made into an object
//[old]~^^ ERROR the trait `Ord` is not dyn compatible
//[old]~| ERROR trait objects without an explicit `dyn` are deprecated
//[old]~| WARNING this is accepted in the current edition (Rust 2015)
(s.starts_with("."), s)

View file

@ -5,7 +5,7 @@ trait X {
}
fn f() -> Box<dyn X<U = u32>> {
//~^ ERROR the trait `X` cannot be made into an object
//~^ ERROR the trait `X` is not dyn compatible
loop {}
}

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `X` cannot be made into an object
error[E0038]: the trait `X` is not dyn compatible
--> $DIR/bounds.rs:7:15
|
LL | fn f() -> Box<dyn X<U = u32>> {
| ^^^^^^^^^^^^^^ `X` cannot be made into an object
| ^^^^^^^^^^^^^^ `X` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/bounds.rs:4:13
|
LL | trait X {
| - this trait cannot be made into an object...
| - this trait is not dyn compatible...
LL | type U: PartialEq<Self>;
| ^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter

View file

@ -0,0 +1,18 @@
// Test that the dyn-compatibility diagnostics for GATs refer first to the
// user-named trait, not the GAT-containing supertrait.
//
// NOTE: this test is currently broken, and first reports:
// "the trait `Super` is not dyn compatible"
//
//@ edition:2018
trait Super {
type Assoc<'a>;
}
trait Child: Super {}
fn take_dyn(_: &dyn Child) {}
//~^ ERROR the trait `Super` is not dyn compatible
fn main() {}

View file

@ -0,0 +1,19 @@
error[E0038]: the trait `Super` is not dyn compatible
--> $DIR/gat-incompatible-supertrait.rs:15:21
|
LL | fn take_dyn(_: &dyn Child) {}
| ^^^^^ `Super` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-incompatible-supertrait.rs:10:10
|
LL | trait Super {
| ----- this trait is not dyn compatible...
LL | type Assoc<'a>;
| ^^^^^ ...because it contains the generic associated type `Assoc`
= help: consider moving `Assoc` to another trait
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.

View file

@ -1,75 +1,80 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:18:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:25:40
|
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:20:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:27:10
|
LL | t as &dyn Bar
| ^^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:27:5
|
LL | t as &dyn Bar
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait

View file

@ -1,30 +1,32 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:20:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/generics.rs:27:5
|
LL | t as &dyn Bar
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait

View file

@ -1,36 +1,38 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:15
|
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
LL | fn foo<T>(&self, val: T);
| ^^^ ...because method `foo` has generic type parameters
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
= help: only type `Thing` implements the trait, consider using it directly instead
= help: only type `Thing` implements `Bar`; consider using it directly instead.
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:30
|
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
LL | fn foo<T>(&self, val: T);
| ^^^ ...because method `foo` has generic type parameters
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
= help: only type `Thing` implements the trait, consider using it directly instead
= help: only type `Thing` implements `Bar`; consider using it directly instead.
= note: required for the cast from `&mut Thing` to `&mut dyn Bar`
error: aborting due to 2 previous errors

View file

@ -36,9 +36,9 @@ impl <'x> Expr for SExpr<'x> {
fn main() {
let a: Box<dyn Expr> = Box::new(SExpr::new());
//~^ ERROR: `Expr` cannot be made into an object
//~^ ERROR: `Expr` is not dyn compatible
let b: Box<dyn Expr> = Box::new(SExpr::new());
//~^ ERROR: `Expr` cannot be made into an object
//~^ ERROR: `Expr` is not dyn compatible
// assert_eq!(a , b);
}

View file

@ -1,47 +1,47 @@
error[E0038]: the trait `Expr` cannot be made into an object
error[E0038]: the trait `Expr` is not dyn compatible
--> $DIR/mentions-Self-in-super-predicates.rs:12:27
|
LL | elements: Vec<Box<dyn Expr + 'x>>,
| ^^^^ `Expr` cannot be made into an object
| ^^^^ `Expr` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
| this trait is not dyn compatible...
error[E0038]: the trait `Expr` cannot be made into an object
error[E0038]: the trait `Expr` is not dyn compatible
--> $DIR/mentions-Self-in-super-predicates.rs:38:20
|
LL | let a: Box<dyn Expr> = Box::new(SExpr::new());
| ^^^^ `Expr` cannot be made into an object
| ^^^^ `Expr` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
| this trait is not dyn compatible...
error[E0038]: the trait `Expr` cannot be made into an object
error[E0038]: the trait `Expr` is not dyn compatible
--> $DIR/mentions-Self-in-super-predicates.rs:40:20
|
LL | let b: Box<dyn Expr> = Box::new(SExpr::new());
| ^^^^ `Expr` cannot be made into an object
| ^^^^ `Expr` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self-in-super-predicates.rs:5:21
|
LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead
| this trait is not dyn compatible...
error: aborting due to 3 previous errors

View file

@ -1,60 +1,64 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mentions-Self.rs:22:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/mentions-Self.rs:28:31
|
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^^^^^ `Baz` cannot be made into an object
| ^^^^^^^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mentions-Self.rs:24:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/mentions-Self.rs:30:5
|
LL | t
| ^ `Baz` cannot be made into an object
| ^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait

View file

@ -1,30 +1,32 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/mentions-Self.rs:24:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
= note: required for the cast from `&T` to `&dyn Bar`
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/mentions-Self.rs:30:5
|
LL | t
| ^ `Baz` cannot be made into an object
| ^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait

View file

@ -2,6 +2,6 @@ trait Foo {
type Bar<T>;
}
fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` cannot be made into an object
fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` is not dyn compatible
fn main() {}

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/missing-assoc-type.rs:5:16
|
LL | fn bar(x: &dyn Foo) {}
| ^^^ `Foo` cannot be made into an object
| ^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/missing-assoc-type.rs:2:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | type Bar<T>;
| ^^^ ...because it contains the generic associated type `Bar`
= help: consider moving `Bar` to another trait

View file

@ -1,17 +1,18 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:12:22
|
LL | fn diverges() -> Box<dyn Foo> {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) {}
@ -21,20 +22,21 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
LL | fn foo() where Self: Sized {}
| +++++++++++++++++
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:22:12
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) {}
@ -44,20 +46,21 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
LL | fn foo() where Self: Sized {}
| +++++++++++++++++
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:22:27
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
help: consider turning `foo` into a method by giving it a `&self` argument
|

View file

@ -1,17 +1,18 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/no-static.rs:22:27
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
| ^^^^^^^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/no-static.rs:9:8
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= help: only type `Bar` implements `Foo`; consider using it directly instead.
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
help: consider turning `foo` into a method by giving it a `&self` argument
|

View file

@ -1,28 +1,30 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized-2.rs:14:31
|
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized-2.rs:9:18
|
LL | trait Bar
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | where Self : Sized
| ^^^^^ ...because it requires `Self: Sized`
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized-2.rs:16:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized-2.rs:9:18
|
LL | trait Bar
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | where Self : Sized
| ^^^^^ ...because it requires `Self: Sized`
= note: required for the cast from `&T` to `&dyn Bar`

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized-2.rs:16:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized-2.rs:9:18
|
LL | trait Bar
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | where Self : Sized
| ^^^^^ ...because it requires `Self: Sized`
= note: required for the cast from `&T` to `&dyn Bar`

View file

@ -1,30 +1,32 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized.rs:12:32
|
LL | fn make_bar<T: Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^ `Bar` cannot be made into an object
| ^^^^^^^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized.rs:8:12
|
LL | trait Bar: Sized {
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized.rs:8:12
|
LL | trait Bar: Sized {
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
= note: required for the cast from `&T` to `&dyn Bar`
error: aborting due to 2 previous errors

View file

@ -1,16 +1,17 @@
error[E0038]: the trait `Bar` cannot be made into an object
error[E0038]: the trait `Bar` is not dyn compatible
--> $DIR/sized.rs:14:5
|
LL | t
| ^ `Bar` cannot be made into an object
| ^ `Bar` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/sized.rs:8:12
|
LL | trait Bar: Sized {
| --- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
= note: required for the cast from `&T` to `&dyn Bar`
error: aborting due to 1 previous error

View file

@ -9,7 +9,7 @@ trait GatTrait {
trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> {
fn c(&self) -> dyn SuperTrait<T>;
//~^ ERROR associated item referring to unboxed trait object for its own trait
//~| ERROR the trait `SuperTrait` cannot be made into an object
//~| ERROR the trait `SuperTrait` is not dyn compatible
}
fn main() {}

View file

@ -20,20 +20,21 @@ help: you might have meant to use `Self` to refer to the implementing type
LL | fn c(&self) -> Self;
| ~~~~
error[E0038]: the trait `SuperTrait` cannot be made into an object
error[E0038]: the trait `SuperTrait` is not dyn compatible
--> $DIR/supertrait-mentions-GAT.rs:10:20
|
LL | fn c(&self) -> dyn SuperTrait<T>;
| ^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
| ^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/supertrait-mentions-GAT.rs:4:10
|
LL | type Gat<'a>
| ^^^ ...because it contains the generic associated type `Gat`
...
LL | trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> {
| ---------- this trait cannot be made into an object...
| ---------- this trait is not dyn compatible...
= help: consider moving `Gat` to another trait
error: aborting due to 3 previous errors

View file

@ -18,19 +18,20 @@ help: consider relaxing the implicit `Sized` restriction
LL | trait Bar<T: ?Sized> {
| ++++++++
error[E0038]: the trait `Baz` cannot be made into an object
error[E0038]: the trait `Baz` is not dyn compatible
--> $DIR/supertrait-mentions-Self.rs:16:35
|
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^ `Baz` cannot be made into an object
| ^^^ `Baz` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/supertrait-mentions-Self.rs:8:13
|
LL | trait Baz : Bar<Self> {
| --- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
| this trait is not dyn compatible...
help: consider using an opaque type instead
|
LL | fn make_baz<T:Baz>(t: &T) -> &impl Baz {

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:15
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^^^^^^^^^ `Qux` cannot be made into an object
| ^^^^^^^^^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
help: consider turning `bar` into a method by giving it a `&self` argument
@ -20,17 +21,18 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
LL | fn bar() where Self: Sized;
| +++++++++++++++++
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:33
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^ `Qux` cannot be made into an object
| ^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
= note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)`
@ -43,17 +45,18 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
LL | fn bar() where Self: Sized;
| +++++++++++++++++
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:15
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^^^^^^^^^ `Qux` cannot be made into an object
| ^^^^^^^^^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

View file

@ -1,14 +1,15 @@
error[E0038]: the trait `Qux` cannot be made into an object
error[E0038]: the trait `Qux` is not dyn compatible
--> $DIR/taint-const-eval.rs:11:33
|
LL | static FOO: &(dyn Qux + Sync) = "desc";
| ^^^^^^ `Qux` cannot be made into an object
| ^^^^^^ `Qux` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/taint-const-eval.rs:8:8
|
LL | trait Qux {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | fn bar();
| ^^^ ...because associated function `bar` has no `self` parameter
= note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)`

View file

@ -9,8 +9,8 @@ trait Qux {
}
static FOO: &(dyn Qux + Sync) = "desc";
//~^ the trait `Qux` cannot be made into an object
//[curr]~| the trait `Qux` cannot be made into an object
//[curr]~| the trait `Qux` cannot be made into an object
//~^ the trait `Qux` is not dyn compatible
//[curr]~| the trait `Qux` is not dyn compatible
//[curr]~| the trait `Qux` is not dyn compatible
fn main() {}

View file

@ -17,13 +17,13 @@ pub trait Fetcher: Send + Sync {
}
fn fetcher() -> Box<dyn Fetcher> {
//~^ ERROR the trait `Fetcher` cannot be made into an object
//~^ ERROR the trait `Fetcher` is not dyn compatible
todo!()
}
pub fn foo() {
let fetcher = fetcher();
//~^ ERROR the trait `Fetcher` cannot be made into an object
//~^ ERROR the trait `Fetcher` is not dyn compatible
let _ = fetcher.get();
//~^ ERROR the trait `Fetcher` cannot be made into an object
//~^ ERROR the trait `Fetcher` is not dyn compatible
}

View file

@ -1,51 +1,54 @@
error[E0038]: the trait `Fetcher` cannot be made into an object
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:19:21
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | fn fetcher() -> Box<dyn Fetcher> {
| ^^^^^^^^^^^ `Fetcher` cannot be made into an object
| ^^^^^^^^^^^ `Fetcher` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
error[E0038]: the trait `Fetcher` cannot be made into an object
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:25:19
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | let fetcher = fetcher();
| ^^^^^^^^^ `Fetcher` cannot be made into an object
| ^^^^^^^^^ `Fetcher` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on
error[E0038]: the trait `Fetcher` cannot be made into an object
error[E0038]: the trait `Fetcher` is not dyn compatible
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:27:13
|
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self`
...
LL | let _ = fetcher.get();
| ^^^^^^^^^^^^^ `Fetcher` cannot be made into an object
| ^^^^^^^^^^^^^ `Fetcher` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22
|
LL | pub trait Fetcher: Send + Sync {
| ------- this trait cannot be made into an object...
| ------- this trait is not dyn compatible...
LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
| ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on

View file

@ -1,29 +1,31 @@
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/E0038.rs:5:20
|
LL | fn call_foo(x: Box<dyn Trait>) {
| ^^^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait
error[E0038]: the trait `Trait` cannot be made into an object
error[E0038]: the trait `Trait` is not dyn compatible
--> $DIR/E0038.rs:7:13
|
LL | let y = x.foo();
| ^^^^^^^ `Trait` cannot be made into an object
| ^^^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
| ----- this trait is not dyn compatible...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait

View file

@ -5,10 +5,10 @@ trait Foo {
}
async fn takes_dyn_trait(x: &dyn Foo) {
//~^ ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
x.bar().await;
//~^ ERROR the trait `Foo` cannot be made into an object
//~| ERROR the trait `Foo` cannot be made into an object
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
}
fn main() {}

View file

@ -1,44 +1,47 @@
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:7:30
|
LL | async fn takes_dyn_trait(x: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:7
|
LL | x.bar().await;
| ^^^ `Foo` cannot be made into an object
| ^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait
error[E0038]: the trait `Foo` cannot be made into an object
error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:5
|
LL | x.bar().await;
| ^^^^^^^ `Foo` cannot be made into an object
| ^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14
|
LL | trait Foo {
| --- this trait cannot be made into an object...
| --- this trait is not dyn compatible...
LL | async fn bar(&self);
| ^^^ ...because method `bar` is `async`
= help: consider moving `bar` to another trait

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