From 17a6ae2df3bc3344c87aacdaea1af84bb6e48582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Oct 2023 01:10:51 +0000 Subject: [PATCH 1/3] Detect object safety errors when assoc type is missing When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with. Fix #103155. --- compiler/rustc_hir_analysis/messages.ftl | 2 +- .../rustc_hir_analysis/src/astconv/errors.rs | 47 +++++-- .../src/astconv/object_safety.rs | 2 +- .../rustc_trait_selection/src/traits/mod.rs | 2 +- .../src/traits/object_safety.rs | 2 +- tests/ui/associated-type-bounds/duplicate.rs | 132 +++++++++--------- .../associated-type-bounds/duplicate.stderr | 132 +++++++++--------- .../overlaping-bound-suggestion.stderr | 2 +- ...rojection-from-multiple-supertraits.stderr | 4 +- .../associated-types-incomplete-object.rs | 6 +- .../associated-types-incomplete-object.stderr | 6 +- tests/ui/associated-types/issue-22560.stderr | 2 +- .../ui/associated-types/issue-23595-1.stderr | 2 +- .../missing-associated-types.stderr | 10 +- tests/ui/error-codes/E0191.stderr | 2 +- tests/ui/error-codes/E0220.stderr | 2 +- tests/ui/error-codes/E0719.stderr | 6 +- tests/ui/issues/issue-19482.rs | 2 +- tests/ui/issues/issue-19482.stderr | 2 +- tests/ui/issues/issue-21950.stderr | 2 +- tests/ui/issues/issue-22434.rs | 2 +- tests/ui/issues/issue-22434.stderr | 2 +- tests/ui/issues/issue-23024.rs | 2 +- tests/ui/issues/issue-23024.stderr | 2 +- tests/ui/issues/issue-28344.stderr | 4 +- tests/ui/object-safety/assoc_type_bounds.rs | 4 +- .../ui/object-safety/assoc_type_bounds.stderr | 4 +- tests/ui/object-safety/assoc_type_bounds2.rs | 4 +- .../object-safety/assoc_type_bounds2.stderr | 4 +- .../assoc_type_bounds_sized_others.rs | 4 +- .../assoc_type_bounds_sized_others.stderr | 4 +- .../ui/suggestions/trait-hidden-method.stderr | 2 +- ...type-argument-instead-of-assoc-type.stderr | 2 +- tests/ui/traits/alias/object-fail.stderr | 2 +- .../with-self-in-projection-output-bad.rs | 4 +- .../with-self-in-projection-output-bad.stderr | 4 +- 36 files changed, 223 insertions(+), 194 deletions(-) diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index e8d9918be22d2..8ab91bebcf672 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 889bc2ea4329f..6e9929edc421e 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,33 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { _ => {} } } - names.sort(); + + let names = names + .into_iter() + .map(|(trait_, assocs)| { + format!( + "{} in `{trait_}`", + match &assocs[..] { + [] => String::new(), + [only] => format!("`{only}`"), + [assocs @ .., last] => format!( + "{} and `{last}`", + assocs.iter().map(|a| format!("`{a}`")).collect::>().join(", ") + ), + } + ) + }) + .collect::>() + .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 30c2ab8f5458c..00ff3f836adf3 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 71007e1f0e0a7..fff5510bbfbb0 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 dfc4bdf148467..17c7f94ee883c 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 4b8bf52c37492..5019804d49495 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 3629aa4fceac2..3888e62230f14 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 61299550e98a9..3f170baefb7da 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`, `IntoIter`, `Item` 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 4f8954b80bc71..38906f274861e 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 `Vehicle`, `Color` in `Box` 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 `Vehicle`, `Color` in `Box` 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 4627dfd2b7808..f6e4bdfbf3766 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 32866c7146805..0c9761afeb517 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 2b88cf0b4411e..4cc4ee2b4a3bc 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 `Sub`, `Output` in `Add` 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 4307477a56afe..3443c4925f4e8 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 f617df984ae35..e44c5f1a8d1f1 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 `Sub`, `Output` in `Mul`, `Output` in `Add` 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 `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Sub`, `Output` in `Mul`, `A` and `B` in `Z` 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 `Output` in `Sub`, `A` in `Y`, `Output` in `Add` 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 `Sub`, `Output` in `Add` 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 cf80c9c46ca2c..57eda4785a9fc 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 e03eadacae4f3..0e0b5c7084ccd 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 685bd7175e3ff..00aea97139a71 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 3f3c5de9b1404..9d0c8d96d29a6 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 d51cc1f081e2d..90e6f79956054 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 731615a6bd8d4..e498565d4e653 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 34057b46ecd42..d9f7b987c64fe 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 b97fa2503b8a8..dab62bcbb4d2e 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 010281ee371cd..25220dc3e611c 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 2c325ffcceeaa..7d187de1bc440 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 f398a5da3e93a..71d642109ac8c 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 9abf7939c4302..8634ba626a18a 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 a1396dc3ad40e..3d5482625af3e 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 0112123fd42cd..f7dc2fb88390f 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 7a3c0e02d485d..815747436bf0d 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 647b72a759fa5..5b07bc92f3212 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 e4c44334b3463..5438faaaf0546 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 a5a65d193db06..5dec20718467c 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 175a5fbba610c..de828c7659dce 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 `A` and `C` 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 048a150df8c52..a27a3ea0ec03e 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/with-self-in-projection-output-bad.rs b/tests/ui/traits/object/with-self-in-projection-output-bad.rs index f34fa80a0ceec..9515397fb8dee 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 641bfe236660b..c9b36e8d29de7 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; From 8c5577283c05a4ee9989f7900bda3b1428877c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 18 Oct 2023 21:37:21 +0000 Subject: [PATCH 2/3] Add test --- .../object/object-unsafe-missing-assoc-type.rs | 7 +++++++ .../object-unsafe-missing-assoc-type.stderr | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/ui/traits/object/object-unsafe-missing-assoc-type.rs create mode 100644 tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr 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 0000000000000..21f7fd92e80da --- /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 0000000000000..fcaa583e2bd45 --- /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`. From b8a8ba9c919b76ef1e51ee42f1c7182fd1ac20cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 30 Oct 2023 22:19:17 +0000 Subject: [PATCH 3/3] Sort errors --- compiler/rustc_hir_analysis/src/astconv/errors.rs | 10 ++++++---- .../overlaping-bound-suggestion.stderr | 2 +- ...ed-type-projection-from-multiple-supertraits.stderr | 4 ++-- tests/ui/associated-types/issue-22560.stderr | 2 +- .../associated-types/missing-associated-types.stderr | 8 ++++---- .../use-type-argument-instead-of-assoc-type.stderr | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index 6e9929edc421e..32be7e0837b6d 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -585,9 +585,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } } - let names = names + let mut names = names .into_iter() - .map(|(trait_, assocs)| { + .map(|(trait_, mut assocs)| { + assocs.sort(); format!( "{} in `{trait_}`", match &assocs[..] { @@ -600,8 +601,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } ) }) - .collect::>() - .join(", "); + .collect::>(); + names.sort(); + let names = names.join(", "); trait_bound_spans.sort(); let mut err = struct_span_err!( diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr index 3f170baefb7da..2a308f83731fa 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 `Item`, `IntoIter`, `Item` and `IntoIter` in `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 38906f274861e..66037054e064a 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` in `Vehicle`, `Color` in `Box` 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` in `Vehicle`, `Color` in `Box` 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/issue-22560.stderr b/tests/ui/associated-types/issue-22560.stderr index 4cc4ee2b4a3bc..46e6e3951a5bd 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` in `Sub`, `Output` in `Add` 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/missing-associated-types.stderr b/tests/ui/associated-types/missing-associated-types.stderr index e44c5f1a8d1f1..e9669afe8c704 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` in `Y`, `Output` in `Sub`, `Output` in `Mul`, `Output` in `Add` 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 `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Sub`, `Output` in `Mul`, `A` and `B` in `Z` 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 `Output` in `Sub`, `A` in `Y`, `Output` in `Add` 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` in `Sub`, `Output` in `Add` 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; 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 de828c7659dce..7c84dd4b8ff33 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` and `C` in `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;