diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index e8d9918be22..8ab91bebcf6 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -404,7 +404,7 @@ hir_analysis_unused_associated_type_bounds = .suggestion = remove this bound hir_analysis_value_of_associated_struct_already_specified = - the value of the associated type `{$item_name}` (from trait `{$def_path}`) is already specified + the value of the associated type `{$item_name}` in trait `{$def_path}` is already specified .label = re-bound here .previous_bound_label = `{$item_name}` bound here first diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index 889bc2ea432..32be7e0837b 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -3,6 +3,7 @@ use crate::errors::{ AssocTypeBindingNotAllowed, ManualImplementation, MissingTypeParams, ParenthesizedFnTraitExpansion, }; +use crate::traits::error_reporting::report_object_safety_error; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, ErrorGuaranteed}; use rustc_hir as hir; @@ -13,6 +14,7 @@ use rustc_session::parse::feature_err; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::symbol::{sym, Ident}; use rustc_span::{Span, Symbol, DUMMY_SP}; +use rustc_trait_selection::traits::object_safety_violations_for_assoc_item; use std::collections::BTreeSet; @@ -520,24 +522,33 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { (span, def_ids.into_iter().map(|did| tcx.associated_item(did)).collect()) }) .collect(); - let mut names = vec![]; + let mut names: FxHashMap> = Default::default(); + let mut names_len = 0; // Account for things like `dyn Foo + 'a`, like in tests `issue-22434.rs` and // `issue-22560.rs`. let mut trait_bound_spans: Vec = vec![]; + let mut object_safety_violations = false; for (span, items) in &associated_types { if !items.is_empty() { trait_bound_spans.push(*span); } for assoc_item in items { let trait_def_id = assoc_item.container_id(tcx); - names.push(format!( - "`{}` (from trait `{}`)", - assoc_item.name, - tcx.def_path_str(trait_def_id), - )); + names.entry(tcx.def_path_str(trait_def_id)).or_default().push(assoc_item.name); + names_len += 1; + + let violations = + object_safety_violations_for_assoc_item(tcx, trait_def_id, *assoc_item); + if !violations.is_empty() { + report_object_safety_error(tcx, *span, trait_def_id, &violations).emit(); + object_safety_violations = true; + } } } + if object_safety_violations { + return; + } if let ([], [bound]) = (&potential_assoc_types[..], &trait_bounds) { match bound.trait_ref.path.segments { // FIXME: `trait_ref.path.span` can point to a full path with multiple @@ -573,15 +584,35 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { _ => {} } } + + let mut names = names + .into_iter() + .map(|(trait_, mut assocs)| { + assocs.sort(); + format!( + "{} in `{trait_}`", + match &assocs[..] { + [] => String::new(), + [only] => format!("`{only}`"), + [assocs @ .., last] => format!( + "{} and `{last}`", + assocs.iter().map(|a| format!("`{a}`")).collect::>().join(", ") + ), + } + ) + }) + .collect::>(); names.sort(); + let names = names.join(", "); + trait_bound_spans.sort(); let mut err = struct_span_err!( tcx.sess, trait_bound_spans, E0191, "the value of the associated type{} {} must be specified", - pluralize!(names.len()), - names.join(", "), + pluralize!(names_len), + names, ); let mut suggestions = vec![]; let mut types_count = 0; diff --git a/compiler/rustc_hir_analysis/src/astconv/object_safety.rs b/compiler/rustc_hir_analysis/src/astconv/object_safety.rs index 30c2ab8f545..00ff3f836ad 100644 --- a/compiler/rustc_hir_analysis/src/astconv/object_safety.rs +++ b/compiler/rustc_hir_analysis/src/astconv/object_safety.rs @@ -380,7 +380,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { span, E0228, "the lifetime bound for this object type cannot be deduced \ - from context; please supply an explicit bound" + from context; please supply an explicit bound" ); let e = if borrowed { // We will have already emitted an error E0106 complaining about a diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 71007e1f0e0..fff5510bbfb 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -47,7 +47,7 @@ pub use self::engine::{ObligationCtxt, TraitEngineExt}; pub use self::fulfill::{FulfillmentContext, PendingPredicateObligation}; pub use self::object_safety::astconv_object_safety_violations; pub use self::object_safety::is_vtable_safe_method; -pub use self::object_safety::MethodViolationCode; +pub use self::object_safety::object_safety_violations_for_assoc_item; pub use self::object_safety::ObjectSafetyViolation; pub use self::project::NormalizeExt; pub use self::project::{normalize_inherent_projection, normalize_projection_type}; diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index dfc4bdf1484..17c7f94ee88 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -360,7 +360,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool { /// Returns `Some(_)` if this item makes the containing trait not object safe. #[instrument(level = "debug", skip(tcx), ret)] -fn object_safety_violations_for_assoc_item( +pub fn object_safety_violations_for_assoc_item( tcx: TyCtxt<'_>, trait_def_id: DefId, item: ty::AssocItem, diff --git a/tests/ui/associated-type-bounds/duplicate.rs b/tests/ui/associated-type-bounds/duplicate.rs index 4b8bf52c374..5019804d494 100644 --- a/tests/ui/associated-type-bounds/duplicate.rs +++ b/tests/ui/associated-type-bounds/duplicate.rs @@ -5,258 +5,258 @@ use std::iter; use std::mem::ManuallyDrop; struct SI1> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: T, } struct SI2> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: T, } struct SI3> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: T, } struct SW1 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: T, } struct SW2 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: T, } struct SW3 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: T, } enum EI1> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] V(T), } enum EI2> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] V(T), } enum EI3> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] V(T), } enum EW1 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { V(T), } enum EW2 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { V(T), } enum EW3 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { V(T), } union UI1> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: ManuallyDrop, } union UI2> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: ManuallyDrop, } union UI3> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: ManuallyDrop, } union UW1 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: ManuallyDrop, } union UW2 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: ManuallyDrop, } union UW3 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: ManuallyDrop, } fn FI1>() {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FI2>() {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FI3>() {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FW1() where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } fn FW2() where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } fn FW3() where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } fn FRPIT1() -> impl Iterator { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] iter::empty() } fn FRPIT2() -> impl Iterator { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] iter::empty() } fn FRPIT3() -> impl Iterator { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] iter::empty() } fn FAPIT1(_: impl Iterator) {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FAPIT2(_: impl Iterator) {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FAPIT3(_: impl Iterator) {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAI1> = T; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAI2> = T; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAI3> = T; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAW1 where T: Iterator, -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] = T; type TAW2 where T: Iterator, -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] = T; type TAW3 where T: Iterator, -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] = T; type ETAI1> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI2> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI3> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI4 = impl Iterator; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI5 = impl Iterator; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI6 = impl Iterator; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRI1> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRI2> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRI3> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRS1: Iterator {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] -//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] +//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRS2: Iterator {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] -//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] +//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRS3: Iterator {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] -//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] +//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRW1 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRW2 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRW3 where T: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRSW1 where Self: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] - //~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] + //~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRSW2 where Self: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] - //~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] + //~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRSW3 where Self: Iterator, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] - //~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] + //~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRA1 { type A: Iterator; - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] } trait TRA2 { type A: Iterator; - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] } trait TRA3 { type A: Iterator; - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] } type TADyn1 = dyn Iterator; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TADyn2 = Box>; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TADyn3 = dyn Iterator; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn main() {} diff --git a/tests/ui/associated-type-bounds/duplicate.stderr b/tests/ui/associated-type-bounds/duplicate.stderr index 3629aa4fcea..3888e62230f 100644 --- a/tests/ui/associated-type-bounds/duplicate.stderr +++ b/tests/ui/associated-type-bounds/duplicate.stderr @@ -1,4 +1,4 @@ -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:7:36 | LL | struct SI1> { @@ -6,7 +6,7 @@ LL | struct SI1> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:11:36 | LL | struct SI2> { @@ -14,7 +14,7 @@ LL | struct SI2> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:15:39 | LL | struct SI3> { @@ -22,7 +22,7 @@ LL | struct SI3> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:21:29 | LL | T: Iterator, @@ -30,7 +30,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:28:29 | LL | T: Iterator, @@ -38,7 +38,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:35:32 | LL | T: Iterator, @@ -46,7 +46,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:41:34 | LL | enum EI1> { @@ -54,7 +54,7 @@ LL | enum EI1> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:45:34 | LL | enum EI2> { @@ -62,7 +62,7 @@ LL | enum EI2> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:49:37 | LL | enum EI3> { @@ -70,7 +70,7 @@ LL | enum EI3> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:55:29 | LL | T: Iterator, @@ -78,7 +78,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:62:29 | LL | T: Iterator, @@ -86,7 +86,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:69:32 | LL | T: Iterator, @@ -94,7 +94,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:75:35 | LL | union UI1> { @@ -102,7 +102,7 @@ LL | union UI1> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:79:35 | LL | union UI2> { @@ -110,7 +110,7 @@ LL | union UI2> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:83:38 | LL | union UI3> { @@ -118,7 +118,7 @@ LL | union UI3> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:89:29 | LL | T: Iterator, @@ -126,7 +126,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:96:29 | LL | T: Iterator, @@ -134,7 +134,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:103:32 | LL | T: Iterator, @@ -142,7 +142,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:109:32 | LL | fn FI1>() {} @@ -150,7 +150,7 @@ LL | fn FI1>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:111:32 | LL | fn FI2>() {} @@ -158,7 +158,7 @@ LL | fn FI2>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:113:35 | LL | fn FI3>() {} @@ -166,7 +166,7 @@ LL | fn FI3>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:117:29 | LL | T: Iterator, @@ -174,7 +174,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:123:29 | LL | T: Iterator, @@ -182,7 +182,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:129:32 | LL | T: Iterator, @@ -190,7 +190,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:134:42 | LL | fn FRPIT1() -> impl Iterator { @@ -198,7 +198,7 @@ LL | fn FRPIT1() -> impl Iterator { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:138:42 | LL | fn FRPIT2() -> impl Iterator { @@ -206,7 +206,7 @@ LL | fn FRPIT2() -> impl Iterator { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:142:45 | LL | fn FRPIT3() -> impl Iterator { @@ -214,7 +214,7 @@ LL | fn FRPIT3() -> impl Iterator { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:146:40 | LL | fn FAPIT1(_: impl Iterator) {} @@ -222,7 +222,7 @@ LL | fn FAPIT1(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:148:40 | LL | fn FAPIT2(_: impl Iterator) {} @@ -230,7 +230,7 @@ LL | fn FAPIT2(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:150:43 | LL | fn FAPIT3(_: impl Iterator) {} @@ -238,7 +238,7 @@ LL | fn FAPIT3(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:153:35 | LL | type TAI1> = T; @@ -246,7 +246,7 @@ LL | type TAI1> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:155:35 | LL | type TAI2> = T; @@ -254,7 +254,7 @@ LL | type TAI2> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:157:38 | LL | type TAI3> = T; @@ -262,7 +262,7 @@ LL | type TAI3> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:161:29 | LL | T: Iterator, @@ -270,7 +270,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:166:29 | LL | T: Iterator, @@ -278,7 +278,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:171:32 | LL | T: Iterator, @@ -286,7 +286,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:175:36 | LL | type ETAI1> = impl Copy; @@ -294,7 +294,7 @@ LL | type ETAI1> = impl Copy; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:177:36 | LL | type ETAI2> = impl Copy; @@ -302,7 +302,7 @@ LL | type ETAI2> = impl Copy; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:179:39 | LL | type ETAI3> = impl Copy; @@ -310,7 +310,7 @@ LL | type ETAI3> = impl Copy; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:181:40 | LL | type ETAI4 = impl Iterator; @@ -318,7 +318,7 @@ LL | type ETAI4 = impl Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:183:40 | LL | type ETAI5 = impl Iterator; @@ -326,7 +326,7 @@ LL | type ETAI5 = impl Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:185:43 | LL | type ETAI6 = impl Iterator; @@ -334,7 +334,7 @@ LL | type ETAI6 = impl Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:188:36 | LL | trait TRI1> {} @@ -342,7 +342,7 @@ LL | trait TRI1> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:190:36 | LL | trait TRI2> {} @@ -350,7 +350,7 @@ LL | trait TRI2> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:192:39 | LL | trait TRI3> {} @@ -358,7 +358,7 @@ LL | trait TRI3> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:194:34 | LL | trait TRS1: Iterator {} @@ -366,7 +366,7 @@ LL | trait TRS1: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:194:34 | LL | trait TRS1: Iterator {} @@ -376,7 +376,7 @@ LL | trait TRS1: Iterator {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:197:34 | LL | trait TRS2: Iterator {} @@ -384,7 +384,7 @@ LL | trait TRS2: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:197:34 | LL | trait TRS2: Iterator {} @@ -394,7 +394,7 @@ LL | trait TRS2: Iterator {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:200:37 | LL | trait TRS3: Iterator {} @@ -402,7 +402,7 @@ LL | trait TRS3: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:200:37 | LL | trait TRS3: Iterator {} @@ -412,7 +412,7 @@ LL | trait TRS3: Iterator {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:205:29 | LL | T: Iterator, @@ -420,7 +420,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:211:29 | LL | T: Iterator, @@ -428,7 +428,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:217:32 | LL | T: Iterator, @@ -436,7 +436,7 @@ LL | T: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:223:32 | LL | Self: Iterator, @@ -444,7 +444,7 @@ LL | Self: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:223:32 | LL | Self: Iterator, @@ -454,7 +454,7 @@ LL | Self: Iterator, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:230:32 | LL | Self: Iterator, @@ -462,7 +462,7 @@ LL | Self: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:230:32 | LL | Self: Iterator, @@ -472,7 +472,7 @@ LL | Self: Iterator, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:237:35 | LL | Self: Iterator, @@ -480,7 +480,7 @@ LL | Self: Iterator, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:237:35 | LL | Self: Iterator, @@ -490,7 +490,7 @@ LL | Self: Iterator, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:255:40 | LL | type TADyn1 = dyn Iterator; @@ -498,7 +498,7 @@ LL | type TADyn1 = dyn Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:257:44 | LL | type TADyn2 = Box>; @@ -506,7 +506,7 @@ LL | type TADyn2 = Box>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:259:43 | LL | type TADyn3 = dyn Iterator; @@ -514,7 +514,7 @@ LL | type TADyn3 = dyn Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:243:34 | LL | type A: Iterator; @@ -522,7 +522,7 @@ LL | type A: Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:247:34 | LL | type A: Iterator; @@ -530,7 +530,7 @@ LL | type A: Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:251:37 | LL | type A: Iterator; diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr index 61299550e98..2a308f83731 100644 --- a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr +++ b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated types `IntoIter` (from trait `IntoIterator`), `IntoIter` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`) must be specified +error[E0191]: the value of the associated types `Item`, `Item`, `IntoIter` and `IntoIter` in `IntoIterator` must be specified --> $DIR/overlaping-bound-suggestion.rs:7:13 | LL | inner: >::IntoIterator as Item>::Core, diff --git a/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr b/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr index 4f8954b80bc..66037054e06 100644 --- a/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr +++ b/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr @@ -45,7 +45,7 @@ LL | fn dent_object(c: dyn BoxCar) { T: Vehicle::Color = COLOR, T: Box::Color = COLOR -error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified +error[E0191]: the value of the associated types `Color` in `Box`, `Color` in `Vehicle` must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30 | LL | type Color; @@ -80,7 +80,7 @@ help: use fully-qualified syntax to disambiguate LL | fn paint(c: C, d: ::Color) { | ~~~~~~~~~~~~ -error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified +error[E0191]: the value of the associated types `Color` in `Box`, `Color` in `Vehicle` must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32 | LL | type Color; diff --git a/tests/ui/associated-types/associated-types-incomplete-object.rs b/tests/ui/associated-types/associated-types-incomplete-object.rs index 4627dfd2b78..f6e4bdfbf37 100644 --- a/tests/ui/associated-types/associated-types-incomplete-object.rs +++ b/tests/ui/associated-types/associated-types-incomplete-object.rs @@ -21,11 +21,11 @@ pub fn main() { let a = &42isize as &dyn Foo; let b = &42isize as &dyn Foo; - //~^ ERROR the value of the associated type `B` (from trait `Foo`) must be specified + //~^ ERROR the value of the associated type `B` in `Foo` must be specified let c = &42isize as &dyn Foo; - //~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified + //~^ ERROR the value of the associated type `A` in `Foo` must be specified let d = &42isize as &dyn Foo; - //~^ ERROR the value of the associated types `A` (from trait `Foo`), `B` (from trait + //~^ ERROR the value of the associated types `A` and `B` in `Foo` } diff --git a/tests/ui/associated-types/associated-types-incomplete-object.stderr b/tests/ui/associated-types/associated-types-incomplete-object.stderr index 32866c71468..0c9761afeb5 100644 --- a/tests/ui/associated-types/associated-types-incomplete-object.stderr +++ b/tests/ui/associated-types/associated-types-incomplete-object.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `B` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `B` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:23:30 | LL | type B; @@ -7,7 +7,7 @@ LL | type B; LL | let b = &42isize as &dyn Foo; | ^^^^^^^^^^^^ help: specify the associated type: `Foo` -error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:26:30 | LL | type A; @@ -16,7 +16,7 @@ LL | type A; LL | let c = &42isize as &dyn Foo; | ^^^^^^^^^^^ help: specify the associated type: `Foo` -error[E0191]: the value of the associated types `A` (from trait `Foo`), `B` (from trait `Foo`) must be specified +error[E0191]: the value of the associated types `A` and `B` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:29:30 | LL | type A; diff --git a/tests/ui/associated-types/issue-22560.stderr b/tests/ui/associated-types/issue-22560.stderr index 2b88cf0b441..46e6e3951a5 100644 --- a/tests/ui/associated-types/issue-22560.stderr +++ b/tests/ui/associated-types/issue-22560.stderr @@ -9,7 +9,7 @@ LL | type Test = dyn Add + Sub; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit -error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified --> $DIR/issue-22560.rs:9:17 | LL | type Output; diff --git a/tests/ui/associated-types/issue-23595-1.stderr b/tests/ui/associated-types/issue-23595-1.stderr index 4307477a56a..3443c4925f4 100644 --- a/tests/ui/associated-types/issue-23595-1.stderr +++ b/tests/ui/associated-types/issue-23595-1.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated types `ChildKey` (from trait `Hierarchy`), `Children` (from trait `Hierarchy`), `Value` (from trait `Hierarchy`) must be specified +error[E0191]: the value of the associated types `Value`, `ChildKey` and `Children` in `Hierarchy` must be specified --> $DIR/issue-23595-1.rs:8:58 | LL | type Value; diff --git a/tests/ui/associated-types/missing-associated-types.stderr b/tests/ui/associated-types/missing-associated-types.stderr index f617df984ae..e9669afe8c7 100644 --- a/tests/ui/associated-types/missing-associated-types.stderr +++ b/tests/ui/associated-types/missing-associated-types.stderr @@ -9,7 +9,7 @@ LL | type Foo = dyn Add + Sub + X + Y; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub + X + Y {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit -error[E0191]: the value of the associated types `A` (from trait `Y`), `Output` (from trait `Add`), `Output` (from trait `Mul`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:12:21 | LL | type A; @@ -38,7 +38,7 @@ LL | type Bar = dyn Add + Sub + X + Z; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub + X + Z {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit -error[E0191]: the value of the associated types `A` (from trait `Z`), `B` (from trait `Z`), `Output` (from trait `Add`), `Output` (from trait `Div`), `Output` (from trait `Div`), `Output` (from trait `Mul`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `A` and `B` in `Z`, `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:15:21 | LL | type A; @@ -74,7 +74,7 @@ LL | type Baz = dyn Add + Sub + Y; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub + Y {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit -error[E0191]: the value of the associated types `A` (from trait `Y`), `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:18:21 | LL | type A; @@ -102,7 +102,7 @@ LL | type Bat = dyn Add + Sub + Fine; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub + Fine {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit -error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:21:21 | LL | type Bat = dyn Add + Sub + Fine; @@ -115,7 +115,7 @@ help: specify the associated types LL | type Bat = dyn Add + Sub + Fine; | ~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~ -error[E0191]: the value of the associated types `Output` (from trait `Div`), `Output` (from trait `Mul`) must be specified +error[E0191]: the value of the associated types `Output` in `Div`, `Output` in `Mul` must be specified --> $DIR/missing-associated-types.rs:24:21 | LL | type Bal = dyn X; diff --git a/tests/ui/error-codes/E0191.stderr b/tests/ui/error-codes/E0191.stderr index cf80c9c46ca..57eda4785a9 100644 --- a/tests/ui/error-codes/E0191.stderr +++ b/tests/ui/error-codes/E0191.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified +error[E0191]: the value of the associated type `Bar` in `Trait` must be specified --> $DIR/E0191.rs:5:16 | LL | type Bar; diff --git a/tests/ui/error-codes/E0220.stderr b/tests/ui/error-codes/E0220.stderr index e03eadacae4..0e0b5c7084c 100644 --- a/tests/ui/error-codes/E0220.stderr +++ b/tests/ui/error-codes/E0220.stderr @@ -4,7 +4,7 @@ error[E0220]: associated type `F` not found for `Trait` LL | type Foo = dyn Trait; | ^ help: `Trait` has the following associated type: `Bar` -error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified +error[E0191]: the value of the associated type `Bar` in `Trait` must be specified --> $DIR/E0220.rs:5:16 | LL | type Bar; diff --git a/tests/ui/error-codes/E0719.stderr b/tests/ui/error-codes/E0719.stderr index 685bd7175e3..00aea97139a 100644 --- a/tests/ui/error-codes/E0719.stderr +++ b/tests/ui/error-codes/E0719.stderr @@ -1,4 +1,4 @@ -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/E0719.rs:1:33 | LL | trait Foo: Iterator {} @@ -6,7 +6,7 @@ LL | trait Foo: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/E0719.rs:1:33 | LL | trait Foo: Iterator {} @@ -16,7 +16,7 @@ LL | trait Foo: Iterator {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/E0719.rs:7:42 | LL | fn test() -> Box> { diff --git a/tests/ui/issues/issue-19482.rs b/tests/ui/issues/issue-19482.rs index 3f3c5de9b14..9d0c8d96d29 100644 --- a/tests/ui/issues/issue-19482.rs +++ b/tests/ui/issues/issue-19482.rs @@ -8,6 +8,6 @@ trait Foo { } fn bar(x: &dyn Foo) {} -//~^ ERROR the associated type `A` (from trait `Foo`) must be specified +//~^ ERROR the associated type `A` in `Foo` must be specified pub fn main() {} diff --git a/tests/ui/issues/issue-19482.stderr b/tests/ui/issues/issue-19482.stderr index d51cc1f081e..90e6f799560 100644 --- a/tests/ui/issues/issue-19482.stderr +++ b/tests/ui/issues/issue-19482.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/issue-19482.rs:10:16 | LL | type A; diff --git a/tests/ui/issues/issue-21950.stderr b/tests/ui/issues/issue-21950.stderr index 731615a6bd8..e498565d4e6 100644 --- a/tests/ui/issues/issue-21950.stderr +++ b/tests/ui/issues/issue-21950.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Output` (from trait `Add`) must be specified +error[E0191]: the value of the associated type `Output` in `Add` must be specified --> $DIR/issue-21950.rs:10:25 | LL | type Output; diff --git a/tests/ui/issues/issue-22434.rs b/tests/ui/issues/issue-22434.rs index 34057b46ecd..d9f7b987c64 100644 --- a/tests/ui/issues/issue-22434.rs +++ b/tests/ui/issues/issue-22434.rs @@ -3,6 +3,6 @@ pub trait Foo { } type I<'a> = &'a (dyn Foo + 'a); -//~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified +//~^ ERROR the value of the associated type `A` in `Foo` must be specified fn main() {} diff --git a/tests/ui/issues/issue-22434.stderr b/tests/ui/issues/issue-22434.stderr index b97fa2503b8..dab62bcbb4d 100644 --- a/tests/ui/issues/issue-22434.stderr +++ b/tests/ui/issues/issue-22434.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/issue-22434.rs:5:23 | LL | type A; diff --git a/tests/ui/issues/issue-23024.rs b/tests/ui/issues/issue-23024.rs index 010281ee371..25220dc3e61 100644 --- a/tests/ui/issues/issue-23024.rs +++ b/tests/ui/issues/issue-23024.rs @@ -8,5 +8,5 @@ fn main() println!("{:?}",(vfnfer[0] as dyn Fn)(3)); //~^ ERROR the precise format of `Fn`-family traits' //~| ERROR missing generics for trait `Fn` - //~| ERROR the value of the associated type `Output` (from trait `FnOnce`) + //~| ERROR the value of the associated type `Output` in `FnOnce` } diff --git a/tests/ui/issues/issue-23024.stderr b/tests/ui/issues/issue-23024.stderr index 2c325ffccee..7d187de1bc4 100644 --- a/tests/ui/issues/issue-23024.stderr +++ b/tests/ui/issues/issue-23024.stderr @@ -18,7 +18,7 @@ help: add missing generic argument LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); | ++++++ -error[E0191]: the value of the associated type `Output` (from trait `FnOnce`) must be specified +error[E0191]: the value of the associated type `Output` in `FnOnce` must be specified --> $DIR/issue-23024.rs:8:39 | LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); diff --git a/tests/ui/issues/issue-28344.stderr b/tests/ui/issues/issue-28344.stderr index f398a5da3e9..71d642109ac 100644 --- a/tests/ui/issues/issue-28344.stderr +++ b/tests/ui/issues/issue-28344.stderr @@ -12,7 +12,7 @@ help: use `dyn` LL | let x: u8 = ::bitor(0 as u8, 0 as u8); | ++++ + -error[E0191]: the value of the associated type `Output` (from trait `BitXor`) must be specified +error[E0191]: the value of the associated type `Output` in `BitXor` must be specified --> $DIR/issue-28344.rs:4:17 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); @@ -40,7 +40,7 @@ help: use `dyn` LL | let g = ::bitor; | ++++ + -error[E0191]: the value of the associated type `Output` (from trait `BitXor`) must be specified +error[E0191]: the value of the associated type `Output` in `BitXor` must be specified --> $DIR/issue-28344.rs:10:13 | LL | let g = BitXor::bitor; diff --git a/tests/ui/object-safety/assoc_type_bounds.rs b/tests/ui/object-safety/assoc_type_bounds.rs index 9abf7939c43..8634ba626a1 100644 --- a/tests/ui/object-safety/assoc_type_bounds.rs +++ b/tests/ui/object-safety/assoc_type_bounds.rs @@ -7,7 +7,7 @@ trait Foo { trait Cake {} impl Cake for () {} -fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified -fn bar(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified +fn bar(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds.stderr b/tests/ui/object-safety/assoc_type_bounds.stderr index a1396dc3ad4..3d5482625af 100644 --- a/tests/ui/object-safety/assoc_type_bounds.stderr +++ b/tests/ui/object-safety/assoc_type_bounds.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds.rs:10:16 | LL | type Bar @@ -7,7 +7,7 @@ LL | type Bar LL | fn foo(_: &dyn Foo<()>) {} | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds.rs:11:16 | LL | type Bar diff --git a/tests/ui/object-safety/assoc_type_bounds2.rs b/tests/ui/object-safety/assoc_type_bounds2.rs index 0112123fd42..f7dc2fb8839 100644 --- a/tests/ui/object-safety/assoc_type_bounds2.rs +++ b/tests/ui/object-safety/assoc_type_bounds2.rs @@ -7,7 +7,7 @@ trait Foo { trait Cake {} impl Cake for () {} -fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified -fn bar(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified +fn bar(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds2.stderr b/tests/ui/object-safety/assoc_type_bounds2.stderr index 7a3c0e02d48..815747436bf 100644 --- a/tests/ui/object-safety/assoc_type_bounds2.stderr +++ b/tests/ui/object-safety/assoc_type_bounds2.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds2.rs:10:16 | LL | type Bar @@ -7,7 +7,7 @@ LL | type Bar LL | fn foo(_: &dyn Foo<()>) {} | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds2.rs:11:16 | LL | type Bar diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs index 647b72a759f..5b07bc92f32 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs @@ -10,7 +10,7 @@ trait Foo { } fn foo(_: &dyn Foo) {} -//~^ ERROR the value of the associated type `Bop` (from trait `Foo`) must be specified +//~^ ERROR the value of the associated type `Bop` in `Foo` must be specified trait Bar { type Bop; @@ -20,6 +20,6 @@ trait Bar { } fn bar(_: &dyn Bar) {} -//~^ ERROR the value of the associated type `Bop` (from trait `Bar`) must be specified +//~^ ERROR the value of the associated type `Bop` in `Bar` must be specified fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr index e4c44334b34..5438faaaf05 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bop` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bop` in `Foo` must be specified --> $DIR/assoc_type_bounds_sized_others.rs:12:16 | LL | type Bop; @@ -7,7 +7,7 @@ LL | type Bop; LL | fn foo(_: &dyn Foo) {} | ^^^ help: specify the associated type: `Foo` -error[E0191]: the value of the associated type `Bop` (from trait `Bar`) must be specified +error[E0191]: the value of the associated type `Bop` in `Bar` must be specified --> $DIR/assoc_type_bounds_sized_others.rs:22:16 | LL | type Bop; diff --git a/tests/ui/suggestions/trait-hidden-method.stderr b/tests/ui/suggestions/trait-hidden-method.stderr index a5a65d193db..5dec2071846 100644 --- a/tests/ui/suggestions/trait-hidden-method.stderr +++ b/tests/ui/suggestions/trait-hidden-method.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified +error[E0191]: the value of the associated type `Item` in `Iterator` must be specified --> $DIR/trait-hidden-method.rs:6:33 | LL | Box::new(1..=10) as Box diff --git a/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr index 175a5fbba61..7c84dd4b8ff 100644 --- a/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr +++ b/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -14,7 +14,7 @@ help: replace the generic bounds with the associated types LL | i: Box>, | +++ +++ -error[E0191]: the value of the associated types `A` (from trait `T`), `C` (from trait `T`) must be specified +error[E0191]: the value of the associated types `C` and `A` in `T` must be specified --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16 | LL | type A; diff --git a/tests/ui/traits/alias/object-fail.stderr b/tests/ui/traits/alias/object-fail.stderr index 048a150df8c..a27a3ea0ec0 100644 --- a/tests/ui/traits/alias/object-fail.stderr +++ b/tests/ui/traits/alias/object-fail.stderr @@ -9,7 +9,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all | = note: the trait cannot be made into an object because it uses `Self` as a type parameter -error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified +error[E0191]: the value of the associated type `Item` in `Iterator` must be specified --> $DIR/object-fail.rs:9:17 | LL | let _: &dyn IteratorAlias = &vec![123].into_iter(); diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs b/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs new file mode 100644 index 00000000000..21f7fd92e80 --- /dev/null +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs @@ -0,0 +1,7 @@ +trait Foo { + type Bar; +} + +fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` cannot be made into an object + +fn main() {} diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr new file mode 100644 index 00000000000..fcaa583e2bd --- /dev/null +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr @@ -0,0 +1,18 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-unsafe-missing-assoc-type.rs:5:16 + | +LL | fn bar(x: &dyn Foo) {} + | ^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | type Bar; + | ^^^ ...because it contains the generic associated type `Bar` + = help: consider moving `Bar` to another trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.rs b/tests/ui/traits/object/with-self-in-projection-output-bad.rs index f34fa80a0ce..9515397fb8d 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.rs +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.rs @@ -43,8 +43,8 @@ impl NormalizableHelper for u32 fn main() { let _x: Box> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` in `Base` must be specified let _y: Box> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` in `Base` must be specified } diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr index 641bfe23666..c9b36e8d29d 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified +error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:45:21 | LL | type Output; @@ -7,7 +7,7 @@ LL | type Output; LL | let _x: Box> = Box::new(2u32); | ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper` -error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified +error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:48:21 | LL | type Output;