diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-03-29 12:09:42 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2022-03-29 12:09:42 +0200 |
| commit | 8071332d833073fca42ee128d25f49ee140229eb (patch) | |
| tree | 740241175ee3906deb3f4b41585bcc6ac90e6bec /src | |
| parent | fd48ea02af40768f4ee9a3656c6a4c1d10e381f3 (diff) | |
| download | rust-8071332d833073fca42ee128d25f49ee140229eb.tar.gz rust-8071332d833073fca42ee128d25f49ee140229eb.zip | |
Merge ItemKind::TyMethodItem branch with ItemKind::FunctionItem and ItemKind::MethodItem in fn_header function
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index fa8f658ca1d..957faec30e1 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -646,6 +646,20 @@ impl Item { /// Returns a `FnHeader` if `self` is a function item, otherwise returns `None`. crate fn fn_header(&self, tcx: TyCtxt<'_>) -> Option<hir::FnHeader> { + fn build_fn_header( + def_id: DefId, + tcx: TyCtxt<'_>, + asyncness: hir::IsAsync, + ) -> hir::FnHeader { + let sig = tcx.fn_sig(def_id); + let constness = + if tcx.is_const_fn(def_id) && is_unstable_const_fn(tcx, def_id).is_none() { + hir::Constness::Const + } else { + hir::Constness::NotConst + }; + hir::FnHeader { unsafety: sig.unsafety(), abi: sig.abi(), constness, asyncness } + } let header = match *self.kind { ItemKind::ForeignFunctionItem(_) => { let abi = tcx.fn_sig(self.def_id.as_def_id().unwrap()).abi(); @@ -662,24 +676,10 @@ impl Item { } ItemKind::FunctionItem(_) | ItemKind::MethodItem(_, _) => { let def_id = self.def_id.as_def_id().unwrap(); - let sig = tcx.fn_sig(def_id); - let constness = - if tcx.is_const_fn(def_id) && is_unstable_const_fn(tcx, def_id).is_none() { - hir::Constness::Const - } else { - hir::Constness::NotConst - }; - let asyncness = tcx.asyncness(def_id); - hir::FnHeader { unsafety: sig.unsafety(), abi: sig.abi(), constness, asyncness } + build_fn_header(def_id, tcx, tcx.asyncness(def_id)) } ItemKind::TyMethodItem(_) => { - let sig = tcx.fn_sig(self.def_id.as_def_id().unwrap()); - hir::FnHeader { - unsafety: sig.unsafety(), - abi: sig.abi(), - constness: hir::Constness::NotConst, - asyncness: hir::IsAsync::NotAsync, - } + build_fn_header(self.def_id.as_def_id().unwrap(), tcx, hir::IsAsync::NotAsync) } _ => return None, }; |
