hir::ItemKind::Fn: use hir::MethodSig
This commit is contained in:
parent
c34472b770
commit
30d7279628
16 changed files with 77 additions and 81 deletions
|
@ -481,13 +481,13 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||||
visitor.visit_ty(typ);
|
visitor.visit_ty(typ);
|
||||||
visitor.visit_nested_body(body);
|
visitor.visit_nested_body(body);
|
||||||
}
|
}
|
||||||
ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
|
ItemKind::Fn(ref sig, ref generics, body_id) => {
|
||||||
visitor.visit_fn(FnKind::ItemFn(item.ident,
|
visitor.visit_fn(FnKind::ItemFn(item.ident,
|
||||||
generics,
|
generics,
|
||||||
header,
|
sig.header,
|
||||||
&item.vis,
|
&item.vis,
|
||||||
&item.attrs),
|
&item.attrs),
|
||||||
declaration,
|
&sig.decl,
|
||||||
body_id,
|
body_id,
|
||||||
item.span,
|
item.span,
|
||||||
item.hir_id)
|
item.hir_id)
|
||||||
|
|
|
@ -317,7 +317,7 @@ impl LoweringContext<'_> {
|
||||||
// declaration (decl), not the return types.
|
// declaration (decl), not the return types.
|
||||||
let body_id = this.lower_maybe_async_body(&decl, header.asyncness.node, body);
|
let body_id = this.lower_maybe_async_body(&decl, header.asyncness.node, body);
|
||||||
|
|
||||||
let (generics, fn_decl) = this.add_in_band_defs(
|
let (generics, decl) = this.add_in_band_defs(
|
||||||
generics,
|
generics,
|
||||||
fn_def_id,
|
fn_def_id,
|
||||||
AnonymousLifetimeMode::PassThrough,
|
AnonymousLifetimeMode::PassThrough,
|
||||||
|
@ -328,13 +328,8 @@ 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) };
|
||||||
hir::ItemKind::Fn(
|
hir::ItemKind::Fn(sig, generics, body_id)
|
||||||
fn_decl,
|
|
||||||
this.lower_fn_header(header),
|
|
||||||
generics,
|
|
||||||
body_id,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)),
|
ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)),
|
||||||
|
|
|
@ -219,16 +219,16 @@ impl<'a> FnLikeNode<'a> {
|
||||||
{
|
{
|
||||||
match self.node {
|
match self.node {
|
||||||
map::Node::Item(i) => match i.kind {
|
map::Node::Item(i) => match i.kind {
|
||||||
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
|
ast::ItemKind::Fn(ref sig, ref generics, block) =>
|
||||||
item_fn(ItemFnParts {
|
item_fn(ItemFnParts {
|
||||||
id: i.hir_id,
|
id: i.hir_id,
|
||||||
ident: i.ident,
|
ident: i.ident,
|
||||||
decl: &decl,
|
decl: &sig.decl,
|
||||||
body: block,
|
body: block,
|
||||||
vis: &i.vis,
|
vis: &i.vis,
|
||||||
span: i.span,
|
span: i.span,
|
||||||
attrs: &i.attrs,
|
attrs: &i.attrs,
|
||||||
header,
|
header: sig.header,
|
||||||
generics,
|
generics,
|
||||||
}),
|
}),
|
||||||
_ => bug!("item FnLikeNode that is not fn-like"),
|
_ => bug!("item FnLikeNode that is not fn-like"),
|
||||||
|
|
|
@ -49,21 +49,21 @@ impl<'hir> Entry<'hir> {
|
||||||
match self.node {
|
match self.node {
|
||||||
Node::Item(ref item) => {
|
Node::Item(ref item) => {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ItemKind::Fn(ref fn_decl, _, _, _) => Some(fn_decl),
|
ItemKind::Fn(ref sig, _, _) => Some(&sig.decl),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::TraitItem(ref item) => {
|
Node::TraitItem(ref item) => {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
TraitItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::ImplItem(ref item) => {
|
Node::ImplItem(ref item) => {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
ImplItemKind::Method(ref sig, _) => Some(&sig.decl),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ impl<'hir> Entry<'hir> {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ItemKind::Const(_, body) |
|
ItemKind::Const(_, body) |
|
||||||
ItemKind::Static(.., body) |
|
ItemKind::Static(.., body) |
|
||||||
ItemKind::Fn(_, _, _, body) => Some(body),
|
ItemKind::Fn(.., body) => Some(body),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -605,7 +605,7 @@ impl<'hir> Map<'hir> {
|
||||||
Node::TraitItem(ref trait_item) => Some(&trait_item.generics),
|
Node::TraitItem(ref trait_item) => Some(&trait_item.generics),
|
||||||
Node::Item(ref item) => {
|
Node::Item(ref item) => {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ItemKind::Fn(_, _, ref generics, _) |
|
ItemKind::Fn(_, ref generics, _) |
|
||||||
ItemKind::TyAlias(_, ref generics) |
|
ItemKind::TyAlias(_, ref generics) |
|
||||||
ItemKind::Enum(_, ref generics) |
|
ItemKind::Enum(_, ref generics) |
|
||||||
ItemKind::Struct(_, ref generics) |
|
ItemKind::Struct(_, ref generics) |
|
||||||
|
@ -702,9 +702,9 @@ impl<'hir> Map<'hir> {
|
||||||
..
|
..
|
||||||
}) => true,
|
}) => true,
|
||||||
Node::Item(&Item {
|
Node::Item(&Item {
|
||||||
kind: ItemKind::Fn(_, header, ..),
|
kind: ItemKind::Fn(ref sig, ..),
|
||||||
..
|
..
|
||||||
}) => header.constness == Constness::Const,
|
}) => sig.header.constness == Constness::Const,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2534,7 +2534,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(P<FnDecl>, FnHeader, Generics, BodyId),
|
Fn(MethodSig, Generics, BodyId),
|
||||||
/// A module.
|
/// A module.
|
||||||
Mod(Mod),
|
Mod(Mod),
|
||||||
/// An external module, e.g. `extern { .. }`.
|
/// An external module, e.g. `extern { .. }`.
|
||||||
|
@ -2599,7 +2599,7 @@ impl ItemKind {
|
||||||
|
|
||||||
pub fn generics(&self) -> Option<&Generics> {
|
pub fn generics(&self) -> Option<&Generics> {
|
||||||
Some(match *self {
|
Some(match *self {
|
||||||
ItemKind::Fn(_, _, ref generics, _) |
|
ItemKind::Fn(_, ref generics, _) |
|
||||||
ItemKind::TyAlias(_, ref generics) |
|
ItemKind::TyAlias(_, ref generics) |
|
||||||
ItemKind::OpaqueTy(OpaqueTy { ref generics, impl_trait_fn: None, .. }) |
|
ItemKind::OpaqueTy(OpaqueTy { ref generics, impl_trait_fn: None, .. }) |
|
||||||
ItemKind::Enum(_, ref generics) |
|
ItemKind::Enum(_, ref generics) |
|
||||||
|
|
|
@ -533,10 +533,10 @@ impl<'a> State<'a> {
|
||||||
self.s.word(";");
|
self.s.word(";");
|
||||||
self.end(); // end the outer cbox
|
self.end(); // end the outer cbox
|
||||||
}
|
}
|
||||||
hir::ItemKind::Fn(ref decl, header, ref param_names, body) => {
|
hir::ItemKind::Fn(ref sig, ref param_names, body) => {
|
||||||
self.head("");
|
self.head("");
|
||||||
self.print_fn(decl,
|
self.print_fn(&sig.decl,
|
||||||
header,
|
sig.header,
|
||||||
Some(item.ident.name),
|
Some(item.ident.name),
|
||||||
param_names,
|
param_names,
|
||||||
&item.vis,
|
&item.vis,
|
||||||
|
|
|
@ -31,10 +31,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
|
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
|
||||||
let fndecl = match self.tcx().hir().get(hir_id) {
|
let fndecl = match self.tcx().hir().get(hir_id) {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
kind: hir::ItemKind::Fn(ref fndecl, ..),
|
kind: hir::ItemKind::Fn(ref m, ..),
|
||||||
..
|
..
|
||||||
}) => &fndecl,
|
})
|
||||||
Node::TraitItem(&hir::TraitItem {
|
| Node::TraitItem(&hir::TraitItem {
|
||||||
kind: hir::TraitItemKind::Method(ref m, ..),
|
kind: hir::TraitItemKind::Method(ref m, ..),
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
|
||||||
}
|
}
|
||||||
|
|
||||||
match item.kind {
|
match item.kind {
|
||||||
hir::ItemKind::Fn(_, header, ..) if header.is_const() => {
|
hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
hir::ItemKind::Impl(..) |
|
hir::ItemKind::Impl(..) |
|
||||||
|
@ -225,8 +225,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||||
// If we are building an executable, only explicitly extern
|
// If we are building an executable, only explicitly extern
|
||||||
// types need to be exported.
|
// types need to be exported.
|
||||||
if let Node::Item(item) = *node {
|
if let Node::Item(item) = *node {
|
||||||
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.kind {
|
let reachable = if let hir::ItemKind::Fn(ref sig, ..) = item.kind {
|
||||||
header.abi != Abi::Rust
|
sig.header.abi != Abi::Rust
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
|
@ -460,8 +460,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
hir::ItemKind::Fn(ref decl, _, ref generics, _) => {
|
hir::ItemKind::Fn(ref sig, ref generics, _) => {
|
||||||
self.visit_early_late(None, decl, generics, |this| {
|
self.visit_early_late(None, &sig.decl, generics, |this| {
|
||||||
intravisit::walk_item(this, item);
|
intravisit::walk_item(this, item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1524,8 +1524,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
{
|
{
|
||||||
match parent {
|
match parent {
|
||||||
Node::Item(item) => {
|
Node::Item(item) => {
|
||||||
if let hir::ItemKind::Fn(decl, _, _, _) = &item.kind {
|
if let hir::ItemKind::Fn(sig, _, _) = &item.kind {
|
||||||
find_arg_use_span(&decl.inputs);
|
find_arg_use_span(&sig.decl.inputs);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Node::ImplItem(impl_item) => {
|
Node::ImplItem(impl_item) => {
|
||||||
|
|
|
@ -383,9 +383,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
let hir = &self.tcx.hir();
|
let hir = &self.tcx.hir();
|
||||||
let node = hir.find(hir_id)?;
|
let node = hir.find(hir_id)?;
|
||||||
if let hir::Node::Item(
|
if let hir::Node::Item(
|
||||||
hir::Item{kind: hir::ItemKind::Fn(_ ,fn_header ,_ , body_id), .. }) = &node {
|
hir::Item{kind: hir::ItemKind::Fn(sig, _, body_id), .. }) = &node {
|
||||||
self.describe_generator(*body_id).or_else(||
|
self.describe_generator(*body_id).or_else(||
|
||||||
Some(if let hir::FnHeader{ asyncness: hir::IsAsync::Async, .. } = fn_header {
|
Some(if let hir::FnHeader{ asyncness: hir::IsAsync::Async, .. } = sig.header {
|
||||||
"an async function"
|
"an async function"
|
||||||
} else {
|
} else {
|
||||||
"a function"
|
"a function"
|
||||||
|
@ -1081,7 +1081,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::Node::Item(hir::Item {
|
hir::Node::Item(hir::Item {
|
||||||
kind: hir::ItemKind::Fn(_, _, generics, _), ..
|
kind: hir::ItemKind::Fn(_, generics, _), ..
|
||||||
}) |
|
}) |
|
||||||
hir::Node::TraitItem(hir::TraitItem {
|
hir::Node::TraitItem(hir::TraitItem {
|
||||||
generics,
|
generics,
|
||||||
|
@ -1112,7 +1112,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
kind: hir::ItemKind::Impl(_, _, _, generics, ..), span, ..
|
kind: hir::ItemKind::Impl(_, _, _, generics, ..), span, ..
|
||||||
}) |
|
}) |
|
||||||
hir::Node::Item(hir::Item {
|
hir::Node::Item(hir::Item {
|
||||||
kind: hir::ItemKind::Fn(_, _, generics, _), span, ..
|
kind: hir::ItemKind::Fn(_, generics, _), span, ..
|
||||||
}) |
|
}) |
|
||||||
hir::Node::Item(hir::Item {
|
hir::Node::Item(hir::Item {
|
||||||
kind: hir::ItemKind::TyAlias(_, generics), span, ..
|
kind: hir::ItemKind::TyAlias(_, generics), span, ..
|
||||||
|
@ -1436,12 +1436,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||||
let node = hir.find(parent_node);
|
let node = hir.find(parent_node);
|
||||||
if let Some(hir::Node::Item(hir::Item {
|
if let Some(hir::Node::Item(hir::Item {
|
||||||
kind: hir::ItemKind::Fn(decl, _, _, body_id),
|
kind: hir::ItemKind::Fn(sig, _, body_id),
|
||||||
..
|
..
|
||||||
})) = node {
|
})) = node {
|
||||||
let body = hir.body(*body_id);
|
let body = hir.body(*body_id);
|
||||||
if let hir::ExprKind::Block(blk, _) = &body.value.kind {
|
if let hir::ExprKind::Block(blk, _) = &body.value.kind {
|
||||||
if decl.output.span().overlaps(span) && blk.expr.is_none() &&
|
if sig.decl.output.span().overlaps(span) && blk.expr.is_none() &&
|
||||||
"()" == &trait_ref.self_ty().to_string()
|
"()" == &trait_ref.self_ty().to_string()
|
||||||
{
|
{
|
||||||
// FIXME(estebank): When encountering a method with a trait
|
// FIXME(estebank): When encountering a method with a trait
|
||||||
|
@ -1493,20 +1493,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
span,
|
span,
|
||||||
kind: hir::ItemKind::Fn(ref decl, ..),
|
kind: hir::ItemKind::Fn(ref sig, ..),
|
||||||
..
|
..
|
||||||
}) |
|
}) |
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
span,
|
span,
|
||||||
kind: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
kind: hir::ImplItemKind::Method(ref sig, _),
|
||||||
..
|
..
|
||||||
}) |
|
}) |
|
||||||
Node::TraitItem(&hir::TraitItem {
|
Node::TraitItem(&hir::TraitItem {
|
||||||
span,
|
span,
|
||||||
kind: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
kind: hir::TraitItemKind::Method(ref sig, _),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
(self.tcx.sess.source_map().def_span(span), decl.inputs.iter()
|
(self.tcx.sess.source_map().def_span(span), sig.decl.inputs.iter()
|
||||||
.map(|arg| match arg.clone().kind {
|
.map(|arg| match arg.clone().kind {
|
||||||
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
|
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
|
||||||
Some(arg.span),
|
Some(arg.span),
|
||||||
|
@ -2040,11 +2040,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
.and_then(|parent_did| self.tcx.hir().get_if_local(parent_did));
|
.and_then(|parent_did| self.tcx.hir().get_if_local(parent_did));
|
||||||
debug!("note_obligation_cause_for_async_await: parent_node={:?}", parent_node);
|
debug!("note_obligation_cause_for_async_await: parent_node={:?}", parent_node);
|
||||||
if let Some(hir::Node::Item(hir::Item {
|
if let Some(hir::Node::Item(hir::Item {
|
||||||
kind: hir::ItemKind::Fn(_, header, _, _),
|
kind: hir::ItemKind::Fn(sig, _, _),
|
||||||
..
|
..
|
||||||
})) = parent_node {
|
})) = parent_node {
|
||||||
debug!("note_obligation_cause_for_async_await: header={:?}", header);
|
debug!("note_obligation_cause_for_async_await: header={:?}", sig.header);
|
||||||
if header.asyncness != hir::IsAsync::Async {
|
if sig.header.asyncness != hir::IsAsync::Async {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1095,10 +1095,10 @@ impl EncodeContext<'tcx> {
|
||||||
self.encode_rendered_const_for_body(body_id)
|
self.encode_rendered_const_for_body(body_id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
hir::ItemKind::Fn(_, header, .., body) => {
|
hir::ItemKind::Fn(ref sig, .., body) => {
|
||||||
let data = FnData {
|
let data = FnData {
|
||||||
asyncness: header.asyncness,
|
asyncness: sig.header.asyncness,
|
||||||
constness: header.constness,
|
constness: sig.header.constness,
|
||||||
param_names: self.encode_fn_param_names_for_body(body),
|
param_names: self.encode_fn_param_names_for_body(body),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1284,14 +1284,14 @@ impl EncodeContext<'tcx> {
|
||||||
|
|
||||||
let mir = match item.kind {
|
let mir = match item.kind {
|
||||||
hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => true,
|
hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => true,
|
||||||
hir::ItemKind::Fn(_, header, ..) => {
|
hir::ItemKind::Fn(ref sig, ..) => {
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let needs_inline =
|
let needs_inline =
|
||||||
(generics.requires_monomorphization(tcx) ||
|
(generics.requires_monomorphization(tcx) ||
|
||||||
tcx.codegen_fn_attrs(def_id).requests_inline()) &&
|
tcx.codegen_fn_attrs(def_id).requests_inline()) &&
|
||||||
!self.metadata_output_only();
|
!self.metadata_output_only();
|
||||||
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
||||||
needs_inline || header.constness == hir::Constness::Const || always_encode_mir
|
needs_inline || sig.header.constness == hir::Constness::Const || always_encode_mir
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,12 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||||
// Figure out what primary body this item has.
|
// Figure out what primary body this item has.
|
||||||
let (body_id, return_ty_span) = match tcx.hir().get(id) {
|
let (body_id, return_ty_span) = match tcx.hir().get(id) {
|
||||||
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
||||||
| Node::Item(hir::Item { kind: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
| Node::Item(
|
||||||
|
hir::Item {
|
||||||
|
kind: hir::ItemKind::Fn(hir::MethodSig { 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::MethodSig { decl, .. }, body_id),
|
||||||
|
|
|
@ -576,10 +576,10 @@ fn is_enclosed(
|
||||||
if used_unsafe.contains(&parent_id) {
|
if used_unsafe.contains(&parent_id) {
|
||||||
Some(("block".to_string(), parent_id))
|
Some(("block".to_string(), parent_id))
|
||||||
} else if let Some(Node::Item(&hir::Item {
|
} else if let Some(Node::Item(&hir::Item {
|
||||||
kind: hir::ItemKind::Fn(_, header, _, _),
|
kind: hir::ItemKind::Fn(ref sig, _, _),
|
||||||
..
|
..
|
||||||
})) = tcx.hir().find(parent_id) {
|
})) = tcx.hir().find(parent_id) {
|
||||||
match header.unsafety {
|
match sig.header.unsafety {
|
||||||
hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)),
|
hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)),
|
||||||
hir::Unsafety::Normal => None,
|
hir::Unsafety::Normal => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -815,8 +815,8 @@ fn primary_body_of(
|
||||||
hir::ItemKind::Const(ref ty, body) |
|
hir::ItemKind::Const(ref ty, body) |
|
||||||
hir::ItemKind::Static(ref ty, _, body) =>
|
hir::ItemKind::Static(ref ty, _, body) =>
|
||||||
Some((body, Some(ty), None, None)),
|
Some((body, Some(ty), None, None)),
|
||||||
hir::ItemKind::Fn(ref decl, ref header, .., body) =>
|
hir::ItemKind::Fn(ref sig, .., body) =>
|
||||||
Some((body, None, Some(header), Some(decl))),
|
Some((body, None, Some(&sig.header), Some(&sig.decl))),
|
||||||
_ =>
|
_ =>
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1297,7 @@ fn check_fn<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
||||||
if let ItemKind::Fn(_, _, ref generics, _) = item.kind {
|
if let ItemKind::Fn(_, ref generics, _) = item.kind {
|
||||||
if !generics.params.is_empty() {
|
if !generics.params.is_empty() {
|
||||||
fcx.tcx.sess.span_err(
|
fcx.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
|
@ -1345,7 +1345,7 @@ fn check_fn<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
if let Node::Item(item) = fcx.tcx.hir().get(fn_id) {
|
||||||
if let ItemKind::Fn(_, _, ref generics, _) = item.kind {
|
if let ItemKind::Fn(_, ref generics, _) = item.kind {
|
||||||
if !generics.params.is_empty() {
|
if !generics.params.is_empty() {
|
||||||
fcx.tcx.sess.span_err(
|
fcx.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
|
@ -4278,7 +4278,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let node = self.tcx.hir().get(self.tcx.hir().get_parent_item(id));
|
let node = self.tcx.hir().get(self.tcx.hir().get_parent_item(id));
|
||||||
match node {
|
match node {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
kind: hir::ItemKind::Fn(_, _, _, body_id), ..
|
kind: hir::ItemKind::Fn(_, _, body_id), ..
|
||||||
}) |
|
}) |
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
kind: hir::ImplItemKind::Method(_, body_id), ..
|
kind: hir::ImplItemKind::Method(_, body_id), ..
|
||||||
|
@ -4303,23 +4303,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
fn get_node_fn_decl(&self, node: Node<'tcx>) -> Option<(&'tcx hir::FnDecl, ast::Ident, bool)> {
|
fn get_node_fn_decl(&self, node: Node<'tcx>) -> Option<(&'tcx hir::FnDecl, ast::Ident, bool)> {
|
||||||
match node {
|
match node {
|
||||||
Node::Item(&hir::Item {
|
Node::Item(&hir::Item {
|
||||||
ident, kind: hir::ItemKind::Fn(ref decl, ..), ..
|
ident, kind: hir::ItemKind::Fn(ref sig, ..), ..
|
||||||
}) => {
|
}) => {
|
||||||
// This is less than ideal, it will not suggest a return type span on any
|
// This is less than ideal, it will not suggest a return type span on any
|
||||||
// method called `main`, regardless of whether it is actually the entry point,
|
// method called `main`, regardless of whether it is actually the entry point,
|
||||||
// but it will still present it as the reason for the expected type.
|
// but it will still present it as the reason for the expected type.
|
||||||
Some((decl, ident, ident.name != sym::main))
|
Some((&sig.decl, ident, ident.name != sym::main))
|
||||||
}
|
}
|
||||||
Node::TraitItem(&hir::TraitItem {
|
Node::TraitItem(&hir::TraitItem {
|
||||||
ident, kind: hir::TraitItemKind::Method(hir::MethodSig {
|
ident, kind: hir::TraitItemKind::Method(ref sig, ..), ..
|
||||||
ref decl, ..
|
}) => Some((&sig.decl, ident, true)),
|
||||||
}, ..), ..
|
|
||||||
}) => Some((decl, ident, true)),
|
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
ident, kind: hir::ImplItemKind::Method(hir::MethodSig {
|
ident, kind: hir::ImplItemKind::Method(ref sig, ..), ..
|
||||||
ref decl, ..
|
}) => Some((&sig.decl, ident, false)),
|
||||||
}, ..), ..
|
|
||||||
}) => Some((decl, ident, false)),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -885,8 +885,8 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
Node::Item(item) => match item.kind {
|
Node::Item(item) => match item.kind {
|
||||||
hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => {
|
hir::ItemKind::Fn(ref sig, .., ref generics, _) => {
|
||||||
has_late_bound_regions(tcx, generics, fn_decl)
|
has_late_bound_regions(tcx, generics, &sig.decl)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
|
@ -1779,17 +1779,17 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||||
|
|
||||||
match tcx.hir().get(hir_id) {
|
match tcx.hir().get(hir_id) {
|
||||||
TraitItem(hir::TraitItem {
|
TraitItem(hir::TraitItem {
|
||||||
kind: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)),
|
kind: TraitItemKind::Method(sig, TraitMethod::Provided(_)),
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| ImplItem(hir::ImplItem {
|
| ImplItem(hir::ImplItem {
|
||||||
kind: ImplItemKind::Method(MethodSig { header, decl }, _),
|
kind: ImplItemKind::Method(sig, _),
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| Item(hir::Item {
|
| Item(hir::Item {
|
||||||
kind: ItemKind::Fn(decl, header, _, _),
|
kind: ItemKind::Fn(sig, _, _),
|
||||||
..
|
..
|
||||||
}) => match get_infer_ret_ty(&decl.output) {
|
}) => match get_infer_ret_ty(&sig.decl.output) {
|
||||||
Some(ty) => {
|
Some(ty) => {
|
||||||
let fn_sig = tcx.typeck_tables_of(def_id).liberated_fn_sigs()[hir_id];
|
let fn_sig = tcx.typeck_tables_of(def_id).liberated_fn_sigs()[hir_id];
|
||||||
let mut diag = bad_placeholder_type(tcx, ty.span);
|
let mut diag = bad_placeholder_type(tcx, ty.span);
|
||||||
|
@ -1805,7 +1805,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||||
diag.emit();
|
diag.emit();
|
||||||
ty::Binder::bind(fn_sig)
|
ty::Binder::bind(fn_sig)
|
||||||
},
|
},
|
||||||
None => AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)
|
None => AstConv::ty_of_fn(&icx, sig.header.unsafety, sig.header.abi, &sig.decl)
|
||||||
},
|
},
|
||||||
|
|
||||||
TraitItem(hir::TraitItem {
|
TraitItem(hir::TraitItem {
|
||||||
|
|
|
@ -438,8 +438,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
om.structs.push(self.visit_variant_data(item, ident.name, sd, gen)),
|
om.structs.push(self.visit_variant_data(item, ident.name, sd, gen)),
|
||||||
hir::ItemKind::Union(ref sd, ref gen) =>
|
hir::ItemKind::Union(ref sd, ref gen) =>
|
||||||
om.unions.push(self.visit_union_data(item, ident.name, sd, gen)),
|
om.unions.push(self.visit_union_data(item, ident.name, sd, gen)),
|
||||||
hir::ItemKind::Fn(ref fd, header, ref gen, body) =>
|
hir::ItemKind::Fn(ref sig, ref gen, body) =>
|
||||||
self.visit_fn(om, item, ident.name, &**fd, header, gen, body),
|
self.visit_fn(om, item, ident.name, &sig.decl, sig.header, gen, body),
|
||||||
hir::ItemKind::TyAlias(ref ty, ref gen) => {
|
hir::ItemKind::TyAlias(ref ty, ref gen) => {
|
||||||
let t = Typedef {
|
let t = Typedef {
|
||||||
ty,
|
ty,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue