1
Fork 0

Move error codes to shared context

This commit is contained in:
Mark Rousskov 2019-09-13 10:34:04 -04:00
parent 98c94f6f77
commit c26518086e

View file

@ -163,7 +163,6 @@ struct Context {
/// real location of an item. This is used to allow external links to /// real location of an item. This is used to allow external links to
/// publicly reused items to redirect to the right location. /// publicly reused items to redirect to the right location.
pub render_redirect_pages: bool, pub render_redirect_pages: bool,
pub codes: ErrorCodes,
/// The map used to ensure all generated 'id=' attributes are unique. /// The map used to ensure all generated 'id=' attributes are unique.
id_map: Rc<RefCell<IdMap>>, id_map: Rc<RefCell<IdMap>>,
pub shared: Arc<SharedContext>, pub shared: Arc<SharedContext>,
@ -208,6 +207,7 @@ crate struct SharedContext {
pub fs: DocFS, pub fs: DocFS,
/// The default edition used to parse doctests. /// The default edition used to parse doctests.
pub edition: Edition, pub edition: Edition,
pub codes: ErrorCodes,
} }
impl SharedContext { impl SharedContext {
@ -540,6 +540,7 @@ pub fn run(mut krate: clean::Crate,
generate_redirect_pages, generate_redirect_pages,
fs: DocFS::new(&errors), fs: DocFS::new(&errors),
edition, edition,
codes: ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()),
}; };
// If user passed in `--playground-url` arg, we fill in crate name here // If user passed in `--playground-url` arg, we fill in crate name here
@ -585,7 +586,6 @@ pub fn run(mut krate: clean::Crate,
current: Vec::new(), current: Vec::new(),
dst, dst,
render_redirect_pages: false, render_redirect_pages: false,
codes: ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()),
id_map: Rc::new(RefCell::new(id_map)), id_map: Rc::new(RefCell::new(id_map)),
shared: Arc::new(scx), shared: Arc::new(scx),
playground, playground,
@ -2353,7 +2353,7 @@ fn render_markdown(
if is_hidden { " hidden" } else { "" }, if is_hidden { " hidden" } else { "" },
prefix, prefix,
Markdown(md_text, &links, &mut ids, Markdown(md_text, &links, &mut ids,
cx.codes, cx.shared.edition, &cx.playground).to_string()) cx.shared.codes, cx.shared.edition, &cx.playground).to_string())
} }
fn document_short( fn document_short(
@ -3961,7 +3961,7 @@ fn render_impl(w: &mut Buffer, cx: &Context, i: &Impl, link: AssocItemLink<'_>,
let mut ids = cx.id_map.borrow_mut(); let mut ids = cx.id_map.borrow_mut();
write!(w, "<div class='docblock'>{}</div>", write!(w, "<div class='docblock'>{}</div>",
Markdown(&*dox, &i.impl_item.links(), &mut ids, Markdown(&*dox, &i.impl_item.links(), &mut ids,
cx.codes, cx.shared.edition, &cx.playground).to_string()); cx.shared.codes, cx.shared.edition, &cx.playground).to_string());
} }
} }