Commit Graph

90 Commits

Author SHA1 Message Date
Joshua Nelson
0aa28446f8 rustdoc: Remove unnecessary StripItem wrapper 2021-05-04 21:56:27 -04:00
Joshua Nelson
b412b46cf7 Do the hard part first
The only bit failing was the module, so change that before removing the
`span` field.
2021-04-24 19:20:46 -04:00
Joshua Nelson
e29f46ce37 rustdoc: Remove unnecessary is_crate field from doctree::Module and clean::Module
It can be calculated on-demand even without a TyCtxt.

This also changed `from_item_kind` to take a whole item, which avoids
having to add more and more parameters.
2021-04-23 15:33:18 -04:00
Camelid
68244fc521 Remove unnecessary Option wrapping around Crate.module
I'm wondering if it was originally there so that we could `take` the
module which enables `after_krate` to take an `&Crate`. However, the two
impls of `after_krate` only use `Crate.name`, so we can pass just the
name instead.
2021-03-23 11:04:09 -07:00
Guillaume Gomez
b5c8eea55d Put clean::Trait extra information into a new struct to make it more coherent 2021-02-23 21:58:16 +01:00
Guillaume Gomez
58a34a4dde Remove is_spotlight field from Trait 2021-02-23 21:57:40 +01:00
Joshua Nelson
d11855a8ce Rename VariantKind -> Variant
There's no `Variant`, so it seems silly to have `Kind`.
2021-01-15 13:55:03 -05:00
Joshua Nelson
dd459a2be6 Remove useless clean::Variant struct
It had exactly one field and no special behavior, so there was no point.
2021-01-15 13:54:59 -05:00
Matthias Krüger
a5807ac61c clippy fixes for librustdoc
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
2021-01-01 21:19:10 +01:00
Matthias Krüger
e5ead5fc58 remove unused return types such as empty Results or Options that would always be Some(..)
remove unused return type of dropck::check_drop_obligations()
don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..)
remove redundant return type of back::write::optimize()
don't Option-wrap return type of compute_type_parameters() since we always return Some(..)
don't return empty Result in assemble_generator_candidates()
don't return empty Result in assemble_closure_candidates()
don't return empty result in assemble_fn_pointer_candidates()
don't return empty result in assemble_candidates_from_impls()
don't return empty result in assemble_candidates_from_auto_impls()
don't return emtpy result in assemble_candidates_for_trait_alias()
don't return empty result in assemble_builtin_bound_candidates()
don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait()
remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..)
remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-30 13:15:40 +01:00
Joshua Nelson
4a4426377e Box ItemKind to reduce the size of Item
This brings the size of `Item` from

```
[src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680
```

to

```
[src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280
```
2020-12-23 12:50:35 -05:00
Joshua Nelson
ab1e634295 Make fold_item_recur non-nullable
This gets rid of a bunch of `unwrap()`s and makes it a little more clear
what's going on.

Originally I wanted to make `fold_item` non-nullable too, which would
have been a lot nicer to work with, but unfortunately `stripper` does
actually return `None` in some places. I might make a follow-up moving
stripper to be special and not a pass so that passes can be
non-nullable.
2020-11-22 12:59:01 -05:00
Joshua Nelson
d6c16e4253 Make all rustdoc functions and structs crate-private
This gives warnings about dead code.
2020-11-15 11:21:12 -05:00
Joshua Nelson
03cbee84af Rename ItemEnum -> ItemKind, inner -> kind 2020-11-14 03:46:18 -05:00
Joshua Nelson
868927fefb rustdoc: Fix intra-doc links for cross-crate re-exports of traits
#58972 ignored extern_traits because before #65983 was fixed, they
would always fail to resolve, giving spurious warnings.
This undoes that change, so extern traits are now seen by the
`collect_intra_doc_links` pass. There are also some minor changes in
librustdoc/fold.rs to avoid borrowing the extern_traits RefCell more
than once at a time.
2020-08-29 17:21:26 -04:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mark Rousskov
c57481001e Remove ReentrantMutex
This drops the parking_lot dependency; the ReentrantMutex type appeared
to be unused (at least, no compilation failures occurred).

This is technically a possible change in behavior of its users, as
lock() would wait on other threads releasing their guards, but since we
didn't actually remove any threading or such in this code, it appears
that we never used that behavior (the behavior change is only noticeable
if the type previously was used in two threads, in a single thread
ReentrantMutex is useless).
2019-08-11 10:36:46 -04:00
Hirokazu Hata
1932d7a52d Transition librustdoc to 2018 edition 2019-02-23 16:40:07 +09:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
QuietMisdreavus
354507e61f shuffle ownership of external_traits
constraints:

- clean/inline.rs needs this map to fill in traits when inlining
- fold.rs needs this map to allow passes to fold trait items
- html/render.rs needs this map to seed the Cache.traits map of all
  known traits

The first two are the real problem, since `DocFolder` only operates on
`clean::Crate` but `clean/inline.rs` only sees the `DocContext`. The
introduction of early passes means that these two now exist at the same
time, so they need to share ownership of the map. Even better, the use
of `Crate` in a rustc thread pool means that it needs to be Sync, so it
can't use `Lrc<Lock>` to manually activate thread-safety.

`parking_lot` is reused from elsewhere in the tree to allow use of its
`ReentrantMutex`, as the relevant parts of rustdoc are still
single-threaded and this allows for easier use in that context.
2018-09-20 05:54:26 -05:00
Mark Rousskov
620c4fdf53 Delete unused code in rustdoc 2018-07-30 16:33:56 -06:00
bors
11864c4e6c Auto merge of #51854 - davidtwco:rfc-2008-rustdoc, r=QuietMisdreavus
RFC 2008 non-exhaustive enums/structs: Rustdoc

Part of #44109. Not sure how those who maintain rustdoc primarily would prefer this addition look or where it should be placed, happy to make any changes required.

r? @QuietMisdreavus (not sure if this is the right person, just guessing)
2018-07-19 19:03:03 +00:00
Alex Crichton
42eb85002a Upgrade to LLVM's master branch (LLVM 7)
This commit upgrades the main LLVM submodule to LLVM's current master branch.
The LLD submodule is updated in tandem as well as compiler-builtins.

Along the way support was also added for LLVM 7's new features. This primarily
includes the support for custom section concatenation natively in LLD so we now
add wasm custom sections in LLVM IR rather than having custom support in rustc
itself for doing so.

Some other miscellaneous changes are:

* We now pass `--gc-sections` to `wasm-ld`
* The optimization level is now passed to `wasm-ld`
* A `--stack-first` option is passed to LLD to have stack overflow always cause
  a trap instead of corrupting static data
* The wasm target for LLVM switched to `wasm32-unknown-unknown`.
* The syntax for aligned pointers has changed in LLVM IR and tests are updated
  to reflect this.
* The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug]

Nowadays we've been mostly only upgrading whenever there's a major release of
LLVM but enough changes have been happening on the wasm target that there's been
growing motivation for quite some time now to upgrade out version of LLD. To
upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet
another version of LLVM on the builders.

The revision of LLVM in use here is arbitrarily chosen. We will likely need to
continue to update it over time if and when we discover bugs. Once LLVM 7 is
fully released we can switch to that channel as well.

[llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
2018-07-10 13:43:01 -07:00
David Wood
5ccafa106f
Simplified checking for non_exhaustive attribute. 2018-07-05 22:44:58 +01:00
David Wood
a074bd7334
Display #[non_exhaustive] in rustdoc on types. 2018-06-27 20:50:59 +01:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Corey Farwell
35d214afe6 Remove redundant 'Variant' in variant names, stop reexporting. 2016-10-02 21:58:23 -04:00
Vadim Petrochenkov
6792bd99fe Support unions in rustdoc 2016-09-03 13:39:34 +03:00
mitaa
b1543a1aac Make the rendering process less pass-aware
Instead of hardcoding knowledge about the strip-private pass into the
rendering process we represent (some) stripped items as `ItemEnum::StrippedItem`.

Rustdoc will, for example, generate redirect pages for public items
contained in private modules which have been re-exported to somewhere
externally reachable - this will now not only work for the `strip-private`
pass, but for other passes as well, such as the `strip-hidden` pass.
2016-04-02 12:00:55 +02:00
mitaa
938c8c18c4 This doesn't seem necessary? 2016-03-04 19:40:01 +01:00
mitaa
8f6e09a956 Simplify if let/match expressions 2016-03-04 19:07:35 +01:00
Vadim Petrochenkov
67a978411a Support #[deprecated] in rustdoc 2015-12-12 23:01:27 +03:00
Alex Crichton
458102eefa rustdoc: Run external traits through filters
This ensures that all external traits are run through the same filters that the
rest of the AST goes through, stripping hidden function as necessary.

Closes #13698
2015-04-07 17:54:33 -07:00
Eduard Burtescu
f98b176314 syntax: gather common fields of impl & trait items into their respective types. 2015-03-11 23:39:16 +02:00
Niko Matsakis
1b3734f8ae Fix fallout from change, adding explicit Sized annotations where necessary. 2015-01-02 12:06:59 -05:00
Jorge Aparicio
ca001e1bd0 librustdoc: fix fallout 2014-12-13 17:03:44 -05:00
gamazeps
16c8cd931c Renamed Extendable to Extend
In order to upgrade, simply rename the Extendable trait to Extend in
your code

Part of #18424

[breaking-change]
2014-11-08 15:02:09 +01:00
Nick Cameron
ce0907e46e Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses.

[breaking-change]

Enum variants are now in both the value and type namespaces. This means that
if you have a variant with the same name as a type in scope in a module, you
will get a name clash and thus an error. The solution is to either rename the
type or the variant.
2014-09-19 15:11:00 +12:00
Patrick Walton
78a841810e librustc: Implement associated types behind a feature gate.
The implementation essentially desugars during type collection and AST
type conversion time into the parameter scheme we have now. Only fully
qualified names--e.g. `<T as Foo>::Bar`--are supported.
2014-09-17 16:38:57 -07:00
Aaron Turon
fc525eeb4e Fallout from renaming 2014-09-16 14:37:48 -07:00
Patrick Walton
9907fa4acc librustc: Stop assuming that implementations and traits only contain
methods.

This paves the way to associated items by introducing an extra level of
abstraction ("impl-or-trait item") between traits/implementations and
methods. This new abstraction is encoded in the metadata and used
throughout the compiler where appropriate.

There are no functional changes; this is purely a refactoring.
2014-08-14 11:40:22 -07:00
Aaron Turon
256df5e3df rustdoc: incorporate stability index throughout
This commit hooks rustdoc into the stability index infrastructure in two
ways:

1. It looks up stability levels via the index, rather than by manual
attributes.

2. It adds stability level information throughout rustdoc output, rather
than just at the top header. In particular, a stability color (with
mouseover text) appears next to essentially every item that appears
in rustdoc's HTML output.

Along the way, the stability index code has been lightly refactored.
2014-06-30 22:36:24 -07:00
Alex Crichton
c746c503f0 rustdoc: Fill in external trait methods
This commit alters rustdoc to crawl the metadata of upstream libraries in order
to fill in default methods for traits implemented in downstream crates. This,
for example, documents the `insert` function on hash maps.

This is a fairly lossy extraction from the metadata. Documentation and
attributes are lost, but they aren't used anyway. Unfortunately, argument names
are also lost because they are not present in the metadata. Source links are
also lost because the spans are not serialized.

While not perfect, it appears that presenting this documentation through rustdoc
is much better than nothing, so I wanted to land this to allow iteration on it
later on.
2014-05-22 09:46:22 -07:00
Marvin Löbel
6200e761f0 Changed iter::Extendable and iter::FromIterator to take a Iterator by value 2014-03-25 21:49:55 +01:00
Patrick Walton
af79a5aa7d test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
2014-03-21 23:37:21 +11:00
Florian Hahn
5d825def29 Mark top level module as a crate in rustdoc, closes #12507 2014-02-26 14:00:00 +01:00
Niko Matsakis
8dff89c238 librustdoc -- move closure to clarify scope 2014-02-11 16:55:24 -05:00
Edward Wang
e9ff91e9be Move replace and swap to std::mem. Get rid of std::util
Also move Void to std::any, move drop to std::mem and reexport in
prelude.
2014-02-11 05:21:35 +08:00
Steven Fackler
758f6e6e68 Fix rustdoc output of enums with private variants
Previously, if every variant was private, it would display as a
variantless enum instead of having the "some variants stripped" comment.
2013-12-16 21:30:02 -08:00
Steven Fackler
d6d31d788d Make Rustdoc strip private fields
In addition, the renderer will add comments to structs and enums saying
that fields or variants have been stripped.
2013-10-13 22:28:45 -07:00