(hir::AssocItemKind::Type, default.is_some())
}
AssocItemKind::Fn(_, sig, _, default) => {
- (hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some())
+ (hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }, default.is_some())
}
AssocItemKind::MacCall(..) => unimplemented!(),
};
}
}
AssocItemKind::Fn(_, sig, ..) => {
- hir::AssocItemKind::Method { has_self: sig.decl.has_self() }
+ hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }
}
AssocItemKind::MacCall(..) => unimplemented!(),
},
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
pub enum AssocItemKind {
Const,
- Method { has_self: bool },
+ Fn { has_self: bool },
Type,
OpaqueTy,
}
// enable E0621 for it.
pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool {
is_first
- && self.tcx().opt_associated_item(scope_def_id).map(|i| i.method_has_self_argument)
+ && self.tcx().opt_associated_item(scope_def_id).map(|i| i.fn_has_self_parameter)
== Some(true)
}
}
EntryKind::AssocConst(container, _, _) => (ty::AssocKind::Const, container, false),
EntryKind::AssocFn(data) => {
let data = data.decode(self);
- (ty::AssocKind::Method, data.container, data.has_self)
+ (ty::AssocKind::Fn, data.container, data.has_self)
}
EntryKind::AssocType(container) => (ty::AssocKind::Type, container, false),
EntryKind::AssocOpaqueTy(container) => (ty::AssocKind::OpaqueTy, container, false),
defaultness: container.defaultness(),
def_id: self.local_def_id(id),
container: container.with_def_id(parent),
- method_has_self_argument: has_self,
+ fn_has_self_parameter: has_self,
}
}
rendered_const,
)
}
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind {
let param_names = match *m {
hir::TraitFn::Required(ref names) => {
EntryKind::AssocFn(self.lazy(AssocFnData {
fn_data,
container,
- has_self: trait_item.method_has_self_argument,
+ has_self: trait_item.fn_has_self_parameter,
}))
}
ty::AssocKind::Type => EntryKind::AssocType(container),
self.encode_const_stability(def_id);
self.encode_deprecation(def_id);
match trait_item.kind {
- ty::AssocKind::Const | ty::AssocKind::Method => {
+ ty::AssocKind::Const | ty::AssocKind::Fn => {
self.encode_item_type(def_id);
}
ty::AssocKind::Type => {
}
ty::AssocKind::OpaqueTy => unreachable!(),
}
- if trait_item.kind == ty::AssocKind::Method {
+ if trait_item.kind == ty::AssocKind::Fn {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
self.encode_variances_of(def_id);
}
bug!()
}
}
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
FnData {
asyncness: sig.header.asyncness,
EntryKind::AssocFn(self.lazy(AssocFnData {
fn_data,
container,
- has_self: impl_item.method_has_self_argument,
+ has_self: impl_item.fn_has_self_parameter,
}))
}
ty::AssocKind::OpaqueTy => EntryKind::AssocOpaqueTy(container),
self.encode_const_stability(def_id);
self.encode_deprecation(def_id);
self.encode_item_type(def_id);
- if impl_item.kind == ty::AssocKind::Method {
+ if impl_item.kind == ty::AssocKind::Fn {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
self.encode_variances_of(def_id);
}
.find(move |impl_item| {
match (trait_item_kind, impl_item.kind) {
| (Const, Const)
- | (Method, Method)
+ | (Fn, Fn)
| (Type, Type)
| (Type, OpaqueTy) // assoc. types can be made opaque in impls
=> tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id),
| (Const, _)
- | (Method, _)
+ | (Fn, _)
| (Type, _)
| (OpaqueTy, _)
=> false,
let method_def_id = tcx
.associated_items(trait_def_id.unwrap())
.in_definition_order()
- .find(|m| m.kind == ty::AssocKind::Method)
+ .find(|m| m.kind == ty::AssocKind::Fn)
.unwrap()
.def_id;
(method_def_id, tcx.mk_substs_trait(source, &[]))
let call_once = tcx
.associated_items(fn_once)
.in_definition_order()
- .find(|it| it.kind == ty::AssocKind::Method)
+ .find(|it| it.kind == ty::AssocKind::Fn)
.unwrap()
.def_id;
let def = ty::InstanceDef::ClosureOnceShim { call_once };
-// ignore-tidy-filelength
-
pub use self::fold::{TypeFoldable, TypeVisitor};
pub use self::AssocItemContainer::*;
pub use self::BorrowKind::*;
pub container: AssocItemContainer,
/// Whether this is a method with an explicit self
- /// as its first argument, allowing method calls.
- pub method_has_self_argument: bool,
+ /// as its first parameter, allowing method calls.
+ pub fn_has_self_parameter: bool,
}
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
pub enum AssocKind {
Const,
- Method,
+ Fn,
OpaqueTy,
Type,
}
impl AssocKind {
- pub fn suggestion_descr(&self) -> &'static str {
- match self {
- ty::AssocKind::Method => "method call",
- ty::AssocKind::Type | ty::AssocKind::OpaqueTy => "associated type",
- ty::AssocKind::Const => "associated constant",
- }
- }
-
pub fn namespace(&self) -> Namespace {
match *self {
ty::AssocKind::OpaqueTy | ty::AssocKind::Type => Namespace::TypeNS,
- ty::AssocKind::Const | ty::AssocKind::Method => Namespace::ValueNS,
+ ty::AssocKind::Const | ty::AssocKind::Fn => Namespace::ValueNS,
}
}
-}
-impl AssocItem {
- pub fn def_kind(&self) -> DefKind {
- match self.kind {
+ pub fn as_def_kind(&self) -> DefKind {
+ match self {
AssocKind::Const => DefKind::AssocConst,
- AssocKind::Method => DefKind::AssocFn,
+ AssocKind::Fn => DefKind::AssocFn,
AssocKind::Type => DefKind::AssocTy,
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
}
}
+}
+impl AssocItem {
/// Tests whether the associated item admits a non-trivial implementation
/// for !
pub fn relevant_for_never(&self) -> bool {
match self.kind {
AssocKind::OpaqueTy | AssocKind::Const | AssocKind::Type => true,
// FIXME(canndrew): Be more thorough here, check if any argument is uninhabited.
- AssocKind::Method => !self.method_has_self_argument,
+ AssocKind::Fn => !self.fn_has_self_parameter,
}
}
pub fn signature(&self, tcx: TyCtxt<'_>) -> String {
match self.kind {
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
// We skip the binder here because the binder would deanonymize all
// late-bound regions, and we don't want method signatures to show up
// `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound
pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
self.associated_items(id)
.in_definition_order()
- .filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value())
+ .filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value())
}
pub fn trait_relevant_for_never(self, did: DefId) -> bool {
let call_mut = tcx
.associated_items(fn_mut)
.in_definition_order()
- .find(|it| it.kind == ty::AssocKind::Method)
+ .find(|it| it.kind == ty::AssocKind::Fn)
.unwrap()
.def_id;
.tcx
.associated_items(trait_def_id)
.filter_by_name_unhygienic(method_name)
- .find(|item| item.kind == ty::AssocKind::Method)
+ .find(|item| item.kind == ty::AssocKind::Fn)
.expect("trait method not found");
let method_ty = self.tcx.type_of(item.def_id);
found_pub_static = true;
intravisit::walk_impl_item(self, impl_item);
}
- AssocItemKind::Method { has_self: false } => {
+ AssocItemKind::Fn { has_self: false } => {
found_pub_static = true;
intravisit::walk_impl_item(self, impl_item);
}
let mut check = self.check(hir_id, vis);
let (check_ty, is_assoc_ty) = match assoc_item_kind {
- AssocItemKind::Const | AssocItemKind::Method { .. } => (true, false),
+ AssocItemKind::Const | AssocItemKind::Fn { .. } => (true, false),
AssocItemKind::Type => (defaultness.has_value(), true),
// `ty()` for opaque types is the underlying type,
// it's not a part of interface, so we skip it.
Res::Def(DefKind::AssocFn, def_id) => {
if cstore
.associated_item_cloned_untracked(def_id, self.r.session)
- .method_has_self_argument
+ .fn_has_self_parameter
{
self.r.has_self.insert(def_id);
}
};
let has_self = match assoc_item_kind {
- Some(hir::AssocItemKind::Method { has_self }) => has_self,
+ Some(hir::AssocItemKind::Fn { has_self }) => has_self,
_ => false,
};
err.note(&format!(
"{}s cannot be accessed directly on a `trait`, they can only be \
accessed through a specific `impl`",
- assoc_item.kind.suggestion_descr(),
+ assoc_item.kind.as_def_kind().descr(def_id)
));
err.span_suggestion(
span,
let trait_methods = tcx
.associated_items(trait_ref.def_id())
.in_definition_order()
- .filter(|item| item.kind == ty::AssocKind::Method);
+ .filter(|item| item.kind == ty::AssocKind::Fn);
// Now list each method's DefId and InternalSubsts (for within its trait).
// If the method can never be called from this object, produce None.
let mut violations: Vec<_> = tcx
.associated_items(trait_def_id)
.in_definition_order()
- .filter(|item| item.kind == ty::AssocKind::Method)
+ .filter(|item| item.kind == ty::AssocKind::Fn)
.filter_map(|item| {
object_safety_violation_for_method(tcx, trait_def_id, &item)
.map(|(code, span)| ObjectSafetyViolation::Method(item.ident.name, code, span))
method: &ty::AssocItem,
) -> Option<MethodViolationCode> {
// The method's first parameter must be named `self`
- if !method.method_has_self_argument {
+ if !method.fn_has_self_parameter {
// We'll attempt to provide a structured suggestion for `Self: Sized`.
let sugg =
tcx.hir().get_if_local(method.def_id).as_ref().and_then(|node| node.generics()).map(
// Count number of methods and add them to the total offset.
// Skip over associated types and constants.
for trait_item in tcx.associated_items(trait_ref.def_id()).in_definition_order() {
- if trait_item.kind == ty::AssocKind::Method {
+ if trait_item.kind == ty::AssocKind::Fn {
entries += 1;
}
}
for trait_item in tcx.associated_items(object.upcast_trait_ref.def_id()).in_definition_order() {
if trait_item.def_id == method_def_id {
// The item with the ID we were given really ought to be a method.
- assert_eq!(trait_item.kind, ty::AssocKind::Method);
+ assert_eq!(trait_item.kind, ty::AssocKind::Fn);
return entries;
}
- if trait_item.kind == ty::AssocKind::Method {
+ if trait_item.kind == ty::AssocKind::Fn {
entries += 1;
}
}
let def_id = tcx.hir().local_def_id(trait_item_ref.id.hir_id);
let (kind, has_self) = match trait_item_ref.kind {
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
- hir::AssocItemKind::Method { has_self } => (ty::AssocKind::Method, has_self),
+ hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
hir::AssocItemKind::Type => (ty::AssocKind::Type, false),
hir::AssocItemKind::OpaqueTy => bug!("only impls can have opaque types"),
};
defaultness: trait_item_ref.defaultness,
def_id,
container: ty::TraitContainer(parent_def_id),
- method_has_self_argument: has_self,
+ fn_has_self_parameter: has_self,
}
}
let def_id = tcx.hir().local_def_id(impl_item_ref.id.hir_id);
let (kind, has_self) = match impl_item_ref.kind {
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
- hir::AssocItemKind::Method { has_self } => (ty::AssocKind::Method, has_self),
+ hir::AssocItemKind::Fn { has_self } => (ty::AssocKind::Fn, has_self),
hir::AssocItemKind::Type => (ty::AssocKind::Type, false),
hir::AssocItemKind::OpaqueTy => (ty::AssocKind::OpaqueTy, false),
};
defaultness: impl_item_ref.defaultness,
def_id,
container: ty::ImplContainer(parent_def_id),
- method_has_self_argument: has_self,
+ fn_has_self_parameter: has_self,
}
}
})
};
- match (trait_m.method_has_self_argument, impl_m.method_has_self_argument) {
+ match (trait_m.fn_has_self_parameter, impl_m.fn_has_self_parameter) {
(false, false) | (true, true) => {}
(false, true) => {
fn assoc_item_kind_str(impl_item: &ty::AssocItem) -> &'static str {
match impl_item.kind {
ty::AssocKind::Const => "const",
- ty::AssocKind::Method => "method",
+ ty::AssocKind::Fn => "method",
ty::AssocKind::Type | ty::AssocKind::OpaqueTy => "type",
}
}
// This function checks if the method isn't static and takes other arguments than `self`.
fn has_no_input_arg(&self, method: &AssocItem) -> bool {
match method.kind {
- ty::AssocKind::Method => {
- self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1
- }
+ ty::AssocKind::Fn => self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1,
_ => false,
}
}
}
}
- let def_kind = pick.item.def_kind();
+ let def_kind = pick.item.kind.as_def_kind();
debug!("resolve_ufcs: def_kind={:?}, def_id={:?}", def_kind, pick.item.def_id);
tcx.check_stability(pick.item.def_id, Some(expr_id), span);
Ok((def_kind, pick.item.def_id))
self.extension_candidates.push(candidate);
}
} else if self.private_candidate.is_none() {
- self.private_candidate = Some((candidate.item.def_kind(), candidate.item.def_id));
+ self.private_candidate =
+ Some((candidate.item.kind.as_def_kind(), candidate.item.def_id));
}
}
expected: Ty<'tcx>,
) -> bool {
match method.kind {
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
let fty = self.tcx.fn_sig(method.def_id);
self.probe(|_| {
let substs = self.fresh_substs_for_item(self.span, method.def_id);
// In Path mode (i.e., resolving a value like `T::next`), consider any
// associated value (i.e., methods, constants) but not types.
match self.mode {
- Mode::MethodCall => item.method_has_self_argument,
+ Mode::MethodCall => item.fn_has_self_parameter,
Mode::Path => match item.kind {
ty::AssocKind::OpaqueTy | ty::AssocKind::Type => false,
- ty::AssocKind::Method | ty::AssocKind::Const => true,
+ ty::AssocKind::Fn | ty::AssocKind::Const => true,
},
}
// FIXME -- check for types that deref to `Self`,
impl_ty: Ty<'tcx>,
substs: SubstsRef<'tcx>,
) -> (Ty<'tcx>, Option<Ty<'tcx>>) {
- if item.kind == ty::AssocKind::Method && self.mode == Mode::MethodCall {
+ if item.kind == ty::AssocKind::Fn && self.mode == Mode::MethodCall {
let sig = self.xform_method_sig(item.def_id, substs);
(sig.inputs()[0], Some(sig.output()))
} else {
ty::AssocKind::Const
| ty::AssocKind::Type
| ty::AssocKind::OpaqueTy => rcvr_ty,
- ty::AssocKind::Method => self
+ ty::AssocKind::Fn => self
.tcx
.fn_sig(item.def_id)
.inputs()
path,
ty,
item.kind,
+ item.def_id,
sugg_span,
idx,
self.tcx.sess.source_map(),
path,
rcvr_ty,
item.kind,
+ item.def_id,
sugg_span,
idx,
self.tcx.sess.source_map(),
err.span_label(span, msg);
}
} else if let Some(lev_candidate) = lev_candidate {
- let def_kind = lev_candidate.def_kind();
+ let def_kind = lev_candidate.kind.as_def_kind();
err.span_suggestion(
span,
&format!(
&& self
.associated_item(info.def_id, item_name, Namespace::ValueNS)
.filter(|item| {
- if let ty::AssocKind::Method = item.kind {
+ if let ty::AssocKind::Fn = item.kind {
let id = self.tcx.hir().as_local_hir_id(item.def_id);
if let Some(hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(fn_sig, method),
trait_name: String,
rcvr_ty: Ty<'_>,
kind: ty::AssocKind,
+ def_id: DefId,
span: Span,
candidate: Option<usize>,
source_map: &source_map::SourceMap,
) {
let mut applicability = Applicability::MachineApplicable;
- let sugg_args = if let (ty::AssocKind::Method, Some(args)) = (kind, args) {
+ let sugg_args = if let (ty::AssocKind::Fn, Some(args)) = (kind, args) {
format!(
"({}{})",
if rcvr_ty.is_region_ptr() {
span,
&format!(
"disambiguate the {} for {}",
- kind.suggestion_descr(),
+ kind.as_def_kind().descr(def_id),
if let Some(candidate) = candidate {
format!("candidate #{}", candidate)
} else {
) {
let kind = match impl_item.kind {
hir::ImplItemKind::Const(..) => ty::AssocKind::Const,
- hir::ImplItemKind::Fn(..) => ty::AssocKind::Method,
+ hir::ImplItemKind::Fn(..) => ty::AssocKind::Fn,
hir::ImplItemKind::OpaqueTy(..) => ty::AssocKind::OpaqueTy,
hir::ImplItemKind::TyAlias(_) => ty::AssocKind::Type,
};
}
hir::ImplItemKind::Fn(..) => {
let opt_trait_span = tcx.hir().span_if_local(ty_trait_item.def_id);
- if ty_trait_item.kind == ty::AssocKind::Method {
+ if ty_trait_item.kind == ty::AssocKind::Fn {
compare_impl_method(
tcx,
&ty_impl_item,
/// structured suggestion.
fn suggestion_signature(assoc: &ty::AssocItem, tcx: TyCtxt<'_>) -> String {
match assoc.kind {
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
// We skip the binder here because the binder would deanonymize all
// late-bound regions, and we don't want method signatures to show up
// `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound
let ty = fcx.normalize_associated_types_in(span, &ty);
fcx.register_wf_obligation(ty, span, code.clone());
}
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
let sig = fcx.tcx.fn_sig(item.def_id);
let sig = fcx.normalize_associated_types_in(span, &sig);
let hir_sig = sig_if_method.expect("bad signature for method");
// Check that the method has a valid receiver type, given the type `Self`.
debug!("check_method_receiver({:?}, self_ty={:?})", method, self_ty);
- if !method.method_has_self_argument {
+ if !method.fn_has_self_parameter {
return;
}
.associated_items(trait_def_id)
.filter_by_name_unhygienic(impl_item.ident.name)
.find(move |trait_item| {
- trait_item.kind == ty::AssocKind::Method
+ trait_item.kind == ty::AssocKind::Fn
&& tcx.hygienic_eq(impl_item.ident, trait_item.ident, trait_def_id)
})
{
let predicates = tcx.predicates_of(def_id).instantiate_identity(tcx);
cgp::parameters_for(&predicates, true)
}
- ty::AssocKind::Method | ty::AssocKind::Const => Vec::new(),
+ ty::AssocKind::Fn | ty::AssocKind::Const => Vec::new(),
}
})
.collect();
};
AssocConstItem(ty.clean(cx), default)
}
- ty::AssocKind::Method => {
+ ty::AssocKind::Fn => {
let generics =
(cx.tcx.generics_of(self.def_id), cx.tcx.explicit_predicates_of(self.def_id))
.clean(cx);
let sig = cx.tcx.fn_sig(self.def_id);
let mut decl = (self.def_id, sig).clean(cx);
- if self.method_has_self_argument {
+ if self.fn_has_self_parameter {
let self_ty = match self.container {
ty::ImplContainer(def_id) => cx.tcx.type_of(def_id),
ty::TraitContainer(_) => cx.tcx.types.self_param,
.filter_by_name_unhygienic(item_name)
.next()
.and_then(|item| match item.kind {
- ty::AssocKind::Method => Some("method"),
+ ty::AssocKind::Fn => Some("method"),
_ => None,
})
.map(|out| (prim, Some(format!("{}#{}.{}", path, out, item_name))))
.find(|item| item.ident.name == item_name);
if let Some(item) = item {
let out = match item.kind {
- ty::AssocKind::Method if ns == ValueNS => "method",
+ ty::AssocKind::Fn if ns == ValueNS => "method",
ty::AssocKind::Const if ns == ValueNS => "associatedconstant",
_ => return self.variant_field(path_str, current_item, module_id),
};
if extra_fragment.is_some() {
- Err(ErrorKind::AnchorFailure(if item.kind == ty::AssocKind::Method {
+ Err(ErrorKind::AnchorFailure(if item.kind == ty::AssocKind::Fn {
"methods cannot be followed by anchors"
} else {
"associated constants cannot be followed by anchors"
.map(|item| cx.tcx.associated_item(*item))
.find(|item| item.ident.name == item_name);
if let Some(item) = item {
- let kind = match item.kind {
- ty::AssocKind::Const if ns == ValueNS => "associatedconstant",
- ty::AssocKind::Type if ns == TypeNS => "associatedtype",
- ty::AssocKind::Method if ns == ValueNS => {
- if item.defaultness.has_value() { "method" } else { "tymethod" }
- }
- _ => return self.variant_field(path_str, current_item, module_id),
- };
+ let kind =
+ match item.kind {
+ ty::AssocKind::Const if ns == ValueNS => "associatedconstant",
+ ty::AssocKind::Type if ns == TypeNS => "associatedtype",
+ ty::AssocKind::Fn if ns == ValueNS => {
+ if item.defaultness.has_value() { "method" } else { "tymethod" }
+ }
+ _ => return self.variant_field(path_str, current_item, module_id),
+ };
if extra_fragment.is_some() {
Err(ErrorKind::AnchorFailure(if item.kind == ty::AssocKind::Const {
|
LL | fn foo() {}
| ^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | Trait1::foo()
| ^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | Trait2::foo()
| ^^^^^^^^^^^
|
= note: candidate #1 is defined in an impl of the trait `inference_unstable_iterator::IpuIterator` for the type `char`
= note: candidate #2 is defined in an impl of the trait `inference_unstable_itertools::IpuItertools` for the type `char`
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | assert_eq!(inference_unstable_iterator::IpuIterator::ipu_flatten(&'x'), 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | assert_eq!(inference_unstable_itertools::IpuItertools::ipu_flatten(&'x'), 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| --^^^--
| | |
| | multiple `foo` found
- | help: disambiguate the method call for candidate #2: `T::foo(&x)`
+ | help: disambiguate the associated function for candidate #2: `T::foo(&x)`
|
note: candidate #1 is defined in an impl for the type `(dyn T + 'a)`
--> $DIR/issue-18446.rs:9:5
|
LL | fn to_int(&self) -> isize { *self }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | ToPrimitive::to_int(&self) + other.to_int()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | Add::to_int(&self) + other.to_int()
| ^^^^^^^^^^^^^^^^^^
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | async::r#struct(&r#fn {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | await::r#struct(&r#fn {});
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | impl Me2 for usize { fn me(&self) -> usize { *self } }
| ^^^^^^^^^^^^^^^^^^^^^
= note: candidate #2 is defined in an impl of the trait `ambig_impl_2_lib::Me` for the type `usize`
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | fn main() { Me2::me(&1_usize); }
| ^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | fn main() { ambig_impl_2_lib::Me::me(&1_usize); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
LL | trait B { fn foo(&self); }
| ^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | A::foo(t);
| ^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | B::foo(t);
| ^^^^^^^^^
|
LL | fn foo(self) {}
| ^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | A::foo(AB {});
| ^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | B::foo(AB {});
| ^^^^^^^^^^^^^
|
LL | fn foo() {}
| ^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | A::foo();
| ^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | B::foo();
| ^^^^^^
|
LL | trait Bar { fn method(&self) {} }
| ^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | Foo::method(&1_usize);
| ^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | Bar::method(&1_usize);
| ^^^^^^^^^^^^^^^^^^^^^
|
LL | fn foo(&self) -> u8;
| ^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | let z = internal::X::foo(x);
| ^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | let z = nuisance_foo::NuisanceFoo::foo(x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #3
+help: disambiguate the associated function for candidate #3
|
LL | let z = FinalFoo::foo(x);
| ^^^^^^^^^^^^^^^^
|
LL | fn foo(&mut self) {}
| ^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | A::foo(&a)
| ^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | B::foo(&a)
| ^^^^^^^^^^
|
LL | fn foo(&self) {}
| ^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | C::foo(&a)
| ^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | D::foo(&a)
| ^^^^^^^^^^
|
LL | fn foo(self) {}
| ^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | E::foo(a)
| ^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | F::foo(a)
| ^^^^^^^^^
candidate #1: `CtxtFn`
candidate #2: `OtherTrait`
candidate #3: `UnusedTrait`
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | u.f8(42) + CtxtFn::f9(u, 342) + m.fff(42)
| ^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | u.f8(42) + OtherTrait::f9(u, 342) + m.fff(42)
| ^^^^^^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #3
+help: disambiguate the associated function for candidate #3
|
LL | u.f8(42) + UnusedTrait::f9(u, 342) + m.fff(42)
| ^^^^^^^^^^^^^^^^^^^^^^^
| --^^^^^^--
| | |
| | this is an associated function, not a method
- | help: disambiguate the method call for the candidate: `ManyImplTrait::is_str(t)`
+ | help: disambiguate the associated function for the candidate: `ManyImplTrait::is_str(t)`
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in the trait `ManyImplTrait`
|
LL | fn foo(&self) {}
| ^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #1
+help: disambiguate the associated function for candidate #1
|
LL | inner::A::foo(&t);
| ^^^^^^^^^^^^^^^^^
-help: disambiguate the method call for candidate #2
+help: disambiguate the associated function for candidate #2
|
LL | inner::B::foo(&t);
| ^^^^^^^^^^^^^^^^^