hir::MethodSig -> hir::FnSig
This commit is contained in:
parent
30d7279628
commit
27511b22df
10 changed files with 26 additions and 25 deletions
|
@ -45,7 +45,7 @@ pub enum FnKind<'a> {
|
||||||
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
|
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
|
||||||
|
|
||||||
/// `fn foo(&self)`
|
/// `fn foo(&self)`
|
||||||
Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
|
Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a [Attribute]),
|
||||||
|
|
||||||
/// `|x, y| {}`
|
/// `|x, y| {}`
|
||||||
Closure(&'a [Attribute]),
|
Closure(&'a [Attribute]),
|
||||||
|
|
|
@ -328,7 +328,7 @@ impl LoweringContext<'_> {
|
||||||
header.asyncness.node.opt_return_id()
|
header.asyncness.node.opt_return_id()
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
let sig = hir::MethodSig { decl, header: this.lower_fn_header(header) };
|
let sig = hir::FnSig { decl, header: this.lower_fn_header(header) };
|
||||||
hir::ItemKind::Fn(sig, generics, body_id)
|
hir::ItemKind::Fn(sig, generics, body_id)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1259,7 +1259,7 @@ impl LoweringContext<'_> {
|
||||||
fn_def_id: DefId,
|
fn_def_id: DefId,
|
||||||
impl_trait_return_allow: bool,
|
impl_trait_return_allow: bool,
|
||||||
is_async: Option<NodeId>,
|
is_async: Option<NodeId>,
|
||||||
) -> (hir::Generics, hir::MethodSig) {
|
) -> (hir::Generics, hir::FnSig) {
|
||||||
let header = self.lower_fn_header(sig.header);
|
let header = self.lower_fn_header(sig.header);
|
||||||
let (generics, decl) = self.add_in_band_defs(
|
let (generics, decl) = self.add_in_band_defs(
|
||||||
generics,
|
generics,
|
||||||
|
@ -1272,7 +1272,7 @@ impl LoweringContext<'_> {
|
||||||
is_async,
|
is_async,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
(generics, hir::MethodSig { header, decl })
|
(generics, hir::FnSig { header, decl })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto {
|
fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto {
|
||||||
|
|
|
@ -158,25 +158,25 @@ impl<'a> FnLikeNode<'a> {
|
||||||
|
|
||||||
pub fn body(self) -> ast::BodyId {
|
pub fn body(self) -> ast::BodyId {
|
||||||
self.handle(|i: ItemFnParts<'a>| i.body,
|
self.handle(|i: ItemFnParts<'a>| i.body,
|
||||||
|_, _, _: &'a ast::MethodSig, _, body: ast::BodyId, _, _| body,
|
|_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body,
|
||||||
|c: ClosureParts<'a>| c.body)
|
|c: ClosureParts<'a>| c.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decl(self) -> &'a FnDecl {
|
pub fn decl(self) -> &'a FnDecl {
|
||||||
self.handle(|i: ItemFnParts<'a>| &*i.decl,
|
self.handle(|i: ItemFnParts<'a>| &*i.decl,
|
||||||
|_, _, sig: &'a ast::MethodSig, _, _, _, _| &sig.decl,
|
|_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
|
||||||
|c: ClosureParts<'a>| c.decl)
|
|c: ClosureParts<'a>| c.decl)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn span(self) -> Span {
|
pub fn span(self) -> Span {
|
||||||
self.handle(|i: ItemFnParts<'_>| i.span,
|
self.handle(|i: ItemFnParts<'_>| i.span,
|
||||||
|_, _, _: &'a ast::MethodSig, _, _, span, _| span,
|
|_, _, _: &'a ast::FnSig, _, _, span, _| span,
|
||||||
|c: ClosureParts<'_>| c.span)
|
|c: ClosureParts<'_>| c.span)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(self) -> ast::HirId {
|
pub fn id(self) -> ast::HirId {
|
||||||
self.handle(|i: ItemFnParts<'_>| i.id,
|
self.handle(|i: ItemFnParts<'_>| i.id,
|
||||||
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
|
|id, _, _: &'a ast::FnSig, _, _, _, _| id,
|
||||||
|c: ClosureParts<'_>| c.id)
|
|c: ClosureParts<'_>| c.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ impl<'a> FnLikeNode<'a> {
|
||||||
let closure = |c: ClosureParts<'a>| {
|
let closure = |c: ClosureParts<'a>| {
|
||||||
FnKind::Closure(c.attrs)
|
FnKind::Closure(c.attrs)
|
||||||
};
|
};
|
||||||
let method = |_, ident: Ident, sig: &'a ast::MethodSig, vis, _, _, attrs| {
|
let method = |_, ident: Ident, sig: &'a ast::FnSig, vis, _, _, attrs| {
|
||||||
FnKind::Method(ident, sig, vis, attrs)
|
FnKind::Method(ident, sig, vis, attrs)
|
||||||
};
|
};
|
||||||
self.handle(item, method, closure)
|
self.handle(item, method, closure)
|
||||||
|
@ -209,7 +209,7 @@ impl<'a> FnLikeNode<'a> {
|
||||||
I: FnOnce(ItemFnParts<'a>) -> A,
|
I: FnOnce(ItemFnParts<'a>) -> A,
|
||||||
M: FnOnce(ast::HirId,
|
M: FnOnce(ast::HirId,
|
||||||
Ident,
|
Ident,
|
||||||
&'a ast::MethodSig,
|
&'a ast::FnSig,
|
||||||
Option<&'a ast::Visibility>,
|
Option<&'a ast::Visibility>,
|
||||||
ast::BodyId,
|
ast::BodyId,
|
||||||
Span,
|
Span,
|
||||||
|
|
|
@ -1876,9 +1876,10 @@ pub struct MutTy {
|
||||||
pub mutbl: Mutability,
|
pub mutbl: Mutability,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a method's signature in a trait declaration or implementation.
|
/// Represents a function's signature in a trait declaration,
|
||||||
|
/// trait implementation, or a free function.
|
||||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
pub struct MethodSig {
|
pub struct FnSig {
|
||||||
pub header: FnHeader,
|
pub header: FnHeader,
|
||||||
pub decl: P<FnDecl>,
|
pub decl: P<FnDecl>,
|
||||||
}
|
}
|
||||||
|
@ -1921,7 +1922,7 @@ pub enum TraitItemKind {
|
||||||
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
|
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
|
||||||
Const(P<Ty>, Option<BodyId>),
|
Const(P<Ty>, Option<BodyId>),
|
||||||
/// A method with an optional body.
|
/// A method with an optional body.
|
||||||
Method(MethodSig, TraitMethod),
|
Method(FnSig, TraitMethod),
|
||||||
/// An associated type with (possibly empty) bounds and optional concrete
|
/// An associated type with (possibly empty) bounds and optional concrete
|
||||||
/// type.
|
/// type.
|
||||||
Type(GenericBounds, Option<P<Ty>>),
|
Type(GenericBounds, Option<P<Ty>>),
|
||||||
|
@ -1955,7 +1956,7 @@ pub enum ImplItemKind {
|
||||||
/// of the expression.
|
/// of the expression.
|
||||||
Const(P<Ty>, BodyId),
|
Const(P<Ty>, BodyId),
|
||||||
/// A method implementation with the given signature and body.
|
/// A method implementation with the given signature and body.
|
||||||
Method(MethodSig, BodyId),
|
Method(FnSig, BodyId),
|
||||||
/// An associated type.
|
/// An associated type.
|
||||||
TyAlias(P<Ty>),
|
TyAlias(P<Ty>),
|
||||||
/// An associated `type = impl Trait`.
|
/// An associated `type = impl Trait`.
|
||||||
|
@ -2534,7 +2535,7 @@ pub enum ItemKind {
|
||||||
/// A `const` item.
|
/// A `const` item.
|
||||||
Const(P<Ty>, BodyId),
|
Const(P<Ty>, BodyId),
|
||||||
/// A function declaration.
|
/// A function declaration.
|
||||||
Fn(MethodSig, Generics, BodyId),
|
Fn(FnSig, Generics, BodyId),
|
||||||
/// A module.
|
/// A module.
|
||||||
Mod(Mod),
|
Mod(Mod),
|
||||||
/// An external module, e.g. `extern { .. }`.
|
/// An external module, e.g. `extern { .. }`.
|
||||||
|
|
|
@ -835,7 +835,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
pub fn print_method_sig(&mut self,
|
pub fn print_method_sig(&mut self,
|
||||||
ident: ast::Ident,
|
ident: ast::Ident,
|
||||||
m: &hir::MethodSig,
|
m: &hir::FnSig,
|
||||||
generics: &hir::Generics,
|
generics: &hir::Generics,
|
||||||
vis: &hir::Visibility,
|
vis: &hir::Visibility,
|
||||||
arg_names: &[ast::Ident],
|
arg_names: &[ast::Ident],
|
||||||
|
|
|
@ -32,20 +32,20 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||||
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
||||||
| Node::Item(
|
| Node::Item(
|
||||||
hir::Item {
|
hir::Item {
|
||||||
kind: hir::ItemKind::Fn(hir::MethodSig { decl, .. }, _, body_id),
|
kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id),
|
||||||
..
|
..
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| Node::ImplItem(
|
| Node::ImplItem(
|
||||||
hir::ImplItem {
|
hir::ImplItem {
|
||||||
kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
|
kind: hir::ImplItemKind::Method(hir::FnSig { decl, .. }, body_id),
|
||||||
..
|
..
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| Node::TraitItem(
|
| Node::TraitItem(
|
||||||
hir::TraitItem {
|
hir::TraitItem {
|
||||||
kind: hir::TraitItemKind::Method(
|
kind: hir::TraitItemKind::Method(
|
||||||
hir::MethodSig { decl, .. },
|
hir::FnSig { decl, .. },
|
||||||
hir::TraitMethod::Provided(body_id),
|
hir::TraitMethod::Provided(body_id),
|
||||||
),
|
),
|
||||||
..
|
..
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
||||||
match ii.kind {
|
match ii.kind {
|
||||||
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
|
hir::ImplItemKind::Method(hir::FnSig { .. }, _) => {
|
||||||
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
|
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
|
||||||
self.push_if_root(def_id);
|
self.push_if_root(def_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ fn check_associated_item(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
item_id: hir::HirId,
|
item_id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
sig_if_method: Option<&hir::MethodSig>,
|
sig_if_method: Option<&hir::FnSig>,
|
||||||
) {
|
) {
|
||||||
debug!("check_associated_item: {:?}", item_id);
|
debug!("check_associated_item: {:?}", item_id);
|
||||||
|
|
||||||
|
@ -783,7 +783,7 @@ const HELP_FOR_SELF_TYPE: &str =
|
||||||
|
|
||||||
fn check_method_receiver<'fcx, 'tcx>(
|
fn check_method_receiver<'fcx, 'tcx>(
|
||||||
fcx: &FnCtxt<'fcx, 'tcx>,
|
fcx: &FnCtxt<'fcx, 'tcx>,
|
||||||
method_sig: &hir::MethodSig,
|
fn_sig: &hir::FnSig,
|
||||||
method: &ty::AssocItem,
|
method: &ty::AssocItem,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
) {
|
) {
|
||||||
|
@ -794,7 +794,7 @@ fn check_method_receiver<'fcx, 'tcx>(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let span = method_sig.decl.inputs[0].span;
|
let span = fn_sig.decl.inputs[0].span;
|
||||||
|
|
||||||
let sig = fcx.tcx.fn_sig(method.def_id);
|
let sig = fcx.tcx.fn_sig(method.def_id);
|
||||||
let sig = fcx.normalize_associated_types_in(span, &sig);
|
let sig = fcx.normalize_associated_types_in(span, &sig);
|
||||||
|
|
|
@ -1809,7 +1809,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||||
},
|
},
|
||||||
|
|
||||||
TraitItem(hir::TraitItem {
|
TraitItem(hir::TraitItem {
|
||||||
kind: TraitItemKind::Method(MethodSig { header, decl }, _),
|
kind: TraitItemKind::Method(FnSig { header, decl }, _),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)
|
AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)
|
||||||
|
|
|
@ -1984,7 +1984,7 @@ pub struct Method {
|
||||||
pub ret_types: Vec<Type>,
|
pub ret_types: Vec<Type>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Clean<Method> for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId,
|
impl<'a> Clean<Method> for (&'a hir::FnSig, &'a hir::Generics, hir::BodyId,
|
||||||
Option<hir::Defaultness>) {
|
Option<hir::Defaultness>) {
|
||||||
fn clean(&self, cx: &DocContext<'_>) -> Method {
|
fn clean(&self, cx: &DocContext<'_>) -> Method {
|
||||||
let (generics, decl) = enter_impl_trait(cx, || {
|
let (generics, decl) = enter_impl_trait(cx, || {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue