diff --git a/Cargo.lock b/Cargo.lock index 2e781fcc66524..f03b033db6fe0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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]] diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index a76ca6772e52e..f31e2c65c792a 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -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, )), diff --git a/compiler/rustc_ast_lowering/src/index.rs b/compiler/rustc_ast_lowering/src/index.rs index 29d4fb9ef2597..9cfdbc47495b1 100644 --- a/compiler/rustc_ast_lowering/src/index.rs +++ b/compiler/rustc_ast_lowering/src/index.rs @@ -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 }; diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 61d7da429f8e8..74870d741504c 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -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: &[], diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index abd314ae74c39..3c78ed0497d79 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -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 }) } } diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 3903c45fda529..bffd9f383343d 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -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(), diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index c44d1a5e5c220..94f21ac5f5742 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -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" diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 9349ae212d21b..009d15a932f7a 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -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); } } diff --git a/compiler/rustc_error_codes/src/error_codes/E0038.md b/compiler/rustc_error_codes/src/error_codes/E0038.md index 014d8c4f761ca..4b06395897a87 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0038.md +++ b/compiler/rustc_error_codes/src/error_codes/E0038.md @@ -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: diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 944665c9ee5b5..081638715dffa 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -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`")), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index f7b7a9de1bfad..1a216ebf117c6 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -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. /// diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs index d8e9227a87c86..b3eade8c8ae47 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -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, diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index 951e8f1da4cf9..4e5f0a3186a9a 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -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() { diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 7d651155781a1..d17ee86ba667c 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -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), diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 6945dbc321697..3c25f4a8b7cc2 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -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) } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index be6d9570e35b4..e26c09e3601cb 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -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) => { diff --git a/compiler/rustc_infer/src/infer/context.rs b/compiler/rustc_infer/src/infer/context.rs index 5fc9b679c8acf..69ab0e69e2147 100644 --- a/compiler/rustc_infer/src/infer/context.rs +++ b/compiler/rustc_infer/src/infer/context.rs @@ -114,7 +114,7 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> { ) } - fn enter_forall> + Copy, U>( + fn enter_forall>, U>( &self, value: ty::Binder<'tcx, T>, f: impl FnOnce(T) -> U, diff --git a/compiler/rustc_infer/src/infer/relate/higher_ranked.rs b/compiler/rustc_infer/src/infer/relate/higher_ranked.rs index 7908733e7348e..061f7e6c22a43 100644 --- a/compiler/rustc_infer/src/infer/relate/higher_ranked.rs +++ b/compiler/rustc_infer/src/infer/relate/higher_ranked.rs @@ -24,9 +24,9 @@ impl<'tcx> InferCtxt<'tcx> { #[instrument(level = "debug", skip(self), ret)] pub fn enter_forall_and_leak_universe(&self, binder: ty::Binder<'tcx, T>) -> T where - T: TypeFoldable> + Copy, + T: TypeFoldable>, { - 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(&self, forall: ty::Binder<'tcx, T>, f: impl FnOnce(T) -> U) -> U where - T: TypeFoldable> + Copy, + T: TypeFoldable>, { // 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 diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index dd72ea2497f7c..35186778671bc 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -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 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 -}; - -inline LLVMRustDIFlags operator&(LLVMRustDIFlags A, LLVMRustDIFlags B) { - return static_cast(static_cast(A) & - static_cast(B)); -} - -inline LLVMRustDIFlags operator|(LLVMRustDIFlags A, LLVMRustDIFlags B) { - return static_cast(static_cast(A) | - static_cast(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(static_cast(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; - } - - 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; +// 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; + +// 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 + +// 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"); + } + + // 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(Flags); } // These values **must** match debuginfo::DISPFlags! They also *happen* diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index 37678bfd8805f..8d1194ee53980 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -277,23 +277,7 @@ where param_env: I::ParamEnv, ty: I::Ty, ) -> Result { - 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 { - 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 { + 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) } } diff --git a/compiler/rustc_target/src/callconv/powerpc64.rs b/compiler/rustc_target/src/callconv/powerpc64.rs index 3a71592cbe090..92c1f6e7148f3 100644 --- a/compiler/rustc_target/src/callconv/powerpc64.rs +++ b/compiler/rustc_target/src/callconv/powerpc64.rs @@ -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; } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index c40ba33084569..bcd3b0109b709 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -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, diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index 592aee24ccc99..f2bcc51e687b6 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -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")); - - 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, - ); - } - } + err.span_label(span, format!("`{trait_str}` is not dyn compatible")); + + attempt_dyn_to_impl_suggestion(tcx, hir_id, &mut err); + 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 \ - ", + "for a trait to be dyn compatible it needs to allow building a vtable\n\ + for more information, visit ", ); // 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>( } } + 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); - 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::>() - } else { - vec![] - }; - let externally_visible = if !impls.is_empty() - && let Some(def_id) = trait_def_id.as_local() + + if !impls_of.blanket_impls().is_empty() { + return; + } + + let concrete_impls: Option>> = 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) - { - true + tcx.resolutions(()).effective_visibilities.is_exported(def_id) } 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::>(); - 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 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::>() + .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}` can be implemented in other crates; if you want to support your users \ + "`{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", )); } +} - err +/// 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, 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;` to + // `type Alias = Box;` + 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, + ); } diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 4498beff4ea34..2b7da4bc5ff07 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -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 Trait for for<..> fn(..A) -> R` was written + // instead of `impl 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 diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index e27143f139641..50d47d20e1a4e 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -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(()); diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index 248ab847f2051..66491d9abe1a7 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -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)), diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 5e270b62b0081..4a3983fca31ce 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -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, Vec> { 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, Vec> { + self.infcx + .at(cause, param_env) + .structurally_normalize_term(value, &mut **self.engine.borrow_mut()) + } } diff --git a/compiler/rustc_trait_selection/src/traits/structural_normalize.rs b/compiler/rustc_trait_selection/src/traits/structural_normalize.rs index f8e8f2176c182..e6d5d336b8d55 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_normalize.rs @@ -7,44 +7,12 @@ use crate::traits::{NormalizeExt, Obligation}; #[extension(pub trait StructurallyNormalizeExt<'tcx>)] impl<'tcx> At<'_, 'tcx> { - fn structurally_normalize( + fn structurally_normalize_ty( &self, ty: Ty<'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx, E>, ) -> Result, Vec> { - 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( @@ -52,14 +20,29 @@ impl<'tcx> At<'_, 'tcx> { ct: ty::Const<'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx, E>, ) -> Result, Vec> { - 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( + &self, + term: ty::Term<'tcx>, + fulfill_cx: &mut dyn TraitEngine<'tcx, E>, + ) -> Result, Vec> { + 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)) } } } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 76a51cc64a88b..01e40f823d953 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -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!( "

This trait is not \ - dyn compatible.

\ + dyn compatible.

\

In older versions of Rust, dyn compatibility was called \"object safety\", \ so this trait is not object safe.

", base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 908cf9f324fbc..63ac447a772ea 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -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 diff --git a/src/tools/wasm-component-ld/Cargo.toml b/src/tools/wasm-component-ld/Cargo.toml index 965e9b01a4466..f8ae91f9e6f1b 100644 --- a/src/tools/wasm-component-ld/Cargo.toml +++ b/src/tools/wasm-component-ld/Cargo.toml @@ -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" diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs index 07fc239a8f86b..427c84679ba1c 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs @@ -8,4 +8,4 @@ fn f<'a>(arg : Box = &'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 diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr index 0c3826c566558..180ba63927b2b 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr @@ -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 = &'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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs index 027574923c7ad..89b55beaea185 100644 --- a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs +++ b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs @@ -5,8 +5,8 @@ use std::ops::Index; pub fn next<'a, T>(s: &'a mut dyn SVec) { //~^ 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; diff --git a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr index 97bd44244f32a..72d1a52f710ba 100644 --- a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr +++ b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr @@ -294,19 +294,20 @@ help: add missing generic argument LL | Output = ::Item> as SVec>::Item, | +++ -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) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 | | ::Item, ... | LL | |/ Output = ::Item, diff --git a/tests/rustdoc/sidebar/sidebar-items.rs b/tests/rustdoc/sidebar/sidebar-items.rs index 57c2eee91a92a..6e13457796e5e 100644 --- a/tests/rustdoc/sidebar/sidebar-items.rs +++ b/tests/rustdoc/sidebar/sidebar-items.rs @@ -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); } diff --git a/tests/ui/associated-consts/associated-const-in-trait.rs b/tests/ui/associated-consts/associated-const-in-trait.rs index 4e8143d5795db..90ad596b23ee1 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.rs +++ b/tests/ui/associated-consts/associated-const-in-trait.rs @@ -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() {} diff --git a/tests/ui/associated-consts/associated-const-in-trait.stderr b/tests/ui/associated-consts/associated-const-in-trait.stderr index b40c100579726..107ceeaf1134f 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.stderr +++ b/tests/ui/associated-consts/associated-const-in-trait.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/associated-item/issue-48027.rs b/tests/ui/associated-item/issue-48027.rs index d2b51184c999a..715f3935107b4 100644 --- a/tests/ui/associated-item/issue-48027.rs +++ b/tests/ui/associated-item/issue-48027.rs @@ -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() {} diff --git a/tests/ui/associated-item/issue-48027.stderr b/tests/ui/associated-item/issue-48027.stderr index 2883259ce2fd8..1baaefd77204f 100644 --- a/tests/ui/associated-item/issue-48027.stderr +++ b/tests/ui/associated-item/issue-48027.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/async-await/async-closures/is-not-fn.stderr b/tests/ui/async-await/async-closures/is-not-fn.current.stderr similarity index 77% rename from tests/ui/async-await/async-closures/is-not-fn.stderr rename to tests/ui/async-await/async-closures/is-not-fn.current.stderr index bc1d5e6e9d112..e7be1d5b10efe 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.current.stderr @@ -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` diff --git a/tests/ui/async-await/async-closures/is-not-fn.next.stderr b/tests/ui/async-await/async-closures/is-not-fn.next.stderr new file mode 100644 index 0000000000000..e7be1d5b10efe --- /dev/null +++ b/tests/ui/async-await/async-closures/is-not-fn.next.stderr @@ -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`. diff --git a/tests/ui/async-await/async-closures/is-not-fn.rs b/tests/ui/async-await/async-closures/is-not-fn.rs index 4acaa5d9809a1..eacd07b7cdd86 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.rs +++ b/tests/ui/async-await/async-closures/is-not-fn.rs @@ -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 `()` } diff --git a/tests/ui/async-await/async-fn/dyn-pos.rs b/tests/ui/async-await/async-fn/dyn-pos.rs index d71af1bd53e2d..ab4685b07bb0d 100644 --- a/tests/ui/async-await/async-fn/dyn-pos.rs +++ b/tests/ui/async-await/async-fn/dyn-pos.rs @@ -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() {} diff --git a/tests/ui/async-await/async-fn/dyn-pos.stderr b/tests/ui/async-await/async-fn/dyn-pos.stderr index 0c90184667198..f9d2a6694775a 100644 --- a/tests/ui/async-await/async-fn/dyn-pos.stderr +++ b/tests/ui/async-await/async-fn/dyn-pos.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | - = note: the trait cannot be made into an object because it contains the generic associated type `CallRefFuture` - = 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 + = note: the trait is not dyn compatible because it contains the generic associated type `CallRefFuture` error: aborting due to 1 previous error diff --git a/tests/ui/async-await/in-trait/dyn-compatibility.rs b/tests/ui/async-await/in-trait/dyn-compatibility.rs index 8174a803e7951..c1b1ec797846b 100644 --- a/tests/ui/async-await/in-trait/dyn-compatibility.rs +++ b/tests/ui/async-await/in-trait/dyn-compatibility.rs @@ -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 } diff --git a/tests/ui/async-await/in-trait/dyn-compatibility.stderr b/tests/ui/async-await/in-trait/dyn-compatibility.stderr index 5cc3b6800ddbc..c6c406902f69b 100644 --- a/tests/ui/async-await/in-trait/dyn-compatibility.stderr +++ b/tests/ui/async-await/in-trait/dyn-compatibility.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/async-await/inference_var_self_argument.rs b/tests/ui/async-await/inference_var_self_argument.rs index 4d5ac4abb199b..d03f2b5c50bff 100644 --- a/tests/ui/async-await/inference_var_self_argument.rs +++ b/tests/ui/async-await/inference_var_self_argument.rs @@ -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!() } diff --git a/tests/ui/async-await/inference_var_self_argument.stderr b/tests/ui/async-await/inference_var_self_argument.stderr index 7b7b3dbc757f1..a674fc0f3a595 100644 --- a/tests/ui/async-await/inference_var_self_argument.stderr +++ b/tests/ui/async-await/inference_var_self_argument.stderr @@ -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: Rc`, `self: Arc`, or `self: Pin

` (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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr b/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr index 542be2dbc305c..20257bbaf285d 100644 --- a/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr +++ b/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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` diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_dyn_compatibility.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_dyn_compatibility.stderr index 7cd5754be8aae..cd7f3a3c21d06 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_dyn_compatibility.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_dyn_compatibility.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $SRC_DIR/core/src/cmp.rs:LL:COL | - = note: the trait cannot be made into an object because it uses `Self` as a type parameter + = 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $SRC_DIR/core/src/cmp.rs:LL:COL | - = note: the trait cannot be made into an object because it uses `Self` as a type parameter + = 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) {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs index 1620e257667bb..9ab715d01f7a0 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs @@ -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() {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr index d2017615e67db..763bc626c9d3b 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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::()]; | ^^^^ ^^^^^^^^^^^^^^^^^^^ ...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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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::()]; | ^^^^ ^^^^^^^^^^^^^^^^^^^ ...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 diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs index b3bbb8426386b..a7b771cd4f840 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs @@ -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() {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr index 26ca2d4df5ffc..56678e4e9af4b 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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::()]: 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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::()]: 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 diff --git a/tests/ui/const-generics/generic_const_exprs/issue-102768.rs b/tests/ui/const-generics/generic_const_exprs/issue-102768.rs index f2ad7d7ce8b9a..882b27a418e55 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-102768.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-102768.rs @@ -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() {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr b/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr index 9a75f372879fd..bd1811bd2cc60 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr @@ -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 = &'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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs index c9a097d3610a1..9cd32ffeb6d0b 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs @@ -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 } diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr index 8ef0d17844449..7994ddf11c3ec 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr @@ -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 + = 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 error: aborting due to 3 previous errors diff --git a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs index 83076f7d5fc3b..1b1b8bcf03dc0 100644 --- a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs +++ b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs @@ -5,8 +5,8 @@ use std::marker::PhantomData; fn transmute(t: T) -> U { (&PhantomData:: as &dyn Foo).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 Dyn for dyn Foo + '_ { -//~^ ERROR the trait `Foo` cannot be made into an object +//~^ ERROR the trait `Foo` is not dyn compatible type Out = U; } impl + ?Sized, U> Super for S { diff --git a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr index 99bcccc20c01a..f241333f2a766 100644 --- a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr +++ b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr @@ -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 Dyn for 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/almost-supertrait-associated-type.rs:33:34 | LL | trait Foo: Super - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... ... LL | fn transmute(&self, t: T) -> >::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` 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:: as &dyn Foo).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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/almost-supertrait-associated-type.rs:33:34 | LL | trait Foo: Super - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... ... LL | fn transmute(&self, t: T) -> >::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` 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:: as &dyn Foo).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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/almost-supertrait-associated-type.rs:33:34 | LL | trait Foo: Super - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... ... LL | fn transmute(&self, t: T) -> >::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` implements the trait, consider using it directly instead = note: required for the cast from `&PhantomData` to `&dyn Foo` error: aborting due to 3 previous errors diff --git a/tests/ui/dyn-compatibility/associated-consts.curr.stderr b/tests/ui/dyn-compatibility/associated-consts.curr.stderr index 17d184942c701..45d4f79554247 100644 --- a/tests/ui/dyn-compatibility/associated-consts.curr.stderr +++ b/tests/ui/dyn-compatibility/associated-consts.curr.stderr @@ -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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr index cc5120232c244..4c8c82196ed24 100644 --- a/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr b/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr index 54daefea31c10..ff5e9fdb6b367 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.old.stderr @@ -26,14 +26,15 @@ help: if this is a dyn-compatible trait, use `dyn` LL | fn id(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: 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 + = 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 error[E0618]: expected function, found `(dyn Copy + 'static)` --> $DIR/avoid-ice-on-warning-2.rs:12:5 diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.rs b/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.rs index 3c2da667b3924..312e0d666f1a9 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.rs +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-2.rs @@ -3,7 +3,7 @@ //@[new] edition:2021 fn id(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! diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr index 6bc2d73a0d0e4..92a2d3401152a 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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; } diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.rs b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.rs index 00d47225e92fa..9ccbfc15a0daa 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.rs +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.rs @@ -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 diff --git a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.new.fixed b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.new.fixed index a54892afd3e4b..b5200e9fff515 100644 --- a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.new.fixed +++ b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.new.fixed @@ -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) diff --git a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr index 45c9b0ce5d9cb..e3ec5b9c3c86a 100644 --- a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr +++ b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.old.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $SRC_DIR/core/src/cmp.rs:LL:COL | - = note: the trait cannot be made into an object because it uses `Self` as a type parameter + = 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 { diff --git a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.rs b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.rs index cf9be612d2e7e..385fd48102cee 100644 --- a/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.rs +++ b/tests/ui/dyn-compatibility/bare-trait-dont-suggest-dyn.rs @@ -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) diff --git a/tests/ui/dyn-compatibility/bounds.rs b/tests/ui/dyn-compatibility/bounds.rs index 1e04d11c516cb..ed4a69129af3d 100644 --- a/tests/ui/dyn-compatibility/bounds.rs +++ b/tests/ui/dyn-compatibility/bounds.rs @@ -5,7 +5,7 @@ trait X { } fn f() -> Box> { - //~^ ERROR the trait `X` cannot be made into an object + //~^ ERROR the trait `X` is not dyn compatible loop {} } diff --git a/tests/ui/dyn-compatibility/bounds.stderr b/tests/ui/dyn-compatibility/bounds.stderr index 9231d524fd173..d45e66b1d5ef6 100644 --- a/tests/ui/dyn-compatibility/bounds.stderr +++ b/tests/ui/dyn-compatibility/bounds.stderr @@ -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> { - | ^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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; | ^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter diff --git a/tests/ui/dyn-compatibility/gat-incompatible-supertrait.rs b/tests/ui/dyn-compatibility/gat-incompatible-supertrait.rs new file mode 100644 index 0000000000000..fff29ac2b51a2 --- /dev/null +++ b/tests/ui/dyn-compatibility/gat-incompatible-supertrait.rs @@ -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() {} diff --git a/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr b/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr new file mode 100644 index 0000000000000..04dc0b1d6f414 --- /dev/null +++ b/tests/ui/dyn-compatibility/gat-incompatible-supertrait.stderr @@ -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 + --> $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`. diff --git a/tests/ui/dyn-compatibility/generics.curr.stderr b/tests/ui/dyn-compatibility/generics.curr.stderr index c63db38a080b4..1607954ab7042 100644 --- a/tests/ui/dyn-compatibility/generics.curr.stderr +++ b/tests/ui/dyn-compatibility/generics.curr.stderr @@ -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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&self, t: T); | ^^^ ...because method `bar` has generic type parameters = help: consider moving `bar` to another trait diff --git a/tests/ui/dyn-compatibility/generics.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/generics.dyn_compatible_for_dispatch.stderr index ba2546ef2dc5c..7f31b29b39c2b 100644 --- a/tests/ui/dyn-compatibility/generics.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/generics.dyn_compatible_for_dispatch.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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(&self, t: T); | ^^^ ...because method `bar` has generic type parameters = help: consider moving `bar` to another trait diff --git a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr index 7378ec023c926..1ed78e1e65943 100644 --- a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr +++ b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8 | LL | fn foo(&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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8 | LL | fn foo(&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 diff --git a/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.rs b/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.rs index c9ec44cc0b815..2ab0c6c8f5dab 100644 --- a/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.rs +++ b/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.rs @@ -36,9 +36,9 @@ impl <'x> Expr for SExpr<'x> { fn main() { let a: Box = Box::new(SExpr::new()); - //~^ ERROR: `Expr` cannot be made into an object + //~^ ERROR: `Expr` is not dyn compatible let b: Box = Box::new(SExpr::new()); - //~^ ERROR: `Expr` cannot be made into an object + //~^ ERROR: `Expr` is not dyn compatible // assert_eq!(a , b); } diff --git a/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.stderr b/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.stderr index 03e57841b1be4..eba2c15dd74fa 100644 --- a/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.stderr +++ b/tests/ui/dyn-compatibility/mentions-Self-in-super-predicates.stderr @@ -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>, - | ^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 = 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 = 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/mentions-Self.curr.stderr b/tests/ui/dyn-compatibility/mentions-Self.curr.stderr index 434e41cf2182d..90db86ffef9b4 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.curr.stderr +++ b/tests/ui/dyn-compatibility/mentions-Self.curr.stderr @@ -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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/mentions-Self.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/mentions-Self.dyn_compatible_for_dispatch.stderr index dc2d1f87eb737..4a50d3f07e4c2 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/mentions-Self.dyn_compatible_for_dispatch.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/missing-assoc-type.rs b/tests/ui/dyn-compatibility/missing-assoc-type.rs index 21f7fd92e80da..135761dd03656 100644 --- a/tests/ui/dyn-compatibility/missing-assoc-type.rs +++ b/tests/ui/dyn-compatibility/missing-assoc-type.rs @@ -2,6 +2,6 @@ trait Foo { type Bar; } -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() {} diff --git a/tests/ui/dyn-compatibility/missing-assoc-type.stderr b/tests/ui/dyn-compatibility/missing-assoc-type.stderr index 184201dd1cee7..3f550494b3388 100644 --- a/tests/ui/dyn-compatibility/missing-assoc-type.stderr +++ b/tests/ui/dyn-compatibility/missing-assoc-type.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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; | ^^^ ...because it contains the generic associated type `Bar` = help: consider moving `Bar` to another trait diff --git a/tests/ui/dyn-compatibility/no-static.curr.stderr b/tests/ui/dyn-compatibility/no-static.curr.stderr index 584db77985566..867c485053d5f 100644 --- a/tests/ui/dyn-compatibility/no-static.curr.stderr +++ b/tests/ui/dyn-compatibility/no-static.curr.stderr @@ -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 { - | ^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 = 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 = 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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` to `Box` help: consider turning `foo` into a method by giving it a `&self` argument | diff --git a/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr index f2deb3b8d84b9..65608a9cca71e 100644 --- a/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr @@ -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 = 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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` to `Box` help: consider turning `foo` into a method by giving it a `&self` argument | diff --git a/tests/ui/dyn-compatibility/sized-2.curr.stderr b/tests/ui/dyn-compatibility/sized-2.curr.stderr index 1017fde53d313..c8fd105623734 100644 --- a/tests/ui/dyn-compatibility/sized-2.curr.stderr +++ b/tests/ui/dyn-compatibility/sized-2.curr.stderr @@ -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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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` diff --git a/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr index 534cf0f1b033f..477dacdf5a1b4 100644 --- a/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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` diff --git a/tests/ui/dyn-compatibility/sized.curr.stderr b/tests/ui/dyn-compatibility/sized.curr.stderr index 613833aad12ee..d86ea9197b9a0 100644 --- a/tests/ui/dyn-compatibility/sized.curr.stderr +++ b/tests/ui/dyn-compatibility/sized.curr.stderr @@ -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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr index cf847bc157785..b763173594b8b 100644 --- a/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs index 14e00d2ef321d..9e5c1bfe4160a 100644 --- a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs +++ b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs @@ -9,7 +9,7 @@ trait GatTrait { trait SuperTrait: for<'a> GatTrait = T> { fn c(&self) -> dyn SuperTrait; //~^ 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() {} diff --git a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr index ac5a5b28d94d4..f5dea25646988 100644 --- a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr +++ b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr @@ -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; - | ^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/supertrait-mentions-GAT.rs:4:10 | LL | type Gat<'a> | ^^^ ...because it contains the generic associated type `Gat` ... LL | trait SuperTrait: for<'a> GatTrait = 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 diff --git a/tests/ui/dyn-compatibility/supertrait-mentions-Self.stderr b/tests/ui/dyn-compatibility/supertrait-mentions-Self.stderr index abeafa1967fba..f9ef0c9b2e040 100644 --- a/tests/ui/dyn-compatibility/supertrait-mentions-Self.stderr +++ b/tests/ui/dyn-compatibility/supertrait-mentions-Self.stderr @@ -18,19 +18,20 @@ help: consider relaxing the implicit `Sized` restriction LL | trait Bar { | ++++++++ -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: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/supertrait-mentions-Self.rs:8:13 | LL | trait Baz : Bar { | --- ^^^^^^^^^ ...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: &T) -> &impl Baz { diff --git a/tests/ui/dyn-compatibility/taint-const-eval.curr.stderr b/tests/ui/dyn-compatibility/taint-const-eval.curr.stderr index ef0abc1634257..8442314835ea9 100644 --- a/tests/ui/dyn-compatibility/taint-const-eval.curr.stderr +++ b/tests/ui/dyn-compatibility/taint-const-eval.curr.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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` diff --git a/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr index 14940365d2325..1c51df8501f10 100644 --- a/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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)` diff --git a/tests/ui/dyn-compatibility/taint-const-eval.rs b/tests/ui/dyn-compatibility/taint-const-eval.rs index 9825ec0ca1c7c..2feae58080bc8 100644 --- a/tests/ui/dyn-compatibility/taint-const-eval.rs +++ b/tests/ui/dyn-compatibility/taint-const-eval.rs @@ -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() {} diff --git a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs index 5c71bd7769ce1..ec32bec7785ac 100644 --- a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs +++ b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs @@ -17,13 +17,13 @@ pub trait Fetcher: Send + Sync { } fn fetcher() -> Box { - //~^ 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 } diff --git a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr index 8d62ac9d923f9..45a924008c7e8 100644 --- a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr +++ b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr @@ -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) -> Pin> + 'a>> | ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self` ... LL | fn fetcher() -> Box { - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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) -> Pin> + '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) -> Pin> + '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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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) -> Pin> + '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) -> Pin> + '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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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) -> Pin> + 'a>> | ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on diff --git a/tests/ui/error-codes/E0038.stderr b/tests/ui/error-codes/E0038.stderr index 54b489c655f64..59e9f504d17b2 100644 --- a/tests/ui/error-codes/E0038.stderr +++ b/tests/ui/error-codes/E0038.stderr @@ -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) { - | ^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs index d9ff45f57ecba..278a5451e842e 100644 --- a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs +++ b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs @@ -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() {} diff --git a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr index f78fc422410be..b4de6b6646933 100644 --- a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr +++ b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr @@ -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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $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 diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs index 3c9e903d4ba00..37eabbf160220 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs @@ -30,6 +30,6 @@ impl Trait for i32 { fn main() { Ptr(Box::new(4)) as Ptr; - //~^ ERROR the trait `Trait` cannot be made into an object - //~^^ ERROR the trait `Trait` cannot be made into an object + //~^ ERROR the trait `Trait` is not dyn compatible + //~^^ ERROR the trait `Trait` is not dyn compatible } diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr index 28caaf8356f8e..f8fc086c4414f 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr @@ -1,38 +1,40 @@ -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:25 | LL | fn ptr(self: Ptr); | --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self` ... LL | Ptr(Box::new(4)) as Ptr; - | ^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18 | LL | trait Trait { - | ----- this trait cannot be made into an object... + | ----- this trait is not dyn compatible... LL | fn ptr(self: Ptr); | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on - = help: only type `i32` implements the trait, consider using it directly instead + = help: only type `i32` implements `Trait`; consider using it directly instead. -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5 | LL | fn ptr(self: Ptr); | --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self` ... LL | Ptr(Box::new(4)) as Ptr; - | ^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18 | LL | trait Trait { - | ----- this trait cannot be made into an object... + | ----- this trait is not dyn compatible... LL | fn ptr(self: Ptr); | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on - = help: only type `i32` implements the trait, consider using it directly instead + = help: only type `i32` implements `Trait`; consider using it directly instead. = note: required for the cast from `Ptr<{integer}>` to `Ptr` error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr b/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr index ed021c154a5b8..10540f0219d48 100644 --- a/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr +++ b/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr @@ -1,28 +1,30 @@ -error[E0038]: the trait `DynIncompatible1` cannot be made into an object +error[E0038]: the trait `DynIncompatible1` is not dyn compatible --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:18:40 | LL | fn takes_dyn_incompatible_ref(obj: &dyn DynIncompatible1) { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:4:25 | LL | trait DynIncompatible1: Sized {} | ---------------- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... -error[E0038]: the trait `DynIncompatible2` cannot be made into an object +error[E0038]: the trait `DynIncompatible2` is not dyn compatible --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:22:46 | LL | fn return_dyn_incompatible_ref() -> &'static dyn DynIncompatible2 { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible2` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible2` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:7:8 | LL | trait DynIncompatible2 { - | ---------------- this trait cannot be made into an object... + | ---------------- this trait is not dyn compatible... LL | fn static_fn() {} | ^^^^^^^^^ ...because associated function `static_fn` has no `self` parameter help: consider turning `static_fn` into a method by giving it a `&self` argument @@ -34,49 +36,52 @@ help: alternatively, consider constraining `static_fn` so it does not apply to t LL | fn static_fn() where Self: Sized {} | +++++++++++++++++ -error[E0038]: the trait `DynIncompatible3` cannot be made into an object +error[E0038]: the trait `DynIncompatible3` is not dyn compatible --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:27:40 | LL | fn takes_dyn_incompatible_box(obj: Box) { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible3` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible3` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:11:8 | LL | trait DynIncompatible3 { - | ---------------- this trait cannot be made into an object... + | ---------------- this trait is not dyn compatible... LL | fn foo(&self); | ^^^ ...because method `foo` has generic type parameters = help: consider moving `foo` to another trait -error[E0038]: the trait `DynIncompatible4` cannot be made into an object +error[E0038]: the trait `DynIncompatible4` is not dyn compatible --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:31:48 | LL | fn return_dyn_incompatible_rc() -> std::rc::Rc { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible4` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible4` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:15:22 | LL | trait DynIncompatible4 { - | ---------------- this trait cannot be made into an object... + | ---------------- this trait is not dyn compatible... LL | fn foo(&self, s: &Self); | ^^^^^ ...because method `foo` references the `Self` type in this parameter = help: consider moving `foo` to another trait -error[E0038]: the trait `DynIncompatible1` cannot be made into an object +error[E0038]: the trait `DynIncompatible1` is not dyn compatible --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:38:16 | LL | impl Trait for dyn DynIncompatible1 {} - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:4:25 | LL | trait DynIncompatible1: Sized {} | ---------------- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error: aborting due to 5 previous errors diff --git a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs index 1a4678c7e70b6..b02739a7d0acb 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs +++ b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs @@ -8,5 +8,5 @@ fn main() { //~| ERROR: binding for associated type `Y` references lifetime //~| ERROR: binding for associated type `Y` references lifetime //~| ERROR: binding for associated type `Y` references lifetime - //~| ERROR: the trait `X` cannot be made into an object + //~| ERROR: the trait `X` is not dyn compatible } diff --git a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr index 867f55b0deead..4c5a47e73c6c4 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr @@ -36,17 +36,18 @@ LL | fn _f(arg : Box X = &'a [u32]>>) {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:19 | LL | fn _f(arg : Box X = &'a [u32]>>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:2:8 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'x>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr index 34642f8fdc6c8..b2b569e6261b5 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr @@ -1,56 +1,50 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/gat-in-trait-path.rs:26:17 | LL | fn f(_arg : Box Foo = &'a ()>>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path.rs:10:10 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy - Fooer -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/gat-in-trait-path.rs:32:5 | LL | f(Box::new(foo)); - | ^^^^^^^^^^^^^ `Foo` cannot be made into an object + | ^^^^^^^^^^^^^ `Foo` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path.rs:10:10 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy - Fooer -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/gat-in-trait-path.rs:32:5 | LL | f(Box::new(foo)); - | ^^^^^^^^^^^^^ `Foo` cannot be made into an object + | ^^^^^^^^^^^^^ `Foo` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path.rs:10:10 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy - Fooer = note: required for the cast from `Box>` to `Box<(dyn Foo = &'a ()> + 'static)>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.rs b/tests/ui/generic-associated-types/gat-in-trait-path.rs index cd759a73cf278..24cae213e0aa4 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.rs +++ b/tests/ui/generic-associated-types/gat-in-trait-path.rs @@ -20,12 +20,11 @@ impl Foo for Fooer { } fn f(_arg : Box Foo = &'a ()>>) {} -//~^ the trait `Foo` cannot be made into an object - +//~^ the trait `Foo` is not dyn compatible fn main() { let foo = Fooer(5); f(Box::new(foo)); - //~^ the trait `Foo` cannot be made into an object - //~| the trait `Foo` cannot be made into an object + //~^ the trait `Foo` is not dyn compatible + //~| the trait `Foo` is not dyn compatible } diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.stderr b/tests/ui/generic-associated-types/gat-in-trait-path.stderr index b2176fa6de3b4..df79556c825a1 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path.stderr @@ -1,56 +1,50 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/gat-in-trait-path.rs:22:17 | LL | fn f(_arg : Box Foo = &'a ()>>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path.rs:6:10 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy - Fooer -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/gat-in-trait-path.rs:28:5 +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/gat-in-trait-path.rs:27:5 | LL | f(Box::new(foo)); - | ^^^^^^^^^^^^^ `Foo` cannot be made into an object + | ^^^^^^^^^^^^^ `Foo` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path.rs:6:10 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy - Fooer -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/gat-in-trait-path.rs:28:5 +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/gat-in-trait-path.rs:27:5 | LL | f(Box::new(foo)); - | ^^^^^^^^^^^^^ `Foo` cannot be made into an object + | ^^^^^^^^^^^^^ `Foo` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-in-trait-path.rs:6:10 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy - Fooer = note: required for the cast from `Box>` to `Box<(dyn Foo = &'a ()> + 'static)>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs index c413442701303..85661c1b84480 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs +++ b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs @@ -12,7 +12,7 @@ fn foo<'a>(arg: Box>) {} //~| ERROR associated type takes 0 generic arguments but 1 generic argument //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR at least one trait is required - //~| ERROR: the trait `X` cannot be made into an object + //~| ERROR: the trait `X` is not dyn compatible fn bar<'a>(arg: Box>) {} @@ -20,6 +20,6 @@ fn bar<'a>(arg: Box>) {} //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR: the trait `X` cannot be made into an object + //~| ERROR: the trait `X` is not dyn compatible fn main() {} diff --git a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr index 97b7019b38515..499ce8e4a321f 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr +++ b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr @@ -123,17 +123,18 @@ error[E0224]: at least one trait is required for an object type LL | fn foo<'a>(arg: Box>) {} | ^^ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/gat-trait-path-parenthesised-args.rs:5:21 | LL | fn foo<'a>(arg: Box>) {} - | ^^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait @@ -188,17 +189,18 @@ help: add missing lifetime argument LL | fn bar<'a>(arg: Box>) {} | ++ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/gat-trait-path-parenthesised-args.rs:18:21 | LL | fn bar<'a>(arg: Box>) {} - | ^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/issue-67510-pass.base.stderr b/tests/ui/generic-associated-types/issue-67510-pass.base.stderr index cac8010018ec0..5630894896946 100644 --- a/tests/ui/generic-associated-types/issue-67510-pass.base.stderr +++ b/tests/ui/generic-associated-types/issue-67510-pass.base.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/issue-67510-pass.rs:12:23 | LL | fn _func1<'a>(_x: Box=&'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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-67510-pass.rs:9:10 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/issue-67510-pass.rs b/tests/ui/generic-associated-types/issue-67510-pass.rs index a48d9c37cd4f4..2bfba7f6942fb 100644 --- a/tests/ui/generic-associated-types/issue-67510-pass.rs +++ b/tests/ui/generic-associated-types/issue-67510-pass.rs @@ -5,6 +5,6 @@ trait X { } fn _func1<'a>(_x: Box=&'a ()>>) {} -//~^ ERROR the trait `X` cannot be made into an object +//~^ ERROR the trait `X` is not dyn compatible fn main() {} diff --git a/tests/ui/generic-associated-types/issue-67510-pass.stderr b/tests/ui/generic-associated-types/issue-67510-pass.stderr index 5560cb0f64df2..f6846f833fea4 100644 --- a/tests/ui/generic-associated-types/issue-67510-pass.stderr +++ b/tests/ui/generic-associated-types/issue-67510-pass.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/issue-67510-pass.rs:7:23 | LL | fn _func1<'a>(_x: Box=&'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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-67510-pass.rs:4:10 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/issue-67510.rs b/tests/ui/generic-associated-types/issue-67510.rs index ab5c25d74da73..5c3150a77ed1b 100644 --- a/tests/ui/generic-associated-types/issue-67510.rs +++ b/tests/ui/generic-associated-types/issue-67510.rs @@ -5,6 +5,6 @@ trait X { fn f(x: Box = &'a ()>>) {} //~^ ERROR: use of undeclared lifetime name `'a` //~| ERROR: use of undeclared lifetime name `'a` -//~| ERROR: the trait `X` cannot be made into an object [E0038] +//~| ERROR: the trait `X` is not dyn compatible [E0038] fn main() {} diff --git a/tests/ui/generic-associated-types/issue-67510.stderr b/tests/ui/generic-associated-types/issue-67510.stderr index 416f04ac2fd6c..e8555a7aa1fda 100644 --- a/tests/ui/generic-associated-types/issue-67510.stderr +++ b/tests/ui/generic-associated-types/issue-67510.stderr @@ -29,17 +29,18 @@ help: consider introducing lifetime `'a` here LL | fn f<'a>(x: Box = &'a ()>>) {} | ++++ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/issue-67510.rs:5:13 | LL | fn f(x: Box = &'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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-67510.rs:2:10 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/issue-71176.rs b/tests/ui/generic-associated-types/issue-71176.rs index 7fffe312f4b7b..d3a0caffec1e7 100644 --- a/tests/ui/generic-associated-types/issue-71176.rs +++ b/tests/ui/generic-associated-types/issue-71176.rs @@ -11,13 +11,13 @@ struct Holder { //~^ ERROR: missing generics for associated type //~| ERROR: missing generics for associated type //~| ERROR: missing generics for associated type - //~| ERROR: the trait `Provider` cannot be made into an object + //~| ERROR: the trait `Provider` is not dyn compatible } fn main() { Holder { inner: Box::new(()), - //~^ ERROR: the trait `Provider` cannot be made into an object - //~| ERROR: the trait `Provider` cannot be made into an object + //~^ ERROR: the trait `Provider` is not dyn compatible + //~| ERROR: the trait `Provider` is not dyn compatible }; } diff --git a/tests/ui/generic-associated-types/issue-71176.stderr b/tests/ui/generic-associated-types/issue-71176.stderr index 1cd2ed0d313dc..a78151384d4bb 100644 --- a/tests/ui/generic-associated-types/issue-71176.stderr +++ b/tests/ui/generic-associated-types/issue-71176.stderr @@ -48,53 +48,56 @@ help: add missing lifetime argument LL | inner: Box = B>>, | ++++ -error[E0038]: the trait `Provider` cannot be made into an object +error[E0038]: the trait `Provider` is not dyn compatible --> $DIR/issue-71176.rs:10:14 | LL | inner: Box>, - | ^^^^^^^^^^^^^^^^^^^ `Provider` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^ `Provider` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-71176.rs:2:10 | LL | trait Provider { - | -------- this trait cannot be made into an object... + | -------- this trait is not dyn compatible... LL | type A<'a>; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: only type `()` implements the trait, consider using it directly instead + = help: only type `()` implements `Provider`; consider using it directly instead. -error[E0038]: the trait `Provider` cannot be made into an object +error[E0038]: the trait `Provider` is not dyn compatible --> $DIR/issue-71176.rs:19:16 | LL | inner: Box::new(()), - | ^^^^^^^^^^^^ `Provider` cannot be made into an object + | ^^^^^^^^^^^^ `Provider` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-71176.rs:2:10 | LL | trait Provider { - | -------- this trait cannot be made into an object... + | -------- this trait is not dyn compatible... LL | type A<'a>; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: only type `()` implements the trait, consider using it directly instead + = help: only type `()` implements `Provider`; consider using it directly instead. -error[E0038]: the trait `Provider` cannot be made into an object +error[E0038]: the trait `Provider` is not dyn compatible --> $DIR/issue-71176.rs:19:16 | LL | inner: Box::new(()), - | ^^^^^^^^^^^^ `Provider` cannot be made into an object + | ^^^^^^^^^^^^ `Provider` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-71176.rs:2:10 | LL | trait Provider { - | -------- this trait cannot be made into an object... + | -------- this trait is not dyn compatible... LL | type A<'a>; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait - = help: only type `()` implements the trait, consider using it directly instead + = help: only type `()` implements `Provider`; consider using it directly instead. = note: required for the cast from `Box<()>` to `Box<(dyn Provider = _> + 'static), {type error}>` error: aborting due to 6 previous errors diff --git a/tests/ui/generic-associated-types/issue-76535.base.stderr b/tests/ui/generic-associated-types/issue-76535.base.stderr index a44c8dc51e7e9..b503fad2d84fe 100644 --- a/tests/ui/generic-associated-types/issue-76535.base.stderr +++ b/tests/ui/generic-associated-types/issue-76535.base.stderr @@ -14,39 +14,41 @@ help: add missing lifetime argument LL | let sub: Box = SubStruct>> = Box::new(SuperStruct::new(0)); | ++++ -error[E0038]: the trait `SuperTrait` cannot be made into an object +error[E0038]: the trait `SuperTrait` is not dyn compatible --> $DIR/issue-76535.rs:39:14 | LL | let sub: Box> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-76535.rs:9:10 | LL | pub trait SuperTrait { - | ---------- this trait cannot be made into an object... + | ---------- this trait is not dyn compatible... LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait - = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead - = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type + = help: only type `SuperStruct` implements `SuperTrait` within this crate. Consider using it directly instead. + = note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type -error[E0038]: the trait `SuperTrait` cannot be made into an object +error[E0038]: the trait `SuperTrait` is not dyn compatible --> $DIR/issue-76535.rs:39:57 | LL | let sub: Box> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-76535.rs:9:10 | LL | pub trait SuperTrait { - | ---------- this trait cannot be made into an object... + | ---------- this trait is not dyn compatible... LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait - = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead - = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type + = help: only type `SuperStruct` implements `SuperTrait` within this crate. Consider using it directly instead. + = note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type = note: required for the cast from `Box` to `Box = SubStruct<'_>>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/issue-76535.stderr b/tests/ui/generic-associated-types/issue-76535.stderr index 613ded6f1ef10..6b7c3bfe73120 100644 --- a/tests/ui/generic-associated-types/issue-76535.stderr +++ b/tests/ui/generic-associated-types/issue-76535.stderr @@ -14,39 +14,41 @@ help: add missing lifetime argument LL | let sub: Box = SubStruct>> = Box::new(SuperStruct::new(0)); | ++++ -error[E0038]: the trait `SuperTrait` cannot be made into an object +error[E0038]: the trait `SuperTrait` is not dyn compatible --> $DIR/issue-76535.rs:34:14 | LL | let sub: Box> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-76535.rs:4:10 | LL | pub trait SuperTrait { - | ---------- this trait cannot be made into an object... + | ---------- this trait is not dyn compatible... LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait - = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead - = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type + = help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead. + = note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type -error[E0038]: the trait `SuperTrait` cannot be made into an object +error[E0038]: the trait `SuperTrait` is not dyn compatible --> $DIR/issue-76535.rs:34:57 | LL | let sub: Box> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-76535.rs:4:10 | LL | pub trait SuperTrait { - | ---------- this trait cannot be made into an object... + | ---------- this trait is not dyn compatible... LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait - = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead - = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type + = help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead. + = note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type = note: required for the cast from `Box` to `Box = SubStruct<'_>>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/issue-78671.base.stderr b/tests/ui/generic-associated-types/issue-78671.base.stderr index 9f2be785460f3..9bfe8c0b95612 100644 --- a/tests/ui/generic-associated-types/issue-78671.base.stderr +++ b/tests/ui/generic-associated-types/issue-78671.base.stderr @@ -14,17 +14,18 @@ help: add missing generic argument LL | Box::new(Family) as &dyn CollectionFamily=usize> | +++ -error[E0038]: the trait `CollectionFamily` cannot be made into an object +error[E0038]: the trait `CollectionFamily` is not dyn compatible --> $DIR/issue-78671.rs:10:25 | LL | Box::new(Family) as &dyn CollectionFamily - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-78671.rs:7:10 | LL | trait CollectionFamily { - | ---------------- this trait cannot be made into an object... + | ---------------- this trait is not dyn compatible... LL | type Member; | ^^^^^^ ...because it contains the generic associated type `Member` = help: consider moving `Member` to another trait diff --git a/tests/ui/generic-associated-types/issue-78671.rs b/tests/ui/generic-associated-types/issue-78671.rs index 0871def173130..1e1863799a523 100644 --- a/tests/ui/generic-associated-types/issue-78671.rs +++ b/tests/ui/generic-associated-types/issue-78671.rs @@ -4,7 +4,7 @@ trait CollectionFamily { fn floatify() { Box::new(Family) as &dyn CollectionFamily //~^ ERROR: missing generics for associated type - //~| ERROR: the trait `CollectionFamily` cannot be made into an object + //~| ERROR: the trait `CollectionFamily` is not dyn compatible } struct Family; diff --git a/tests/ui/generic-associated-types/issue-78671.stderr b/tests/ui/generic-associated-types/issue-78671.stderr index fbd76c73895a6..c85e97067cbc5 100644 --- a/tests/ui/generic-associated-types/issue-78671.stderr +++ b/tests/ui/generic-associated-types/issue-78671.stderr @@ -14,17 +14,18 @@ help: add missing generic argument LL | Box::new(Family) as &dyn CollectionFamily=usize> | +++ -error[E0038]: the trait `CollectionFamily` cannot be made into an object +error[E0038]: the trait `CollectionFamily` is not dyn compatible --> $DIR/issue-78671.rs:5:25 | LL | Box::new(Family) as &dyn CollectionFamily - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-78671.rs:2:10 | LL | trait CollectionFamily { - | ---------------- this trait cannot be made into an object... + | ---------------- this trait is not dyn compatible... LL | type Member; | ^^^^^^ ...because it contains the generic associated type `Member` = help: consider moving `Member` to another trait diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr index 3ea62bdbb2763..c3de2b71762e4 100644 --- a/tests/ui/generic-associated-types/issue-79422.base.stderr +++ b/tests/ui/generic-associated-types/issue-79422.base.stderr @@ -14,41 +14,37 @@ help: add missing lifetime argument LL | as Box = dyn RefCont<'_, u8>>>; | ++++ -error[E0038]: the trait `MapLike` cannot be made into an object +error[E0038]: the trait `MapLike` is not dyn compatible --> $DIR/issue-79422.rs:47:12 | LL | as Box>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-79422.rs:23:10 | LL | trait MapLike { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead: - std::collections::BTreeMap - Source -error[E0038]: the trait `MapLike` cannot be made into an object +error[E0038]: the trait `MapLike` is not dyn compatible --> $DIR/issue-79422.rs:44:13 | LL | let m = Box::new(std::collections::BTreeMap::::new()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-79422.rs:23:10 | LL | trait MapLike { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead: - std::collections::BTreeMap - Source = note: required for the cast from `Box>` to `Box = (dyn RefCont<'_, u8> + 'static)>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/issue-79422.stderr b/tests/ui/generic-associated-types/issue-79422.stderr index 26567e5e927d1..a81217e96c386 100644 --- a/tests/ui/generic-associated-types/issue-79422.stderr +++ b/tests/ui/generic-associated-types/issue-79422.stderr @@ -14,41 +14,37 @@ help: add missing lifetime argument LL | as Box = dyn RefCont<'_, u8>>>; | ++++ -error[E0038]: the trait `MapLike` cannot be made into an object +error[E0038]: the trait `MapLike` is not dyn compatible --> $DIR/issue-79422.rs:41:12 | LL | as Box>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-79422.rs:18:10 | LL | trait MapLike { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead: - std::collections::BTreeMap - Source -error[E0038]: the trait `MapLike` cannot be made into an object +error[E0038]: the trait `MapLike` is not dyn compatible --> $DIR/issue-79422.rs:39:13 | LL | let m = Box::new(std::collections::BTreeMap::::new()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-79422.rs:18:10 | LL | trait MapLike { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead: - std::collections::BTreeMap - Source = note: required for the cast from `Box>` to `Box = (dyn RefCont<'_, u8> + 'static)>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/missing_lifetime_args.rs b/tests/ui/generic-associated-types/missing_lifetime_args.rs index 470db5412b281..e0f2db5eb21ed 100644 --- a/tests/ui/generic-associated-types/missing_lifetime_args.rs +++ b/tests/ui/generic-associated-types/missing_lifetime_args.rs @@ -12,7 +12,7 @@ fn foo<'c, 'd>(_arg: Box>) {} //~^ ERROR missing generics for associated type //~| ERROR missing generics for associated type //~| ERROR missing generics for associated type -//~| ERROR the trait `X` cannot be made into an object +//~| ERROR the trait `X` is not dyn compatible fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {} //~^ ERROR struct takes 3 lifetime arguments but 2 lifetime diff --git a/tests/ui/generic-associated-types/missing_lifetime_args.stderr b/tests/ui/generic-associated-types/missing_lifetime_args.stderr index 61cf4f3dd4a7e..6b8df5cc12f98 100644 --- a/tests/ui/generic-associated-types/missing_lifetime_args.stderr +++ b/tests/ui/generic-associated-types/missing_lifetime_args.stderr @@ -48,17 +48,18 @@ help: add missing lifetime arguments LL | fn foo<'c, 'd>(_arg: Box = (&'c u32, &'d u32)>>) {} | ++++++++ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/missing_lifetime_args.rs:11:26 | LL | fn foo<'c, 'd>(_arg: Box>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/missing_lifetime_args.rs:2:10 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a, 'b>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs index d6fc3df1026f6..c828691bb3058 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs +++ b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs @@ -10,7 +10,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 the trait `X` cannot be made into an object + //~| ERROR the trait `X` is not dyn compatible }; fn main() {} diff --git a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr index 91f0f7b3fcf2d..5c9e9dbe3d7d0 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr +++ b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr @@ -92,17 +92,18 @@ LL | type Y<'a>; | ^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/trait-path-type-error-once-implemented.rs:6:23 | LL | fn f2<'a>(arg : Box = &'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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-path-type-error-once-implemented.rs:2:10 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | type Y<'a>; | ^ ...because it contains the generic associated type `Y` = help: consider moving `Y` to another trait diff --git a/tests/ui/generic-associated-types/trait-objects.base.stderr b/tests/ui/generic-associated-types/trait-objects.base.stderr index 0b5a9b9f7fb64..fe9ab165d4af4 100644 --- a/tests/ui/generic-associated-types/trait-objects.base.stderr +++ b/tests/ui/generic-associated-types/trait-objects.base.stderr @@ -1,44 +1,47 @@ -error[E0038]: the trait `StreamingIterator` cannot be made into an object +error[E0038]: the trait `StreamingIterator` is not dyn compatible --> $DIR/trait-objects.rs:13:21 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-objects.rs:7:10 | LL | trait StreamingIterator { - | ----------------- this trait cannot be made into an object... + | ----------------- this trait is not dyn compatible... LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait -error[E0038]: the trait `StreamingIterator` cannot be made into an object +error[E0038]: the trait `StreamingIterator` is not dyn compatible --> $DIR/trait-objects.rs:15:7 | LL | x.size_hint().0 - | ^^^^^^^^^ `StreamingIterator` cannot be made into an object + | ^^^^^^^^^ `StreamingIterator` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-objects.rs:7:10 | LL | trait StreamingIterator { - | ----------------- this trait cannot be made into an object... + | ----------------- this trait is not dyn compatible... LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait -error[E0038]: the trait `StreamingIterator` cannot be made into an object +error[E0038]: the trait `StreamingIterator` is not dyn compatible --> $DIR/trait-objects.rs:15:5 | LL | x.size_hint().0 - | ^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object + | ^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-objects.rs:7:10 | LL | trait StreamingIterator { - | ----------------- this trait cannot be made into an object... + | ----------------- this trait is not dyn compatible... LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait diff --git a/tests/ui/generic-associated-types/trait-objects.rs b/tests/ui/generic-associated-types/trait-objects.rs index bad9289ee5eec..ed324b562e1c8 100644 --- a/tests/ui/generic-associated-types/trait-objects.rs +++ b/tests/ui/generic-associated-types/trait-objects.rs @@ -6,10 +6,10 @@ trait StreamingIterator { } fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { - //~^ the trait `StreamingIterator` cannot be made into an object + //~^ the trait `StreamingIterator` is not dyn compatible x.size_hint().0 - //~^ the trait `StreamingIterator` cannot be made into an object - //~| the trait `StreamingIterator` cannot be made into an object + //~^ the trait `StreamingIterator` is not dyn compatible + //~| the trait `StreamingIterator` is not dyn compatible } fn main() {} diff --git a/tests/ui/generic-associated-types/trait-objects.stderr b/tests/ui/generic-associated-types/trait-objects.stderr index 3e74776f999ac..56a1cb1906fb9 100644 --- a/tests/ui/generic-associated-types/trait-objects.stderr +++ b/tests/ui/generic-associated-types/trait-objects.stderr @@ -1,44 +1,47 @@ -error[E0038]: the trait `StreamingIterator` cannot be made into an object +error[E0038]: the trait `StreamingIterator` is not dyn compatible --> $DIR/trait-objects.rs:8:21 | LL | fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-objects.rs:2:10 | LL | trait StreamingIterator { - | ----------------- this trait cannot be made into an object... + | ----------------- this trait is not dyn compatible... LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait -error[E0038]: the trait `StreamingIterator` cannot be made into an object +error[E0038]: the trait `StreamingIterator` is not dyn compatible --> $DIR/trait-objects.rs:10:7 | LL | x.size_hint().0 - | ^^^^^^^^^ `StreamingIterator` cannot be made into an object + | ^^^^^^^^^ `StreamingIterator` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-objects.rs:2:10 | LL | trait StreamingIterator { - | ----------------- this trait cannot be made into an object... + | ----------------- this trait is not dyn compatible... LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait -error[E0038]: the trait `StreamingIterator` cannot be made into an object +error[E0038]: the trait `StreamingIterator` is not dyn compatible --> $DIR/trait-objects.rs:10:5 | LL | x.size_hint().0 - | ^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object + | ^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible | -note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/trait-objects.rs:2:10 | LL | trait StreamingIterator { - | ----------------- this trait cannot be made into an object... + | ----------------- this trait is not dyn compatible... LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs index aeace9f2158ae..5d039cd5dc656 100644 --- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs @@ -12,8 +12,8 @@ fn needs_bar(_: *mut Type2) {} fn main() { let x: &dyn Foo = &(); - //~^ 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 needs_bar(x); //~^ ERROR mismatched types diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr index d48bf8a471d61..fc3d9c2171d2c 100644 --- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr @@ -1,31 +1,33 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/span-bug-issue-121597.rs:14:23 | LL | let 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/span-bug-issue-121597.rs:4:12 | LL | trait Foo: for Bar {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... = note: required for the cast from `&()` to `&dyn Foo` -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/span-bug-issue-121597.rs:14:12 | LL | let 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/span-bug-issue-121597.rs:4:12 | LL | trait Foo: for Bar {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error[E0308]: mismatched types --> $DIR/span-bug-issue-121597.rs:18:15 diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs index 76dbb05f53d66..046ced072bac2 100644 --- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs +++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs @@ -19,7 +19,7 @@ impl DynIncompatible for B { } } -fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` cannot be made into an object +fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not dyn compatible //~^ ERROR return type cannot have an unboxed trait object if true { return A; @@ -27,11 +27,11 @@ fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` cannot b B } -fn cat() -> Box { //~ ERROR the trait `DynIncompatible` cannot be made into an +fn cat() -> Box { //~ ERROR the trait `DynIncompatible` is not dyn compatible if true { - return Box::new(A); //~ ERROR cannot be made into an object + return Box::new(A); //~ ERROR is not dyn compatible } - Box::new(B) //~ ERROR cannot be made into an object + Box::new(B) //~ ERROR is not dyn compatible } fn main() {} diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr index 576bd909cbc7d..4abd7bcf31c54 100644 --- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr +++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr @@ -1,19 +1,22 @@ -error[E0038]: the trait `DynIncompatible` cannot be made into an object +error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:13 | LL | fn car() -> 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8 | LL | trait DynIncompatible { - | --------------- this trait cannot be made into an object... + | --------------- this trait is not dyn compatible... LL | fn foo() -> Self; | ^^^ ...because associated function `foo` has no `self` parameter - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `DynIncompatible` for this new enum and using it instead: + = help: the following types implement `DynIncompatible`: A B + consider defining an enum where each variant holds one of these types, + implementing `DynIncompatible` for this new enum and using it instead help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) -> Self; @@ -23,22 +26,25 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() -> Self where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `DynIncompatible` cannot be made into an object +error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:30:17 | LL | fn cat() -> Box { - | ^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8 | LL | trait DynIncompatible { - | --------------- this trait cannot be made into an object... + | --------------- this trait is not dyn compatible... LL | fn foo() -> Self; | ^^^ ...because associated function `foo` has no `self` parameter - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `DynIncompatible` for this new enum and using it instead: + = help: the following types implement `DynIncompatible`: A B + consider defining an enum where each variant holds one of these types, + implementing `DynIncompatible` for this new enum and using it instead help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) -> Self; @@ -65,22 +71,25 @@ LL | } LL ~ Box::new(B) | -error[E0038]: the trait `DynIncompatible` cannot be made into an object +error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:16 | LL | return Box::new(A); - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8 | LL | trait DynIncompatible { - | --------------- this trait cannot be made into an object... + | --------------- this trait is not dyn compatible... LL | fn foo() -> Self; | ^^^ ...because associated function `foo` has no `self` parameter - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `DynIncompatible` for this new enum and using it instead: + = help: the following types implement `DynIncompatible`: A B + consider defining an enum where each variant holds one of these types, + implementing `DynIncompatible` for this new enum and using it instead = note: required for the cast from `Box` to `Box<(dyn DynIncompatible + 'static)>` help: consider turning `foo` into a method by giving it a `&self` argument | @@ -91,22 +100,25 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() -> Self where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `DynIncompatible` cannot be made into an object +error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:34:5 | LL | Box::new(B) - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8 | LL | trait DynIncompatible { - | --------------- this trait cannot be made into an object... + | --------------- this trait is not dyn compatible... LL | fn foo() -> Self; | ^^^ ...because associated function `foo` has no `self` parameter - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `DynIncompatible` for this new enum and using it instead: + = help: the following types implement `DynIncompatible`: A B + consider defining an enum where each variant holds one of these types, + implementing `DynIncompatible` for this new enum and using it instead = note: required for the cast from `Box` to `Box<(dyn DynIncompatible + 'static)>` help: consider turning `foo` into a method by giving it a `&self` argument | diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.current.stderr similarity index 96% rename from tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr rename to tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.current.stderr index 28a0f7461e2d5..146a3d21068cd 100644 --- a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.stderr +++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.current.stderr @@ -1,11 +1,11 @@ error[E0407]: method `line_stream` is not a member of trait `X` - --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:5 + --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:28:5 | LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X` error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:22:21 + --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:21 | LL | type LineStream<'a, Repr> | -- ---- @@ -18,7 +18,7 @@ LL | type LineStream<'c, 'd> = impl Stream; | found 0 type parameters error[E0277]: `()` is not a future - --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:43 + --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:28:43 | LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr new file mode 100644 index 0000000000000..3c24eb9adbee7 --- /dev/null +++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr @@ -0,0 +1,29 @@ +error[E0407]: method `line_stream` is not a member of trait `X` + --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:28:5 + | +LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X` + +error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:21 + | +LL | type LineStream<'a, Repr> + | -- ---- + | | + | expected 1 type parameter +... +LL | type LineStream<'c, 'd> = impl Stream; + | ^^ ^^ + | | + | found 0 type parameters + +error[E0271]: type mismatch resolving `::LineStreamFut<'a, Repr> == ()` + --> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:28:43 + | +LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0049, E0271, E0407. +For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs index d6fa56663a3f0..c97bd1799436f 100644 --- a/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs +++ b/tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.rs @@ -1,3 +1,6 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver // test for ICE #112823 // Unexpected parameter Type(Repr) when substituting in region @@ -23,8 +26,9 @@ impl X for Y { //~^ ERROR type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter type LineStreamFut<'a, Repr> = impl Future>; fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} - //~^ ERROR `()` is not a future - //~^^ method `line_stream` is not a member of trait `X` + //[current]~^ ERROR `()` is not a future + //[next]~^^ ERROR type mismatch resolving `::LineStreamFut<'a, Repr> == ()` + //~^^^ method `line_stream` is not a member of trait `X` } pub fn main() {} diff --git a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.rs b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.rs index daf29a0005dec..d6fa34419d2b2 100644 --- a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.rs +++ b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.rs @@ -14,13 +14,13 @@ impl MyTrait for Outer { } impl dyn MyTrait { - //~^ ERROR the trait `MyTrait` cannot be made into an object + //~^ ERROR the trait `MyTrait` is not dyn compatible fn other(&self) -> impl Marker { - //~^ ERROR the trait `MyTrait` cannot be made into an object + //~^ ERROR the trait `MyTrait` is not dyn compatible MyTrait::foo(&self) //~^ ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied //~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied - //~| ERROR the trait `MyTrait` cannot be made into an object + //~| ERROR the trait `MyTrait` is not dyn compatible } } diff --git a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.stderr b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.stderr index a975b6204aa5a..44ca09150fe3d 100644 --- a/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.stderr +++ b/tests/ui/impl-trait/in-trait/cycle-effective-visibilities-during-dyn-compatibility-check.stderr @@ -8,21 +8,22 @@ LL | MyTrait::foo(&self) | = help: the trait `MyTrait` is implemented for `Outer` -error[E0038]: the trait `MyTrait` cannot be made into an object +error[E0038]: the trait `MyTrait` is not dyn compatible --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:20:9 | LL | MyTrait::foo(&self) - | ^^^^^^^^^^^^ `MyTrait` cannot be made into an object + | ^^^^^^^^^^^^ `MyTrait` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:5:22 | LL | trait MyTrait { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | fn foo(&self) -> impl Marker; | ^^^^^^^^^^^ ...because method `foo` references an `impl Trait` type in its return type = help: consider moving `foo` to another trait - = help: only type `Outer` implements the trait, consider using it directly instead + = help: only type `Outer` implements `MyTrait`; consider using it directly instead. error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:20:9 @@ -32,37 +33,39 @@ LL | MyTrait::foo(&self) | = help: the trait `MyTrait` is implemented for `Outer` -error[E0038]: the trait `MyTrait` cannot be made into an object +error[E0038]: the trait `MyTrait` is not dyn compatible --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:16:6 | LL | impl dyn MyTrait { - | ^^^^^^^^^^^ `MyTrait` cannot be made into an object + | ^^^^^^^^^^^ `MyTrait` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:5:22 | LL | trait MyTrait { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | fn foo(&self) -> impl Marker; | ^^^^^^^^^^^ ...because method `foo` references an `impl Trait` type in its return type = help: consider moving `foo` to another trait - = help: only type `Outer` implements the trait, consider using it directly instead + = help: only type `Outer` implements `MyTrait`; consider using it directly instead. -error[E0038]: the trait `MyTrait` cannot be made into an object +error[E0038]: the trait `MyTrait` is not dyn compatible --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:18:15 | LL | fn other(&self) -> impl Marker { - | ^^^^ `MyTrait` cannot be made into an object + | ^^^^ `MyTrait` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/cycle-effective-visibilities-during-dyn-compatibility-check.rs:5:22 | LL | trait MyTrait { - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... LL | fn foo(&self) -> impl Marker; | ^^^^^^^^^^^ ...because method `foo` references an `impl Trait` type in its return type = help: consider moving `foo` to another trait - = help: only type `Outer` implements the trait, consider using it directly instead + = help: only type `Outer` implements `MyTrait`; consider using it directly instead. error: aborting due to 5 previous errors diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs index 5cca4ad839c26..85b1ba269fc8c 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs @@ -12,9 +12,9 @@ impl Foo for u32 { fn main() { let i = Box::new(42_u32) as Box; - //~^ 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 let s = i.baz(); - //~^ 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 } diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr index 115cb014b8c34..87a5480b1e3d1 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr @@ -1,66 +1,70 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/dyn-compatibility.rs:14:33 | LL | let i = Box::new(42_u32) as Box; - | ^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-compatibility.rs:4:22 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait - = help: only type `u32` implements the trait, consider using it directly instead + = help: only type `u32` 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.rs:17:15 | LL | let s = i.baz(); - | ^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-compatibility.rs:4:22 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait - = help: only type `u32` implements the trait, consider using it directly instead + = help: only type `u32` 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.rs:17:13 | LL | let s = i.baz(); - | ^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-compatibility.rs:4:22 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait - = help: only type `u32` implements the trait, consider using it directly instead + = help: only type `u32` 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.rs:14:13 | LL | let i = Box::new(42_u32) as Box; - | ^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-compatibility.rs:4:22 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait - = help: only type `u32` implements the trait, consider using it directly instead + = help: only type `u32` implements `Foo`; consider using it directly instead. = note: required for the cast from `Box` to `Box` error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs b/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs index 600dba03b74b9..5b891170a4f10 100644 --- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.rs @@ -4,5 +4,5 @@ extern crate rpitit; fn main() { let _: &dyn rpitit::Foo = todo!(); - //~^ ERROR the trait `Foo` cannot be made into an object + //~^ ERROR the trait `Foo` is not dyn compatible } diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr index 895d8686742b3..07d09468b0462 100644 --- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr @@ -1,15 +1,16 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/foreign-dyn-error.rs:6:12 | LL | let _: &dyn rpitit::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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/auxiliary/rpitit.rs:4:21 | LL | fn bar(self) -> impl Deref; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because method `bar` references an `impl Trait` type in its return type - = help: only type `rpitit::Foreign` implements the trait, consider using it directly instead + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait is not dyn compatible because method `bar` references an `impl Trait` type in its return type + = help: only type `rpitit::Foreign` implements `Foo`; consider using it directly instead. error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-18959.stderr b/tests/ui/issues/issue-18959.stderr index 5bb452250aa40..49d501c397f14 100644 --- a/tests/ui/issues/issue-18959.stderr +++ b/tests/ui/issues/issue-18959.stderr @@ -1,77 +1,82 @@ -error[E0038]: the trait `Bar` cannot be made into an object +error[E0038]: the trait `Bar` is not dyn compatible --> $DIR/issue-18959.rs:11:12 | LL | fn foo(b: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } | ^^^ ...because method `foo` has generic type parameters LL | pub trait Bar: Foo { } - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait -error[E0038]: the trait `Bar` cannot be made into an object +error[E0038]: the trait `Bar` is not dyn compatible --> $DIR/issue-18959.rs:13:5 | LL | b.foo(&0) - | ^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } | ^^^ ...because method `foo` has generic type parameters LL | pub trait Bar: Foo { } - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait -error[E0038]: the trait `Bar` cannot be made into an object +error[E0038]: the trait `Bar` is not dyn compatible --> $DIR/issue-18959.rs:19:15 | LL | let test: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } | ^^^ ...because method `foo` has generic type parameters LL | pub trait Bar: Foo { } - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait -error[E0038]: the trait `Bar` cannot be made into an object +error[E0038]: the trait `Bar` is not dyn compatible --> $DIR/issue-18959.rs:19:26 | LL | let test: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } | ^^^ ...because method `foo` has generic type parameters LL | pub trait Bar: Foo { } - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait = note: required for the cast from `&mut Thing` to `&dyn Bar` -error[E0038]: the trait `Bar` cannot be made into an object +error[E0038]: the trait `Bar` is not dyn compatible --> $DIR/issue-18959.rs:22:9 | LL | foo(test); - | ^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-18959.rs:1:20 | LL | pub trait Foo { fn foo(&self, ext_thing: &T); } | ^^^ ...because method `foo` has generic type parameters LL | pub trait Bar: Foo { } - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait error: aborting due to 5 previous errors diff --git a/tests/ui/issues/issue-19380.stderr b/tests/ui/issues/issue-19380.stderr index afbe67befa1ab..7d4812c36935b 100644 --- a/tests/ui/issues/issue-19380.stderr +++ b/tests/ui/issues/issue-19380.stderr @@ -1,17 +1,18 @@ -error[E0038]: the trait `Qiz` cannot be made into an object +error[E0038]: the trait `Qiz` is not dyn compatible --> $DIR/issue-19380.rs:11:29 | LL | foos: &'static [&'static (dyn Qiz + 'static)] - | ^^^^^^^^^^^^^^^^^ `Qiz` cannot be made into an object + | ^^^^^^^^^^^^^^^^^ `Qiz` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-19380.rs:2:6 | LL | trait Qiz { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn qiz(); | ^^^ ...because associated function `qiz` has no `self` parameter - = help: only type `Foo` implements the trait, consider using it directly instead + = help: only type `Foo` implements `Qiz`; consider using it directly instead. help: consider turning `qiz` into a method by giving it a `&self` argument | LL | fn qiz(&self); @@ -21,20 +22,21 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o LL | fn qiz() where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `Qiz` cannot be made into an object +error[E0038]: the trait `Qiz` is not dyn compatible --> $DIR/issue-19380.rs:16:33 | LL | const BAR : Bar = Bar { foos: &[&FOO]}; - | ^^^^ `Qiz` cannot be made into an object + | ^^^^ `Qiz` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-19380.rs:2:6 | LL | trait Qiz { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn qiz(); | ^^^ ...because associated function `qiz` has no `self` parameter - = help: only type `Foo` implements the trait, consider using it directly instead + = help: only type `Foo` implements `Qiz`; consider using it directly instead. = note: required for the cast from `&Foo` to `&'static (dyn Qiz + 'static)` help: consider turning `qiz` into a method by giving it a `&self` argument | @@ -45,20 +47,21 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o LL | fn qiz() where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `Qiz` cannot be made into an object +error[E0038]: the trait `Qiz` is not dyn compatible --> $DIR/issue-19380.rs:16:31 | LL | const BAR : Bar = Bar { foos: &[&FOO]}; - | ^^^^^^^ `Qiz` cannot be made into an object + | ^^^^^^^ `Qiz` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-19380.rs:2:6 | LL | trait Qiz { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn qiz(); | ^^^ ...because associated function `qiz` has no `self` parameter - = help: only type `Foo` implements the trait, consider using it directly instead + = help: only type `Foo` implements `Qiz`; consider using it directly instead. help: consider turning `qiz` into a method by giving it a `&self` argument | LL | fn qiz(&self); diff --git a/tests/ui/issues/issue-26056.stderr b/tests/ui/issues/issue-26056.stderr index c5ae41200f6e0..d1cdf43351ec7 100644 --- a/tests/ui/issues/issue-26056.stderr +++ b/tests/ui/issues/issue-26056.stderr @@ -1,16 +1,17 @@ -error[E0038]: the trait `Map` cannot be made into an object +error[E0038]: the trait `Map` is not dyn compatible --> $DIR/issue-26056.rs:20:17 | LL | as &dyn Map; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `Map` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^^^^^ `Map` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-26056.rs:9:12 | LL | trait Map: MapLookup<::Key> { | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-33941.stderr b/tests/ui/issues/issue-33941.current.stderr similarity index 93% rename from tests/ui/issues/issue-33941.stderr rename to tests/ui/issues/issue-33941.current.stderr index 9535ea57430d0..d653bbd327427 100644 --- a/tests/ui/issues/issue-33941.stderr +++ b/tests/ui/issues/issue-33941.current.stderr @@ -1,5 +1,5 @@ error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` - --> $DIR/issue-33941.rs:6:36 + --> $DIR/issue-33941.rs:9:36 | LL | for _ in HashMap::new().iter().cloned() {} | ^^^^^^ expected `&_`, found `(&_, &_)` @@ -7,7 +7,7 @@ LL | for _ in HashMap::new().iter().cloned() {} = note: expected reference `&_` found tuple `(&_, &_)` note: the method call chain might not have had the expected associated types - --> $DIR/issue-33941.rs:6:29 + --> $DIR/issue-33941.rs:9:29 | LL | for _ in HashMap::new().iter().cloned() {} | -------------- ^^^^^^ `Iterator::Item` is `(&_, &_)` here @@ -17,7 +17,7 @@ note: required by a bound in `cloned` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` - --> $DIR/issue-33941.rs:6:14 + --> $DIR/issue-33941.rs:9:14 | LL | for _ in HashMap::new().iter().cloned() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `(&_, &_)` diff --git a/tests/ui/issues/issue-33941.next.stderr b/tests/ui/issues/issue-33941.next.stderr new file mode 100644 index 0000000000000..a5a6e51545a58 --- /dev/null +++ b/tests/ui/issues/issue-33941.next.stderr @@ -0,0 +1,25 @@ +error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + --> $DIR/issue-33941.rs:9:36 + | +LL | for _ in HashMap::new().iter().cloned() {} + | ^^^^^^ expected `&_`, found `(&_, &_)` + | + = note: expected reference `&_` + found tuple `(&_, &_)` +note: required by a bound in `cloned` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + --> $DIR/issue-33941.rs:9:14 + | +LL | for _ in HashMap::new().iter().cloned() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `(&_, &_)` + | + = note: expected reference `&_` + found tuple `(&_, &_)` + = note: required for `Cloned>` to implement `Iterator` + = note: required for `Cloned>` to implement `IntoIterator` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/issues/issue-33941.rs b/tests/ui/issues/issue-33941.rs index 7b5be30834b9d..b0736204a0811 100644 --- a/tests/ui/issues/issue-33941.rs +++ b/tests/ui/issues/issue-33941.rs @@ -1,8 +1,12 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver //@ compile-flags: -Zdeduplicate-diagnostics=yes use std::collections::HashMap; fn main() { - for _ in HashMap::new().iter().cloned() {} //~ ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + for _ in HashMap::new().iter().cloned() {} //~^ ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` + //~| ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` } diff --git a/tests/ui/issues/issue-50781.rs b/tests/ui/issues/issue-50781.rs index 32253c3c23608..ab90db1cadcf2 100644 --- a/tests/ui/issues/issue-50781.rs +++ b/tests/ui/issues/issue-50781.rs @@ -9,11 +9,11 @@ impl X for () { } impl Trait for dyn X {} -//~^ ERROR the trait `X` cannot be made into an object +//~^ ERROR the trait `X` is not dyn compatible pub fn main() { // Check that this does not segfault. ::foo(&()); - //~^ ERROR the trait `X` cannot be made into an object - //~| ERROR the trait `X` cannot be made into an object + //~^ ERROR the trait `X` is not dyn compatible + //~| ERROR the trait `X` is not dyn compatible } diff --git a/tests/ui/issues/issue-50781.stderr b/tests/ui/issues/issue-50781.stderr index 3e54a53aa95f8..293e9839944a6 100644 --- a/tests/ui/issues/issue-50781.stderr +++ b/tests/ui/issues/issue-50781.stderr @@ -1,51 +1,54 @@ -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/issue-50781.rs:11:16 | LL | impl Trait for dyn X {} - | ^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-50781.rs:4:8 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | fn foo(&self) where Self: Trait; | ^^^ ...because method `foo` references the `Self` type in its `where` clause = help: consider moving `foo` to another trait - = help: only type `()` implements the trait, consider using it directly instead + = help: only type `()` implements `X`; consider using it directly instead. -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/issue-50781.rs:16:23 | LL | ::foo(&()); - | ^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-50781.rs:4:8 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | fn foo(&self) where Self: Trait; | ^^^ ...because method `foo` references the `Self` type in its `where` clause = help: consider moving `foo` to another trait - = help: only type `()` implements the trait, consider using it directly instead + = help: only type `()` implements `X`; consider using it directly instead. = note: required for the cast from `&()` to `&dyn X` -error[E0038]: the trait `X` cannot be made into an object +error[E0038]: the trait `X` is not dyn compatible --> $DIR/issue-50781.rs:16:6 | LL | ::foo(&()); - | ^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-50781.rs:4:8 | LL | trait X { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | fn foo(&self) where Self: Trait; | ^^^ ...because method `foo` references the `Self` type in its `where` clause = help: consider moving `foo` to another trait - = help: only type `()` implements the trait, consider using it directly instead + = help: only type `()` implements `X`; consider using it directly instead. error: aborting due to 3 previous errors diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr index c392879db3ebb..83446fc9ec0fa 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr @@ -19,33 +19,35 @@ note: required by a bound in `take_param` LL | fn take_param(foo: &T) { } | ^^^ required by this bound in `take_param` -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/kindck-inherited-copy-bound.rs:28:19 | LL | let z = &x as &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/kindck-inherited-copy-bound.rs:10:13 | LL | trait Foo : Copy { | --- ^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/kindck-inherited-copy-bound.rs:28:13 | LL | let z = &x as &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/kindck-inherited-copy-bound.rs:10:13 | LL | trait Foo : Copy { | --- ^^^^ ...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 `&Box<{integer}>` to `&dyn Foo` error: aborting due to 3 previous errors diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.dyn_compatible_for_dispatch.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.dyn_compatible_for_dispatch.stderr index 34dcad13af30b..271e5afb9e7ec 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.dyn_compatible_for_dispatch.stderr @@ -19,19 +19,20 @@ note: required by a bound in `take_param` LL | fn take_param(foo: &T) { } | ^^^ required by this bound in `take_param` -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/kindck-inherited-copy-bound.rs:28:13 | LL | let z = &x as &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/kindck-inherited-copy-bound.rs:10:13 | LL | trait Foo : Copy { | --- ^^^^ ...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 `&Box` to `&dyn Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs index 37d94830db2cf..2a27164f9cba2 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs @@ -1,4 +1,6 @@ -//@ compile-flags: --test +// -Zpanic_abort_tests makes this test work on panic=abort targets and +// it's a no-op on panic=unwind targets +//@ compile-flags: --test -Zpanic_abort_tests //@ run-pass #![feature(core_intrinsics, generic_assert)] diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs index 86cc7adb90de6..254d59076e531 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs @@ -1,4 +1,6 @@ -//@ compile-flags: --test +// -Zpanic_abort_tests makes this test work on panic=abort targets and +// it's a no-op on panic=unwind targets +//@ compile-flags: --test -Zpanic_abort_tests // ignore-tidy-linelength //@ run-pass diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed new file mode 100644 index 0000000000000..7383ab177dc31 --- /dev/null +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed @@ -0,0 +1,12 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[current] run-rustfix +fn main() { + let _ = (-10..=10).find(|x: &i32| x.signum() == 0); + //[current]~^ ERROR type mismatch in closure arguments + //[next]~^^ ERROR expected a `FnMut(& as Iterator>::Item)` closure, found + let _ = (-10..=10).find(|x: &i32| x.signum() == 0); + //[current]~^ ERROR type mismatch in closure arguments + //[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` +} diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.stderr similarity index 92% rename from tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr rename to tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.stderr index e52e095e9f729..c35d70a635cbd 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.stderr @@ -1,5 +1,5 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch-issue-45727.rs:3:24 + --> $DIR/closure-arg-type-mismatch-issue-45727.rs:6:24 | LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); | ^^^^ -------- found signature defined here @@ -16,7 +16,7 @@ LL | let _ = (-10..=10).find(|x: &i32| x.signum() == 0); | + error[E0631]: type mismatch in closure arguments - --> $DIR/closure-arg-type-mismatch-issue-45727.rs:4:24 + --> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:24 | LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); | ^^^^ ----------- found signature defined here diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.fixed b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.fixed deleted file mode 100644 index e6e3e1551e959..0000000000000 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.fixed +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-rustfix -fn main() { - let _ = (-10..=10).find(|x: &i32| x.signum() == 0); //~ ERROR type mismatch in closure arguments - let _ = (-10..=10).find(|x: &i32| x.signum() == 0); //~ ERROR type mismatch in closure arguments -} diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr new file mode 100644 index 0000000000000..6104a08933737 --- /dev/null +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr @@ -0,0 +1,24 @@ +error[E0277]: expected a `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + --> $DIR/closure-arg-type-mismatch-issue-45727.rs:6:29 + | +LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(& as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + | | + | required by a bound introduced by this call + | + = help: the trait `for<'a> FnMut(&'a as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + = note: expected a closure with arguments `(i32,)` + found a closure with arguments `(& as Iterator>::Item,)` +note: required by a bound in `find` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error[E0271]: expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` + --> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:33 + | +LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); + | ^^^^^^ expected `&&i32`, found integer + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs index 64e815606d427..668a1a7a29c6f 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs @@ -1,5 +1,12 @@ -//@ run-rustfix +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[current] run-rustfix fn main() { - let _ = (-10..=10).find(|x: i32| x.signum() == 0); //~ ERROR type mismatch in closure arguments - let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); //~ ERROR type mismatch in closure arguments + let _ = (-10..=10).find(|x: i32| x.signum() == 0); + //[current]~^ ERROR type mismatch in closure arguments + //[next]~^^ ERROR expected a `FnMut(& as Iterator>::Item)` closure, found + let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); + //[current]~^ ERROR type mismatch in closure arguments + //[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` } diff --git a/tests/ui/resolve/issue-3907-2.stderr b/tests/ui/resolve/issue-3907-2.stderr index 7c47c5973e313..4ab72a42eb84b 100644 --- a/tests/ui/resolve/issue-3907-2.stderr +++ b/tests/ui/resolve/issue-3907-2.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `issue_3907::Foo` cannot be made into an object +error[E0038]: the trait `issue_3907::Foo` is not dyn compatible --> $DIR/issue-3907-2.rs:11:12 | LL | fn bar(_x: Foo) {} - | ^^^ `issue_3907::Foo` cannot be made into an object + | ^^^ `issue_3907::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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/auxiliary/issue-3907.rs:2:8 | LL | fn bar(); - | ^^^ the trait cannot be made into an object because associated function `bar` has no `self` parameter + | ^^^ the trait is not dyn compatible because associated function `bar` has no `self` parameter error[E0277]: the size for values of type `(dyn issue_3907::Foo + 'static)` cannot be known at compilation time --> $DIR/issue-3907-2.rs:11:12 diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.curr.stderr b/tests/ui/self/arbitrary-self-types-dyn-incompatible.curr.stderr index 2eb7597d5c105..3e018995ba55d 100644 --- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.curr.stderr +++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.curr.stderr @@ -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/arbitrary-self-types-dyn-incompatible.rs:33:32 | LL | fn foo(self: &Rc) -> usize; | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` ... LL | let x = Rc::new(5usize) as Rc; - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/arbitrary-self-types-dyn-incompatible.rs:8:18 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn foo(self: &Rc) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = help: only type `usize` implements the trait, consider using it directly instead + = help: only type `usize` 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/arbitrary-self-types-dyn-incompatible.rs:33:13 | LL | fn foo(self: &Rc) -> usize; | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` ... LL | let x = Rc::new(5usize) as Rc; - | ^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/arbitrary-self-types-dyn-incompatible.rs:8:18 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn foo(self: &Rc) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = help: only type `usize` implements the trait, consider using it directly instead + = help: only type `usize` implements `Foo`; consider using it directly instead. = note: required for the cast from `Rc` to `Rc` error: aborting due to 2 previous errors diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr b/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr index 02af692c4a352..12c93d58537ee 100644 --- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr @@ -1,20 +1,21 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/arbitrary-self-types-dyn-incompatible.rs:33:13 | LL | fn foo(self: &Rc) -> usize; | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` ... LL | let x = Rc::new(5usize) as Rc; - | ^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/arbitrary-self-types-dyn-incompatible.rs:8:18 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn foo(self: &Rc) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = help: only type `usize` implements the trait, consider using it directly instead + = help: only type `usize` implements `Foo`; consider using it directly instead. = note: required for the cast from `Rc` to `Rc` error: aborting due to 1 previous error diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.rs b/tests/ui/statics/unsizing-wfcheck-issue-127299.rs index cd15be54ec785..fd07937d90f24 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.rs +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.rs @@ -6,12 +6,12 @@ trait Qux { pub struct Lint { pub desc: &'static dyn Qux, - //~^ ERROR cannot be made into an object + //~^ ERROR is not dyn compatible } static FOO: &Lint = &Lint { desc: "desc" }; //~^ ERROR cannot be shared between threads safely -//~| ERROR cannot be made into an object -//~| ERROR cannot be made into an object +//~| ERROR is not dyn compatible +//~| ERROR is not dyn compatible fn main() {} diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr index 35dd570e91fbb..08c744979f5c3 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr @@ -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/unsizing-wfcheck-issue-127299.rs:8:24 | LL | pub desc: &'static dyn Qux, - | ^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/unsizing-wfcheck-issue-127299.rs:4:8 | LL | trait Qux { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn bar() -> i32; | ^^^ ...because associated function `bar` has no `self` parameter help: consider turning `bar` into a method by giving it a `&self` argument @@ -36,17 +37,18 @@ LL | pub struct Lint { = note: required because it appears within the type `&'static Lint` = note: shared static variables must have a type that implements `Sync` -error[E0038]: the trait `Qux` cannot be made into an object +error[E0038]: the trait `Qux` is not dyn compatible --> $DIR/unsizing-wfcheck-issue-127299.rs:12:35 | LL | static FOO: &Lint = &Lint { desc: "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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/unsizing-wfcheck-issue-127299.rs:4:8 | LL | trait Qux { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn bar() -> i32; | ^^^ ...because associated function `bar` has no `self` parameter = note: required for the cast from `&'static str` to `&'static (dyn Qux + 'static)` @@ -59,17 +61,18 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o LL | fn bar() -> i32 where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `Qux` cannot be made into an object +error[E0038]: the trait `Qux` is not dyn compatible --> $DIR/unsizing-wfcheck-issue-127299.rs:12:35 | LL | static FOO: &Lint = &Lint { desc: "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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/unsizing-wfcheck-issue-127299.rs:4:8 | LL | trait Qux { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn bar() -> i32; | ^^^ ...because associated function `bar` has no `self` parameter help: consider turning `bar` into a method by giving it a `&self` argument diff --git a/tests/ui/suggestions/dyn-incompatible-trait-references-self.rs b/tests/ui/suggestions/dyn-incompatible-trait-references-self.rs index 4b3d5faba4655..66b435247d40d 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-references-self.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-references-self.rs @@ -6,10 +6,10 @@ trait Trait { //~| ERROR the size for values of type `Self` cannot be known } -fn bar(x: &dyn Trait) {} //~ ERROR the trait `Trait` cannot be made into an object +fn bar(x: &dyn Trait) {} //~ ERROR the trait `Trait` is not dyn compatible trait Other: Sized {} -fn foo(x: &dyn Other) {} //~ ERROR the trait `Other` cannot be made into an object +fn foo(x: &dyn Other) {} //~ ERROR the trait `Other` is not dyn compatible fn main() {} diff --git a/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr b/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr index 242c44abd9d66..cb0e7fce91043 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/dyn-incompatible-trait-references-self.rs:9:12 | LL | fn bar(x: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-references-self.rs:2:22 | LL | trait Trait { - | ----- 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 this parameter LL | @@ -17,19 +18,20 @@ LL | fn bat(&self) -> Self {} = help: consider moving `baz` to another trait = help: consider moving `bat` to another trait -error[E0038]: the trait `Other` cannot be made into an object +error[E0038]: the trait `Other` is not dyn compatible --> $DIR/dyn-incompatible-trait-references-self.rs:13:12 | LL | fn foo(x: &dyn Other) {} - | ^^^^^^^^^ `Other` cannot be made into an object + | ^^^^^^^^^ `Other` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-references-self.rs:11:14 | LL | trait Other: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/dyn-incompatible-trait-references-self.rs:2:22 diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs index 4ab10f40eb68d..747926c400ae0 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs @@ -3,12 +3,12 @@ trait A: Sized { fn f(a: dyn A) -> dyn A; //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `A` cannot be made into an object + //~| ERROR the trait `A` is not dyn compatible } trait B { fn f(a: dyn B) -> dyn B; //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `B` cannot be made into an object + //~| ERROR the trait `B` is not dyn compatible } trait C { fn f(&self, a: dyn C) -> dyn C; diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr index 5e0d1a1445230..2efcad1e7bd39 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr @@ -11,19 +11,20 @@ help: you might have meant to use `Self` to refer to the implementing type LL | fn f(a: Self) -> Self; | ~~~~ ~~~~ -error[E0038]: the trait `A` cannot be made into an object +error[E0038]: the trait `A` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:4:13 | LL | fn f(a: dyn A) -> dyn 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:3:10 | LL | trait A: Sized { | - ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error: associated item referring to unboxed trait object for its own trait --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:9:13 @@ -38,17 +39,18 @@ help: you might have meant to use `Self` to refer to the implementing type LL | fn f(a: Self) -> Self; | ~~~~ ~~~~ -error[E0038]: the trait `B` cannot be made into an object +error[E0038]: the trait `B` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:9:13 | LL | fn f(a: dyn B) -> dyn 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:9:8 | LL | trait B { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | fn f(a: dyn B) -> dyn B; | ^ ...because associated function `f` has no `self` parameter help: consider turning `f` into a method by giving it a `&self` argument diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs index 75f99075eb18f..2893bbc8b7139 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs @@ -2,12 +2,12 @@ trait A: Sized { fn f(a: A) -> A; //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `A` cannot be made into an object + //~| ERROR the trait `A` is not dyn compatible } trait B { fn f(a: B) -> B; //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `B` cannot be made into an object + //~| ERROR the trait `B` is not dyn compatible } trait C { fn f(&self, a: C) -> C; diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr index 93f6ea2b12e67..ecb3ee9185f9b 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr @@ -11,19 +11,20 @@ help: you might have meant to use `Self` to refer to the implementing type LL | fn f(a: Self) -> Self; | ~~~~ ~~~~ -error[E0038]: the trait `A` cannot be made into an object +error[E0038]: the trait `A` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13 | LL | 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-should-use-self.rs:2:10 | LL | trait A: Sized { | - ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error: associated item referring to unboxed trait object for its own trait --> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13 @@ -38,17 +39,18 @@ help: you might have meant to use `Self` to refer to the implementing type LL | fn f(a: Self) -> Self; | ~~~~ ~~~~ -error[E0038]: the trait `B` cannot be made into an object +error[E0038]: the trait `B` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13 | LL | fn f(a: 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-should-use-self.rs:8:8 | LL | trait B { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | fn f(a: B) -> B; | ^ ...because associated function `f` has no `self` parameter help: consider turning `f` into a method by giving it a `&self` argument diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.fixed b/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.fixed index fd9b78934c7da..2b26d8cc82ee3 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.fixed +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.fixed @@ -6,7 +6,7 @@ trait Trait { fn bar(self: &Self) {} //~ ERROR invalid `self` parameter type } -fn bar(x: &dyn Trait) {} //~ ERROR the trait `Trait` cannot be made into an object +fn bar(x: &dyn Trait) {} //~ ERROR the trait `Trait` is not dyn compatible trait Other {} diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.rs index e4aa0d892391b..b0b02dedb2b90 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.rs @@ -6,7 +6,7 @@ trait Trait { fn bar(self: ()) {} //~ ERROR invalid `self` parameter type } -fn bar(x: &dyn Trait) {} //~ ERROR the trait `Trait` cannot be made into an object +fn bar(x: &dyn Trait) {} //~ ERROR the trait `Trait` is not dyn compatible trait Other {} diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.stderr index beafd7c2ab00f..696840d3ba42f 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-where-sized.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-where-sized.rs:9:12 | LL | fn bar(x: &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/dyn-incompatible-trait-should-use-where-sized.rs:5:8 | LL | trait Trait { - | ----- this trait cannot be made into an object... + | ----- this trait is not dyn compatible... LL | fn foo() where Self: Other, { } | ^^^ ...because associated function `foo` has no `self` parameter LL | fn bar(self: ()) {} diff --git a/tests/ui/suggestions/issue-116434-2015.rs b/tests/ui/suggestions/issue-116434-2015.rs index 2e94473eb1a12..1518765152ff8 100644 --- a/tests/ui/suggestions/issue-116434-2015.rs +++ b/tests/ui/suggestions/issue-116434-2015.rs @@ -7,7 +7,7 @@ trait Foo { //~| WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| HELP if this is a dyn-compatible trait, use `dyn` - //~| ERROR the trait `Clone` cannot be made into an object [E0038] + //~| ERROR the trait `Clone` is not dyn compatible [E0038] //~| HELP there is an associated type with the same name } @@ -22,7 +22,7 @@ trait DbInterface { //~| WARNING trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| HELP if this is a dyn-compatible trait, use `dyn` - //~| ERROR the trait `DbHandle` cannot be made into an object [E0038] + //~| ERROR the trait `DbHandle` is not dyn compatible [E0038] //~| HELP there is an associated type with the same name } diff --git a/tests/ui/suggestions/issue-116434-2015.stderr b/tests/ui/suggestions/issue-116434-2015.stderr index 24fc87f765f80..508c3ec5e4fd3 100644 --- a/tests/ui/suggestions/issue-116434-2015.stderr +++ b/tests/ui/suggestions/issue-116434-2015.stderr @@ -39,14 +39,15 @@ help: if this is a dyn-compatible trait, use `dyn` LL | fn foo() -> dyn Clone; | +++ -error[E0038]: the trait `Clone` cannot be made into an object +error[E0038]: the trait `Clone` is not dyn compatible --> $DIR/issue-116434-2015.rs:3:17 | LL | fn foo() -> Clone; - | ^^^^^ `Clone` cannot be made into an object + | ^^^^^ `Clone` 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 + = 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 help: there is an associated type with the same name | LL | fn foo() -> Self::Clone; @@ -66,19 +67,20 @@ help: if this is a dyn-compatible trait, use `dyn` LL | fn handle() -> dyn DbHandle; | +++ -error[E0038]: the trait `DbHandle` cannot be made into an object +error[E0038]: the trait `DbHandle` is not dyn compatible --> $DIR/issue-116434-2015.rs:18:20 | LL | fn handle() -> DbHandle; - | ^^^^^^^^ `DbHandle` cannot be made into an object + | ^^^^^^^^ `DbHandle` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-116434-2015.rs:14:17 | LL | trait DbHandle: Sized {} | -------- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... help: there is an associated type with the same name | LL | fn handle() -> Self::DbHandle; diff --git a/tests/ui/suggestions/issue-98500.rs b/tests/ui/suggestions/issue-98500.rs index 289b16abf4b37..869b665c8cbb7 100644 --- a/tests/ui/suggestions/issue-98500.rs +++ b/tests/ui/suggestions/issue-98500.rs @@ -9,6 +9,6 @@ pub trait B where } struct S(Box); -//~^ ERROR the trait `B` cannot be made into an object +//~^ ERROR the trait `B` is not dyn compatible fn main() {} diff --git a/tests/ui/suggestions/issue-98500.stderr b/tests/ui/suggestions/issue-98500.stderr index d7136ec1a649f..97b712acfcbea 100644 --- a/tests/ui/suggestions/issue-98500.stderr +++ b/tests/ui/suggestions/issue-98500.stderr @@ -1,10 +1,11 @@ -error[E0038]: the trait `B` cannot be made into an object +error[E0038]: the trait `B` is not dyn compatible --> $DIR/issue-98500.rs:11:14 | LL | struct S(Box); - | ^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/auxiliary/dyn-incompatible.rs:4:8 | LL | fn f(); @@ -15,7 +16,7 @@ LL | fn f2(self: &Arc); ::: $DIR/issue-98500.rs:5:11 | LL | pub trait B where - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... = help: consider moving `f` to another trait = help: consider moving `f2` to another trait diff --git a/tests/ui/traits/alias/generic-default-in-dyn.rs b/tests/ui/traits/alias/generic-default-in-dyn.rs index b180f0a68031e..b263e578c31d2 100644 --- a/tests/ui/traits/alias/generic-default-in-dyn.rs +++ b/tests/ui/traits/alias/generic-default-in-dyn.rs @@ -2,9 +2,9 @@ trait SendEqAlias = PartialEq; //~^ ERROR trait aliases are experimental struct Foo(dyn SendEqAlias); -//~^ ERROR the trait alias `SendEqAlias` cannot be made into an object +//~^ ERROR the trait alias `SendEqAlias` is not dyn compatible struct Bar(dyn SendEqAlias, T); -//~^ ERROR the trait alias `SendEqAlias` cannot be made into an object +//~^ ERROR the trait alias `SendEqAlias` is not dyn compatible fn main() {} diff --git a/tests/ui/traits/alias/generic-default-in-dyn.stderr b/tests/ui/traits/alias/generic-default-in-dyn.stderr index 902d18de9448b..1ab9e6d5c5ca0 100644 --- a/tests/ui/traits/alias/generic-default-in-dyn.stderr +++ b/tests/ui/traits/alias/generic-default-in-dyn.stderr @@ -8,33 +8,35 @@ LL | trait SendEqAlias = PartialEq; = help: add `#![feature(trait_alias)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0038]: the trait alias `SendEqAlias` cannot be made into an object +error[E0038]: the trait alias `SendEqAlias` is not dyn compatible --> $DIR/generic-default-in-dyn.rs:4:19 | LL | struct Foo(dyn SendEqAlias); - | ^^^^^^^^^^^^^^ `SendEqAlias` cannot be made into an object + | ^^^^^^^^^^^^^^ `SendEqAlias` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/generic-default-in-dyn.rs:1:24 | LL | trait SendEqAlias = PartialEq; | ----------- ^^^^^^^^^ ...because it uses `Self` as a type parameter | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... -error[E0038]: the trait alias `SendEqAlias` cannot be made into an object +error[E0038]: the trait alias `SendEqAlias` is not dyn compatible --> $DIR/generic-default-in-dyn.rs:7:19 | LL | struct Bar(dyn SendEqAlias, T); - | ^^^^^^^^^^^^^^ `SendEqAlias` cannot be made into an object + | ^^^^^^^^^^^^^^ `SendEqAlias` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/generic-default-in-dyn.rs:1:24 | LL | trait SendEqAlias = PartialEq; | ----------- ^^^^^^^^^ ...because it uses `Self` as a type parameter | | - | this trait cannot be made into an object... + | this trait is not dyn compatible... error: aborting due to 3 previous errors diff --git a/tests/ui/traits/alias/object-fail.rs b/tests/ui/traits/alias/object-fail.rs index 38da7b8eef400..9a1cbad53e71b 100644 --- a/tests/ui/traits/alias/object-fail.rs +++ b/tests/ui/traits/alias/object-fail.rs @@ -5,7 +5,7 @@ trait IteratorAlias = Iterator; fn main() { let _: &dyn EqAlias = &123; - //~^ ERROR the trait alias `EqAlias` cannot be made into an object [E0038] + //~^ ERROR the trait alias `EqAlias` is not dyn compatible [E0038] let _: &dyn IteratorAlias = &vec![123].into_iter(); //~^ ERROR must be specified } diff --git a/tests/ui/traits/alias/object-fail.stderr b/tests/ui/traits/alias/object-fail.stderr index e4968ee2adc41..52ce79a45973e 100644 --- a/tests/ui/traits/alias/object-fail.stderr +++ b/tests/ui/traits/alias/object-fail.stderr @@ -1,10 +1,11 @@ -error[E0038]: the trait alias `EqAlias` cannot be made into an object +error[E0038]: the trait alias `EqAlias` is not dyn compatible --> $DIR/object-fail.rs:7:17 | LL | let _: &dyn EqAlias = &123; - | ^^^^^^^ `EqAlias` cannot be made into an object + | ^^^^^^^ `EqAlias` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: ...because it uses `Self` as a type parameter @@ -12,7 +13,7 @@ note: for a trait to be "dyn-compatible" it needs to allow building a vtable to ::: $DIR/object-fail.rs:3:7 | LL | trait EqAlias = Eq; - | ------- this trait cannot be made into an object... + | ------- this trait is not dyn compatible... error[E0191]: the value of the associated type `Item` in `Iterator` must be specified --> $DIR/object-fail.rs:9:17 diff --git a/tests/ui/traits/alias/self-in-const-generics.rs b/tests/ui/traits/alias/self-in-const-generics.rs index b0de8ccd67847..a7d0ac9cbb4c2 100644 --- a/tests/ui/traits/alias/self-in-const-generics.rs +++ b/tests/ui/traits/alias/self-in-const-generics.rs @@ -7,6 +7,6 @@ trait Bar {} trait BB = Bar<{ 2 + 1 }>; fn foo(x: &dyn BB) {} -//~^ ERROR the trait alias `BB` cannot be made into an object [E0038] +//~^ ERROR the trait alias `BB` is not dyn compatible [E0038] fn main() {} diff --git a/tests/ui/traits/alias/self-in-const-generics.stderr b/tests/ui/traits/alias/self-in-const-generics.stderr index 6dd6fabe7b203..3c799492591a2 100644 --- a/tests/ui/traits/alias/self-in-const-generics.stderr +++ b/tests/ui/traits/alias/self-in-const-generics.stderr @@ -1,16 +1,17 @@ -error[E0038]: the trait alias `BB` cannot be made into an object +error[E0038]: the trait alias `BB` is not dyn compatible --> $DIR/self-in-const-generics.rs:9:16 | LL | fn foo(x: &dyn BB) {} - | ^^ `BB` cannot be made into an object + | ^^ `BB` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/self-in-const-generics.rs:7:12 | LL | trait BB = Bar<{ 2 + 1 }>; | -- ^^^^^^^^^^^^^^ ...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 foo(x: &impl BB) {} diff --git a/tests/ui/traits/alias/self-in-generics.rs b/tests/ui/traits/alias/self-in-generics.rs index 433b741532d6c..53752d9cede66 100644 --- a/tests/ui/traits/alias/self-in-generics.rs +++ b/tests/ui/traits/alias/self-in-generics.rs @@ -6,6 +6,6 @@ pub trait SelfInput = Fn(&mut Self); pub fn f(_f: &dyn SelfInput) {} -//~^ ERROR the trait alias `SelfInput` cannot be made into an object [E0038] +//~^ ERROR the trait alias `SelfInput` is not dyn compatible [E0038] fn main() {} diff --git a/tests/ui/traits/alias/self-in-generics.stderr b/tests/ui/traits/alias/self-in-generics.stderr index 4fbd979e5f53e..5639b2b44a18b 100644 --- a/tests/ui/traits/alias/self-in-generics.stderr +++ b/tests/ui/traits/alias/self-in-generics.stderr @@ -1,10 +1,11 @@ -error[E0038]: the trait alias `SelfInput` cannot be made into an object +error[E0038]: the trait alias `SelfInput` is not dyn compatible --> $DIR/self-in-generics.rs:8:19 | LL | pub fn f(_f: &dyn SelfInput) {} - | ^^^^^^^^^ `SelfInput` cannot be made into an object + | ^^^^^^^^^ `SelfInput` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/self-in-generics.rs:6:23 | LL | pub trait SelfInput = Fn(&mut Self); @@ -12,7 +13,7 @@ LL | pub trait SelfInput = Fn(&mut Self); | | | | | ...because it uses `Self` as a type parameter | | ...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 | pub fn f(_f: &impl SelfInput) {} diff --git a/tests/ui/traits/issue-20692.rs b/tests/ui/traits/issue-20692.rs index 1cb2d8c7302a0..10611a232f71c 100644 --- a/tests/ui/traits/issue-20692.rs +++ b/tests/ui/traits/issue-20692.rs @@ -2,10 +2,10 @@ trait Array: Sized + Copy {} fn f(x: &T) { let _ = x - //~^ ERROR `Array` cannot be made into an object + //~^ ERROR `Array` is not dyn compatible as &dyn Array; - //~^ ERROR `Array` cannot be made into an object + //~^ ERROR `Array` is not dyn compatible } fn main() {} diff --git a/tests/ui/traits/issue-20692.stderr b/tests/ui/traits/issue-20692.stderr index 5e6a967fdc4e9..50ea7cde96119 100644 --- a/tests/ui/traits/issue-20692.stderr +++ b/tests/ui/traits/issue-20692.stderr @@ -1,32 +1,34 @@ -error[E0038]: the trait `Array` cannot be made into an object +error[E0038]: the trait `Array` is not dyn compatible --> $DIR/issue-20692.rs:7:5 | LL | &dyn Array; - | ^^^^^^^^^^ `Array` cannot be made into an object + | ^^^^^^^^^^ `Array` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-20692.rs:1:14 | LL | trait Array: Sized + Copy {} | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized` | | | | | ...because it requires `Self: Sized` - | this trait cannot be made into an object... + | this trait is not dyn compatible... -error[E0038]: the trait `Array` cannot be made into an object +error[E0038]: the trait `Array` is not dyn compatible --> $DIR/issue-20692.rs:4:13 | LL | let _ = x - | ^ `Array` cannot be made into an object + | ^ `Array` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-20692.rs:1:14 | LL | trait Array: Sized + Copy {} | ----- ^^^^^ ^^^^ ...because it requires `Self: 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 Array` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/issue-28576.rs b/tests/ui/traits/issue-28576.rs index e19bd2635813e..fd026044401b6 100644 --- a/tests/ui/traits/issue-28576.rs +++ b/tests/ui/traits/issue-28576.rs @@ -6,7 +6,7 @@ pub trait Bar: Foo { //~^ ERROR: the size for values of type `Self` cannot be known //~| ERROR: the size for values of type `Self` cannot be known fn new(&self, b: & - dyn Bar //~ ERROR the trait `Bar` cannot be made into an object + dyn Bar //~ ERROR the trait `Bar` is not dyn compatible ); } diff --git a/tests/ui/traits/issue-28576.stderr b/tests/ui/traits/issue-28576.stderr index cb0d55dce5920..ba113d573d69f 100644 --- a/tests/ui/traits/issue-28576.stderr +++ b/tests/ui/traits/issue-28576.stderr @@ -18,15 +18,16 @@ help: consider relaxing the implicit `Sized` restriction LL | pub trait Foo { | ++++++++ -error[E0038]: the trait `Bar` cannot be made into an object +error[E0038]: the trait `Bar` is not dyn compatible --> $DIR/issue-28576.rs:9:16 | LL | dyn Bar | ________________^ LL | | - | |________________________^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-28576.rs:5:16 | LL | pub trait Bar: Foo { @@ -34,7 +35,7 @@ LL | pub trait Bar: Foo { | | | | | | | ...because it uses `Self` as a type parameter | | ...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 | impl Bar diff --git a/tests/ui/traits/issue-38404.rs b/tests/ui/traits/issue-38404.rs index 9b60116f733dc..36da594c01588 100644 --- a/tests/ui/traits/issue-38404.rs +++ b/tests/ui/traits/issue-38404.rs @@ -1,8 +1,8 @@ trait A: std::ops::Add + Sized {} trait B: A {} trait C: A> {} -//~^ ERROR the trait `B` cannot be made into an object -//~| ERROR the trait `B` cannot be made into an object -//~| ERROR the trait `B` cannot be made into an object +//~^ ERROR the trait `B` is not dyn compatible +//~| ERROR the trait `B` is not dyn compatible +//~| ERROR the trait `B` is not dyn compatible fn main() {} diff --git a/tests/ui/traits/issue-38404.stderr b/tests/ui/traits/issue-38404.stderr index 98d49fa3cba75..f9e592255dd75 100644 --- a/tests/ui/traits/issue-38404.stderr +++ b/tests/ui/traits/issue-38404.stderr @@ -1,45 +1,48 @@ -error[E0038]: the trait `B` cannot be made into an object +error[E0038]: the trait `B` is not dyn compatible --> $DIR/issue-38404.rs:3:19 | LL | trait C: A> {} - | ^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-38404.rs:1:13 | LL | trait A: std::ops::Add + Sized {} | ^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter LL | trait B: A {} - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... -error[E0038]: the trait `B` cannot be made into an object +error[E0038]: the trait `B` is not dyn compatible --> $DIR/issue-38404.rs:3:19 | LL | trait C: A> {} - | ^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-38404.rs:1:13 | LL | trait A: std::ops::Add + Sized {} | ^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter LL | trait B: A {} - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0038]: the trait `B` cannot be made into an object +error[E0038]: the trait `B` is not dyn compatible --> $DIR/issue-38404.rs:3:19 | LL | trait C: A> {} - | ^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-38404.rs:1:13 | LL | trait A: std::ops::Add + Sized {} | ^^^^^^^^^^^^^^^^^^^ ...because it uses `Self` as a type parameter LL | trait B: A {} - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 3 previous errors diff --git a/tests/ui/traits/issue-38604.rs b/tests/ui/traits/issue-38604.rs index 002a3c43fcba6..d90aa61ef9f33 100644 --- a/tests/ui/traits/issue-38604.rs +++ b/tests/ui/traits/issue-38604.rs @@ -11,6 +11,6 @@ impl Foo for () { } fn main() { - let _f: Box = //~ ERROR `Foo` cannot be made into an object - Box::new(()); //~ ERROR `Foo` cannot be made into an object + let _f: Box = //~ ERROR `Foo` is not dyn compatible + Box::new(()); //~ ERROR `Foo` is not dyn compatible } diff --git a/tests/ui/traits/issue-38604.stderr b/tests/ui/traits/issue-38604.stderr index 5c788b0c85d19..94f9c1540ad3b 100644 --- a/tests/ui/traits/issue-38604.stderr +++ b/tests/ui/traits/issue-38604.stderr @@ -1,32 +1,34 @@ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/issue-38604.rs:14:13 | LL | let _f: Box = - | ^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-38604.rs:2:22 | LL | trait Foo where u32: Q { | --- ^^^^^^^ ...because it uses `Self` as a type parameter | | - | this trait cannot be made into an object... - = help: only type `()` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = 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/issue-38604.rs:15:9 | LL | Box::new(()); - | ^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-38604.rs:2:22 | LL | trait Foo where u32: Q { | --- ^^^^^^^ ...because it uses `Self` as a type parameter | | - | this trait cannot be made into an object... - = help: only type `()` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `()` implements `Foo`; consider using it directly instead. = note: required for the cast from `Box<()>` to `Box` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/issue-72410.rs b/tests/ui/traits/issue-72410.rs index c95f1dfdca53a..df3738e2730d9 100644 --- a/tests/ui/traits/issue-72410.rs +++ b/tests/ui/traits/issue-72410.rs @@ -12,7 +12,7 @@ pub trait Foo { pub trait Bar { fn map() where for<'a> &'a mut [dyn Bar]: ; - //~^ ERROR: the trait `Bar` cannot be made into an object + //~^ ERROR: the trait `Bar` is not dyn compatible } fn main() {} diff --git a/tests/ui/traits/issue-72410.stderr b/tests/ui/traits/issue-72410.stderr index 6d56a198fc1c0..002345bff84dd 100644 --- a/tests/ui/traits/issue-72410.stderr +++ b/tests/ui/traits/issue-72410.stderr @@ -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-72410.rs:14:19 | LL | where for<'a> &'a mut [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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-72410.rs:13:8 | LL | pub trait Bar { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn map() | ^^^ ...because associated function `map` has no `self` parameter help: consider turning `map` into a method by giving it a `&self` argument diff --git a/tests/ui/traits/item-privacy.rs b/tests/ui/traits/item-privacy.rs index a3e1a22e7a83d..f5c741ccaa514 100644 --- a/tests/ui/traits/item-privacy.rs +++ b/tests/ui/traits/item-privacy.rs @@ -99,8 +99,8 @@ fn check_assoc_const() { S::C; // OK // A, B, C are resolved as inherent items, their traits don't need to be in scope ::A; //~ ERROR associated constant `A` is private - //~^ ERROR the trait `assoc_const::C` cannot be made into an object - ::B; // ERROR the trait `assoc_const::C` cannot be made into an object + //~^ ERROR the trait `assoc_const::C` is not dyn compatible + ::B; // ERROR the trait `assoc_const::C` is not dyn compatible C::C; // OK } diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index c20d2f723c598..c97158a5b760a 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -136,13 +136,14 @@ LL | const A: u8 = 0; LL | ::A; | ^ private associated constant -error[E0038]: the trait `assoc_const::C` cannot be made into an object +error[E0038]: the trait `assoc_const::C` is not dyn compatible --> $DIR/item-privacy.rs:101:6 | LL | ::A; - | ^^^^^ `assoc_const::C` cannot be made into an object + | ^^^^^ `assoc_const::C` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/item-privacy.rs:25:15 | LL | const A: u8 = 0; @@ -152,13 +153,13 @@ LL | const B: u8 = 0; | ^ ...because it contains this associated `const` ... LL | pub trait C: A + B { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | const C: u8 = 0; | ^ ...because it contains this associated `const` = help: consider moving `C` to another trait = help: consider moving `A` to another trait = help: consider moving `B` to another trait - = help: only type `S` implements the trait, consider using it directly instead + = help: only type `S` implements `assoc_const::C`; consider using it directly instead. error[E0223]: ambiguous associated type --> $DIR/item-privacy.rs:115:12 diff --git a/tests/ui/traits/missing-for-type-in-impl.e2015.stderr b/tests/ui/traits/missing-for-type-in-impl.e2015.stderr index 541b49b024fda..682d18842b887 100644 --- a/tests/ui/traits/missing-for-type-in-impl.e2015.stderr +++ b/tests/ui/traits/missing-for-type-in-impl.e2015.stderr @@ -34,17 +34,18 @@ help: you might have intended to implement this trait for a given type LL | impl Foo for /* Type */ { | ++++++++++++++ -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/missing-for-type-in-impl.rs:8:6 | LL | impl 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/missing-for-type-in-impl.rs:4:8 | LL | trait Foo { - | --- this trait cannot be made into an object... + | --- this trait is not dyn compatible... LL | fn id(me: T) -> T; | ^^ ...because associated function `id` has no `self` parameter help: consider turning `id` into a method by giving it a `&self` argument diff --git a/tests/ui/traits/missing-for-type-in-impl.rs b/tests/ui/traits/missing-for-type-in-impl.rs index e5dd365160984..e8163954274f2 100644 --- a/tests/ui/traits/missing-for-type-in-impl.rs +++ b/tests/ui/traits/missing-for-type-in-impl.rs @@ -11,7 +11,7 @@ impl Foo { //[e2015]~| WARNING trait objects without an explicit `dyn` are deprecated //[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! -//[e2015]~| ERROR the trait `Foo` cannot be made into an object +//[e2015]~| ERROR the trait `Foo` is not dyn compatible fn id(me: i64) -> i64 {me} } diff --git a/tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs b/tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs new file mode 100644 index 0000000000000..5cea9bb74d793 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs @@ -0,0 +1,28 @@ +//@ compile-flags: -Znext-solver + +// When encountering a fulfillment error from an `alias-relate` goal failing, we +// would previously manually construct a `normalizes-to` goal involving the alias +// and an infer var. This would then ICE as normalization would return a nested +// goal (the `T: Sized` from the `Trait` impl for `Foo` below) from the root goal +// which is not supported. + +struct Foo(T); + +trait Trait { + type Assoc; +} + +// `T: Sized` being explicit is not required, but the bound being present *is*. +impl Trait for Foo { + type Assoc = u64; +} + +fn bar>(_: T) {} + +fn main() { + let foo = Foo(Default::default()); + bar(foo); + //~^ ERROR: type mismatch resolving ` as Trait>::Assoc == u32` + // Here diagnostics would manually construct a ` as Trait>::Assoc normalizes-to ?x` goal + // which would return a nested goal of `?y: Sized` from the impl. +} diff --git a/tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.stderr b/tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.stderr new file mode 100644 index 0000000000000..ff3cbdb2c7841 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.stderr @@ -0,0 +1,17 @@ +error[E0271]: type mismatch resolving ` as Trait>::Assoc == u32` + --> $DIR/alias_relate_error_uses_structurally_normalize.rs:24:9 + | +LL | bar(foo); + | --- ^^^ expected `u32`, found `u64` + | | + | required by a bound introduced by this call + | +note: required by a bound in `bar` + --> $DIR/alias_relate_error_uses_structurally_normalize.rs:20:17 + | +LL | fn bar>(_: T) {} + | ^^^^^^^^^^^ required by this bound in `bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr new file mode 100644 index 0000000000000..a863886181cc5 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.current.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Foo: Trait` is not satisfied + --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:24:20 + | +LL | requires_trait(Foo); + | -------------- ^^^ the trait `Trait` is not implemented for `Foo` + | | + | required by a bound introduced by this call + | +note: required by a bound in `requires_trait` + --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:19:22 + | +LL | fn requires_trait(_: T) {} + | ^^^^^ required by this bound in `requires_trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr new file mode 100644 index 0000000000000..a863886181cc5 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.next.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Foo: Trait` is not satisfied + --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:24:20 + | +LL | requires_trait(Foo); + | -------------- ^^^ the trait `Trait` is not implemented for `Foo` + | | + | required by a bound introduced by this call + | +note: required by a bound in `requires_trait` + --> $DIR/dont-pick-fnptr-bound-as-leaf.rs:19:22 + | +LL | fn requires_trait(_: T) {} + | ^^^^^ required by this bound in `requires_trait` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs new file mode 100644 index 0000000000000..995f2c9fbeed3 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/dont-pick-fnptr-bound-as-leaf.rs @@ -0,0 +1,28 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +// When emitting an error for `Foo: Trait` not holding we attempt to find a nested goal +// to give as the reason why the bound does not hold. This test checks that we do not +// try to tell the user that `Foo: FnPtr` is unimplemented as that would be confusing. + +#![feature(fn_ptr_trait)] + +use std::marker::FnPtr; + +trait Trait {} + +impl Trait for T {} + +struct Foo; + +fn requires_trait(_: T) {} +//~^ NOTE: required by a bound in `requires_trait` +//~| NOTE: required by this bound in `requires_trait` + +fn main() { + requires_trait(Foo); + //~^ ERROR: the trait bound `Foo: Trait` is not satisfied + //~| NOTE: the trait `Trait` is not implemented for `Foo` + //~| NOTE: required by a bound introduced by this call +} diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs index a635edb4485bd..28785ae3dea14 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs +++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs @@ -17,8 +17,8 @@ impl Bar for () {} fn main() { let x: &dyn Foo = &(); - //~^ 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 needs_bar(x); - //~^ ERROR the trait `Foo` cannot be made into an object + //~^ ERROR the trait `Foo` is not dyn compatible } diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr index dd2dca74f9087..8448890c08479 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr +++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr @@ -7,51 +7,54 @@ LL | #![feature(non_lifetime_binders)] = note: see issue #108185 for more information = note: `#[warn(incomplete_features)]` on by default -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/supertrait-dyn-compatibility.rs:19:23 | LL | let 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/supertrait-dyn-compatibility.rs:4:12 | LL | trait Foo: for Bar {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | - | this trait cannot be made into an object... - = help: only type `()` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `()` implements `Foo`; consider using it directly instead. = note: required for the cast from `&()` to `&dyn Foo` -error[E0038]: the trait `Foo` cannot be made into an object +error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/supertrait-dyn-compatibility.rs:19:12 | LL | let 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/supertrait-dyn-compatibility.rs:4:12 | LL | trait Foo: for Bar {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | - | this trait cannot be made into an object... - = help: only type `()` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = 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/supertrait-dyn-compatibility.rs:22:5 | LL | needs_bar(x); - | ^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/supertrait-dyn-compatibility.rs:4:12 | LL | trait Foo: for Bar {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | - | this trait cannot be made into an object... - = help: only type `()` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `()` implements `Foo`; consider using it directly instead. error: aborting due to 3 previous errors; 1 warning emitted diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs index 3af299e5b115a..6dcfc754448b6 100644 --- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs +++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs @@ -8,8 +8,8 @@ trait Try { fn w<'a, T: 'a, F: Fn(&'a T)>() { let b: &dyn FromResidual = &(); - //~^ ERROR: the trait `FromResidual` cannot be made into an object - //~| ERROR: the trait `FromResidual` cannot be made into an object + //~^ ERROR: the trait `FromResidual` is not dyn compatible + //~| ERROR: the trait `FromResidual` is not dyn compatible } fn main() {} diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr index a131227e78e34..7040c067f5c20 100644 --- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr +++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `FromResidual` cannot be made into an object +error[E0038]: the trait `FromResidual` is not dyn compatible --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:32 | LL | let b: &dyn FromResidual = &(); - | ^^^ `FromResidual` cannot be made into an object + | ^^^ `FromResidual` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:2:8 | LL | trait FromResidual::Residual> { - | ------------ this trait cannot be made into an object... + | ------------ this trait is not dyn compatible... LL | fn from_residual(residual: R) -> Self; | ^^^^^^^^^^^^^ ...because associated function `from_residual` has no `self` parameter = note: required for the cast from `&()` to `&dyn FromResidual<{type error}>` @@ -21,17 +22,18 @@ help: alternatively, consider constraining `from_residual` so it does not apply LL | fn from_residual(residual: R) -> Self where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `FromResidual` cannot be made into an object +error[E0038]: the trait `FromResidual` is not dyn compatible --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:12 | LL | let b: &dyn FromResidual = &(); - | ^^^^^^^^^^^^^^^^^ `FromResidual` cannot be made into an object + | ^^^^^^^^^^^^^^^^^ `FromResidual` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:2:8 | LL | trait FromResidual::Residual> { - | ------------ this trait cannot be made into an object... + | ------------ this trait is not dyn compatible... LL | fn from_residual(residual: R) -> Self; | ^^^^^^^^^^^^^ ...because associated function `from_residual` has no `self` parameter help: consider turning `from_residual` into a method by giving it a `&self` argument diff --git a/tests/ui/traits/object/macro-matcher.rs b/tests/ui/traits/object/macro-matcher.rs index 91097874997b4..675d9f51532a4 100644 --- a/tests/ui/traits/object/macro-matcher.rs +++ b/tests/ui/traits/object/macro-matcher.rs @@ -6,7 +6,7 @@ macro_rules! m { fn main() { m!(dyn Copy + Send + 'static); - //~^ ERROR the trait `Copy` cannot be made into an object + //~^ ERROR the trait `Copy` is not dyn compatible m!(dyn 'static + Send); m!(dyn 'static +); //~ ERROR at least one trait is required for an object type } diff --git a/tests/ui/traits/object/macro-matcher.stderr b/tests/ui/traits/object/macro-matcher.stderr index 7924c86e29400..ab0fc213c9f10 100644 --- a/tests/ui/traits/object/macro-matcher.stderr +++ b/tests/ui/traits/object/macro-matcher.stderr @@ -4,14 +4,15 @@ error[E0224]: at least one trait is required for an object type LL | m!(dyn 'static +); | ^^^^^^^^^^^^^ -error[E0038]: the trait `Copy` cannot be made into an object +error[E0038]: the trait `Copy` is not dyn compatible --> $DIR/macro-matcher.rs:8:8 | LL | m!(dyn Copy + Send + '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 + = 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 error: aborting due to 2 previous errors diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr index a2cb656b08d3e..eab59f39c2843 100644 --- a/tests/ui/traits/object/safety.stderr +++ b/tests/ui/traits/object/safety.stderr @@ -1,17 +1,18 @@ -error[E0038]: the trait `Tr` cannot be made into an object +error[E0038]: the trait `Tr` is not dyn compatible --> $DIR/safety.rs:15:22 | LL | let _: &dyn Tr = &St; - | ^^^ `Tr` cannot be made into an object + | ^^^ `Tr` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/safety.rs:4:8 | LL | trait Tr { - | -- 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 `St` implements the trait, consider using it directly instead + = help: only type `St` implements `Tr`; consider using it directly instead. = note: required for the cast from `&St` to `&dyn Tr` help: consider turning `foo` into a method by giving it a `&self` argument | @@ -22,20 +23,21 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `Tr` cannot be made into an object +error[E0038]: the trait `Tr` is not dyn compatible --> $DIR/safety.rs:15:12 | LL | let _: &dyn Tr = &St; - | ^^^^^^^ `Tr` cannot be made into an object + | ^^^^^^^ `Tr` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/safety.rs:4:8 | LL | trait Tr { - | -- 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 `St` implements the trait, consider using it directly instead + = help: only type `St` implements `Tr`; consider using it directly instead. help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self); diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index 3da95b478448f..8915e490b4d21 100644 --- a/tests/ui/traits/test-2.stderr +++ b/tests/ui/traits/test-2.stderr @@ -26,65 +26,74 @@ note: method defined here, with 1 generic parameter: `X` LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } | ^^^^ - -error[E0038]: the trait `bar` cannot be made into an object +error[E0038]: the trait `bar` is not dyn compatible --> $DIR/test-2.rs:13:22 | LL | (Box::new(10) as Box).dup(); - | ^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/test-2.rs:4:30 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } | --- ^^^^ ^^^^ ...because method `blah` has generic type parameters | | | | | ...because method `dup` references the `Self` type in its return type - | this trait cannot be made into an object... + | this trait is not dyn compatible... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead: + = help: the following types implement `bar`: i32 u32 + consider defining an enum where each variant holds one of these types, + implementing `bar` for this new enum and using it instead -error[E0038]: the trait `bar` cannot be made into an object +error[E0038]: the trait `bar` is not dyn compatible --> $DIR/test-2.rs:13:5 | LL | (Box::new(10) as Box).dup(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/test-2.rs:4:30 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } | --- ^^^^ ^^^^ ...because method `blah` has generic type parameters | | | | | ...because method `dup` references the `Self` type in its return type - | this trait cannot be made into an object... + | this trait is not dyn compatible... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead: + = help: the following types implement `bar`: i32 u32 + consider defining an enum where each variant holds one of these types, + implementing `bar` for this new enum and using it instead -error[E0038]: the trait `bar` cannot be made into an object +error[E0038]: the trait `bar` is not dyn compatible --> $DIR/test-2.rs:13:6 | LL | (Box::new(10) as Box).dup(); - | ^^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/test-2.rs:4:30 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } | --- ^^^^ ^^^^ ...because method `blah` has generic type parameters | | | | | ...because method `dup` references the `Self` type in its return type - | this trait cannot be made into an object... + | this trait is not dyn compatible... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead: + = help: the following types implement `bar`: i32 u32 + consider defining an enum where each variant holds one of these types, + implementing `bar` for this new enum and using it instead = note: required for the cast from `Box<{integer}>` to `Box` error: aborting due to 5 previous errors diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr index 2d5bcf1fbc4cf..71717c6945e04 100644 --- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr +++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -10,21 +10,20 @@ help: consider using a box or reference as appropriate LL | let y = x as dyn MyAdd; | ^ -error[E0038]: the trait `MyAdd` cannot be made into an object +error[E0038]: the trait `MyAdd` is not dyn compatible --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18 | LL | let y = x as dyn MyAdd; - | ^^^^^^^^^^^^^^ `MyAdd` cannot be made into an object + | ^^^^^^^^^^^^^^ `MyAdd` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:6:55 | LL | trait MyAdd { fn add(&self, other: &Rhs) -> Self; } - | ----- ^^^^ ...because method `add` references the `Self` type in its return type - | | - | this trait cannot be made into an object... + | ----- this trait is not dyn compatible... ^^^^ ...because method `add` references the `Self` type in its return type = help: consider moving `add` to another trait - = help: only type `i32` implements the trait, consider using it directly instead + = help: only type `i32` implements `MyAdd`; consider using it directly instead. error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.current.stderr similarity index 88% rename from tests/ui/typeck/bad-index-due-to-nested.stderr rename to tests/ui/typeck/bad-index-due-to-nested.current.stderr index dd2ce092368a8..dc3d998c399a9 100644 --- a/tests/ui/typeck/bad-index-due-to-nested.stderr +++ b/tests/ui/typeck/bad-index-due-to-nested.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `K: Hash` is not satisfied - --> $DIR/bad-index-due-to-nested.rs:20:5 + --> $DIR/bad-index-due-to-nested.rs:24:5 | LL | map[k] | ^^^ the trait `Hash` is not implemented for `K` | note: required for `HashMap` to implement `Index<&K>` - --> $DIR/bad-index-due-to-nested.rs:7:12 + --> $DIR/bad-index-due-to-nested.rs:11:12 | LL | impl Index<&K> for HashMap | ^^^^^^^^^ ^^^^^^^^^^^^^ @@ -18,13 +18,13 @@ LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap, k: K) -> &'a V | +++++++++++++++++ error[E0277]: the trait bound `V: Copy` is not satisfied - --> $DIR/bad-index-due-to-nested.rs:20:5 + --> $DIR/bad-index-due-to-nested.rs:24:5 | LL | map[k] | ^^^ the trait `Copy` is not implemented for `V` | note: required for `HashMap` to implement `Index<&K>` - --> $DIR/bad-index-due-to-nested.rs:7:12 + --> $DIR/bad-index-due-to-nested.rs:11:12 | LL | impl Index<&K> for HashMap | ^^^^^^^^^ ^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap, k: K) -> &'a | +++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/bad-index-due-to-nested.rs:20:9 + --> $DIR/bad-index-due-to-nested.rs:24:9 | LL | fn index<'a, K, V>(map: &'a HashMap, k: K) -> &'a V { | - found this type parameter @@ -52,7 +52,7 @@ LL | map[&k] | + error[E0308]: mismatched types - --> $DIR/bad-index-due-to-nested.rs:20:5 + --> $DIR/bad-index-due-to-nested.rs:24:5 | LL | fn index<'a, K, V>(map: &'a HashMap, k: K) -> &'a V { | - found this type parameter ----- expected `&'a V` because of return type diff --git a/tests/ui/typeck/bad-index-due-to-nested.next.stderr b/tests/ui/typeck/bad-index-due-to-nested.next.stderr new file mode 100644 index 0000000000000..a0b275b7852ba --- /dev/null +++ b/tests/ui/typeck/bad-index-due-to-nested.next.stderr @@ -0,0 +1,76 @@ +error[E0277]: the trait bound `K: Hash` is not satisfied + --> $DIR/bad-index-due-to-nested.rs:24:5 + | +LL | map[k] + | ^^^ the trait `Hash` is not implemented for `K` + | +note: required for `HashMap` to implement `Index<&K>` + --> $DIR/bad-index-due-to-nested.rs:11:12 + | +LL | impl Index<&K> for HashMap + | ^^^^^^^^^ ^^^^^^^^^^^^^ +LL | where +LL | K: Hash, + | ---- unsatisfied trait bound introduced here +help: consider restricting type parameter `K` with trait `Hash` + | +LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap, k: K) -> &'a V { + | +++++++++++++++++ + +error[E0277]: the trait bound `V: Copy` is not satisfied + --> $DIR/bad-index-due-to-nested.rs:24:5 + | +LL | map[k] + | ^^^ the trait `Copy` is not implemented for `V` + | +note: required for `HashMap` to implement `Index<&K>` + --> $DIR/bad-index-due-to-nested.rs:11:12 + | +LL | impl Index<&K> for HashMap + | ^^^^^^^^^ ^^^^^^^^^^^^^ +... +LL | V: Copy, + | ---- unsatisfied trait bound introduced here +help: consider restricting type parameter `V` with trait `Copy` + | +LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap, k: K) -> &'a V { + | +++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/bad-index-due-to-nested.rs:24:9 + | +LL | fn index<'a, K, V>(map: &'a HashMap, k: K) -> &'a V { + | - found this type parameter +LL | map[k] + | ^ expected `&K`, found type parameter `K` + | + = note: expected reference `&_` + found type parameter `_` +help: consider borrowing here + | +LL | map[&k] + | + + +error[E0277]: the trait bound `K: Hash` is not satisfied + --> $DIR/bad-index-due-to-nested.rs:24:5 + | +LL | map[k] + | ^^^^^^ the trait `Hash` is not implemented for `K` + | +note: required for `HashMap` to implement `Index<&K>` + --> $DIR/bad-index-due-to-nested.rs:11:12 + | +LL | impl Index<&K> for HashMap + | ^^^^^^^^^ ^^^^^^^^^^^^^ +LL | where +LL | K: Hash, + | ---- unsatisfied trait bound introduced here +help: consider restricting type parameter `K` with trait `Hash` + | +LL | fn index<'a, K: std::hash::Hash, V>(map: &'a HashMap, k: K) -> &'a V { + | +++++++++++++++++ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/bad-index-due-to-nested.rs b/tests/ui/typeck/bad-index-due-to-nested.rs index 2564b530004e5..e7f385865af5f 100644 --- a/tests/ui/typeck/bad-index-due-to-nested.rs +++ b/tests/ui/typeck/bad-index-due-to-nested.rs @@ -1,3 +1,7 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + use std::hash::Hash; use std::marker::PhantomData; use std::ops::Index; @@ -21,7 +25,8 @@ fn index<'a, K, V>(map: &'a HashMap, k: K) -> &'a V { //~^ ERROR the trait bound `K: Hash` is not satisfied //~| ERROR the trait bound `V: Copy` is not satisfied //~| ERROR mismatched types - //~| ERROR mismatched types + //[current]~| ERROR mismatched types + //[next]~^^^^^ ERROR the trait bound `K: Hash` is not satisfied } fn main() {} diff --git a/tests/ui/union/union-derive-eq.stderr b/tests/ui/union/union-derive-eq.current.stderr similarity index 95% rename from tests/ui/union/union-derive-eq.stderr rename to tests/ui/union/union-derive-eq.current.stderr index b068edd6d69cc..151ceebe1ba67 100644 --- a/tests/ui/union/union-derive-eq.stderr +++ b/tests/ui/union/union-derive-eq.current.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `PartialEqNotEq: Eq` is not satisfied - --> $DIR/union-derive-eq.rs:13:5 + --> $DIR/union-derive-eq.rs:21:5 | LL | #[derive(Eq)] | -- in this derive macro expansion diff --git a/tests/ui/union/union-derive-eq.next.stderr b/tests/ui/union/union-derive-eq.next.stderr new file mode 100644 index 0000000000000..3952b1f12840f --- /dev/null +++ b/tests/ui/union/union-derive-eq.next.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `PartialEqNotEq: Eq` is not satisfied + --> $DIR/union-derive-eq.rs:21:5 + | +LL | #[derive(Eq)] + | -- in this derive macro expansion +LL | union U2 { +LL | a: PartialEqNotEq, + | ^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `PartialEqNotEq` + | + = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` + | +LL + #[derive(Eq)] +LL | struct PartialEqNotEq; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/union/union-derive-eq.rs b/tests/ui/union/union-derive-eq.rs index e689f8c27d772..085262a72a18f 100644 --- a/tests/ui/union/union-derive-eq.rs +++ b/tests/ui/union/union-derive-eq.rs @@ -1,9 +1,17 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + #[derive(Eq)] // OK union U1 { a: u8, } -impl PartialEq for U1 { fn eq(&self, rhs: &Self) -> bool { true } } +impl PartialEq for U1 { + fn eq(&self, rhs: &Self) -> bool { + true + } +} #[derive(PartialEq, Copy, Clone)] struct PartialEqNotEq; @@ -13,6 +21,10 @@ union U2 { a: PartialEqNotEq, //~ ERROR the trait bound `PartialEqNotEq: Eq` is not satisfied } -impl PartialEq for U2 { fn eq(&self, rhs: &Self) -> bool { true } } +impl PartialEq for U2 { + fn eq(&self, rhs: &Self) -> bool { + true + } +} fn main() {} diff --git a/tests/ui/wf/issue-87495.rs b/tests/ui/wf/issue-87495.rs index 5aab7431134ba..ce5c617bbbd38 100644 --- a/tests/ui/wf/issue-87495.rs +++ b/tests/ui/wf/issue-87495.rs @@ -2,7 +2,7 @@ trait T { const CONST: (bool, dyn T); - //~^ ERROR: the trait `T` cannot be made into an object [E0038] + //~^ ERROR: the trait `T` is not dyn compatible [E0038] } fn main() {} diff --git a/tests/ui/wf/issue-87495.stderr b/tests/ui/wf/issue-87495.stderr index 5973fff3e009e..7be327e61d105 100644 --- a/tests/ui/wf/issue-87495.stderr +++ b/tests/ui/wf/issue-87495.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `T` cannot be made into an object +error[E0038]: the trait `T` is not dyn compatible --> $DIR/issue-87495.rs:4:25 | LL | const CONST: (bool, dyn T); - | ^^^^^ `T` cannot be made into an object + | ^^^^^ `T` 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/issue-87495.rs:4:11 | LL | trait T { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | const CONST: (bool, dyn T); | ^^^^^ ...because it contains this associated `const` = help: consider moving `CONST` to another trait diff --git a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr index 38426545bc8cb..0b7f4cd43622d 100644 --- a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr +++ b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr @@ -1,49 +1,52 @@ -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:16:33 | LL | let t_box: Box = Box::new(S); - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: only type `S` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `S` implements `Trait`; consider using it directly instead. = note: required for the cast from `Box` to `Box` -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:17:15 | LL | takes_box(Box::new(S)); - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: only type `S` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `S` implements `Trait`; consider using it directly instead. = note: required for the cast from `Box` to `Box<(dyn Trait + 'static)>` -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:15:5 | LL | Box::new(S) as Box; - | ^^^^^^^^^^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: only type `S` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `S` implements `Trait`; consider using it directly instead. = note: required for the cast from `Box` to `Box` error: aborting due to 3 previous errors diff --git a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr index 94259aa5b0aa8..3f50e1192cf00 100644 --- a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr +++ b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr @@ -1,49 +1,52 @@ -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:16:25 | LL | let t: &dyn Trait = &S; - | ^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: only type `S` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `S` implements `Trait`; consider using it directly instead. = note: required for the cast from `&S` to `&dyn Trait` -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:17:17 | LL | takes_trait(&S); - | ^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: only type `S` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `S` implements `Trait`; consider using it directly instead. = note: required for the cast from `&S` to `&dyn Trait` -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:15:5 | LL | &S as &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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: only type `S` implements the trait, consider using it directly instead + | this trait is not dyn compatible... + = help: only type `S` implements `Trait`; consider using it directly instead. = note: required for the cast from `&S` to `&dyn Trait` error: aborting due to 3 previous errors diff --git a/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr b/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr index 6cd4ebf8412b6..8f68f9c5b6b3c 100644 --- a/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr +++ b/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr @@ -12,40 +12,46 @@ LL | | } = note: expected reference `&S` found reference `&R` -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-dyn-incompat-trait-obj-match.rs:26:21 | LL | Some(()) => &S, - | ^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-dyn-incompat-trait-obj-match.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead: + | this trait is not dyn compatible... + = help: the following types implement `Trait`: S R + consider defining an enum where each variant holds one of these types, + implementing `Trait` for this new enum and using it instead = note: required for the cast from `&S` to `&dyn Trait` -error[E0038]: the trait `Trait` cannot be made into an object +error[E0038]: the trait `Trait` is not dyn compatible --> $DIR/wf-dyn-incompat-trait-obj-match.rs:27:17 | LL | None => &R, - | ^^ `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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-dyn-incompat-trait-obj-match.rs:6:14 | LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | - | this trait cannot be made into an object... - = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead: + | this trait is not dyn compatible... + = help: the following types implement `Trait`: S R + consider defining an enum where each variant holds one of these types, + implementing `Trait` for this new enum and using it instead = note: required for the cast from `&R` to `&dyn Trait` error: aborting due to 3 previous errors diff --git a/tests/ui/wf/wf-dyn-incompatible.stderr b/tests/ui/wf/wf-dyn-incompatible.stderr index cf016b63c7405..1803376aaa193 100644 --- a/tests/ui/wf/wf-dyn-incompatible.stderr +++ b/tests/ui/wf/wf-dyn-incompatible.stderr @@ -1,14 +1,15 @@ -error[E0038]: the trait `A` cannot be made into an object +error[E0038]: the trait `A` is not dyn compatible --> $DIR/wf-dyn-incompatible.rs:9:13 | LL | let _x: &dyn 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 +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit --> $DIR/wf-dyn-incompatible.rs:5:23 | LL | trait A { - | - this trait cannot be made into an object... + | - this trait is not dyn compatible... LL | fn foo(&self, _x: &Self); | ^^^^^ ...because method `foo` references the `Self` type in this parameter = help: consider moving `foo` to another trait diff --git a/tests/ui/wf/wf-fn-where-clause.stderr b/tests/ui/wf/wf-fn-where-clause.stderr index 76671dedabf47..d73376e9861e6 100644 --- a/tests/ui/wf/wf-fn-where-clause.stderr +++ b/tests/ui/wf/wf-fn-where-clause.stderr @@ -14,14 +14,15 @@ help: consider further restricting type parameter `U` with trait `Copy` LL | fn foo() where T: ExtraCopy, U: std::marker::Copy | ++++++++++++++++++++++ -error[E0038]: the trait `Copy` cannot be made into an object +error[E0038]: the trait `Copy` is not dyn compatible --> $DIR/wf-fn-where-clause.rs:12:16 | LL | fn bar() where Vec:, {} - | ^^^^^^^^^^^^^ `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 + = 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 error[E0277]: the size for values of type `(dyn Copy + 'static)` cannot be known at compilation time --> $DIR/wf-fn-where-clause.rs:12:16 diff --git a/tests/ui/wf/wf-trait-fn-arg.stderr b/tests/ui/wf/wf-trait-fn-arg.current.stderr similarity index 74% rename from tests/ui/wf/wf-trait-fn-arg.stderr rename to tests/ui/wf/wf-trait-fn-arg.current.stderr index 8b35f36fa68a8..d5dd36fad6dd6 100644 --- a/tests/ui/wf/wf-trait-fn-arg.stderr +++ b/tests/ui/wf/wf-trait-fn-arg.current.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `Self: Eq` is not satisfied - --> $DIR/wf-trait-fn-arg.rs:10:23 + --> $DIR/wf-trait-fn-arg.rs:16:23 | LL | fn bar(&self, x: &Bar); | ^^^^^^^^^ the trait `Eq` is not implemented for `Self` | note: required by a bound in `Bar` - --> $DIR/wf-trait-fn-arg.rs:7:14 + --> $DIR/wf-trait-fn-arg.rs:11:15 | -LL | struct Bar { value: Box } - | ^^ required by this bound in `Bar` +LL | struct Bar { + | ^^ required by this bound in `Bar` help: consider further restricting `Self` | LL | fn bar(&self, x: &Bar) where Self: Eq; diff --git a/tests/ui/wf/wf-trait-fn-arg.next.stderr b/tests/ui/wf/wf-trait-fn-arg.next.stderr new file mode 100644 index 0000000000000..c55dc5c8a121a --- /dev/null +++ b/tests/ui/wf/wf-trait-fn-arg.next.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `Self: Eq` is not satisfied + --> $DIR/wf-trait-fn-arg.rs:16:23 + | +LL | fn bar(&self, x: &Bar); + | ^^^^^^^^^ the trait `Eq` is not implemented for `Self` + | +help: consider further restricting `Self` + | +LL | fn bar(&self, x: &Bar) where Self: Eq; + | ++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-trait-fn-arg.rs b/tests/ui/wf/wf-trait-fn-arg.rs index 0445699427e2a..13a5b32828d82 100644 --- a/tests/ui/wf/wf-trait-fn-arg.rs +++ b/tests/ui/wf/wf-trait-fn-arg.rs @@ -1,16 +1,22 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + // Check that we test WF conditions for fn arguments in a trait definition. #![feature(rustc_attrs)] #![allow(dead_code)] #![allow(unused_variables)] -struct Bar { value: Box } +struct Bar { + value: Box, +} trait Foo { fn bar(&self, x: &Bar); - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. } -fn main() { } +fn main() {} diff --git a/tests/ui/wf/wf-trait-fn-ret.stderr b/tests/ui/wf/wf-trait-fn-ret.current.stderr similarity index 74% rename from tests/ui/wf/wf-trait-fn-ret.stderr rename to tests/ui/wf/wf-trait-fn-ret.current.stderr index 3d70f04def2e0..0ad786c2fd566 100644 --- a/tests/ui/wf/wf-trait-fn-ret.stderr +++ b/tests/ui/wf/wf-trait-fn-ret.current.stderr @@ -1,14 +1,14 @@ error[E0277]: the trait bound `Self: Eq` is not satisfied - --> $DIR/wf-trait-fn-ret.rs:10:23 + --> $DIR/wf-trait-fn-ret.rs:15:23 | LL | fn bar(&self) -> &Bar; | ^^^^^^^^^ the trait `Eq` is not implemented for `Self` | note: required by a bound in `Bar` - --> $DIR/wf-trait-fn-ret.rs:7:14 + --> $DIR/wf-trait-fn-ret.rs:10:15 | -LL | struct Bar { value: Box } - | ^^ required by this bound in `Bar` +LL | struct Bar { + | ^^ required by this bound in `Bar` help: consider further restricting `Self` | LL | fn bar(&self) -> &Bar where Self: Eq; diff --git a/tests/ui/wf/wf-trait-fn-ret.next.stderr b/tests/ui/wf/wf-trait-fn-ret.next.stderr new file mode 100644 index 0000000000000..b3dca17672d31 --- /dev/null +++ b/tests/ui/wf/wf-trait-fn-ret.next.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `Self: Eq` is not satisfied + --> $DIR/wf-trait-fn-ret.rs:15:23 + | +LL | fn bar(&self) -> &Bar; + | ^^^^^^^^^ the trait `Eq` is not implemented for `Self` + | +help: consider further restricting `Self` + | +LL | fn bar(&self) -> &Bar where Self: Eq; + | ++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-trait-fn-ret.rs b/tests/ui/wf/wf-trait-fn-ret.rs index f49e43087701b..c00f6dd10af21 100644 --- a/tests/ui/wf/wf-trait-fn-ret.rs +++ b/tests/ui/wf/wf-trait-fn-ret.rs @@ -1,16 +1,21 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) // Check that we test WF conditions for fn return types in a trait definition. #![feature(rustc_attrs)] #![allow(dead_code)] #![allow(unused_variables)] -struct Bar { value: Box } +struct Bar { + value: Box, +} trait Foo { fn bar(&self) -> &Bar; - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. } -fn main() { } +fn main() {} diff --git a/tests/ui/wf/wf-trait-fn-where-clause.current.stderr b/tests/ui/wf/wf-trait-fn-where-clause.current.stderr new file mode 100644 index 0000000000000..db5454d0f3c22 --- /dev/null +++ b/tests/ui/wf/wf-trait-fn-where-clause.current.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `Self: Eq` is not satisfied + --> $DIR/wf-trait-fn-where-clause.rs:18:20 + | +LL | Bar: Copy; + | ^^^^ the trait `Eq` is not implemented for `Self` + | +note: required by a bound in `Bar` + --> $DIR/wf-trait-fn-where-clause.rs:10:15 + | +LL | struct Bar { + | ^^ required by this bound in `Bar` +help: consider further restricting `Self` + | +LL | Bar: Copy, Self: Eq; + | ++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-trait-fn-where-clause.next.stderr b/tests/ui/wf/wf-trait-fn-where-clause.next.stderr new file mode 100644 index 0000000000000..8c8a5fa3e7041 --- /dev/null +++ b/tests/ui/wf/wf-trait-fn-where-clause.next.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `Self: Eq` is not satisfied + --> $DIR/wf-trait-fn-where-clause.rs:18:20 + | +LL | Bar: Copy; + | ^^^^ the trait `Eq` is not implemented for `Self` + | +help: consider further restricting `Self` + | +LL | Bar: Copy, Self: Eq; + | ++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-trait-fn-where-clause.rs b/tests/ui/wf/wf-trait-fn-where-clause.rs index 1d2427ff981d7..9e36682e449d5 100644 --- a/tests/ui/wf/wf-trait-fn-where-clause.rs +++ b/tests/ui/wf/wf-trait-fn-where-clause.rs @@ -1,17 +1,24 @@ -// Check that we test WF conditions for fn where clauses in a trait definition. +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +// Check that we test WF conditions for fn where clauses in a trait definition. #![allow(dead_code)] #![allow(unused_variables)] -struct Bar { value: Box } +struct Bar { + value: Box, +} trait Foo { - fn bar(&self) where Self: Sized, Bar: Copy; - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. + fn bar(&self) + where + Self: Sized, + Bar: Copy; + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. } - -fn main() { } +fn main() {} diff --git a/tests/ui/wf/wf-trait-fn-where-clause.stderr b/tests/ui/wf/wf-trait-fn-where-clause.stderr deleted file mode 100644 index 0ad3b58e7c76a..0000000000000 --- a/tests/ui/wf/wf-trait-fn-where-clause.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: the trait bound `Self: Eq` is not satisfied - --> $DIR/wf-trait-fn-where-clause.rs:10:49 - | -LL | fn bar(&self) where Self: Sized, Bar: Copy; - | ^^^^ the trait `Eq` is not implemented for `Self` - | -note: required by a bound in `Bar` - --> $DIR/wf-trait-fn-where-clause.rs:7:14 - | -LL | struct Bar { value: Box } - | ^^ required by this bound in `Bar` -help: consider further restricting `Self` - | -LL | fn bar(&self) where Self: Sized, Bar: Copy, Self: Eq; - | ++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr similarity index 58% rename from tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr rename to tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr index 840df342ef9a9..d1de813a2d9f8 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr @@ -1,14 +1,17 @@ error[E0277]: the trait bound `Bar: Eq` is not satisfied - --> $DIR/where-clauses-method-unsatisfied.rs:18:7 + --> $DIR/where-clauses-method-unsatisfied.rs:24:7 | LL | x.equals(&x); | ^^^^^^ the trait `Eq` is not implemented for `Bar` | note: required by a bound in `Foo::::equals` - --> $DIR/where-clauses-method-unsatisfied.rs:11:52 + --> $DIR/where-clauses-method-unsatisfied.rs:16:12 | -LL | fn equals(&self, u: &Foo) -> bool where T : Eq { - | ^^ required by this bound in `Foo::::equals` +LL | fn equals(&self, u: &Foo) -> bool + | ------ required by a bound in this associated function +LL | where +LL | T: Eq, + | ^^ required by this bound in `Foo::::equals` help: consider annotating `Bar` with `#[derive(Eq)]` | LL + #[derive(Eq)] diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr new file mode 100644 index 0000000000000..d1de813a2d9f8 --- /dev/null +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `Bar: Eq` is not satisfied + --> $DIR/where-clauses-method-unsatisfied.rs:24:7 + | +LL | x.equals(&x); + | ^^^^^^ the trait `Eq` is not implemented for `Bar` + | +note: required by a bound in `Foo::::equals` + --> $DIR/where-clauses-method-unsatisfied.rs:16:12 + | +LL | fn equals(&self, u: &Foo) -> bool + | ------ required by a bound in this associated function +LL | where +LL | T: Eq, + | ^^ required by this bound in `Foo::::equals` +help: consider annotating `Bar` with `#[derive(Eq)]` + | +LL + #[derive(Eq)] +LL | struct Bar; // does not implement Eq + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs b/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs index a8ae02964078b..34e9d9b57d1c6 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.rs @@ -1,14 +1,20 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) // Test that a where clause attached to a method allows us to add // additional constraints to a parameter out of scope. struct Foo { - value: T + value: T, } struct Bar; // does not implement Eq impl Foo { - fn equals(&self, u: &Foo) -> bool where T : Eq { + fn equals(&self, u: &Foo) -> bool + where + T: Eq, + { self.value == u.value } } diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr similarity index 62% rename from tests/ui/where-clauses/where-clauses-unsatisfied.stderr rename to tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr index 205b82d49bfeb..485b9459ddd0e 100644 --- a/tests/ui/where-clauses/where-clauses-unsatisfied.stderr +++ b/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr @@ -1,14 +1,17 @@ error[E0277]: the trait bound `Struct: Eq` is not satisfied - --> $DIR/where-clauses-unsatisfied.rs:6:10 + --> $DIR/where-clauses-unsatisfied.rs:15:10 | LL | drop(equal(&Struct, &Struct)) | ^^^^^ the trait `Eq` is not implemented for `Struct` | note: required by a bound in `equal` - --> $DIR/where-clauses-unsatisfied.rs:1:45 + --> $DIR/where-clauses-unsatisfied.rs:7:8 | -LL | fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } - | ^^ required by this bound in `equal` +LL | fn equal(a: &T, b: &T) -> bool + | ----- required by a bound in this function +LL | where +LL | T: Eq, + | ^^ required by this bound in `equal` help: consider annotating `Struct` with `#[derive(Eq)]` | LL + #[derive(Eq)] diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr new file mode 100644 index 0000000000000..485b9459ddd0e --- /dev/null +++ b/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `Struct: Eq` is not satisfied + --> $DIR/where-clauses-unsatisfied.rs:15:10 + | +LL | drop(equal(&Struct, &Struct)) + | ^^^^^ the trait `Eq` is not implemented for `Struct` + | +note: required by a bound in `equal` + --> $DIR/where-clauses-unsatisfied.rs:7:8 + | +LL | fn equal(a: &T, b: &T) -> bool + | ----- required by a bound in this function +LL | where +LL | T: Eq, + | ^^ required by this bound in `equal` +help: consider annotating `Struct` with `#[derive(Eq)]` + | +LL + #[derive(Eq)] +LL | struct Struct; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.rs b/tests/ui/where-clauses/where-clauses-unsatisfied.rs index 8b067d30a2a85..48798e2a15dbb 100644 --- a/tests/ui/where-clauses/where-clauses-unsatisfied.rs +++ b/tests/ui/where-clauses/where-clauses-unsatisfied.rs @@ -1,4 +1,13 @@ -fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +fn equal(a: &T, b: &T) -> bool +where + T: Eq, +{ + a == b +} struct Struct;