self.lctx.allocate_hir_id_counter(item.id);
match item.kind {
- AssocItemKind::Method(_, None) => {
+ AssocItemKind::Fn(_, None) => {
// Ignore patterns in trait methods without bodies
self.with_hir_id_owner(None, |this| {
visit::walk_trait_item(this, item)
.map(|x| self.lower_const_body(i.span, Some(x))),
),
),
- AssocItemKind::Method(ref sig, None) => {
+ AssocItemKind::Fn(ref sig, None) => {
let names = self.lower_fn_params_to_names(&sig.decl);
let (generics, sig) = self.lower_method_sig(
&i.generics,
);
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
}
- AssocItemKind::Method(ref sig, Some(ref body)) => {
+ AssocItemKind::Fn(ref sig, Some(ref body)) => {
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
let (generics, sig) = self.lower_method_sig(
&i.generics,
AssocItemKind::TyAlias(_, ref default) => {
(hir::AssocItemKind::Type, default.is_some())
}
- AssocItemKind::Method(ref sig, ref default) => (
+ AssocItemKind::Fn(ref sig, ref default) => (
hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
},
self.lower_const_body(i.span, expr.as_deref()),
),
),
- AssocItemKind::Method(ref sig, ref body) => {
+ AssocItemKind::Fn(ref sig, ref body) => {
self.current_item = Some(i.span);
let body_id = self.lower_maybe_async_body(
i.span,
None => hir::AssocItemKind::Type,
Some(_) => hir::AssocItemKind::OpaqueTy,
},
- AssocItemKind::Method(sig, _) => hir::AssocItemKind::Method {
+ AssocItemKind::Fn(sig, _) => hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
},
AssocItemKind::Macro(..) => unimplemented!(),
fn flat_map_trait_item(&mut self, i: ast::AssocItem) -> SmallVec<[ast::AssocItem; 1]> {
let is_const = match i.kind {
ast::AssocItemKind::Const(..) => true,
- ast::AssocItemKind::Method(ref sig, _) => Self::is_sig_const(sig),
+ ast::AssocItemKind::Fn(ref sig, _) => Self::is_sig_const(sig),
_ => false,
};
self.run(is_const, |s| noop_flat_map_assoc_item(i, s))
}
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::AssocItem) {
- if let ast::AssocItemKind::Method(ref sig, None) = item.kind {
+ if let ast::AssocItemKind::Fn(ref sig, None) = item.kind {
if sig.header.unsafety == ast::Unsafety::Unsafe {
self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
}
impl EarlyLintPass for AnonymousParameters {
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) {
match it.kind {
- ast::AssocItemKind::Method(ref sig, _) => {
+ ast::AssocItemKind::Fn(ref sig, _) => {
for arg in sig.decl.inputs.iter() {
match arg.pat.kind {
ast::PatKind::Ident(_, ident, None) => {
})?;
let sig = FnSig { header, decl };
let body = self.parse_assoc_fn_body(at_end, attrs)?;
- Ok((ident, AssocItemKind::Method(sig, body), generics))
+ Ok((ident, AssocItemKind::Fn(sig, body), generics))
}
/// Parse the "body" of a method in an associated item definition.
}
for impl_item in impl_items {
self.invalid_visibility(&impl_item.vis, None);
- if let AssocItemKind::Method(ref sig, _) = impl_item.kind {
+ if let AssocItemKind::Fn(ref sig, _) = impl_item.kind {
self.check_trait_fn_not_const(sig.header.constness);
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
}
AssocItemKind::Const(_, body) => {
self.check_impl_item_provided(ii.span, body, "constant", " = <expr>;");
}
- AssocItemKind::Method(sig, body) => {
+ AssocItemKind::Fn(sig, body) => {
self.check_impl_item_provided(ii.span, body, "function", " { <body> }");
self.check_fn_decl(&sig.decl);
}
self.invalid_visibility(&ti.vis, None);
self.check_defaultness(ti.span, ti.defaultness);
- if let AssocItemKind::Method(sig, block) = &ti.kind {
+ if let AssocItemKind::Fn(sig, block) = &ti.kind {
self.check_fn_decl(&sig.decl);
self.check_trait_fn_not_async(ti.span, sig.header.asyncness.node);
self.check_trait_fn_not_const(sig.header.constness);
}
fn visit_assoc_item(&mut self, item: &'a AssocItem) {
- if let AssocItemKind::Method(sig, _) = &item.kind {
+ if let AssocItemKind::Fn(sig, _) = &item.kind {
self.check_c_varadic_type(&sig.decl);
}
visit::walk_assoc_item(self, item);
let item_def_id = self.r.definitions.local_def_id(item.id);
let (res, ns) = match item.kind {
AssocItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
- AssocItemKind::Method(ref sig, _) => {
+ AssocItemKind::Fn(ref sig, _) => {
if sig.decl.has_self() {
self.r.has_self.insert(item_def_id);
}
fn visit_trait_item(&mut self, ti: &'a AssocItem) {
let def_data = match ti.kind {
- AssocItemKind::Method(..) | AssocItemKind::Const(..) =>
- DefPathData::ValueNs(ti.ident.name),
- AssocItemKind::TyAlias(..) => {
- DefPathData::TypeNs(ti.ident.name)
- },
+ AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(ti.ident.name),
+ AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ti.ident.name),
AssocItemKind::Macro(..) => return self.visit_macro_invoc(ti.id),
};
fn visit_impl_item(&mut self, ii: &'a AssocItem) {
let def_data = match ii.kind {
- AssocItemKind::Method(FnSig {
+ AssocItemKind::Fn(FnSig {
ref header,
ref decl,
}, ref body) if header.asyncness.node.is_async() => {
body.as_deref(),
)
}
- AssocItemKind::Method(..) |
+ AssocItemKind::Fn(..) |
AssocItemKind::Const(..) => DefPathData::ValueNs(ii.ident.name),
AssocItemKind::TyAlias(..) => DefPathData::TypeNs(ii.ident.name),
AssocItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),
});
}
}
- AssocItemKind::Method(_, _) => {
+ AssocItemKind::Fn(_, _) => {
visit::walk_assoc_item(this, trait_item)
}
AssocItemKind::TyAlias(..) => {
visit::walk_assoc_item(this, impl_item)
});
}
- AssocItemKind::Method(..) => {
+ AssocItemKind::Fn(..) => {
// If this is a trait impl, ensure the method
// exists in trait
this.check_trait_item(impl_item.ident,
&trait_item.attrs,
);
}
- ast::AssocItemKind::Method(ref sig, ref body) => {
+ ast::AssocItemKind::Fn(ref sig, ref body) => {
self.process_method(
sig,
body.as_ref().map(|x| &**x),
&impl_item.attrs,
);
}
- ast::AssocItemKind::Method(ref sig, ref body) => {
+ ast::AssocItemKind::Fn(ref sig, ref body) => {
self.process_method(
sig,
body.as_deref(),
Const(P<Ty>, Option<P<Expr>>),
/// An associated function.
- /// FIXME(Centril): Rename to `Fn`.
- Method(FnSig, Option<P<Block>>),
+ Fn(FnSig, Option<P<Block>>),
/// An associated type.
TyAlias(GenericBounds, Option<P<Ty>>),
fn visit_trait_item(&mut self, ti: &'a ast::AssocItem) {
match ti.kind {
- ast::AssocItemKind::Method(ref sig, ref block) => {
+ ast::AssocItemKind::Fn(ref sig, ref block) => {
if block.is_none() {
self.check_extern(sig.header.ext);
}
}
match ii.kind {
- ast::AssocItemKind::Method(ref sig, _) => {
+ ast::AssocItemKind::Fn(ref sig, _) => {
if sig.decl.c_variadic() {
gate_feature_post!(
&self, c_variadic, ii.span,
visitor.visit_ty(ty);
visit_opt(expr, |expr| visitor.visit_expr(expr));
}
- AssocItemKind::Method(sig, body) => {
+ AssocItemKind::Fn(sig, body) => {
visit_fn_sig(sig, visitor);
visit_opt(body, |body| visitor.visit_block(body));
}
ast::AssocItemKind::Const(ty, expr) => {
self.print_associated_const(item.ident, ty, expr.as_deref(), &item.vis);
}
- ast::AssocItemKind::Method(sig, body) => {
+ ast::AssocItemKind::Fn(sig, body) => {
if body.is_some() {
self.head("");
}
visitor.visit_ty(ty);
walk_list!(visitor, visit_expr, expr);
}
- AssocItemKind::Method(ref sig, None) => {
+ AssocItemKind::Fn(ref sig, None) => {
visitor.visit_fn_header(&sig.header);
walk_fn_decl(visitor, &sig.decl);
}
- AssocItemKind::Method(ref sig, Some(ref body)) => {
+ AssocItemKind::Fn(ref sig, Some(ref body)) => {
visitor.visit_fn(FnKind::Method(item.ident, sig, &item.vis, body),
&sig.decl, item.span, item.id);
}
vis: respan(trait_lo_sp, ast::VisibilityKind::Inherited),
defaultness: ast::Defaultness::Final,
ident: method_ident,
- kind: ast::AssocItemKind::Method(sig, Some(body_block)),
+ kind: ast::AssocItemKind::Fn(sig, Some(body_block)),
tokens: None,
}
}