1
Fork 0

Unify suggestion wording

This commit is contained in:
Esteban Küber 2023-10-16 18:25:11 +00:00
parent 6cf01fcf1e
commit 890e92feed
31 changed files with 145 additions and 168 deletions

View file

@ -1018,7 +1018,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
} }
err.span_suggestions( err.span_suggestions(
span, span,
"use the fully-qualified path", "use fully-qualified syntax",
suggestions, suggestions,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
@ -1190,7 +1190,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
} else { } else {
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.with_hi(assoc_name.span.lo()), span.with_hi(assoc_name.span.lo()),
"use fully qualified syntax to disambiguate", "use fully-qualified syntax to disambiguate",
format!("<{ty_param_name} as {}>::", bound.print_only_trait_path()), format!("<{ty_param_name} as {}>::", bound.print_only_trait_path()),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );

View file

@ -1260,6 +1260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Dynamic limit to avoid hiding just one candidate, which is silly. // Dynamic limit to avoid hiding just one candidate, which is silly.
let limit = if sources.len() == 5 { 5 } else { 4 }; let limit = if sources.len() == 5 { 5 } else { 4 };
let mut suggs = vec![];
for (idx, source) in sources.iter().take(limit).enumerate() { for (idx, source) in sources.iter().take(limit).enumerate() {
match *source { match *source {
CandidateSource::Impl(impl_did) => { CandidateSource::Impl(impl_did) => {
@ -1334,7 +1335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.copied() .copied()
.unwrap_or(rcvr_ty), .unwrap_or(rcvr_ty),
}; };
print_disambiguation_help( if let Some(sugg) = print_disambiguation_help(
item_name, item_name,
args, args,
err, err,
@ -1347,7 +1348,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
idx, idx,
self.tcx.sess.source_map(), self.tcx.sess.source_map(),
item.fn_has_self_parameter, item.fn_has_self_parameter,
); ) {
suggs.push(sugg);
}
} }
} }
CandidateSource::Trait(trait_did) => { CandidateSource::Trait(trait_did) => {
@ -1371,7 +1374,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}; };
if let Some(sugg_span) = sugg_span { if let Some(sugg_span) = sugg_span {
let path = self.tcx.def_path_str(trait_did); let path = self.tcx.def_path_str(trait_did);
print_disambiguation_help( if let Some(sugg) = print_disambiguation_help(
item_name, item_name,
args, args,
err, err,
@ -1384,11 +1387,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
idx, idx,
self.tcx.sess.source_map(), self.tcx.sess.source_map(),
item.fn_has_self_parameter, item.fn_has_self_parameter,
); ) {
suggs.push(sugg);
}
} }
} }
} }
} }
if !suggs.is_empty() && let Some(span) = sugg_span {
err.span_suggestions(
span.with_hi(item_name.span.lo()),
"use fully-qualified syntax to disambiguate",
suggs,
Applicability::MachineApplicable,
);
}
if sources.len() > limit { if sources.len() > limit {
err.note(format!("and {} others", sources.len() - limit)); err.note(format!("and {} others", sources.len() - limit));
} }
@ -3155,47 +3168,44 @@ fn print_disambiguation_help<'tcx>(
candidate: Option<usize>, candidate: Option<usize>,
source_map: &source_map::SourceMap, source_map: &source_map::SourceMap,
fn_has_self_parameter: bool, fn_has_self_parameter: bool,
) { ) -> Option<String> {
let mut applicability = Applicability::MachineApplicable; Some(
let (span, sugg) = if let ( if let (ty::AssocKind::Fn, Some(MethodCallComponents { receiver, args, .. })) = (kind, args)
ty::AssocKind::Fn, {
Some(MethodCallComponents { receiver, args, .. }), let args = format!(
) = (kind, args) "({}{})",
{ rcvr_ty.ref_mutability().map_or("", |mutbl| mutbl.ref_prefix_str()),
let args = format!( std::iter::once(receiver)
"({}{})", .chain(args.iter())
rcvr_ty.ref_mutability().map_or("", |mutbl| mutbl.ref_prefix_str()), .map(|arg| source_map
std::iter::once(receiver) .span_to_snippet(arg.span)
.chain(args.iter()) .unwrap_or_else(|_| { "_".to_owned() }))
.map(|arg| source_map.span_to_snippet(arg.span).unwrap_or_else(|_| { .collect::<Vec<_>>()
applicability = Applicability::HasPlaceholders; .join(", "),
"_".to_owned() );
})) let trait_name = if !fn_has_self_parameter && let Some(impl_self_ty) = impl_self_ty {
.collect::<Vec<_>>()
.join(", "),
);
let trait_name = if !fn_has_self_parameter && let Some(impl_self_ty) = impl_self_ty {
format!("<{impl_self_ty} as {trait_name}>") format!("<{impl_self_ty} as {trait_name}>")
} else { } else {
trait_name trait_name
}; };
(span, format!("{trait_name}::{item_name}{args}")) err.span_suggestion_verbose(
} else if let Some(impl_self_ty) = impl_self_ty { span,
(span.with_hi(item_name.span.lo()), format!("<{impl_self_ty} as {trait_name}>::")) format!(
} else { "disambiguate the {def_kind_descr} for {}",
(span.with_hi(item_name.span.lo()), format!("{trait_name}::")) if let Some(candidate) = candidate {
}; format!("candidate #{candidate}")
err.span_suggestion_verbose( } else {
span, "the candidate".to_string()
format!( },
"disambiguate the {def_kind_descr} for {}", ),
if let Some(candidate) = candidate { format!("{trait_name}::{item_name}{args}"),
format!("candidate #{candidate}") Applicability::HasPlaceholders,
} else { );
"the candidate".to_string() return None;
}, } else if let Some(impl_self_ty) = impl_self_ty {
), format!("<{impl_self_ty} as {trait_name}>::")
sugg, } else {
applicability, format!("{trait_name}::")
); },
)
} }

View file

@ -14,14 +14,12 @@ note: candidate #2 is defined in an impl of the trait `Bar` for the type `i32`
| |
LL | const ID: i32 = 3; LL | const ID: i32 = 3;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1 help: use fully-qualified syntax to disambiguate
|
LL | const X: i32 = <i32 as Foo>::ID;
| ~~~~~~~~~~~~~~
help: disambiguate the associated constant for candidate #2
| |
LL | const X: i32 = <i32 as Bar>::ID; LL | const X: i32 = <i32 as Bar>::ID;
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
LL | const X: i32 = <i32 as Foo>::ID;
| ~~~~~~~~~~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -33,7 +33,7 @@ error[E0223]: ambiguous associated type
--> $DIR/issue-109071.rs:15:22 --> $DIR/issue-109071.rs:15:22
| |
LL | fn T() -> Option<Self::Item> {} LL | fn T() -> Option<Self::Item> {}
| ^^^^^^^^^^ help: use the fully-qualified path: `<Windows<T> as IntoIterator>::Item` | ^^^^^^^^^^ help: use fully-qualified syntax: `<Windows<T> as IntoIterator>::Item`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:12 --> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:12
| |
LL | let _: S::<bool>::Pr = (); LL | let _: S::<bool>::Pr = ();
| ^^^^^^^^^^^^^ help: use the fully-qualified path: `<S<bool> as Tr>::Pr` | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<S<bool> as Tr>::Pr`
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/ambiguous-associated-type-with-generics.rs:13:13 --> $DIR/ambiguous-associated-type-with-generics.rs:13:13
| |
LL | let _x: <dyn Trait<i32>>::Ty; LL | let _x: <dyn Trait<i32>>::Ty;
| ^^^^^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<dyn Trait<i32> as Assoc>::Ty` | ^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<dyn Trait<i32> as Assoc>::Ty`
error: aborting due to previous error error: aborting due to previous error

View file

@ -13,7 +13,7 @@ error[E0223]: ambiguous associated type
--> $DIR/associated-item-duplicate-names-3.rs:18:12 --> $DIR/associated-item-duplicate-names-3.rs:18:12
| |
LL | let x: Baz::Bar = 5; LL | let x: Baz::Bar = 5;
| ^^^^^^^^ help: use the fully-qualified path: `<Baz as Foo>::Bar` | ^^^^^^^^ help: use fully-qualified syntax: `<Baz as Foo>::Bar`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -10,11 +10,11 @@ LL | type Color;
LL | fn a<C:Vehicle+Box>(_: C::Color) { LL | fn a<C:Vehicle+Box>(_: C::Color) {
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) { LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) {
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) { LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) {
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
@ -31,11 +31,11 @@ LL | type Color;
LL | fn b<C>(_: C::Color) where C : Vehicle+Box { LL | fn b<C>(_: C::Color) where C : Vehicle+Box {
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box { LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box {
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box { LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box {
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
@ -52,11 +52,11 @@ LL | type Color;
LL | fn c<C>(_: C::Color) where C : Vehicle, C : Box { LL | fn c<C>(_: C::Color) where C : Vehicle, C : Box {
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box { LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box {
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box { LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box {
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
@ -73,11 +73,11 @@ LL | type Color;
LL | fn e(&self, _: X::Color) where X : Box; LL | fn e(&self, _: X::Color) where X : Box;
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn e(&self, _: <X as Box>::Color) where X : Box; LL | fn e(&self, _: <X as Box>::Color) where X : Box;
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn e(&self, _: <X as Vehicle>::Color) where X : Box; LL | fn e(&self, _: <X as Vehicle>::Color) where X : Box;
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
@ -94,11 +94,11 @@ LL | type Color;
LL | fn f(&self, _: X::Color) where X : Box { } LL | fn f(&self, _: X::Color) where X : Box { }
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn f(&self, _: <X as Box>::Color) where X : Box { } LL | fn f(&self, _: <X as Box>::Color) where X : Box { }
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn f(&self, _: <X as Vehicle>::Color) where X : Box { } LL | fn f(&self, _: <X as Vehicle>::Color) where X : Box { }
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
@ -115,11 +115,11 @@ LL | type Color;
LL | fn d(&self, _: X::Color) where X : Box { } LL | fn d(&self, _: X::Color) where X : Box { }
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn d(&self, _: <X as Box>::Color) where X : Box { } LL | fn d(&self, _: <X as Box>::Color) where X : Box { }
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn d(&self, _: <X as Vehicle>::Color) where X : Box { } LL | fn d(&self, _: <X as Vehicle>::Color) where X : Box { }
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~

View file

@ -18,11 +18,11 @@ LL | type Color;
LL | fn dent<C:BoxCar>(c: C, color: C::Color) { LL | fn dent<C:BoxCar>(c: C, color: C::Color) {
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) { LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) {
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) { LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) {
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
@ -71,11 +71,11 @@ LL | type Color;
LL | fn paint<C:BoxCar>(c: C, d: C::Color) { LL | fn paint<C:BoxCar>(c: C, d: C::Color) {
| ^^^^^^^^ ambiguous associated type `Color` | ^^^^^^^^ ambiguous associated type `Color`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) { LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) {
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) { LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) {
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~

View file

@ -13,7 +13,7 @@ error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:22:17 --> $DIR/associated-types-in-ambiguous-context.rs:22:17
| |
LL | trait Foo where Foo::Assoc: Bar { LL | trait Foo where Foo::Assoc: Bar {
| ^^^^^^^^^^ help: use the fully-qualified path: `<Self as Foo>::Assoc` | ^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Foo>::Assoc`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:27:10 --> $DIR/associated-types-in-ambiguous-context.rs:27:10
@ -21,7 +21,7 @@ error[E0223]: ambiguous associated type
LL | type X = std::ops::Deref::Target; LL | type X = std::ops::Deref::Target;
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
| |
help: use the fully-qualified path help: use fully-qualified syntax
| |
LL | type X = <CString as Deref>::Target; LL | type X = <CString as Deref>::Target;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -37,7 +37,7 @@ error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:13:23 --> $DIR/associated-types-in-ambiguous-context.rs:13:23
| |
LL | fn grab(&self) -> Grab::Value; LL | fn grab(&self) -> Grab::Value;
| ^^^^^^^^^^^ help: use the fully-qualified path: `<Self as Grab>::Value` | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Grab>::Value`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:16:22 --> $DIR/associated-types-in-ambiguous-context.rs:16:22

View file

@ -16,11 +16,11 @@ LL | type A;
LL | pub fn f2<T: Foo + Bar>(a: T, x: T::A) {} LL | pub fn f2<T: Foo + Bar>(a: T, x: T::A) {}
| ^^^^ ambiguous associated type `A` | ^^^^ ambiguous associated type `A`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Bar>::A) {} LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Bar>::A) {}
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Foo>::A) {} LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Foo>::A) {}
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~

View file

@ -191,7 +191,7 @@ error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:33:10 --> $DIR/bad-assoc-ty.rs:33:10
| |
LL | type H = Fn(u8) -> (u8)::Output; LL | type H = Fn(u8) -> (u8)::Output;
| ^^^^^^^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output` | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:39:19 --> $DIR/bad-assoc-ty.rs:39:19

View file

@ -14,12 +14,10 @@ note: candidate #2 is defined in an impl of the trait `Trait2` for the type `Tes
| |
LL | fn foo() {} LL | fn foo() {}
| ^^^^^^^^ | ^^^^^^^^
help: disambiguate the associated function for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <Test as Trait1>::foo() LL | <Test as Trait1>::foo()
| ~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
|
LL | <Test as Trait2>::foo() LL | <Test as Trait2>::foo()
| ~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~~

View file

@ -10,11 +10,11 @@ LL | fn do_something() {
LL | let _: Self::A; LL | let _: Self::A;
| ^^^^^^^ ambiguous associated type `A` | ^^^^^^^ ambiguous associated type `A`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | let _: <Self as Foo>::A; LL | let _: <Self as Foo>::A;
| ~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | let _: <Self as Bar>::A; LL | let _: <Self as Bar>::A;
| ~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~
@ -29,7 +29,7 @@ LL | let _: Self::Err;
| ^^^^^^^^^ ambiguous associated type `Err` | ^^^^^^^^^ ambiguous associated type `Err`
| |
= note: associated type `Self` could derive from `FromStr` = note: associated type `Self` could derive from `FromStr`
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | let _: <Self as My>::Err; LL | let _: <Self as My>::Err;
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~

View file

@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/E0223.rs:8:14 --> $DIR/E0223.rs:8:14
| |
LL | let foo: MyTrait::X; LL | let foo: MyTrait::X;
| ^^^^^^^^^^ help: use the fully-qualified path: `<MyStruct as MyTrait>::X` | ^^^^^^^^^^ help: use fully-qualified syntax: `<MyStruct as MyTrait>::X`
error: aborting due to previous error error: aborting due to previous error

View file

@ -16,7 +16,7 @@ error[E0223]: ambiguous associated type
--> $DIR/bare-trait-objects-path.rs:23:12 --> $DIR/bare-trait-objects-path.rs:23:12
| |
LL | let _: Dyn::Ty; LL | let _: Dyn::Ty;
| ^^^^^^^ help: use the fully-qualified path: `<dyn Dyn as Assoc>::Ty` | ^^^^^^^ help: use fully-qualified syntax: `<dyn Dyn as Assoc>::Ty`
warning: trait objects without an explicit `dyn` are deprecated warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/bare-trait-objects-path.rs:14:5 --> $DIR/bare-trait-objects-path.rs:14:5

View file

@ -29,12 +29,10 @@ fn main() {
let s = S; let s = S;
S::foo(&s); //~ ERROR multiple applicable items in scope S::foo(&s); //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `foo` found //~^ NOTE multiple `foo` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax to disambiguate
//~| HELP disambiguate
S::CONST; //~ ERROR multiple applicable items in scope S::CONST; //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `CONST` found //~^ NOTE multiple `CONST` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax to disambiguate
//~| HELP disambiguate
let _: S::Type; //~ ERROR ambiguous associated type let _: S::Type; //~ ERROR ambiguous associated type
//~^ HELP use the fully-qualified path //~^ HELP use fully-qualified syntax
} }

View file

@ -1,10 +1,10 @@
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/disambiguate-multiple-blanket-impl.rs:38:12 --> $DIR/disambiguate-multiple-blanket-impl.rs:36:12
| |
LL | let _: S::Type; LL | let _: S::Type;
| ^^^^^^^ | ^^^^^^^
| |
help: use the fully-qualified path help: use fully-qualified syntax
| |
LL | let _: <S as A>::Type; LL | let _: <S as A>::Type;
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
@ -27,17 +27,15 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `T`
| |
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
help: disambiguate the method for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <T as A>::foo(&s); LL | <T as A>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the method for candidate #2
|
LL | <T as B>::foo(&s); LL | <T as B>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
error[E0034]: multiple applicable items in scope error[E0034]: multiple applicable items in scope
--> $DIR/disambiguate-multiple-blanket-impl.rs:34:8 --> $DIR/disambiguate-multiple-blanket-impl.rs:33:8
| |
LL | S::CONST; LL | S::CONST;
| ^^^^^ multiple `CONST` found | ^^^^^ multiple `CONST` found
@ -52,12 +50,10 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `T`
| |
LL | const CONST: usize = 2; LL | const CONST: usize = 2;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <T as A>::CONST; LL | <T as A>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the associated constant for candidate #2
|
LL | <T as B>::CONST; LL | <T as B>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~

View file

@ -28,12 +28,10 @@ fn main() {
let s = S; let s = S;
S::foo(&s); //~ ERROR multiple applicable items in scope S::foo(&s); //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `foo` found //~^ NOTE multiple `foo` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
let _: S::Type = (); //~ ERROR ambiguous associated type let _: S::Type = (); //~ ERROR ambiguous associated type
//~| HELP use the fully-qualified path //~| HELP use fully-qualified syntax
let _ = S::CONST; //~ ERROR multiple applicable items in scope let _ = S::CONST; //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `CONST` found //~^ NOTE multiple `CONST` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
} }

View file

@ -1,10 +1,10 @@
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/disambiguate-multiple-impl.rs:33:12 --> $DIR/disambiguate-multiple-impl.rs:32:12
| |
LL | let _: S::Type = (); LL | let _: S::Type = ();
| ^^^^^^^ | ^^^^^^^
| |
help: use the fully-qualified path help: use fully-qualified syntax
| |
LL | let _: <S as A>::Type = (); LL | let _: <S as A>::Type = ();
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
@ -27,17 +27,15 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `S`
| |
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
help: disambiguate the method for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <S as A>::foo(&s); LL | <S as A>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the method for candidate #2
|
LL | <S as B>::foo(&s); LL | <S as B>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
error[E0034]: multiple applicable items in scope error[E0034]: multiple applicable items in scope
--> $DIR/disambiguate-multiple-impl.rs:35:16 --> $DIR/disambiguate-multiple-impl.rs:34:16
| |
LL | let _ = S::CONST; LL | let _ = S::CONST;
| ^^^^^ multiple `CONST` found | ^^^^^ multiple `CONST` found
@ -52,12 +50,10 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `S`
| |
LL | const CONST: usize = 2; LL | const CONST: usize = 2;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | let _ = <S as A>::CONST; LL | let _ = <S as A>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the associated constant for candidate #2
|
LL | let _ = <S as B>::CONST; LL | let _ = <S as B>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~

View file

@ -19,12 +19,11 @@ fn a<T: C>(t: T) {
//~| HELP disambiguate the method //~| HELP disambiguate the method
let _ = T::CONST; //~ ERROR multiple applicable items in scope let _ = T::CONST; //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `CONST` found //~^ NOTE multiple `CONST` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
let _: T::Type; //~ ERROR ambiguous associated type let _: T::Type; //~ ERROR ambiguous associated type
//~^ NOTE ambiguous associated type `Type` //~^ NOTE ambiguous associated type `Type`
//~| HELP use fully qualified syntax //~| HELP use fully-qualified syntax
//~| HELP use fully qualified syntax //~| HELP use fully-qualified syntax
} }
#[derive(Debug)] #[derive(Debug)]
@ -46,12 +45,10 @@ fn main() {
let s = S; let s = S;
S::foo(&s); //~ ERROR multiple applicable items in scope S::foo(&s); //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `foo` found //~^ NOTE multiple `foo` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
let _ = S::CONST; //~ ERROR multiple applicable items in scope let _ = S::CONST; //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `CONST` found //~^ NOTE multiple `CONST` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
let _: S::Type; //~ ERROR ambiguous associated type let _: S::Type; //~ ERROR ambiguous associated type
//~^ HELP use the fully-qualified path //~^ HELP use fully-qualified syntax
} }

View file

@ -1,5 +1,5 @@
error[E0221]: ambiguous associated type `Type` in bounds of `T` error[E0221]: ambiguous associated type `Type` in bounds of `T`
--> $DIR/disambiguate-multiple-trait-2.rs:24:12 --> $DIR/disambiguate-multiple-trait-2.rs:23:12
| |
LL | type Type; LL | type Type;
| --------- ambiguous `Type` from `A` | --------- ambiguous `Type` from `A`
@ -10,11 +10,11 @@ LL | type Type;
LL | let _: T::Type; LL | let _: T::Type;
| ^^^^^^^ ambiguous associated type `Type` | ^^^^^^^ ambiguous associated type `Type`
| |
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | let _: <T as A>::Type; LL | let _: <T as A>::Type;
| ~~~~~~~~~~ | ~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully-qualified syntax to disambiguate
| |
LL | let _: <T as B>::Type; LL | let _: <T as B>::Type;
| ~~~~~~~~~~ | ~~~~~~~~~~
@ -60,22 +60,20 @@ note: candidate #2 is defined in the trait `B`
| |
LL | const CONST: usize; LL | const CONST: usize;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | let _ = A::CONST; LL | let _ = A::CONST;
| ~~~ | ~~~
help: disambiguate the associated constant for candidate #2
|
LL | let _ = B::CONST; LL | let _ = B::CONST;
| ~~~ | ~~~
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/disambiguate-multiple-trait-2.rs:55:12 --> $DIR/disambiguate-multiple-trait-2.rs:52:12
| |
LL | let _: S::Type; LL | let _: S::Type;
| ^^^^^^^ | ^^^^^^^
| |
help: use the fully-qualified path help: use fully-qualified syntax
| |
LL | let _: <S as A>::Type; LL | let _: <S as A>::Type;
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
@ -83,52 +81,48 @@ LL | let _: <S as B>::Type;
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
error[E0034]: multiple applicable items in scope error[E0034]: multiple applicable items in scope
--> $DIR/disambiguate-multiple-trait-2.rs:47:8 --> $DIR/disambiguate-multiple-trait-2.rs:46:8
| |
LL | S::foo(&s); LL | S::foo(&s);
| ^^^ multiple `foo` found | ^^^ multiple `foo` found
| |
note: candidate #1 is defined in an impl of the trait `A` for the type `T` note: candidate #1 is defined in an impl of the trait `A` for the type `T`
--> $DIR/disambiguate-multiple-trait-2.rs:36:5 --> $DIR/disambiguate-multiple-trait-2.rs:35:5
| |
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `B` for the type `T` note: candidate #2 is defined in an impl of the trait `B` for the type `T`
--> $DIR/disambiguate-multiple-trait-2.rs:42:5 --> $DIR/disambiguate-multiple-trait-2.rs:41:5
| |
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
help: disambiguate the method for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <T as A>::foo(&s); LL | <T as A>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the method for candidate #2
|
LL | <T as B>::foo(&s); LL | <T as B>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
error[E0034]: multiple applicable items in scope error[E0034]: multiple applicable items in scope
--> $DIR/disambiguate-multiple-trait-2.rs:51:16 --> $DIR/disambiguate-multiple-trait-2.rs:49:16
| |
LL | let _ = S::CONST; LL | let _ = S::CONST;
| ^^^^^ multiple `CONST` found | ^^^^^ multiple `CONST` found
| |
note: candidate #1 is defined in an impl of the trait `A` for the type `T` note: candidate #1 is defined in an impl of the trait `A` for the type `T`
--> $DIR/disambiguate-multiple-trait-2.rs:35:5 --> $DIR/disambiguate-multiple-trait-2.rs:34:5
| |
LL | const CONST: usize = 1; LL | const CONST: usize = 1;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `B` for the type `T` note: candidate #2 is defined in an impl of the trait `B` for the type `T`
--> $DIR/disambiguate-multiple-trait-2.rs:41:5 --> $DIR/disambiguate-multiple-trait-2.rs:40:5
| |
LL | const CONST: usize = 1; LL | const CONST: usize = 1;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | let _ = <T as A>::CONST; LL | let _ = <T as A>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the associated constant for candidate #2
|
LL | let _ = <T as B>::CONST; LL | let _ = <T as B>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~

View file

@ -23,12 +23,10 @@ fn main() {
let s = S; let s = S;
S::foo(&s); //~ ERROR multiple applicable items in scope S::foo(&s); //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `foo` found //~^ NOTE multiple `foo` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
let _ = S::CONST; //~ ERROR multiple applicable items in scope let _ = S::CONST; //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `CONST` found //~^ NOTE multiple `CONST` found
//~| HELP disambiguate //~| HELP use fully-qualified syntax
//~| HELP disambiguate
let _: S::Type; //~ ERROR ambiguous associated type let _: S::Type; //~ ERROR ambiguous associated type
//~^ HELP use the fully-qualified path //~^ HELP use fully-qualified syntax
} }

View file

@ -1,10 +1,10 @@
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/disambiguate-multiple-trait.rs:32:12 --> $DIR/disambiguate-multiple-trait.rs:30:12
| |
LL | let _: S::Type; LL | let _: S::Type;
| ^^^^^^^ | ^^^^^^^
| |
help: use the fully-qualified path help: use fully-qualified syntax
| |
LL | let _: <S as A>::Type; LL | let _: <S as A>::Type;
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
@ -27,17 +27,15 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `T`
| |
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
help: disambiguate the method for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <T as A>::foo(&s); LL | <T as A>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the method for candidate #2
|
LL | <T as B>::foo(&s); LL | <T as B>::foo(&s);
| ~~~~~~~~~~ | ~~~~~~~~~~
error[E0034]: multiple applicable items in scope error[E0034]: multiple applicable items in scope
--> $DIR/disambiguate-multiple-trait.rs:28:16 --> $DIR/disambiguate-multiple-trait.rs:27:16
| |
LL | let _ = S::CONST; LL | let _ = S::CONST;
| ^^^^^ multiple `CONST` found | ^^^^^ multiple `CONST` found
@ -52,12 +50,10 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `T`
| |
LL | const CONST: usize = 2; LL | const CONST: usize = 2;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | let _ = <T as A>::CONST; LL | let _ = <T as A>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~
help: disambiguate the associated constant for candidate #2
|
LL | let _ = <T as B>::CONST; LL | let _ = <T as B>::CONST;
| ~~~~~~~~~~ | ~~~~~~~~~~

View file

@ -14,12 +14,10 @@ note: candidate #2 is defined in an impl of the trait `B` for the type `AB`
| |
LL | fn foo() {} LL | fn foo() {}
| ^^^^^^^^ | ^^^^^^^^
help: disambiguate the associated function for candidate #1 help: use fully-qualified syntax to disambiguate
| |
LL | <AB as A>::foo(); LL | <AB as A>::foo();
| ~~~~~~~~~~~ | ~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
|
LL | <AB as B>::foo(); LL | <AB as B>::foo();
| ~~~~~~~~~~~ | ~~~~~~~~~~~

View file

@ -2,13 +2,13 @@ error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:23:16 --> $DIR/self-impl.rs:23:16
| |
LL | let _: <Self>::Baz = true; LL | let _: <Self>::Baz = true;
| ^^^^^^^^^^^ help: use the fully-qualified path: `<Bar as Foo>::Baz` | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:25:16 --> $DIR/self-impl.rs:25:16
| |
LL | let _: Self::Baz = true; LL | let _: Self::Baz = true;
| ^^^^^^^^^ help: use the fully-qualified path: `<Bar as Foo>::Baz` | ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -48,19 +48,19 @@ error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:32:13 --> $DIR/struct-path-associated-type.rs:32:13
| |
LL | let s = S::A {}; LL | let s = S::A {};
| ^^^^ help: use the fully-qualified path: `<S as Tr>::A` | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:33:13 --> $DIR/struct-path-associated-type.rs:33:13
| |
LL | let z = S::A::<u8> {}; LL | let z = S::A::<u8> {};
| ^^^^ help: use the fully-qualified path: `<S as Tr>::A` | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:35:9 --> $DIR/struct-path-associated-type.rs:35:9
| |
LL | S::A {} => {} LL | S::A {} => {}
| ^^^^ help: use the fully-qualified path: `<S as Tr>::A` | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A`
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View file

@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38 --> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38
| |
LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {} LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {}
| ^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'a S as IntoIterator>::Item` | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'a S as IntoIterator>::Item`
error: aborting due to previous error error: aborting due to previous error

View file

@ -159,13 +159,13 @@ error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:116:12 --> $DIR/item-privacy.rs:116:12
| |
LL | let _: S::B; LL | let _: S::B;
| ^^^^ help: use the fully-qualified path: `<S as assoc_ty::B>::B` | ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::B>::B`
error[E0223]: ambiguous associated type error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:117:12 --> $DIR/item-privacy.rs:117:12
| |
LL | let _: S::C; LL | let _: S::C;
| ^^^^ help: use the fully-qualified path: `<S as assoc_ty::C>::C` | ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::C>::C`
error[E0624]: associated type `A` is private error[E0624]: associated type `A` is private
--> $DIR/item-privacy.rs:119:12 --> $DIR/item-privacy.rs:119:12

View file

@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/issue-107087.rs:16:5 --> $DIR/issue-107087.rs:16:5
| |
LL | A::B::<>::C LL | A::B::<>::C
| ^^^^^^^^ help: use the fully-qualified path: `<A<_> as Foo>::B` | ^^^^^^^^ help: use fully-qualified syntax: `<A<_> as Foo>::B`
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,7 +2,7 @@ error[E0223]: ambiguous associated type
--> $DIR/issue-110052.rs:6:30 --> $DIR/issue-110052.rs:6:30
| |
LL | for<'iter> dyn Validator<<&'iter I>::Item>:, LL | for<'iter> dyn Validator<<&'iter I>::Item>:,
| ^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'iter I as IntoIterator>::Item` | ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'iter I as IntoIterator>::Item`
error: aborting due to previous error error: aborting due to previous error