diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-04-17 21:55:17 +0300 |
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2020-04-24 13:44:07 -0500 |
| commit | 95b3c427d4cf740ebb3602c04dc5717aeb2ea4ee (patch) | |
| tree | ad677eab8a90049dcde01b6d27f41bd6ec84d525 /src/librustdoc | |
| parent | d1db782dffc085cc24a9024b31d6b83862b02d8a (diff) | |
Remove `Option` from the return type of `def_kind`.
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 18 |
3 files changed, 8 insertions, 14 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 6208c147101..cd098936ed6 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -278,7 +278,7 @@ fn build_type_alias_type(cx: &DocContext<'_>, did: DefId) -> Option<clean::Type> } pub fn build_ty(cx: &DocContext, did: DefId) -> Option<clean::Type> { - match cx.tcx.def_kind(did)? { + match cx.tcx.def_kind(did) { DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::Const | DefKind::Static => { Some(cx.tcx.type_of(did).clean(cx)) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 4d03bb21cb3..9849000e91c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2134,7 +2134,7 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> { let for_ = self.for_.clean(cx); let type_alias = for_.def_id().and_then(|did| match cx.tcx.def_kind(did) { - Some(DefKind::TyAlias) => Some(cx.tcx.type_of(did).clean(cx)), + DefKind::TyAlias => Some(cx.tcx.type_of(did).clean(cx)), _ => None, }); let make_item = |trait_: Option<Type>, for_: Type, items: Vec<Item>| Item { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index ec5ac48ffe4..c4e4802db6c 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -209,7 +209,7 @@ pub fn get_real_types( res.extend(adds); } else if !ty.is_full_generic() { if let Some(kind) = - ty.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) + ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((ty, kind)); } @@ -226,9 +226,7 @@ pub fn get_real_types( if !adds.is_empty() { res.extend(adds); } else if !ty.is_full_generic() { - if let Some(kind) = - ty.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) - { + if let Some(kind) = ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((ty.clone(), kind)); } } @@ -236,7 +234,7 @@ pub fn get_real_types( } } } else { - if let Some(kind) = arg.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) { + if let Some(kind) = arg.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((arg.clone(), kind)); } if let Some(gens) = arg.generics() { @@ -246,9 +244,7 @@ pub fn get_real_types( if !adds.is_empty() { res.extend(adds); } - } else if let Some(kind) = - gen.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) - { + } else if let Some(kind) = gen.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { res.insert((gen.clone(), kind)); } } @@ -275,7 +271,7 @@ pub fn get_all_types( if !args.is_empty() { all_types.extend(args); } else { - if let Some(kind) = arg.type_.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) { + if let Some(kind) = arg.type_.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { all_types.insert((arg.type_.clone(), kind)); } } @@ -285,9 +281,7 @@ pub fn get_all_types( FnRetTy::Return(ref return_type) => { let mut ret = get_real_types(generics, &return_type, cx, 0); if ret.is_empty() { - if let Some(kind) = - return_type.def_id().and_then(|did| cx.tcx.def_kind(did).clean(cx)) - { + if let Some(kind) = return_type.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { ret.insert((return_type.clone(), kind)); } } |
