about summary refs log tree commit diff
path: root/src/librustdoc/html/format.rs
AgeCommit message (Collapse)AuthorLines
2021-03-24Rework rustdoc const typeGuillaume Gomez-313/+404
2021-03-07Avoid temporary allocations in `render_assoc_item`Joshua Nelson-0/+4
`render_assoc_item` came up as very hot in a profile of rustdoc on `bevy`. This avoids some temporary allocations just to calculate the length of the header. This should be a strict improvement, since all string formatting was done twice before.
2021-02-06Restore linking to itself in implementors section of trait pageLeSeulArtichaut-43/+2
2021-02-05Rollup merge of #81497 - camelid:rustdoc-display_fn-remove-cell, r=jyn514Mara Bos-11/+11
rustdoc: Move `display_fn` struct inside `display_fn` This makes it clear that it's an implementation detail of `display_fn` and shouldn't be used elsewhere, and it enforces in the compiler that no one else can use it. r? ````@GuillaumeGomez````
2021-01-29rustdoc: Move `display_fn` struct inside `display_fn`Camelid-11/+11
This makes it clear that it's an implementation detail of `display_fn` and shouldn't be used elsewhere, and it enforces in the compiler that no one else can use it.
2021-01-27rustdoc: Render HRTB correctly for bare functionsCamelid-6/+15
The angle brackets were not rendered, so code like this: some_func: for<'a> fn(val: &'a i32) -> i32 would be rendered as: some_func: fn'a(val: &'a i32) -> i32 However, rendering with angle brackets is still invalid syntax: some_func: fn<'a>(val: &'a i32) -> i32 so now it renders correctly as: some_func: for<'a> fn(val: &'a i32) -> i32 ----- However, note that this code: some_trait: dyn for<'a> Trait<'a> will still render as: some_trait: dyn Trait<'a> which is not invalid syntax, but is still unclear. Unfortunately I think it's hard to fix that case because there isn't enough information in the `rustdoc::clean::Type` that this code operates on. Perhaps that case can be fixed in a later PR.
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-228/+279
2021-01-09Replace under-used ImplPolarity enum with a booleanGuillaume Gomez-1/+1
2021-01-01clippy fixes for librustdocMatthias Krüger-9/+9
fixes clippy warnings of type: match_like_matches_macro or_fun_call op_ref needless_return let_and_return single_char_add_str useless_format unnecessary_sort_by match_ref_pats redundant_field_names
2020-12-31Add FIXME for visibility of a moduleCamelid-0/+3
2020-12-30Update `find_nearest_parent_module`Camelid-3/+3
2020-12-25Prefer `pub(crate)` over no modifierCamelid-3/+3
2020-12-25Handle `pub(super)`Camelid-1/+9
2020-12-25Fix bugs; fix and add testsCamelid-27/+29
2020-12-25rustdoc: Render visibilities succinctlyCamelid-2/+11
2020-12-18Remove `DefPath` from `Visibility` and calculate it on demandJoshua Nelson-5/+6
2020-12-17Continue String to Symbol conversion in rustdocGuillaume Gomez-9/+8
2020-12-16Replace String with Symbol where possibleGuillaume Gomez-8/+5
2020-11-17Add `from_def_id_and_kind` reducing duplication in rustdocJoshua Nelson-1/+0
- Add `Item::from_hir_id_and_kind` convenience wrapper - Make name parameter mandatory `tcx.opt_item_name` doesn't handle renames, so this is necessary for any item that could be renamed, which is almost all of them. - Override visibilities to be `Inherited` for enum variants `tcx.visibility` returns the effective visibility, not the visibility that was written in the source code. `pub enum E { A, B }` always has public variants `A` and `B`, so there's no sense printing `pub` again. - Don't duplicate handling of `Visibility::Crate` Instead, represent it as just another `Restricted` path.
2020-11-17Use DefPath for clean::Visibility, not clean::PathJoshua Nelson-5/+18
Visibility needs much less information than a full path, since modules can never have generics. This allows constructing a Visibility from only a DefId. Note that this means that paths are now normalized to their DefPath. In other words, `pub(self)` or `pub(super)` now always shows `pub(in path)` instead of preserving the original text.
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-14/+14
This gives warnings about dead code.
2020-10-09Simplify included import items handlingGuillaume Gomez-8/+8
2020-10-09Correctly handle "pub use" reexportsGuillaume Gomez-2/+2
2020-08-31Fix strings indentGuillaume Gomez-1/+1
2020-07-27Extract `Cache` and other types from `html` moduleJoseph Ryan-9/+11
2020-07-16Revert "Remove "important traits" feature"Manish Goregaokar-0/+12
This reverts commit 1244ced9580b942926afc06815e0691cf3f4a846.
2020-06-26Generate docs for links to private items when passed --document-privateJoshua Nelson-1/+1
- Pass around document_private a lot more - Add tests + Add tests for intra-doc links to private items + Add ignored tests for warnings in reference links
2020-02-27Remove "important traits" featureGuillaume Gomez-12/+0
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-1/+1
2020-01-26rustdoc: Fix re-exporting primitive typesOliver Middleton-5/+8
* Generate links to the primitive type docs for re-exports. * Don't ICE on cross crate primitive type re-exports. * Make primitive type re-exports show up cross crate.
2020-01-20Add `MaybeConst` variant to `{ast,hir}::TraitBoundModifier`Dylan MacKenzie-0/+1
2020-01-07Rollup merge of #67908 - ollie27:rustdoc_const_html_escape, r=GuillaumeGomezYuki Okushi-3/+14
rustdoc: HTML escape const values r? @GuillaumeGomez
2020-01-05rustdoc: HTML escape const valuesOliver Middleton-3/+14
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-2/+2
2020-01-04canonicalize FxHash{Map,Set} importsMazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-254/+285
2019-12-22Implement PrintWithSpace trait on hir::MutabilityGuillaume Gomez-11/+11
2019-12-08Sort auto trait and blanket implementations displayGuillaume Gomez-0/+11
2019-09-28rustc: rely on c_variadic == true instead of CVarArgs in HIR/Ty fn signatures.Eduard-Mihai Burtescu-4/+11
2019-09-13Remove *Space wrappers in favor of direct impls or functionsMark Rousskov-68/+43
2019-09-13Unwrap Visibility fieldsMark Rousskov-6/+2
There's not really any reason to not have the visibility default to inherited, and this saves us the trouble of checking everywhere for whether we have a visibility or not.
2019-09-13Move to print functions on types instead of impl fmt::DisplayMark Rousskov-413/+468
This will eventually allow us to easily pass in more parameters to the functions without TLS or other such hacks
2019-09-07Move to buffers throughout print_itemMark Rousskov-3/+3
2019-09-07layout::render takes Print instead of fmt::DisplayMark Rousskov-1/+5
2019-09-07De-indent all fmt::Display impls for later replacement to functionsMark Rousskov-5/+5
2019-09-07Implement Print for FnOnce(&mut Buffer)Mark Rousskov-9/+11
This means that callers can pass in a closure like `|buf| some_function(..., &mut buf)` and pass in arbitrary arguments to that function without complicating the trait definition. We also keep the impl for str and String, since it's useful to be able to just pass in "" or format!("{}"...) results in some cases. This changes Print's definition to take self, instead of &self, because otherwise FnOnce cannot be called directly. We could instead take FnMut or even Fn, but that seems like it'd merely complicate matters -- most of the time, the FnOnce does not constrain us at all anyway. If it does, a custom Print impl for &'_ SomeStruct is not all that painful.
2019-09-07Move sidebar to Buffer-printingMark Rousskov-0/+23
2019-09-07Add buffer abstractionMark Rousskov-0/+65
2019-08-26Transition a few fmt::Display impls to functionsMark Rousskov-49/+53
This introduces a WithFormatter abstraction that permits one-time fmt::Display on an arbitrary closure, created via `display_fn`. This allows us to prevent allocation while still using functions instead of structs, which are a bit unwieldy to thread arguments through as they can't easily call each other (and are generally a bit opaque). The eventual goal here is likely to move us off of the formatting infrastructure entirely in favor of something more structured, but this is a good step to move us in that direction as it makes, for example, passing a context describing current state to the formatting impl much easier.
2019-08-26Inline RawMutableSpaceMark Rousskov-16/+7