Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hir::MethodSig -> hir::FnSig
  • Loading branch information
Centril committed Nov 8, 2019
commit 27511b22dfb08c98e53a8f672b2789d4de872f55
2 changes: 1 addition & 1 deletion src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum FnKind<'a> {
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),

/// `fn foo(&self)`
Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a [Attribute]),

/// `|x, y| {}`
Closure(&'a [Attribute]),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl LoweringContext<'_> {
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)
})
}
Expand Down Expand Up @@ -1259,7 +1259,7 @@ impl LoweringContext<'_> {
fn_def_id: DefId,
impl_trait_return_allow: bool,
is_async: Option<NodeId>,
) -> (hir::Generics, hir::MethodSig) {
) -> (hir::Generics, hir::FnSig) {
let header = self.lower_fn_header(sig.header);
let (generics, decl) = self.add_in_band_defs(
generics,
Expand All @@ -1272,7 +1272,7 @@ impl LoweringContext<'_> {
is_async,
),
);
(generics, hir::MethodSig { header, decl })
(generics, hir::FnSig { header, decl })
}

fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/hir/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,25 @@ impl<'a> FnLikeNode<'a> {

pub fn body(self) -> ast::BodyId {
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)
}

pub fn decl(self) -> &'a FnDecl {
self.handle(|i: ItemFnParts<'a>| &*i.decl,
|_, _, sig: &'a ast::MethodSig, _, _, _, _| &sig.decl,
|_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
|c: ClosureParts<'a>| c.decl)
}

pub fn span(self) -> Span {
self.handle(|i: ItemFnParts<'_>| i.span,
|_, _, _: &'a ast::MethodSig, _, _, span, _| span,
|_, _, _: &'a ast::FnSig, _, _, span, _| span,
|c: ClosureParts<'_>| c.span)
}

pub fn id(self) -> ast::HirId {
self.handle(|i: ItemFnParts<'_>| i.id,
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
|id, _, _: &'a ast::FnSig, _, _, _, _| id,
|c: ClosureParts<'_>| c.id)
}

Expand All @@ -199,7 +199,7 @@ impl<'a> FnLikeNode<'a> {
let closure = |c: ClosureParts<'a>| {
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)
};
self.handle(item, method, closure)
Expand All @@ -209,7 +209,7 @@ impl<'a> FnLikeNode<'a> {
I: FnOnce(ItemFnParts<'a>) -> A,
M: FnOnce(ast::HirId,
Ident,
&'a ast::MethodSig,
&'a ast::FnSig,
Option<&'a ast::Visibility>,
ast::BodyId,
Span,
Expand Down
11 changes: 6 additions & 5 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1876,9 +1876,10 @@ pub struct MutTy {
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)]
pub struct MethodSig {
pub struct FnSig {
pub header: FnHeader,
pub decl: P<FnDecl>,
}
Expand Down Expand Up @@ -1921,7 +1922,7 @@ pub enum TraitItemKind {
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
Const(P<Ty>, Option<BodyId>),
/// A method with an optional body.
Method(MethodSig, TraitMethod),
Method(FnSig, TraitMethod),
/// An associated type with (possibly empty) bounds and optional concrete
/// type.
Type(GenericBounds, Option<P<Ty>>),
Expand Down Expand Up @@ -1955,7 +1956,7 @@ pub enum ImplItemKind {
/// of the expression.
Const(P<Ty>, BodyId),
/// A method implementation with the given signature and body.
Method(MethodSig, BodyId),
Method(FnSig, BodyId),
/// An associated type.
TyAlias(P<Ty>),
/// An associated `type = impl Trait`.
Expand Down Expand Up @@ -2534,7 +2535,7 @@ pub enum ItemKind {
/// A `const` item.
Const(P<Ty>, BodyId),
/// A function declaration.
Fn(MethodSig, Generics, BodyId),
Fn(FnSig, Generics, BodyId),
/// A module.
Mod(Mod),
/// An external module, e.g. `extern { .. }`.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ impl<'a> State<'a> {
}
pub fn print_method_sig(&mut self,
ident: ast::Ident,
m: &hir::MethodSig,
m: &hir::FnSig,
generics: &hir::Generics,
vis: &hir::Visibility,
arg_names: &[ast::Ident],
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::Item(
hir::Item {
kind: hir::ItemKind::Fn(hir::MethodSig { decl, .. }, _, body_id),
kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id),
..
}
)
| Node::ImplItem(
hir::ImplItem {
kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
kind: hir::ImplItemKind::Method(hir::FnSig { decl, .. }, body_id),
..
}
)
| Node::TraitItem(
hir::TraitItem {
kind: hir::TraitItemKind::Method(
hir::MethodSig { decl, .. },
hir::FnSig { decl, .. },
hir::TraitMethod::Provided(body_id),
),
..
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {

fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
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);
self.push_if_root(def_id);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn check_associated_item(
tcx: TyCtxt<'_>,
item_id: hir::HirId,
span: Span,
sig_if_method: Option<&hir::MethodSig>,
sig_if_method: Option<&hir::FnSig>,
) {
debug!("check_associated_item: {:?}", item_id);

Expand Down Expand Up @@ -783,7 +783,7 @@ const HELP_FOR_SELF_TYPE: &str =

fn check_method_receiver<'fcx, 'tcx>(
fcx: &FnCtxt<'fcx, 'tcx>,
method_sig: &hir::MethodSig,
fn_sig: &hir::FnSig,
method: &ty::AssocItem,
self_ty: Ty<'tcx>,
) {
Expand All @@ -794,7 +794,7 @@ fn check_method_receiver<'fcx, 'tcx>(
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.normalize_associated_types_in(span, &sig);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
},

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)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ pub struct Method {
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>) {
fn clean(&self, cx: &DocContext<'_>) -> Method {
let (generics, decl) = enter_impl_trait(cx, || {
Expand Down