| Age | Commit message (Collapse) | Author | Lines |
|
|
|
`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.
|
|
|
|
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````
|
|
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.
|
|
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.
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 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.
|
|
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.
|
|
This gives warnings about dead code.
|
|
|
|
|
|
|
|
|
|
This reverts commit 1244ced9580b942926afc06815e0691cf3f4a846.
|
|
- 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
|
|
|
|
|
|
* 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.
|
|
|
|
rustdoc: HTML escape const values
r? @GuillaumeGomez
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
This will eventually allow us to easily pass in more parameters to the
functions without TLS or other such hacks
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
|