diff options
| author | bors <bors@rust-lang.org> | 2020-12-12 19:41:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-12 19:41:56 +0000 |
| commit | 7efc097c4fe6e97f54a44cee91c56189e9ddb41c (patch) | |
| tree | f8094e561a815df3c428d239f0e35d1f446325eb /src/librustdoc/formats/renderer.rs | |
| parent | 388eb24b6c479088a83c1b094d79221a32dfc7ff (diff) | |
| parent | 9684557c8f1b9fd55cb6fcc27533044022b0ed22 (diff) | |
| download | rust-7efc097c4fe6e97f54a44cee91c56189e9ddb41c.tar.gz rust-7efc097c4fe6e97f54a44cee91c56189e9ddb41c.zip | |
Auto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomez
[rustdoc] Calculate span information on demand instead of storing it ahead of time This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`. ~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback. Helps with #79103
Diffstat (limited to 'src/librustdoc/formats/renderer.rs')
| -rw-r--r-- | src/librustdoc/formats/renderer.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index d0fdc69cc19..6334524eb1c 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -1,5 +1,7 @@ use std::sync::Arc; +use rustc_data_structures::sync::Lrc; +use rustc_session::Session; use rustc_span::edition::Edition; use crate::clean; @@ -19,6 +21,7 @@ crate trait FormatRenderer: Clone { render_info: RenderInfo, edition: Edition, cache: &mut Cache, + sess: Lrc<Session>, ) -> Result<(Self, clean::Crate), Error>; /// Renders a single non-module item. This means no recursive sub-item rendering is required. @@ -49,6 +52,7 @@ crate fn run_format<T: FormatRenderer>( render_info: RenderInfo, diag: &rustc_errors::Handler, edition: Edition, + sess: Lrc<Session>, ) -> Result<(), Error> { let (krate, mut cache) = Cache::from_krate( render_info.clone(), @@ -59,7 +63,7 @@ crate fn run_format<T: FormatRenderer>( ); let (mut format_renderer, mut krate) = - T::init(krate, options, render_info, edition, &mut cache)?; + T::init(krate, options, render_info, edition, &mut cache, sess)?; let cache = Arc::new(cache); // Freeze the cache now that the index has been built. Put an Arc into TLS for future |
