diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-05-29 10:03:40 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-05-29 10:04:08 +0000 |
| commit | a34c26e7ecfbfe3f4fd5fbd4868a0cba5676e6a5 (patch) | |
| tree | ed274505213e5fb6ed3320bd9a5213dd9fca4616 /src/librustdoc/clean | |
| parent | ceb45d55190eb00d30b8762bc4c34cf71c53b637 (diff) | |
| download | rust-a34c26e7ecfbfe3f4fd5fbd4868a0cba5676e6a5.tar.gz rust-a34c26e7ecfbfe3f4fd5fbd4868a0cba5676e6a5.zip | |
Make `body_owned_by` return the body directly.
Almost all callers want this anyway, and now we can use it to also return fed bodies
Diffstat (limited to 'src/librustdoc/clean')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 7490688e36c..711aef34c27 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2133,7 +2133,9 @@ impl Discriminant { /// Will be `None` in the case of cross-crate reexports, and may be /// simplified pub(crate) fn expr(&self, tcx: TyCtxt<'_>) -> Option<String> { - self.expr.map(|body| rendered_const(tcx, body)) + self.expr.map(|body| { + rendered_const(tcx, tcx.hir().body(body), tcx.hir().body_owner_def_id(body)) + }) } pub(crate) fn value(&self, tcx: TyCtxt<'_>, with_underscores: bool) -> String { print_evaluated_const(tcx, self.value, with_underscores, false).unwrap() @@ -2419,7 +2421,7 @@ impl ConstantKind { ConstantKind::TyConst { ref expr } => expr.to_string(), ConstantKind::Extern { def_id } => print_inlined_const(tcx, def_id), ConstantKind::Local { body, .. } | ConstantKind::Anonymous { body } => { - rendered_const(tcx, body) + rendered_const(tcx, tcx.hir().body(body), tcx.hir().body_owner_def_id(body)) } } } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index aa923cc6117..803650beaf6 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -342,7 +342,7 @@ pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String { match n.kind() { ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args: _ }) => { let s = if let Some(def) = def.as_local() { - rendered_const(cx.tcx, cx.tcx.hir().body_owned_by(def)) + rendered_const(cx.tcx, &cx.tcx.hir().body_owned_by(def), def) } else { inline::print_inlined_const(cx.tcx, def) }; |
