diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 9e05fa599a7..75174e84a08 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -111,8 +111,6 @@ crate struct SharedContext<'tcx> { crate static_root_path: Option, /// The fs handle we are working with. crate fs: DocFS, - /// The default edition used to parse doctests. - crate edition: Edition, pub(super) codes: ErrorCodes, pub(super) playground: Option, all: RefCell, @@ -141,6 +139,10 @@ impl SharedContext<'_> { crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option { if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() } } + + crate fn edition(&self) -> Edition { + self.tcx.sess.edition() + } } impl<'tcx> Context<'tcx> { @@ -434,7 +436,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { resource_suffix, static_root_path, fs: DocFS::new(sender), - edition: tcx.sess.edition(), codes: ErrorCodes::from(unstable_features.is_nightly_build()), playground, all: RefCell::new(AllTypes::new()), diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index d773f37ad90..6cf4bedadcc 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -530,7 +530,7 @@ fn render_markdown( &links, &mut ids, cx.shared.codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground ) .into_string() @@ -660,7 +660,7 @@ fn short_item_info( ¬e, &mut ids, error_codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground, ); message.push_str(&format!(": {}", html.into_string())); @@ -702,7 +702,7 @@ fn short_item_info( &unstable_reason.as_str(), &mut ids, error_codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground, ) .into_string() @@ -1358,7 +1358,7 @@ fn render_impl( &i.impl_item.links(cx), &mut ids, cx.shared.codes, - cx.shared.edition, + cx.shared.edition(), &cx.shared.playground ) .into_string() diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 78bcd40af75..8e10c696df0 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -425,7 +425,7 @@ pub(super) fn write_shared( md_opts.output = cx.dst.clone(); md_opts.external_html = (*cx.shared).layout.external_html.clone(); - crate::markdown::render(&index_page, md_opts, cx.shared.edition) + crate::markdown::render(&index_page, md_opts, cx.shared.edition()) .map_err(|e| Error::new(e, &index_page))?; } else { let dst = cx.dst.join("index.html"); diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 001c8b09044..5a2a165191a 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -129,7 +129,7 @@ impl SourceCollector<'_, 'tcx> { &self.scx.layout, &page, "", - |buf: &mut _| print_src(buf, contents, self.scx.edition), + |buf: &mut _| print_src(buf, contents, self.scx.edition()), &self.scx.style_files, ); self.scx.fs.write(&cur, v.as_bytes())?;