diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 5f0fbcc3b0f..9d9a027645f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -473,7 +473,7 @@ pub fn create_substs_for_generic_args<'b>( self_ty: Option>, args_for_def_id: impl Fn(DefId) -> (Option<&'b GenericArgs>, bool), provided_kind: impl Fn(&GenericParamDef, &GenericArg) -> subst::GenericArg<'tcx>, - inferred_kind: impl Fn( + mut inferred_kind: impl FnMut( Option<&[subst::GenericArg<'tcx>]>, &GenericParamDef, bool, @@ -674,6 +674,7 @@ fn create_substs_for_ast_path<'a>( false }; + let mut missing_type_params = vec![]; let substs = Self::create_substs_for_generic_args( tcx, def_id, @@ -709,19 +710,7 @@ fn create_substs_for_ast_path<'a>( // defaults. This will lead to an ICE if we are not // careful! if default_needs_object_self(param) { - struct_span_err!( - tcx.sess, - span, - E0393, - "the type parameter `{}` must be explicitly specified", - param.name - ) - .span_label(span, format!("missing reference to `{}`", param.name)) - .note(&format!( - "because of the default `Self` reference, type parameters \ - must be specified on object types" - )) - .emit(); + missing_type_params.push(param.name.to_string()); tcx.types.err.into() } else { // This is a default type parameter. @@ -759,6 +748,70 @@ fn create_substs_for_ast_path<'a>( } }, ); + if !missing_type_params.is_empty() { + let display = missing_type_params + .iter() + .map(|n| format!("`{}`", n)) + .collect::>() + .join(", "); + let mut err = struct_span_err!( + tcx.sess, + span, + E0393, + "the type parameter{} {} must be explicitly specified", + pluralize!(missing_type_params.len()), + display, + ); + err.span_label( + self.tcx().def_span(def_id), + &format!( + "type parameter{} {} must be specified for this", + pluralize!(missing_type_params.len()), + display, + ), + ); + let mut suggested = false; + if let (Ok(snippet), true) = ( + tcx.sess.source_map().span_to_snippet(span), + // Don't suggest setting the type params if there are some already: the order is + // tricky to get right and the user will already know what the syntax is. + generic_args.args.is_empty(), + ) { + if snippet.ends_with('>') { + // The user wrote `Trait<'a, T>` or similar. To provide an accurate suggestion + // we would have to preserve the right order. For now, as clearly the user is + // aware of the syntax, we do nothing. + } else { + // The user wrote `Iterator`, so we don't have a type we can suggest, but at + // least we can clue them to the correct syntax `Iterator`. + err.span_suggestion( + span, + &format!( + "set the type parameter{plural} to the desired type{plural}", + plural = pluralize!(missing_type_params.len()), + ), + format!("{}<{}>", snippet, missing_type_params.join(", ")), + Applicability::HasPlaceholders, + ); + suggested = true; + } + } + if !suggested { + err.span_label( + span, + format!( + "missing reference{} to {}", + pluralize!(missing_type_params.len()), + display, + ), + ); + } + err.note(&format!( + "because of the default `Self` reference, type parameters must be \ + specified on object types" + )); + err.emit(); + } // Convert associated-type bindings or constraints into a separate vector. // Example: Given this: @@ -854,8 +907,18 @@ pub(super) fn instantiate_poly_trait_ref_inner( self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1); + let path_span = if trait_ref.path.segments.len() == 1 { + // FIXME: `trait_ref.path.span` can point to a full path with multiple + // segments, even though `trait_ref.path.segments` is of length `1`. Work + // around that bug here, even though it should be fixed elsewhere. + // This would otherwise cause an invalid suggestion. For an example, look at + // `src/test/ui/issues/issue-28344.rs`. + trait_ref.path.segments[0].ident.span + } else { + trait_ref.path.span + }; let (substs, assoc_bindings, potential_assoc_types) = self.create_substs_for_ast_trait_ref( - trait_ref.path.span, + path_span, trait_def_id, self_ty, trait_ref.path.segments.last().unwrap(), @@ -947,13 +1010,21 @@ fn create_substs_for_ast_trait_ref<'a>( && trait_segment.generic_args().parenthesized != trait_def.paren_sugar { // For now, require that parenthetical notation be used only with `Fn()` etc. - let msg = if trait_def.paren_sugar { - "the precise format of `Fn`-family traits' type parameters is subject to change. \ - Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead" + let (msg, help) = if trait_def.paren_sugar { + ( + "the precise format of `Fn`-family traits' type parameters is subject to \ + change", + Some("use parenthetical notation instead: `Fn(Foo, Bar) -> Baz`"), + ) } else { - "parenthetical notation is only stable when used with `Fn`-family traits" + ("parenthetical notation is only stable when used with `Fn`-family traits", None) }; - feature_err(&self.tcx().sess.parse_sess, sym::unboxed_closures, span, msg).emit(); + let sess = &self.tcx().sess.parse_sess; + let mut err = feature_err(sess, sym::unboxed_closures, span, msg); + if let Some(help) = help { + err.help(help); + } + err.emit(); } self.create_substs_for_ast_path( @@ -1213,8 +1284,8 @@ fn add_predicates_for_ast_type_binding( self.tcx().sess, binding.span, E0719, - "the value of the associated type `{}` (from the trait `{}`) \ - is already specified", + "the value of the associated type `{}` (from trait `{}`) \ + is already specified", binding.item_name, tcx.def_path_str(assoc_ty.container.id()) ) @@ -1378,65 +1449,123 @@ fn conv_object_ty_poly_trait_ref( } if !associated_types.is_empty() { + // Account for things like `dyn Foo + 'a` by pointing at the `TraitRef.path` + // `Span` instead of the `PolyTraitRef` `Span`. That way the suggestion will + // be valid, otherwise we would suggest `dyn Foo + 'a`. See tests + // `issue-22434.rs` and `issue-22560.rs` for examples. + let sugg_span = if potential_assoc_types.is_empty() && trait_bounds.len() == 1 { + if trait_bounds[0].trait_ref.path.segments.len() == 1 + && trait_bounds[0].trait_ref.path.segments[0].args.is_none() + { + // FIXME: `trait_ref.path.span` can point to a full path with multiple + // segments, even though `trait_ref.path.segments` is of length `1`. Work + // around that bug here, even though it should be fixed elsewhere. + // This would otherwise cause an invalid suggestion. For an example, look at + // `src/test/ui/issues/issue-28344.rs`. + trait_bounds[0].trait_ref.path.segments[0].ident.span + } else { + trait_bounds[0].trait_ref.path.span + } + } else { + span + }; let names = associated_types .iter() .map(|item_def_id| { let assoc_item = tcx.associated_item(*item_def_id); let trait_def_id = assoc_item.container.id(); format!( - "`{}` (from the trait `{}`)", + "`{}` (from trait `{}`)", assoc_item.ident, - tcx.def_path_str(trait_def_id), + tcx.def_path_str(trait_def_id) ) }) .collect::>() .join(", "); let mut err = struct_span_err!( tcx.sess, - span, + sugg_span, E0191, "the value of the associated type{} {} must be specified", pluralize!(associated_types.len()), names, ); - let (suggest, potential_assoc_types_spans) = + let mut suggestions = Vec::new(); + let mut applicability = Applicability::MaybeIncorrect; + for (i, item_def_id) in associated_types.iter().enumerate() { + let assoc_item = tcx.associated_item(*item_def_id); + if let Some(sp) = tcx.hir().span_if_local(*item_def_id) { + err.span_label(sp, format!("`{}` defined here", assoc_item.ident)); + } if potential_assoc_types.len() == associated_types.len() { // Only suggest when the amount of missing associated types equals the number of // extra type arguments present, as that gives us a relatively high confidence // that the user forgot to give the associtated type's name. The canonical // example would be trying to use `Iterator` instead of // `Iterator`. - (true, potential_assoc_types) - } else { - (false, Vec::new()) - }; - let mut suggestions = Vec::new(); - for (i, item_def_id) in associated_types.iter().enumerate() { - let assoc_item = tcx.associated_item(*item_def_id); - err.span_label( - span, - format!("associated type `{}` must be specified", assoc_item.ident), - ); - if let Some(sp) = tcx.hir().span_if_local(*item_def_id) { - err.span_label(sp, format!("`{}` defined here", assoc_item.ident)); - } - if suggest { if let Ok(snippet) = - tcx.sess.source_map().span_to_snippet(potential_assoc_types_spans[i]) + tcx.sess.source_map().span_to_snippet(potential_assoc_types[i]) { suggestions.push(( - potential_assoc_types_spans[i], + potential_assoc_types[i], format!("{} = {}", assoc_item.ident, snippet), )); } } } - if !suggestions.is_empty() { - let msg = format!( - "if you meant to specify the associated {}, write", - if suggestions.len() == 1 { "type" } else { "types" } + let mut suggestions_len = suggestions.len(); + if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(sugg_span) { + if potential_assoc_types.is_empty() && trait_bounds.len() == 1 && + // Do not attempt to suggest when we don't know which path segment needs the + // type parameter set. + trait_bounds[0].trait_ref.path.segments.len() == 1 + { + debug!("path segments {:?}", trait_bounds[0].trait_ref.path.segments); + applicability = Applicability::HasPlaceholders; + let assoc_types: Vec = associated_types + .iter() + .map(|item_def_id| { + let assoc_item = tcx.associated_item(*item_def_id); + format!("{} = Type", assoc_item.ident) + }) + .collect(); + let sugg = assoc_types.join(", "); + if snippet.ends_with('>') { + // The user wrote `Trait<'a>` or similar and we don't have a type we can + // suggest, but at least we can clue them to the correct syntax + // `Trait<'a, Item = Type>` while accounting for the `<'a>` in the + // suggestion. + suggestions.push(( + sugg_span, + format!("{}, {}>", &snippet[..snippet.len() - 1], sugg,), + )); + } else { + // The user wrote `Iterator`, so we don't have a type we can suggest, but at + // least we can clue them to the correct syntax `Iterator`. + suggestions.push((sugg_span, format!("{}<{}>", snippet, sugg))); + } + suggestions_len = assoc_types.len(); + } + } + if suggestions.len() != 1 { + // We don't need this label if there's an inline suggestion, show otherwise. + let names = associated_types + .iter() + .map(|t| format!("`{}`", tcx.associated_item(*t).ident)) + .collect::>() + .join(", "); + err.span_label( + span, + format!( + "associated type{} {} must be specified", + pluralize!(associated_types.len()), + names, + ), ); - err.multipart_suggestion(&msg, suggestions, Applicability::MaybeIncorrect); + } + if !suggestions.is_empty() { + let msg = format!("specify the associated type{}", pluralize!(suggestions_len)); + err.multipart_suggestion(&msg, suggestions, applicability); } err.emit(); } @@ -1645,23 +1774,32 @@ fn one_bound_for_assoc_type( }) .and_then(|item| self.tcx().hir().span_if_local(item.def_id)); - if let Some(span) = bound_span { + if let Some(bound_span) = bound_span { err.span_label( - span, + bound_span, format!( "ambiguous `{}` from `{}`", assoc_name, - bound.print_only_trait_path() + bound.print_only_trait_path(), ), ); - } else { - span_note!( - &mut err, + err.span_suggestion( span, + "use fully qualified syntax to disambiguate", + format!( + "<{} as {}>::{}", + ty_param_name, + bound.print_only_trait_path(), + assoc_name, + ), + Applicability::MaybeIncorrect, + ); + } else { + err.note(&format!( "associated type `{}` could derive from `{}`", ty_param_name, - bound.print_only_trait_path() - ); + bound.print_only_trait_path(), + )); } } err.emit(); diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs index 2912c4ead7a..1970b9af14e 100644 --- a/src/test/compile-fail/issue-23595-1.rs +++ b/src/test/compile-fail/issue-23595-1.rs @@ -1,12 +1,12 @@ #![feature(associated_type_defaults)] -use std::ops::{Index}; +use std::ops::Index; trait Hierarchy { type Value; type ChildKey; type Children = dyn Index; - //~^ ERROR: the value of the associated types `Value` (from the trait `Hierarchy`), `ChildKey` + //~^ ERROR: the value of the associated types `Value` (from trait `Hierarchy`), `ChildKey` fn data(&self) -> Option<(Self::Value, Self::Children)>; } diff --git a/src/test/ui/associated-type-bounds/duplicate.rs b/src/test/ui/associated-type-bounds/duplicate.rs index a89fd9807da..64bc9eeec25 100644 --- a/src/test/ui/associated-type-bounds/duplicate.rs +++ b/src/test/ui/associated-type-bounds/duplicate.rs @@ -9,175 +9,175 @@ use std::iter; struct SI1> { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] struct SI2> { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] struct SI3> { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] struct SW1 where T: Iterator { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] struct SW2 where T: Iterator { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] struct SW3 where T: Iterator { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] enum EI1> { V(T) } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] enum EI2> { V(T) } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] enum EI3> { V(T) } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] enum EW1 where T: Iterator { V(T) } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] enum EW2 where T: Iterator { V(T) } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] enum EW3 where T: Iterator { V(T) } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] union UI1> { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] union UI2> { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] union UI3> { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] union UW1 where T: Iterator { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] union UW2 where T: Iterator { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] union UW3 where T: Iterator { f: T } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FI1>() {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FI2>() {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FI3>() {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FW1() where T: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FW2() where T: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FW3() where T: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FRPIT1() -> impl Iterator { iter::empty() } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FRPIT2() -> impl Iterator { iter::empty() } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FRPIT3() -> impl Iterator { iter::empty() } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FAPIT1(_: impl Iterator) {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FAPIT2(_: impl Iterator) {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn FAPIT3(_: impl Iterator) {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] const CIT1: impl Iterator = iter::empty(); -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] const CIT2: impl Iterator = iter::empty(); -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] const CIT3: impl Iterator = iter::empty(); -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] static SIT1: impl Iterator = iter::empty(); -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] static SIT2: impl Iterator = iter::empty(); -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] static SIT3: impl Iterator = iter::empty(); -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn lit1() { let _: impl Iterator = iter::empty(); } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn lit2() { let _: impl Iterator = iter::empty(); } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] fn lit3() { let _: impl Iterator = iter::empty(); } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TAI1> = T; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TAI2> = T; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TAI3> = T; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TAW1 where T: Iterator = T; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TAW2 where T: Iterator = T; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TAW3 where T: Iterator = T; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type ETAI1> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses //~| ERROR could not find defining uses type ETAI2> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses //~| ERROR could not find defining uses type ETAI3> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses //~| ERROR could not find defining uses type ETAI4 = impl Iterator; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses //~| ERROR could not find defining uses type ETAI5 = impl Iterator; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses //~| ERROR could not find defining uses type ETAI6 = impl Iterator; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses //~| ERROR could not find defining uses trait TRI1> {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRI2> {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRI3> {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRS1: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRS2: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRS3: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRW1 where T: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRW2 where T: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRW3 where T: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRSW1 where Self: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRSW2 where Self: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRSW3 where Self: Iterator {} -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRA1 { type A: Iterator; } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRA2 { type A: Iterator; } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] trait TRA3 { type A: Iterator; } -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] type TADyn1 = dyn Iterator; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses type TADyn2 = Box>; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses type TADyn3 = dyn Iterator; -//~^ ERROR the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified [E0719] //~| ERROR could not find defining uses //~| ERROR could not find defining uses diff --git a/src/test/ui/associated-type-bounds/duplicate.stderr b/src/test/ui/associated-type-bounds/duplicate.stderr index e5e85d6856f..caecc5e85f6 100644 --- a/src/test/ui/associated-type-bounds/duplicate.stderr +++ b/src/test/ui/associated-type-bounds/duplicate.stderr @@ -6,7 +6,7 @@ LL | #![feature(impl_trait_in_bindings)] | = note: `#[warn(incomplete_features)]` on by default -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:11:36 | LL | struct SI1> { f: T } @@ -14,7 +14,7 @@ LL | struct SI1> { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:13:36 | LL | struct SI2> { f: T } @@ -22,7 +22,7 @@ LL | struct SI2> { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:15:39 | LL | struct SI3> { f: T } @@ -30,7 +30,7 @@ LL | struct SI3> { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:17:45 | LL | struct SW1 where T: Iterator { f: T } @@ -38,7 +38,7 @@ LL | struct SW1 where T: Iterator { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:19:45 | LL | struct SW2 where T: Iterator { f: T } @@ -46,7 +46,7 @@ LL | struct SW2 where T: Iterator { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:21:48 | LL | struct SW3 where T: Iterator { f: T } @@ -54,7 +54,7 @@ LL | struct SW3 where T: Iterator { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:24:34 | LL | enum EI1> { V(T) } @@ -62,7 +62,7 @@ LL | enum EI1> { V(T) } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:26:34 | LL | enum EI2> { V(T) } @@ -70,7 +70,7 @@ LL | enum EI2> { V(T) } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:28:37 | LL | enum EI3> { V(T) } @@ -78,7 +78,7 @@ LL | enum EI3> { V(T) } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:30:43 | LL | enum EW1 where T: Iterator { V(T) } @@ -86,7 +86,7 @@ LL | enum EW1 where T: Iterator { V(T) } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:32:43 | LL | enum EW2 where T: Iterator { V(T) } @@ -94,7 +94,7 @@ LL | enum EW2 where T: Iterator { V(T) } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:34:46 | LL | enum EW3 where T: Iterator { V(T) } @@ -102,7 +102,7 @@ LL | enum EW3 where T: Iterator { V(T) } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:37:35 | LL | union UI1> { f: T } @@ -110,7 +110,7 @@ LL | union UI1> { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:39:35 | LL | union UI2> { f: T } @@ -118,7 +118,7 @@ LL | union UI2> { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:41:38 | LL | union UI3> { f: T } @@ -126,7 +126,7 @@ LL | union UI3> { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:43:44 | LL | union UW1 where T: Iterator { f: T } @@ -134,7 +134,7 @@ LL | union UW1 where T: Iterator { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:45:44 | LL | union UW2 where T: Iterator { f: T } @@ -142,7 +142,7 @@ LL | union UW2 where T: Iterator { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:47:47 | LL | union UW3 where T: Iterator { f: T } @@ -150,7 +150,7 @@ LL | union UW3 where T: Iterator { f: T } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:50:32 | LL | fn FI1>() {} @@ -158,7 +158,7 @@ LL | fn FI1>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:52:32 | LL | fn FI2>() {} @@ -166,7 +166,7 @@ LL | fn FI2>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:54:35 | LL | fn FI3>() {} @@ -174,7 +174,7 @@ LL | fn FI3>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:56:43 | LL | fn FW1() where T: Iterator {} @@ -182,7 +182,7 @@ LL | fn FW1() where T: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:58:43 | LL | fn FW2() where T: Iterator {} @@ -190,7 +190,7 @@ LL | fn FW2() where T: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:60:46 | LL | fn FW3() where T: Iterator {} @@ -198,7 +198,7 @@ LL | fn FW3() where T: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:69:40 | LL | fn FAPIT1(_: impl Iterator) {} @@ -206,7 +206,7 @@ LL | fn FAPIT1(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:71:40 | LL | fn FAPIT2(_: impl Iterator) {} @@ -214,7 +214,7 @@ LL | fn FAPIT2(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:73:43 | LL | fn FAPIT3(_: impl Iterator) {} @@ -222,7 +222,7 @@ LL | fn FAPIT3(_: impl Iterator) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:63:42 | LL | fn FRPIT1() -> impl Iterator { iter::empty() } @@ -230,7 +230,7 @@ LL | fn FRPIT1() -> impl Iterator { iter::empty() } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:65:42 | LL | fn FRPIT2() -> impl Iterator { iter::empty() } @@ -238,7 +238,7 @@ LL | fn FRPIT2() -> impl Iterator { iter::empty() } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:67:45 | LL | fn FRPIT3() -> impl Iterator { iter::empty() } @@ -246,7 +246,7 @@ LL | fn FRPIT3() -> impl Iterator { iter::empty() | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:76:39 | LL | const CIT1: impl Iterator = iter::empty(); @@ -254,7 +254,7 @@ LL | const CIT1: impl Iterator = iter::empty(); | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:78:39 | LL | const CIT2: impl Iterator = iter::empty(); @@ -262,7 +262,7 @@ LL | const CIT2: impl Iterator = iter::empty(); | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:80:42 | LL | const CIT3: impl Iterator = iter::empty(); @@ -270,7 +270,7 @@ LL | const CIT3: impl Iterator = iter::empty(); | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:82:40 | LL | static SIT1: impl Iterator = iter::empty(); @@ -278,7 +278,7 @@ LL | static SIT1: impl Iterator = iter::empty(); | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:84:40 | LL | static SIT2: impl Iterator = iter::empty(); @@ -286,7 +286,7 @@ LL | static SIT2: impl Iterator = iter::empty(); | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:86:43 | LL | static SIT3: impl Iterator = iter::empty(); @@ -294,7 +294,7 @@ LL | static SIT3: impl Iterator = iter::empty(); | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:89:46 | LL | fn lit1() { let _: impl Iterator = iter::empty(); } @@ -302,7 +302,7 @@ LL | fn lit1() { let _: impl Iterator = iter::empty(); } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:91:46 | LL | fn lit2() { let _: impl Iterator = iter::empty(); } @@ -310,7 +310,7 @@ LL | fn lit2() { let _: impl Iterator = iter::empty(); } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:93:49 | LL | fn lit3() { let _: impl Iterator = iter::empty(); } @@ -318,7 +318,7 @@ LL | fn lit3() { let _: impl Iterator = iter::empt | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:96:35 | LL | type TAI1> = T; @@ -326,7 +326,7 @@ LL | type TAI1> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:98:35 | LL | type TAI2> = T; @@ -334,7 +334,7 @@ LL | type TAI2> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:100:38 | LL | type TAI3> = T; @@ -342,7 +342,7 @@ LL | type TAI3> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:102:44 | LL | type TAW1 where T: Iterator = T; @@ -350,7 +350,7 @@ LL | type TAW1 where T: Iterator = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:104:44 | LL | type TAW2 where T: Iterator = T; @@ -358,7 +358,7 @@ LL | type TAW2 where T: Iterator = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:106:47 | LL | type TAW3 where T: Iterator = T; @@ -372,7 +372,7 @@ error: could not find defining uses LL | type ETAI1> = impl Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:109:36 | LL | type ETAI1> = impl Copy; @@ -386,7 +386,7 @@ error: could not find defining uses LL | type ETAI2> = impl Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:114:36 | LL | type ETAI2> = impl Copy; @@ -400,7 +400,7 @@ error: could not find defining uses LL | type ETAI3> = impl Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:119:39 | LL | type ETAI3> = impl Copy; @@ -414,7 +414,7 @@ error: could not find defining uses LL | type ETAI4 = impl Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:124:40 | LL | type ETAI4 = impl Iterator; @@ -428,7 +428,7 @@ error: could not find defining uses LL | type ETAI5 = impl Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:129:40 | LL | type ETAI5 = impl Iterator; @@ -442,7 +442,7 @@ error: could not find defining uses LL | type ETAI6 = impl Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:134:43 | LL | type ETAI6 = impl Iterator; @@ -450,7 +450,7 @@ LL | type ETAI6 = impl Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:140:36 | LL | trait TRI1> {} @@ -458,7 +458,7 @@ LL | trait TRI1> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:142:36 | LL | trait TRI2> {} @@ -466,7 +466,7 @@ LL | trait TRI2> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:144:39 | LL | trait TRI3> {} @@ -474,7 +474,7 @@ LL | trait TRI3> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:146:34 | LL | trait TRS1: Iterator {} @@ -482,7 +482,7 @@ LL | trait TRS1: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:148:34 | LL | trait TRS2: Iterator {} @@ -490,7 +490,7 @@ LL | trait TRS2: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:150:37 | LL | trait TRS3: Iterator {} @@ -498,7 +498,7 @@ LL | trait TRS3: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:152:45 | LL | trait TRW1 where T: Iterator {} @@ -506,7 +506,7 @@ LL | trait TRW1 where T: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:154:45 | LL | trait TRW2 where T: Iterator {} @@ -514,7 +514,7 @@ LL | trait TRW2 where T: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:156:48 | LL | trait TRW3 where T: Iterator {} @@ -522,7 +522,7 @@ LL | trait TRW3 where T: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:158:46 | LL | trait TRSW1 where Self: Iterator {} @@ -530,7 +530,7 @@ LL | trait TRSW1 where Self: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:160:46 | LL | trait TRSW2 where Self: Iterator {} @@ -538,7 +538,7 @@ LL | trait TRSW2 where Self: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:162:49 | LL | trait TRSW3 where Self: Iterator {} @@ -546,7 +546,7 @@ LL | trait TRSW3 where Self: Iterator {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:164:43 | LL | trait TRA1 { type A: Iterator; } @@ -554,7 +554,7 @@ LL | trait TRA1 { type A: Iterator; } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:166:43 | LL | trait TRA2 { type A: Iterator; } @@ -562,7 +562,7 @@ LL | trait TRA2 { type A: Iterator; } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:168:46 | LL | trait TRA3 { type A: Iterator; } @@ -570,7 +570,7 @@ LL | trait TRA3 { type A: Iterator; } | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:171:40 | LL | type TADyn1 = dyn Iterator; @@ -578,7 +578,7 @@ LL | type TADyn1 = dyn Iterator; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:175:44 | LL | type TADyn2 = Box>; @@ -586,7 +586,7 @@ LL | type TADyn2 = Box>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/duplicate.rs:179:43 | LL | type TADyn3 = dyn Iterator; diff --git a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr b/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr index 9ec6ffb0565..6de8459954c 100644 --- a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr +++ b/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr @@ -9,6 +9,15 @@ LL | type Color; ... LL | fn a(_: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn a(_: ::Color) { + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn a(_: ::Color) { + | ^^^^^^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:20:12 @@ -21,6 +30,15 @@ LL | type Color; ... LL | fn b(_: C::Color) where C : Vehicle+Box { | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn b(_: ::Color) where C : Vehicle+Box { + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn b(_: ::Color) where C : Vehicle+Box { + | ^^^^^^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:24:12 @@ -33,6 +51,15 @@ LL | type Color; ... LL | fn c(_: C::Color) where C : Vehicle, C : Box { | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn c(_: ::Color) where C : Vehicle, C : Box { + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn c(_: ::Color) where C : Vehicle, C : Box { + | ^^^^^^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Color` in bounds of `X` --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:35:20 @@ -45,6 +72,15 @@ LL | type Color; ... LL | fn e(&self, _: X::Color) where X : Box; | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn e(&self, _: ::Color) where X : Box; + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn e(&self, _: ::Color) where X : Box; + | ^^^^^^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Color` in bounds of `X` --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:38:20 @@ -57,6 +93,15 @@ LL | type Color; ... LL | fn f(&self, _: X::Color) where X : Box { } | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn f(&self, _: ::Color) where X : Box { } + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn f(&self, _: ::Color) where X : Box { } + | ^^^^^^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Color` in bounds of `X` --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:30:20 @@ -69,6 +114,15 @@ LL | type Color; ... LL | fn d(&self, _: X::Color) where X : Box { } | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn d(&self, _: ::Color) where X : Box { } + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn d(&self, _: ::Color) where X : Box { } + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs index 7a678445796..f50587bac16 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs @@ -20,13 +20,26 @@ fn dent(c: C, color: C::Color) { //~^ ERROR ambiguous associated type `Color` in bounds of `C` } +// FIXME: add error code to detect this case and explain that you'll want the approach in +// `dent_object_3` of using a new type param and relying on the `where` clauses. fn dent_object(c: dyn BoxCar) { //~^ ERROR ambiguous associated type - //~| ERROR the value of the associated type `Color` (from the trait `Vehicle`) must be specified + //~| ERROR the value of the associated type `Color` (from trait `Vehicle`) must be specified } fn paint(c: C, d: C::Color) { //~^ ERROR ambiguous associated type `Color` in bounds of `C` } +fn dent_object_2(c: dyn BoxCar) where ::Color = COLOR { + //~^ ERROR the value of the associated types `Color` (from trait `Vehicle`), `Color` (from + //~| ERROR equality constraints are not yet supported in where clauses +} + +fn dent_object_3(c: X) +where X: BoxCar, + X: Vehicle, + X: Box +{} // OK! + pub fn main() { } diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr index 6118ebef125..4f14cffb065 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr @@ -1,3 +1,9 @@ +error: equality constraints are not yet supported in where clauses (see #20041) + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:34:46 + | +LL | fn dent_object_2(c: dyn BoxCar) where ::Color = COLOR { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-from-multiple-supertraits.rs:19:32 | @@ -9,9 +15,18 @@ LL | type Color; ... LL | fn dent(c: C, color: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn dent(c: C, color: ::Color) { + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn dent(c: C, color: ::Color) { + | ^^^^^^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Color` in bounds of `BoxCar` - --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37 + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:25:37 | LL | type Color; | ----------- ambiguous `Color` from `Vehicle` @@ -21,18 +36,27 @@ LL | type Color; ... LL | fn dent_object(c: dyn BoxCar) { | ^^^^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn dent_object(c: dyn BoxCar<::Color>) { + | ^^^^^^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn dent_object(c: dyn BoxCar<::Color>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0191]: the value of the associated type `Color` (from the trait `Vehicle`) must be specified - --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:26 +error[E0191]: the value of the associated type `Color` (from trait `Vehicle`) must be specified + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:25:30 | LL | type Color; | ----------- `Color` defined here ... LL | fn dent_object(c: dyn BoxCar) { - | ^^^^^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified + | ^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `BoxCar` error[E0221]: ambiguous associated type `Color` in bounds of `C` - --> $DIR/associated-type-projection-from-multiple-supertraits.rs:28:29 + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:30:29 | LL | type Color; | ----------- ambiguous `Color` from `Vehicle` @@ -42,8 +66,29 @@ LL | type Color; ... LL | fn paint(c: C, d: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` + | +help: use fully qualified syntax to disambiguate + | +LL | fn paint(c: C, d: ::Color) { + | ^^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | fn paint(c: C, d: ::Color) { + | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error[E0191]: the value of the associated types `Color` (from trait `Vehicle`), `Color` (from trait `Box`) must be specified + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:34:32 + | +LL | type Color; + | ----------- `Color` defined here +... +LL | type Color; + | ----------- `Color` defined here +... +LL | fn dent_object_2(c: dyn BoxCar) where ::Color = COLOR { + | ^^^^^^ help: specify the associated types: `BoxCar` + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0191, E0221. For more information about an error, try `rustc --explain E0191`. diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.rs b/src/test/ui/associated-types/associated-types-incomplete-object.rs index 4993b131215..4627dfd2b78 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.rs +++ b/src/test/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 the trait `Foo`) must be specified + //~^ ERROR the value of the associated type `B` (from trait `Foo`) must be specified let c = &42isize as &dyn Foo; - //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified + //~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified let d = &42isize as &dyn Foo; - //~^ ERROR the value of the associated types `A` (from the trait `Foo`), `B` (from the trait + //~^ ERROR the value of the associated types `A` (from trait `Foo`), `B` (from trait } diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.stderr b/src/test/ui/associated-types/associated-types-incomplete-object.stderr index b4c08f4a4cc..24732271c42 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.stderr +++ b/src/test/ui/associated-types/associated-types-incomplete-object.stderr @@ -1,23 +1,23 @@ -error[E0191]: the value of the associated type `B` (from the trait `Foo`) must be specified - --> $DIR/associated-types-incomplete-object.rs:23:26 +error[E0191]: the value of the associated type `B` (from trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:23:30 | LL | type B; | ------- `B` defined here ... LL | let b = &42isize as &dyn Foo; - | ^^^^^^^^^^^^^^^^ associated type `B` must be specified + | ^^^^^^^^^^^^ help: specify the associated type: `Foo` -error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified - --> $DIR/associated-types-incomplete-object.rs:26:26 +error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:26:30 | LL | type A; | ------- `A` defined here ... LL | let c = &42isize as &dyn Foo; - | ^^^^^^^^^^^^^^^ associated type `A` must be specified + | ^^^^^^^^^^^ help: specify the associated type: `Foo` -error[E0191]: the value of the associated types `A` (from the trait `Foo`), `B` (from the trait `Foo`) must be specified - --> $DIR/associated-types-incomplete-object.rs:29:26 +error[E0191]: the value of the associated types `A` (from trait `Foo`), `B` (from trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:29:30 | LL | type A; | ------- `A` defined here @@ -25,10 +25,7 @@ LL | type B; | ------- `B` defined here ... LL | let d = &42isize as &dyn Foo; - | ^^^^^^^ - | | - | associated type `A` must be specified - | associated type `B` must be specified + | ^^^ help: specify the associated types: `Foo` error: aborting due to 3 previous errors diff --git a/src/test/ui/associated-types/associated-types-path-1.stderr b/src/test/ui/associated-types/associated-types-path-1.stderr index a10cf7f890c..b7856e20afa 100644 --- a/src/test/ui/associated-types/associated-types-path-1.stderr +++ b/src/test/ui/associated-types/associated-types-path-1.stderr @@ -15,6 +15,15 @@ LL | type A; ... LL | pub fn f2(a: T, x: T::A) {} | ^^^^ ambiguous associated type `A` + | +help: use fully qualified syntax to disambiguate + | +LL | pub fn f2(a: T, x: ::A) {} + | ^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | pub fn f2(a: T, x: ::A) {} + | ^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0191.stderr b/src/test/ui/error-codes/E0191.stderr index 92fa85bca0e..d69a14916e1 100644 --- a/src/test/ui/error-codes/E0191.stderr +++ b/src/test/ui/error-codes/E0191.stderr @@ -1,11 +1,11 @@ -error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified - --> $DIR/E0191.rs:5:12 +error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified + --> $DIR/E0191.rs:5:16 | LL | type Bar; | --------- `Bar` defined here ... LL | type Foo = dyn Trait; - | ^^^^^^^^^ associated type `Bar` must be specified + | ^^^^^ help: specify the associated type: `Trait` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr index 5da302748cd..58a92fe9832 100644 --- a/src/test/ui/error-codes/E0220.stderr +++ b/src/test/ui/error-codes/E0220.stderr @@ -4,14 +4,14 @@ error[E0220]: associated type `F` not found for `Trait` LL | type Foo = dyn Trait; | ^^^^^ associated type `F` not found -error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified - --> $DIR/E0220.rs:5:12 +error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified + --> $DIR/E0220.rs:5:16 | LL | type Bar; | --------- `Bar` defined here ... LL | type Foo = dyn Trait; - | ^^^^^^^^^^^^^^^^ associated type `Bar` must be specified + | ^^^^^^^^^^^^ help: specify the associated type: `Trait` error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0221.stderr b/src/test/ui/error-codes/E0221.stderr index 043f0c68bbc..0b4819143ce 100644 --- a/src/test/ui/error-codes/E0221.stderr +++ b/src/test/ui/error-codes/E0221.stderr @@ -9,6 +9,15 @@ LL | type A: T2; LL | fn do_something() { LL | let _: Self::A; | ^^^^^^^ ambiguous associated type `A` + | +help: use fully qualified syntax to disambiguate + | +LL | let _: ::A; + | ^^^^^^^^^^^^^^^^ +help: use fully qualified syntax to disambiguate + | +LL | let _: ::A; + | ^^^^^^^^^^^^^^^^ error[E0221]: ambiguous associated type `Err` in bounds of `Self` --> $DIR/E0221.rs:21:16 @@ -16,14 +25,13 @@ error[E0221]: ambiguous associated type `Err` in bounds of `Self` LL | type Err: T3; | ------------- ambiguous `Err` from `My` LL | fn test() { -LL | let _: Self::Err; - | ^^^^^^^^^ ambiguous associated type `Err` - | -note: associated type `Self` could derive from `std::str::FromStr` - --> $DIR/E0221.rs:21:16 - | LL | let _: Self::Err; | ^^^^^^^^^ + | | + | ambiguous associated type `Err` + | help: use fully qualified syntax to disambiguate: `::Err` + | + = note: associated type `Self` could derive from `std::str::FromStr` error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0393.stderr b/src/test/ui/error-codes/E0393.stderr index 543e3213633..7771bacc9ed 100644 --- a/src/test/ui/error-codes/E0393.stderr +++ b/src/test/ui/error-codes/E0393.stderr @@ -1,8 +1,11 @@ error[E0393]: the type parameter `T` must be explicitly specified --> $DIR/E0393.rs:3:47 | +LL | trait A {} + | ------------------ type parameter `T` must be specified for this +LL | LL | fn together_we_will_rule_the_galaxy(son: &dyn A) {} - | ^ missing reference to `T` + | ^ help: set the type parameter to the desired type: `A` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/error-codes/E0719.stderr b/src/test/ui/error-codes/E0719.stderr index c5b9a71c659..a046fbfc3d0 100644 --- a/src/test/ui/error-codes/E0719.stderr +++ b/src/test/ui/error-codes/E0719.stderr @@ -1,4 +1,4 @@ -error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::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 the trait `std::iter::Iterator`) is already specified +error[E0719]: the value of the associated type `Item` (from trait `std::iter::Iterator`) is already specified --> $DIR/E0719.rs:6:42 | LL | fn test() -> Box> { diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 657bf13c873..48230dc035b 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -34,7 +34,7 @@ LL | extern "rust-call" fn call_once(&self, args: ()) -> () {} = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:9:6 | LL | impl Fn<()> for Foo { @@ -42,6 +42,7 @@ LL | impl Fn<()> for Foo { | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` error[E0229]: associated type bindings are not allowed here --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:6 @@ -49,7 +50,7 @@ error[E0229]: associated type bindings are not allowed here LL | impl FnOnce() for Foo1 { | ^^^^^^^^ associated type not allowed here -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:21:6 | LL | impl FnMut<()> for Bar { @@ -57,8 +58,9 @@ LL | impl FnMut<()> for Bar { | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:27:6 | LL | impl FnOnce<()> for Baz { @@ -66,6 +68,7 @@ LL | impl FnOnce<()> for Baz { | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` error: aborting due to 8 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr index f343a42eb8f..67814a5d016 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr @@ -7,7 +7,7 @@ LL | extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures.rs:5:6 | LL | impl FnOnce<(u32, u32)> for Test { @@ -15,6 +15,7 @@ LL | impl FnOnce<(u32, u32)> for Test { | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-19482.rs b/src/test/ui/issues/issue-19482.rs index 9e4b77d87f8..3f3c5de9b14 100644 --- a/src/test/ui/issues/issue-19482.rs +++ b/src/test/ui/issues/issue-19482.rs @@ -8,6 +8,6 @@ fn dummy(&self) { } } fn bar(x: &dyn Foo) {} -//~^ ERROR the associated type `A` (from the trait `Foo`) must be specified +//~^ ERROR the associated type `A` (from trait `Foo`) must be specified pub fn main() {} diff --git a/src/test/ui/issues/issue-19482.stderr b/src/test/ui/issues/issue-19482.stderr index f1e5419c712..42a5a015969 100644 --- a/src/test/ui/issues/issue-19482.stderr +++ b/src/test/ui/issues/issue-19482.stderr @@ -1,11 +1,11 @@ -error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified - --> $DIR/issue-19482.rs:10:12 +error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified + --> $DIR/issue-19482.rs:10:16 | LL | type A; | ------- `A` defined here ... LL | fn bar(x: &dyn Foo) {} - | ^^^^^^^ associated type `A` must be specified + | ^^^ help: specify the associated type: `Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index 9be7b052da3..c904236b31b 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -1,16 +1,27 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-21950.rs:5:18 | -LL | &dyn Add; - | ^^^ missing reference to `Rhs` +LL | &dyn Add; + | ^^^ help: set the type parameter to the desired type: `Add` + | + ::: $SRC_DIR/libcore/ops/arith.rs:LL:COL + | +LL | / pub trait Add { +LL | | /// The resulting type after applying the `+` operator. +LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | | type Output; +... | +LL | | fn add(self, rhs: Rhs) -> Self::Output; +LL | | } + | |_- type parameter `Rhs` must be specified for this | = note: because of the default `Self` reference, type parameters must be specified on object types -error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified - --> $DIR/issue-21950.rs:5:14 +error[E0191]: the value of the associated type `Output` (from trait `std::ops::Add`) must be specified + --> $DIR/issue-21950.rs:5:18 | LL | &dyn Add; - | ^^^^^^^ associated type `Output` must be specified + | ^^^ help: specify the associated type: `Add` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-22370.stderr b/src/test/ui/issues/issue-22370.stderr index 3ce164e9548..950c12ef7a2 100644 --- a/src/test/ui/issues/issue-22370.stderr +++ b/src/test/ui/issues/issue-22370.stderr @@ -1,8 +1,11 @@ error[E0393]: the type parameter `T` must be explicitly specified --> $DIR/issue-22370.rs:3:14 | +LL | trait A {} + | ------------------ type parameter `T` must be specified for this +LL | LL | fn f(a: &dyn A) {} - | ^ missing reference to `T` + | ^ help: set the type parameter to the desired type: `A` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/issues/issue-22434.rs b/src/test/ui/issues/issue-22434.rs index 3e800a2b61d..34057b46ecd 100644 --- a/src/test/ui/issues/issue-22434.rs +++ b/src/test/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 the trait `Foo`) must be specified +//~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified fn main() {} diff --git a/src/test/ui/issues/issue-22434.stderr b/src/test/ui/issues/issue-22434.stderr index eb78c4fc311..79b9d85610b 100644 --- a/src/test/ui/issues/issue-22434.stderr +++ b/src/test/ui/issues/issue-22434.stderr @@ -1,11 +1,11 @@ -error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified - --> $DIR/issue-22434.rs:5:19 +error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified + --> $DIR/issue-22434.rs:5:23 | LL | type A; | ------- `A` defined here ... LL | type I<'a> = &'a (dyn Foo + 'a); - | ^^^^^^^^^^^^ associated type `A` must be specified + | ^^^ help: specify the associated type: `Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index 5b58adb197c..bce49aaf16d 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -1,16 +1,38 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:6:13 | -LL | Sub; - | ^^^ missing reference to `Rhs` +LL | Sub; + | ^^^ help: set the type parameter to the desired type: `Sub` + | + ::: $SRC_DIR/libcore/ops/arith.rs:LL:COL + | +LL | / pub trait Sub { +LL | | /// The resulting type after applying the `-` operator. +LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | | type Output; +... | +LL | | fn sub(self, rhs: Rhs) -> Self::Output; +LL | | } + | |_- type parameter `Rhs` must be specified for this | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:3:17 | -LL | type Test = dyn Add + - | ^^^ missing reference to `Rhs` +LL | type Test = dyn Add + + | ^^^ help: set the type parameter to the desired type: `Add` + | + ::: $SRC_DIR/libcore/ops/arith.rs:LL:COL + | +LL | / pub trait Add { +LL | | /// The resulting type after applying the `+` operator. +LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | | type Output; +... | +LL | | fn add(self, rhs: Rhs) -> Self::Output; +LL | | } + | |_- type parameter `Rhs` must be specified for this | = note: because of the default `Self` reference, type parameters must be specified on object types @@ -29,20 +51,15 @@ LL | Sub; | additional non-auto trait | trait alias used in trait object type (additional use) -error[E0191]: the value of the associated types `Output` (from the trait `std::ops::Add`), `Output` (from the trait `std::ops::Sub`) must be specified +error[E0191]: the value of the associated types `Output` (from trait `std::ops::Add`), `Output` (from trait `std::ops::Sub`) must be specified --> $DIR/issue-22560.rs:3:13 | LL | type Test = dyn Add + | _____________^ - | |_____________| - | | LL | | LL | | LL | | Sub; - | | ^ - | |_______________| - | |_______________associated type `Output` must be specified - | associated type `Output` must be specified + | |_______________^ associated types `Output`, `Output` must be specified error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-23024.rs b/src/test/ui/issues/issue-23024.rs index 2638e15f0ea..63675368162 100644 --- a/src/test/ui/issues/issue-23024.rs +++ b/src/test/ui/issues/issue-23024.rs @@ -9,5 +9,5 @@ fn h(x:i32) -> i32 {3*x} println!("{:?}",(vfnfer[0] as dyn Fn)(3)); //~^ ERROR the precise format of `Fn`-family traits' //~| ERROR wrong number of type arguments: expected 1, found 0 [E0107] - //~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`) + //~| ERROR the value of the associated type `Output` (from trait `std::ops::FnOnce`) } diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index 43561938ef1..11d5c9f1f2e 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -1,4 +1,4 @@ -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/issue-23024.rs:9:39 | LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); @@ -6,6 +6,7 @@ LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` error[E0107]: wrong number of type arguments: expected 1, found 0 --> $DIR/issue-23024.rs:9:39 @@ -13,11 +14,11 @@ error[E0107]: wrong number of type arguments: expected 1, found 0 LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); | ^^ expected 1 type argument -error[E0191]: the value of the associated type `Output` (from the trait `std::ops::FnOnce`) must be specified - --> $DIR/issue-23024.rs:9:35 +error[E0191]: the value of the associated type `Output` (from trait `std::ops::FnOnce`) must be specified + --> $DIR/issue-23024.rs:9:39 | LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); - | ^^^^^^ associated type `Output` must be specified + | ^^ help: specify the associated type: `Fn` error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-28344.stderr b/src/test/ui/issues/issue-28344.stderr index 34ce2358a0a..e315317c98a 100644 --- a/src/test/ui/issues/issue-28344.stderr +++ b/src/test/ui/issues/issue-28344.stderr @@ -1,8 +1,8 @@ -error[E0191]: the value of the associated type `Output` (from the trait `std::ops::BitXor`) must be specified +error[E0191]: the value of the associated type `Output` (from trait `std::ops::BitXor`) must be specified --> $DIR/issue-28344.rs:4:17 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - | ^^^^^^^^^^^^^ associated type `Output` must be specified + | ^^^^^^ help: specify the associated type: `BitXor` error[E0599]: no function or associated item named `bitor` found for type `dyn std::ops::BitXor<_>` in the current scope --> $DIR/issue-28344.rs:4:25 @@ -13,11 +13,11 @@ LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); | function or associated item not found in `dyn std::ops::BitXor<_>` | help: there is a method with a similar name: `bitxor` -error[E0191]: the value of the associated type `Output` (from the trait `std::ops::BitXor`) must be specified +error[E0191]: the value of the associated type `Output` (from trait `std::ops::BitXor`) must be specified --> $DIR/issue-28344.rs:8:13 | LL | let g = BitXor::bitor; - | ^^^^^^^^^^^^^ associated type `Output` must be specified + | ^^^^^^ help: specify the associated type: `BitXor` error[E0599]: no function or associated item named `bitor` found for type `dyn std::ops::BitXor<_>` in the current scope --> $DIR/issue-28344.rs:8:21 diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr index 098d76a5c48..321196d14b7 100644 --- a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -6,7 +6,7 @@ LL | i: Box>, | | | unexpected type argument -error[E0191]: the value of the associated types `A` (from the trait `T`), `C` (from the trait `T`) must be specified +error[E0191]: the value of the associated types `A` (from trait `T`), `C` (from trait `T`) must be specified --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:12 | LL | type A; @@ -16,12 +16,9 @@ LL | type C; | ------- `C` defined here ... LL | i: Box>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | associated type `A` must be specified - | associated type `C` must be specified + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated types `A`, `C` must be specified | -help: if you meant to specify the associated types, write +help: specify the associated types | LL | i: Box>, | ^^^^^^^^^ ^^^^^^^^^ diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr b/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr index 9a9b9177030..5551b1303b9 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr @@ -6,11 +6,11 @@ LL | let _: &dyn EqAlias = &123; | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses -error[E0191]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) must be specified - --> $DIR/trait-alias-object-fail.rs:9:13 +error[E0191]: the value of the associated type `Item` (from trait `std::iter::Iterator`) must be specified + --> $DIR/trait-alias-object-fail.rs:9:17 | LL | let _: &dyn IteratorAlias = &vec![123].into_iter(); - | ^^^^^^^^^^^^^^^^^ associated type `Item` must be specified + | ^^^^^^^^^^^^^ help: specify the associated type: `IteratorAlias` error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs b/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs index 766bd147431..f34fa80a0ce 100644 --- a/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs +++ b/src/test/ui/traits/trait-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 the trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified let _y: Box> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from the trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified } diff --git a/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr b/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr index 350f8ea8507..79eb27e101a 100644 --- a/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr +++ b/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr @@ -1,20 +1,20 @@ -error[E0191]: the value of the associated type `Output` (from the trait `Base`) must be specified - --> $DIR/trait-object-with-self-in-projection-output-bad.rs:45:17 +error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified + --> $DIR/trait-object-with-self-in-projection-output-bad.rs:45:21 | LL | type Output; | ------------ `Output` defined here ... LL | let _x: Box> = Box::new(2u32); - | ^^^^^^^^^^^^^^^^^^^^^^ associated type `Output` must be specified + | ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper` -error[E0191]: the value of the associated type `Output` (from the trait `Base`) must be specified - --> $DIR/trait-object-with-self-in-projection-output-bad.rs:48:17 +error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified + --> $DIR/trait-object-with-self-in-projection-output-bad.rs:48:21 | LL | type Output; | ------------ `Output` defined here ... LL | let _y: Box> = Box::new(2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type `Output` must be specified + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `NormalizableHelper` error: aborting due to 2 previous errors diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr index 0d6ca9d9dcd..eafd3cf79db 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr @@ -1,8 +1,13 @@ error[E0393]: the type parameter `T` must be explicitly specified --> $DIR/type-parameter-defaults-referencing-Self.rs:10:16 | -LL | fn foo(x: &dyn Foo) { } - | ^^^ missing reference to `T` +LL | / trait Foo { +LL | | fn method(&self); +LL | | } + | |_- type parameter `T` must be specified for this +LL | +LL | fn foo(x: &dyn Foo) { } + | ^^^ help: set the type parameter to the desired type: `Foo` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr index a76954287e4..7ae8caee6f8 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr @@ -2,7 +2,7 @@ error[E0658]: parenthetical notation is only stable when used with `Fn`-family t --> $DIR/unboxed-closure-feature-gate.rs:13:20 | LL | let x: Box; - | ^^^^^^^^^^ + | ^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr index c116728190f..d661603465c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr @@ -1,20 +1,22 @@ -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:17 | LL | fn bar1(x: &dyn Fn<(), Output=()>) { - | ^^^^^^^^^^^^^^^^^ + | ^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` -error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:7:28 | LL | fn bar2(x: &T) where T: Fn<()> { - | ^^^^^^ + | ^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + = help: use parenthetical notation instead: `Fn(Foo, Bar) -> Baz` error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr index e9d51983a7a..b92f054498b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr @@ -2,7 +2,7 @@ error[E0107]: wrong number of lifetime arguments: expected 1, found 0 --> $DIR/unboxed-closure-sugar-region.rs:30:51 | LL | fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) { - | ^^^^^^^^^^ expected 1 lifetime argument + | ^^^ expected 1 lifetime argument error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr index f42ac38d370..f482098cbff 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr @@ -2,7 +2,7 @@ error[E0107]: wrong number of type arguments: expected 3, found 1 --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16 | LL | fn foo(_: &dyn Three()) - | ^^^^^^^ expected 3 type arguments + | ^^^^^ expected 3 type arguments error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>` --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16 diff --git a/src/test/ui/unspecified-self-in-trait-ref.stderr b/src/test/ui/unspecified-self-in-trait-ref.stderr index 06370cec90e..b72d45ebdbf 100644 --- a/src/test/ui/unspecified-self-in-trait-ref.stderr +++ b/src/test/ui/unspecified-self-in-trait-ref.stderr @@ -25,8 +25,13 @@ LL | let d = Bar::::lol(); error[E0393]: the type parameter `A` must be explicitly specified --> $DIR/unspecified-self-in-trait-ref.rs:18:13 | -LL | let e = Bar::::lol(); - | ^^^^^^^^^^^^^^^^^ missing reference to `A` +LL | / pub trait Bar { +LL | | fn foo(&self); +LL | | } + | |_- type parameter `A` must be specified for this +... +LL | let e = Bar::::lol(); + | ^^^ missing reference to `A` | = note: because of the default `Self` reference, type parameters must be specified on object types