use require_c_abi_if_variadic;
use util::common::ErrorReported;
use util::nodemap::FxHashMap;
-use errors::{FatalError, DiagnosticId};
+use errors::{Applicability, FatalError, DiagnosticId};
use lint;
use std::iter;
trait_str: &str,
name: &str) {
struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type")
- .span_label(span, "ambiguous associated type")
- .note(&format!("specify the type using the syntax `<{} as {}>::{}`",
- type_str, trait_str, name))
- .emit();
-
+ .span_suggestion_with_applicability(
+ span,
+ "use fully-qualified syntax",
+ format!("<{} as {}>::{}", type_str, trait_str, name),
+ Applicability::HasPlaceholders
+ ).emit();
}
// Search for a bound on a type parameter which includes the associated item
--> $DIR/associated-types-in-ambiguous-context.rs:16:36
|
LL | fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
- | ^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<Type as Get>::Value`
+ | ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Get>::Value`
error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:25:10
|
LL | type X = std::ops::Deref::Target;
- | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<Type as std::ops::Deref>::Target`
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as std::ops::Deref>::Target`
error[E0223]: ambiguous associated type
--> $DIR/associated-types-in-ambiguous-context.rs:21:23
|
LL | fn grab(&self) -> Grab::Value;
- | ^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<Type as Grab>::Value`
+ | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Grab>::Value`
error: aborting due to 3 previous errors
--> $DIR/bad-assoc-ty.rs:11:10
|
LL | type A = [u8; 4]::AssocTy;
- | ^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<[u8; _] as Trait>::AssocTy`
+ | ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8; _] as Trait>::AssocTy`
error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:15:10
|
LL | type B = [u8]::AssocTy;
- | ^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<[u8] as Trait>::AssocTy`
+ | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8] as Trait>::AssocTy`
error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:19:10
|
LL | type C = (u8)::AssocTy;
- | ^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<u8 as Trait>::AssocTy`
+ | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`
error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:23:10
|
LL | type D = (u8, u8)::AssocTy;
- | ^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<(u8, u8) as Trait>::AssocTy`
+ | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(u8, u8) as Trait>::AssocTy`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/bad-assoc-ty.rs:27:10
--> $DIR/bad-assoc-ty.rs:31:19
|
LL | type F = &'static (u8)::AssocTy;
- | ^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<u8 as Trait>::AssocTy`
+ | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy`
error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:37:10
|
LL | type G = 'static + (Send)::AssocTy;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<(dyn std::marker::Send + 'static) as Trait>::AssocTy`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy`
error[E0223]: ambiguous associated type
--> $DIR/bad-assoc-ty.rs:43:10
|
LL | type H = Fn(u8) -> (u8)::Output;
- | ^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output`
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output`
error: aborting due to 15 previous errors
--> $DIR/E0223.rs:14:14
|
LL | let foo: MyTrait::X;
- | ^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<Type as MyTrait>::X`
+ | ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as MyTrait>::X`
error: aborting due to previous error
--> $DIR/impl_trait_projections.rs:21:50
|
LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item {
- | ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<impl std::iter::Iterator as Trait>::Item`
+ | ^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<impl std::iter::Iterator as Trait>::Item`
error: aborting due to 5 previous errors
--> $DIR/issue-23073.rs:16:17
|
LL | type FooT = <<Self as Bar>::Foo>::T; //~ ERROR ambiguous associated type
- | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<<Self as Bar>::Foo as Trait>::T`
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<Self as Bar>::Foo as Trait>::T`
error: aborting due to previous error
--> $DIR/issue-34209.rs:17:9
|
LL | S::B{ } => { },
- | ^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::B`
+ | ^^^^ help: use fully-qualified syntax: `<S as Trait>::B`
error: aborting due to previous error
--> $DIR/qualified-path-params-2.rs:28:10
|
LL | type A = <S as Tr>::A::f<u8>;
- | ^^^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<<S as Tr>::A as Trait>::f`
+ | ^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<S as Tr>::A as Trait>::f`
error: aborting due to 2 previous errors
--> $DIR/self-impl.rs:33:16
|
LL | let _: <Self>::Baz = true;
- | ^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<Bar as Trait>::Baz`
+ | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Trait>::Baz`
error[E0223]: ambiguous associated type
--> $DIR/self-impl.rs:35:16
|
LL | let _: Self::Baz = true;
- | ^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<Bar as Trait>::Baz`
+ | ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Trait>::Baz`
error: aborting due to 2 previous errors
--> $DIR/struct-path-associated-type.rs:42:13
|
LL | let s = S::A {}; //~ ERROR ambiguous associated type
- | ^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::A`
+ | ^^^^ help: use fully-qualified syntax: `<S as Trait>::A`
error[E0109]: type parameters are not allowed on this type
--> $DIR/struct-path-associated-type.rs:43:20
--> $DIR/struct-path-associated-type.rs:43:13
|
LL | let z = S::A::<u8> {}; //~ ERROR ambiguous associated type
- | ^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::A`
+ | ^^^^^^^^^^ help: use fully-qualified syntax: `<S as Trait>::A`
error[E0223]: ambiguous associated type
--> $DIR/struct-path-associated-type.rs:46:9
|
LL | S::A {} => {} //~ ERROR ambiguous associated type
- | ^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::A`
+ | ^^^^ help: use fully-qualified syntax: `<S as Trait>::A`
error: aborting due to 9 previous errors
--> $DIR/trait-item-privacy.rs:127:12
|
LL | let _: S::A; //~ ERROR ambiguous associated type
- | ^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::A`
+ | ^^^^ help: use fully-qualified syntax: `<S as Trait>::A`
error[E0223]: ambiguous associated type
--> $DIR/trait-item-privacy.rs:128:12
|
LL | let _: S::B; //~ ERROR ambiguous associated type
- | ^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::B`
+ | ^^^^ help: use fully-qualified syntax: `<S as Trait>::B`
error[E0223]: ambiguous associated type
--> $DIR/trait-item-privacy.rs:129:12
|
LL | let _: S::C; //~ ERROR ambiguous associated type
- | ^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<S as Trait>::C`
+ | ^^^^ help: use fully-qualified syntax: `<S as Trait>::C`
error: associated type `A` is private
--> $DIR/trait-item-privacy.rs:131:12
--> $DIR/ufcs-partially-resolved.rs:46:12
|
LL | let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type
- | ^^^^^^^^^^^^^^^^^ ambiguous associated type
- |
- = note: specify the type using the syntax `<<u8 as Tr>::Y as Trait>::NN`
+ | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<u8 as Tr>::Y as Trait>::NN`
error[E0599]: no associated item named `NN` found for type `<u8 as Tr>::Y` in the current scope
--> $DIR/ufcs-partially-resolved.rs:48:5