Commit Graph

1924 Commits

Author SHA1 Message Date
Dylan DPC 61372e1af6
Rollup merge of #82846 - GuillaumeGomez:doc-alias-list, r=jyn514
rustdoc: allow list syntax for #[doc(alias)] attributes

Fixes https://github.com/rust-lang/rust/issues/81205.

It now allows to have:

```rust
#[doc(alias = "x")]
// and:
#[doc(alias("y", "z"))]
```

cc ``@jplatte``
r? ``@jyn514``
2021-03-19 15:03:21 +01:00
Vadim Petrochenkov 38ed36bba4 hir: Preserve used syntax in `TyKind::TraitObject` 2021-03-18 03:02:32 +03:00
Vadim Petrochenkov b25d3ba781 ast/hir: Rename field-related structures
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03:00
Guillaume Gomez 1d26e6b632 Improve code by removing similar function calls and using loops instead for collecting iterators 2021-03-11 22:33:40 +01:00
bors 066f01d81b Auto merge of #82960 - camelid:masked_crates, r=jyn514
Remove `masked_crates` from `clean::Crate`

Previously, `masked_crates` existed both on `Cache` and on
`clean::Crate`. During cache population, the `clean::Crate` version was
`take`n and moved to `Cache`.

This change removes the version on `clean::Crate` and instead directly
mutates `Cache.masked_crates` to initialize it. This has the advantage
of avoiding duplication and avoiding unnecessary allocation, as well as
making the flow of information through rustdoc less confusing.

The one downside I see is that `clean::utils::krate()` now uses the side
effect of mutating `DocContext.cache` instead of returning the data
directly, but it already mutated the `Cache` for other things (e.g.,
`deref_trait_did`) so it's not really new behavior. Also,
`clean::utils::krate()` is only called once (and is meant to only be
called once since it performs expensive and potentially destructive
operations) so the mutation shouldn't be an issue.

Follow-up to https://github.com/rust-lang/rust/pull/82018#discussion_r584197747.

cc `@jyn514`
2021-03-10 21:54:06 +00:00
Guillaume Gomez bbbefa3edc Allow doc alias attributes to use both list and value 2021-03-10 10:17:37 +01:00
Camelid b7d91b0ae4 Remove `masked_crates` from `clean::Crate`
Previously, `masked_crates` existed both on `Cache` and on
`clean::Crate`. During cache population, the `clean::Crate` version was
`take`n and moved to `Cache`.

This change removes the version on `clean::Crate` and instead directly
mutates `Cache.masked_crates` to initialize it. This has the advantage
of avoiding duplication and avoiding unnecessary allocation, as well as
making the flow of information through rustdoc less confusing.

The one downside I see is that `clean::utils::krate()` now uses the side
effect of mutating `DocContext.cache` instead of returning the data
directly, but it already mutated the `Cache` for other things (e.g.,
`deref_trait_did`) so it's not really new behavior. Also,
`clean::utils::krate()` is only called once (and is meant to only be
called once since it performs expensive and potentially destructive
operations) so the mutation shouldn't be an issue.
2021-03-09 20:02:52 -08:00
Camille GILLOT c701872a6c Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
Mara Bos bb9542b016
Rollup merge of #82841 - hvdijk:x32, r=joshtriplett
Change x64 size checks to not apply to x32.

Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-09 09:05:24 +00:00
Yuki Okushi 379679b913
Rollup merge of #82803 - jyn514:unversioned-files, r=GuillaumeGomez
rustdoc: Add an unstable option to print all unversioned files

This allows sharing those files between different doc invocations
without having to know their names ahead of time.

Helps with https://github.com/rust-lang/docs.rs/issues/1302.
r? ````@GuillaumeGomez```` cc ````@pietroalbini```` ````@Nemo157````
2021-03-07 10:41:18 +09:00
Harald van Dijk 95e096d623
Change x64 size checks to not apply to x32.
Rust contains various size checks conditional on target_arch = "x86_64",
but these checks were never intended to apply to
x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the
conditions.
2021-03-06 16:02:48 +00:00
Joshua Nelson 69a879f3d1 Store `UNVERSIONED_FILES` in a data structure
This allows querying it programatically.
2021-03-05 10:55:15 -05:00
Guillaume Gomez f879ecc4ef Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make transition over hir::ItemKind simpler 2021-03-05 16:04:24 +01:00
Camelid c79af86240 Pass `CrateNum` by value instead of by reference
It's more idiomatic to pass a small Copy type by value and `CrateNum` is
half the size of `&CrateNum` on 64-bit systems. The memory use change is
almost certainly insignificant, but why not!
2021-03-03 20:07:15 -08:00
Yuki Okushi 43bcfdb0d0
Rollup merge of #82597 - noslaver:fix-82137, r=nagisa
Get TyCtxt from self instead of passing as argument in AutoTraitFinder

First contribution 🦀, let me know if anything is amiss.

Fix #82137.
2021-03-02 21:23:19 +09:00
Yuki Okushi 543ef7f13c
Rollup merge of #82593 - sunfishcode:wasi-docs, r=alexcrichton
Teach rustdoc how to display WASI.

As a followup to [this comment] in #82420, this patch teaches rustdoc
how to display WASI.

[this comment]: https://github.com/rust-lang/rust/pull/82420#issuecomment-784523826

r? `@alexcrichton`
2021-03-02 21:23:18 +09:00
Noam Koren 854fffde5d Get TyCtxt from self instead of passing as argument in AutoTraitFinder
methods
2021-03-01 22:59:24 +02:00
Joshua Nelson be069a687a Remove `krate.version`; fix `crate_version` in JSON
Previously, `JsonRenderer::after_krate` called `krate.version.clone()`.
The problem was it did that after the version was already moved into the
cache, so it would always be None. The fix was to get the version from
the cache instead.
2021-03-01 00:30:40 -05:00
Joshua Nelson 4d7a648485 Remove the dummy cache in `DocContext`
The same information is available everywhere; the only reason the dummy
cache was needed is because it waas previously stored in three different
places. This consolidates the info a bit so the cache in `DocContext` is
used throughout. As a bonus, it means `renderinfo` is used much much
less.

- Return a `Cache` from `run_global_ctxt`, not `RenderInfo`
- Remove the unused `render_info` from `run_renderer`
- Remove RefCell around `inlined`
- Add intra-doc links
2021-03-01 00:30:30 -05:00
bors e37a13cc35 Auto merge of #81349 - jyn514:blanket-impls-cleanup, r=lcnr
Remove unnecessary `self_ty` parameter to `get_blanket_impls`

It can be calculated when necessary at the callsite, there's no need to
pass it separately.

This also renames `param_env_def_id` to `item_def_id`.

cc `@eddyb`
2021-02-28 19:19:09 +00:00
Joshua Nelson c47c2c6016 Remove unnecessary `self_ty` parameter to `get_blanket_impls`
It can be calculated when necessary at the callsite, there's no need to
pass it separately.

This also renames `param_env_def_id` to `item_def_id`.
2021-02-28 11:09:11 -05:00
Simonas Kazlauskas a757fae245 Remove the x86_64-rumprun-netbsd target
Closes #81514
2021-02-27 17:55:22 +02:00
Dan Gohman b89e828c04 Teach rustdoc how to display WASI.
As a followup to [this comment] in #82420, this patch teaches rustdoc
how to display WASI.

[this comment]: https://github.com/rust-lang/rust/pull/82420#issuecomment-784523826
2021-02-27 07:33:28 -08:00
bors b36f77012d Auto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514
Prevent to compute Item attributes twice

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc `@camelid`

r? `@jyn514`
2021-02-25 12:33:21 +00:00
Guillaume Gomez cc0d531463 Make DocContext &mut for clean 2021-02-24 10:16:33 +01:00
Guillaume Gomez f24eac5e64 Prevent to compute Item attributes twice 2021-02-24 10:05:19 +01:00
Guillaume Gomez 33aaead6a1 Improve code readability 2021-02-23 22:13:48 +01:00
Guillaume Gomez 3c59e64abf * Fix some typo
* Improve documentation
* Add a test to ensure that spotlighted traits from dependencies are taken into account as expected
2021-02-23 21:58:17 +01: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 fa51c0f472 Use a qualified path to make it more clear where `list_contains_name` function comes from 2021-02-23 21:57:42 +01:00
Guillaume Gomez 58a34a4dde Remove is_spotlight field from `Trait` 2021-02-23 21:57:40 +01:00
Camelid e4ac499b7e Remove many RefCells from DocContext
I left some of them so this change doesn't balloon in size and because
removing the RefCell in `DocContext.resolver` would require compiler
changes.

Thanks to `@jyn514` for making this a lot easier with #82020!
2021-02-22 10:02:56 -08:00
Camelid 6a85719b6a rustdoc: Remove unnecessary `Cell` around `param_env` 2021-02-20 17:12:22 -08:00
Guillaume Gomez 3071685505 Don't render [src] link on dummy spans 2021-02-20 19:51:38 +01:00
Guillaume Gomez d20e05b78b Show negative implementation of Sized trait 2021-02-19 22:38:07 +01:00
Joshua Nelson 2bc5a0a600 Make `Clean` take &mut DocContext
- Take `FnMut` in `rustc_trait_selection::find_auto_trait_generics`
- Take `&mut DocContext` in most of `clean`
- Collect the iterator in auto_trait_impls instead of iterating lazily; the lifetimes were really bad.
- Changes `fn sess` to properly return a borrow with the lifetime of `'tcx`, not the mutable borrow.
2021-02-16 21:25:14 -05:00
bors 8fe989dd76 Auto merge of #81611 - cjgillot:meowner, r=estebank
Only store a LocalDefId in some HIR nodes

Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.

This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16 22:14:32 +00:00
Guillaume Gomez 46b93b2e44
Rollup merge of #82163 - matthiaskrgr:slice, r=jyn514
avoid full-slicing slices

If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing
2021-02-16 19:21:20 +01:00
Matthias Krüger 4390a61b64 avoid full-slicing slices
If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing
2021-02-16 00:31:11 +01:00
Camille GILLOT c4e7427081 Only store a LocalDefId in hir::MacroDef. 2021-02-15 19:35:55 +01:00
Camille GILLOT 996dc8d5c5 Only store a LocalDefId in hir::ForeignItem. 2021-02-15 19:32:29 +01:00
Camille GILLOT 786a80e9ea Only store a LocalDefId in hir::ImplItem. 2021-02-15 19:32:29 +01:00
Camille GILLOT a871a0f111 Only store a LocalDefId in hir::TraitItem. 2021-02-15 19:32:28 +01:00
Camille GILLOT cebbba081e Only store a LocalDefId in hir::Item.
Items are guaranteed to be HIR owner.
2021-02-15 19:32:10 +01:00
Camille GILLOT c676e358a5 Use ItemId as a strongly typed index. 2021-02-15 19:24:58 +01:00
Takayuki Maeda ba72bc9b83 fix typo 2021-02-14 21:18:17 +09:00
Yuki Okushi 4c8e38aa60
Rollup merge of #82033 - magurotuna:issue82016, r=jyn514
Refactor `get_word_attr` to return only `Option`

This commit removes `bool` from the return type of `NestedAttributesExt::get_word_attr` so it will return only `Option<ast::NestedMetaItem>` for less redundancy.

Closes #82016

r? `@jyn514`
2021-02-13 16:36:48 +09:00
Yusuke Tanaka 681cccad57
Rename to `inline_attr` and use if-let to extract `NestedMetaItem` 2021-02-13 01:48:00 +09:00
Yusuke Tanaka 715c19e75e
Refactor `get_word_attr` to return only `Option` 2021-02-13 01:13:50 +09:00
Yuki Okushi 1a9d20b430
Rollup merge of #82004 - GuillaumeGomez:clean-static-struct, r=jyn514
clean up clean::Static struct

Having a `String` for the expression didn't make much sense, and even less when it's actually not used (except in json so I kept it).

r? ``@jyn514``
2021-02-12 19:32:18 +09:00