about summary refs log tree commit diff
path: root/src/test/rustdoc
AgeCommit message (Collapse)AuthorLines
2020-12-01Rollup merge of #79527 - jyn514:intra-doc-tests, r=ManishearthMara Bos-258/+254
Move intra-doc link tests into a subdirectory They were starting to get unwieldy. r? ``@Manishearth``
2020-12-01Rollup merge of #79525 - jyn514:feature-gate-normalize, r=GuillaumeGomezMara Bos-1/+1
Add -Z normalize-docs and enable it for compiler docs Works around https://github.com/rust-lang/rust/issues/79459 by only enabling normalization for the compiler itself (and anyone who opts-in on nightly). Eventually I want to remove this and enable normalization by default, but that's turned out to be [really hard](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20do.20I.20normalize.20projection.20types.20to.20a.20single.20type.3F/near/218125195). This uses a command line option instead of a feature gate so it's easier to pass it to all crates at once. Theoretically it's better to use a feature gate instead so that it's easier for people to use on docs.rs, but I'm also not terribly concerned with how easy it to use a temporary hack. Addresses https://github.com/rust-lang/rust/issues/77459.
2020-11-30Auto merge of #76467 - jyn514:intra-link-self, r=Manishearthbors-0/+49
Fix intra-doc links for `Self` on cross-crate items and primitives - Remove the difference between `parent_item` and `current_item`; these should never have been different. - Remove `current_item` from `resolve` and `variant_field` so that `Self` is only substituted in one place at the very start. - Resolve the current item as a `DefId`, not a `HirId`. This is what actually fixed the bug. Hacks: - `clean` uses `TypedefItem` when it _really_ should be `AssociatedTypeItem`. I tried fixing this without success and hacked around it instead (see comments) - This second-guesses the `to_string()` impl since it wants fully-qualified paths. Possibly there's a better way to do this.
2020-11-29Add support for stable-const-since in docs on items (standalone or assoc)Rune Tynan-0/+10
2020-11-29Add -Z normalize-docs and enable it for compiler docsJoshua Nelson-1/+1
2020-11-29Add test for cross-crate SelfJoshua Nelson-0/+13
2020-11-29Fix intra-doc links for `Self` on primitivesJoshua Nelson-0/+36
- Remove the difference between `parent_item` and `current_item`; these should never have been different. - Remove `current_item` from `resolve` and `variant_field` so that `Self` is only substituted in one place at the very start. - Resolve the current item as a `DefId`, not a `HirId`. This is what actually fixed the bug. Hacks: - `clean` uses `TypedefItem` when it _really_ should be `AssociatedTypeItem`. I tried fixing this without success and hacked around it instead (see comments) - This stringifies DefIds, then resolves them a second time. This is really silly and rustdoc should just use DefIds throughout. Fixing this is a larger task than I want to take on right now.
2020-11-29Auto merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514bors-0/+2
Update tests to remove old numeric constants Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-29Auto merge of #79455 - CraftSpider:master, r=jyn514bors-0/+53
Remove doctree::Macro and distinguish between `macro_rules!` and `pub macro` This is a part of #78082, removing doctree::Macro. Uses the changes in #79372 Fixes #76761
2020-11-29Update tests to remove old numeric constantsbstrie-0/+2
Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-28Add test for macro by example syntax in decl macros with only one optionRune Tynan-0/+7
2020-11-29Rollup merge of #79464 - GuillaumeGomez:doc-keyword-ident, r=jyn514Dylan DPC-0/+5
Extend doc keyword feature by allowing any ident Part of #51315. As suggested by ``@danielhenrymantilla`` in [this comment](https://github.com/rust-lang/rust/issues/51315#issuecomment-733879934), this PR extends `#[doc(keyword = "...")]` to allow any ident to be used as keyword. The final goal is to allow (proc-)macro crates' owners to write documentation of the keywords they might introduce. r? ``@jyn514``
2020-11-29Rollup merge of #79340 - GuillaumeGomez:rename-stability, r=jyn514Dylan DPC-7/+7
Rename "stability" CSS class to "item-info" and combine `document_stability` with `document_short` Follow-up of #79300 The point of this PR is to make the CSS class more accurate since it's not only about stability anymore. r? ``@jyn514``
2020-11-28Move `src/test/rustdoc` intra-doc link tests into a subdirectoryJoshua Nelson-258/+254
They were starting to get unwieldy.
2020-11-28Add support for multi-argument decl macrosRune Tynan-0/+17
2020-11-28Update src/test/rustdoc/decl_macro_priv.rsRune Tynan-0/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-11-27Update decl_macro test, add decl_macro_priv test for --document-private-itemsRune Tynan-3/+15
2020-11-27Add test, fix pub macro impl, compile errorRune Tynan-0/+16
2020-11-27Revert the effect of #77467 by disabling normalization in rustdocoli-0/+1
2020-11-27Add tests for doc_keyword feature extensionGuillaume Gomez-0/+5
2020-11-26Auto merge of #77467 - jyn514:query-docs, r=oli-obkbors-0/+80
Normalize `<X as Y>::T` for rustdoc - Only run for `QPath::Resolved` with `Some` self parameter (`<X as Y>::T`) - Fall back to the previous behavior if the path can't be resolved The first commit is a pure refactor and should probably be reviewed by `@GuillaumeGomez.` I recommend reviewing the second commit on its own. Fixes https://github.com/rust-lang/rust/issues/77459. r? `@eddyb` cc `@danielhenrymantilla` , `@lcnr`
2020-11-26Rollup merge of #79412 - GuillaumeGomez:cleanup-rustdoc-tests, r=jyn514Jonas Schievink-6/+0
Clean up rustdoc tests by removing unnecessary features r? ``@jyn514``
2020-11-25Clean up rustdoc tests by removing unnecessary featuresGuillaume Gomez-6/+0
2020-11-25Auto merge of #79336 - camelid:rename-feature-oibit-to-auto, r=oli-obkbors-16/+16
Rename `optin_builtin_traits` to `auto_traits` They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>. r? `@oli-obk` (feel free to re-assign if you're not the right reviewer for this)
2020-11-24Use the name "auto traits" everywhere in the compilerCamelid-9/+9
Goodbye, OIBIT!
2020-11-24Track `ParamEnv`s properlyJoshua Nelson-1/+6
This uses the same `with_param_env` pattern that late lints use. Thanks to all the doctree refactors, this was very easy to add.
2020-11-24Normalize `<X as Y>::T` for rustdocJoshua Nelson-0/+75
- Only run for `QPath::Resolved` with `Some` self parameter (`<X as Y>::T`) - Fall back to the previous behavior if the path can't be resolved - Show what the behavior is if the type can't be normalized - Run `resolve_vars_if_possible` It's not clear whether or not this is necessary. See https://github.com/rust-lang/rust/pull/77616 for more context. - Add a test for cross-crate re-exports - Use the same code for both `hir::Ty` and `Ty`
2020-11-24Rename "stability" CSS class to "item-info"Guillaume Gomez-7/+7
2020-11-23Rename `optin_builtin_traits` to `auto_traits`Camelid-7/+7
They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.
2020-11-23Apply `doc(cfg)` from parent items while collecting trait implsWim Looman-1/+43
Because trait impls bypass the standard `clean` hierarchy they do not participate in the `propagate_doc_cfg` pass, so instead we need to pre-collect all possible `doc(cfg)` attributes that will apply to them when cleaning.
2020-11-22Accept '!' in intra-doc linksCamelid-0/+3
This will allow linking to things like `Result<T, !>`.
2020-11-21Auto merge of #78461 - TimDiekmann:vec-alloc, r=Amanieubors-2/+3
Add support for custom allocators in `Vec` This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections. r? `@Amanieu` This pull request requires a crater run. ### Prior work: - #71873: Crater-test to solve rust-lang/wg-allocators#1 - [`alloc-wg`](https://github.com/TimDiekmann/alloc-wg)-crate
2020-11-21Rollup merge of #79264 - jyn514:less-doctree, r=GuillaumeGomezDylan DPC-0/+12
Get rid of some doctree items They can be derived directly from the `hir::Item`, there's no special logic. - TypeDef - OpaqueTy - Constant - Static - TraitAlias - Enum - Union - Struct Part of #78082 (the easiest part, I'm still debugging some other changes). r? `@GuillaumeGomez`
2020-11-21Rollup merge of #79182 - lochsh:78777-fix-extern-types-ref, r=jyn514Dylan DPC-0/+18
Fix links to extern types in rustdoc (fixes #78777) r? `@jyn514` Fixes #78777. The initial fix we tried was: ```diff diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 8be9482acff..c4b7086fdb1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs `@@` -433,8 +433,9 `@@` impl<'a, 'tcx> LinkCollector<'a, 'tcx> { Res::PrimTy(prim) => Some( self.resolve_primitive_associated_item(prim, ns, module_id, item_name, item_str), ), - Res::Def(DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::TyAlias, did) => { + Res::Def(kind, did) if kind.ns() == Some(Namespace::TypeNS) => { debug!("looking for associated item named {} for item {:?}", item_name, did); + // Checks if item_name belongs to `impl SomeItem` let assoc_item = cx .tcx ``` However, this caused traits to be matched, resulting in a panic when `resolve_associated_trait_item` is called further down in this function. This PR also adds an error message for that panic. Currently it will look something like: ```rust thread 'rustc' panicked at 'Not a type: DefIndex(8624)', compiler/rustc_metadata/src/rmeta/decoder.rs:951:32 ``` I wasn't sure how to get a better debug output than `DefIndex(...)`, and am open to suggestions.
2020-11-21Add more tests for renamed itemsJoshua Nelson-0/+12
2020-11-18Add testHannah McLaughlin-0/+18
2020-11-18add [src] links to methods on a trait's pageNixon Enraght-Moony-0/+26
2020-11-18Add support for custom allocators in `Vec`Tim Diekmann-2/+3
2020-11-17Add `from_def_id_and_kind` reducing duplication in rustdocJoshua Nelson-0/+2
- 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-9/+7
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-16Rollup merge of #78678 - Nemo157:doc-cfg-w-traits, r=jyn514,GuillaumeGomezMara Bos-0/+124
Add tests and improve rendering of cfgs on traits Shows the additional features required to get the trait implementation, suppressing any already shown on the current page. One interesting effect from this is if you have a cfg-ed type, implementing a cfg-ed trait (so the implementation depends on both cfgs), you will get the inverted pair of cfgs shown on each page: ![image](https://user-images.githubusercontent.com/81079/97904671-207bdc00-1d41-11eb-8144-707e8017d2b6.png) ![image](https://user-images.githubusercontent.com/81079/97904700-27a2ea00-1d41-11eb-8b9f-e925ba339044.png) The hidden items on the trait implementation also now get the correct cfgs displayed on them. Tests are blocked on #78673. fixes #68100 cc #43781
2020-11-15Rollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514Dylan DPC-0/+22
Add a test for r# identifiers I'm not entirely sure I properly ran the test locally (I think so though), waiting for CI to confirm. :) ```````@rustbot``````` modify labels: T-rustdoc r? ```````@jyn514```````
2020-11-14Add tests and improve rendering of features on traitsWim Looman-0/+124
2020-11-13Auto merge of #78683 - Nemo157:issue-78673, r=lcnrbors-0/+24
Check predicates from blanket trait impls while testing if they apply fixes #78673
2020-11-13Rollup merge of #78984 - GuillaumeGomez:rustdoc-check-option, r=jyn514Guillaume Gomez-0/+5
Rustdoc check option The ultimate goal behind this option would be to have `rustdoc --check` being run when you use `cargo check` as a second step. r? `@jyn514`
2020-11-13Fix wrong XPathAlexis Bourget-4/+6
2020-11-12Handle and test wildcard argumentsJoshua Nelson-2/+7
2020-11-12Don't reuse bindings for `ref mut`Joshua Nelson-0/+8
Reusing bindings causes errors later in lowering: ``` error[E0596]: cannot borrow `vec` as mutable, as it is not declared as mutable --> /checkout/src/test/ui/async-await/argument-patterns.rs:12:20 | LL | async fn b(n: u32, ref mut vec: A) { | ^^^^^^^^^^^ | | | cannot borrow as mutable | help: consider changing this to be mutable: `mut vec` ```
2020-11-12Add tests for rustdoc --check optionGuillaume Gomez-0/+5
2020-11-12Rollup merge of #78916 - lcnr:const-generics-tests, r=varkorGuillaume Gomez-0/+148
extend const generics test suite should implement most of #78433, especially all parts of [the hackmd](https://hackmd.io/WnFmN4MjRCqAjGmYfYcu2A?view) which I did not explicitly mention in that issue. r? ``@varkor``