about summary refs log tree commit diff
path: root/src/test/rustdoc
AgeCommit message (Collapse)AuthorLines
2020-09-05Rollup merge of #76078 - jyn514:no-disambiguator, r=manishearthDylan DPC-0/+51
Remove disambiguators from intra doc link text Closes https://github.com/rust-lang/rust/issues/65354. r? @Manishearth The commits are mostly atomic, but there might be some mix between them here and there. I recommend reading 'refactor ItemLink' and 'refactor RenderedLink' on their own though, lots of churn without any logic changes.
2020-09-04Misc cleanupJoshua Nelson-33/+51
- Preserve suffixes when displaying - Rename test file to match `intra-link*` - Remove unnecessary .clone()s - Improve comments and naming - Fix more bugs and add tests - Escape intra-doc link example in public documentation
2020-09-03rustdoc: fix min_const_generics with ty::ParamBastian Kauschke-0/+6
2020-09-03Auto merge of #73819 - euclio:rustdoc-summaries, r=jyn514,GuillaumeGomezbors-0/+72
rustdoc: do not use plain summary for trait impls Fixes #38386. Fixes #48332. Fixes #49430. Fixes #62741. Fixes #73474. Unfortunately this is not quite ready to go because the newly-working links trigger a bunch of linkcheck failures. The failures are tough to fix because the links are resolved relative to the implementor, which could be anywhere in the module hierarchy. (In the current docs, these links end up rendering as uninterpreted markdown syntax, so I don't think these failures are any worse than the status quo. It might be acceptable to just add them to the linkchecker whitelist.) Ideally this could be fixed with intra-doc links ~~but it isn't working for me: I am currently investigating if it's possible to solve it this way.~~ Opened #73829. EDIT: This is now ready!
2020-09-03Remove disambiguators from link textJoshua Nelson-0/+33
Related to https://github.com/rust-lang/rust/issues/65354 - Pass through the replacement text to `markdown.rs` - Add some tests - Add a state machine that actually replaces the text when parsing Markdown
2020-09-01Use "Fira Sans" for crate list fontCamelid-2/+2
Fira Sans is what's used for module lists and other item lists. Previously, the default body font, "Source Serif Pro", was used for crate lists, which didn't visually match other item lists.
2020-08-30Improve testsJoshua Nelson-4/+18
Now this actually tests the links are generated correctly
2020-08-30rustdoc: do not use plain summary for trait implsAndy Russell-0/+72
Fixes #38386. Fixes #48332. Fixes #49430. Fixes #62741. Fixes #73474.
2020-08-30Comment out test for generated docs until rustdoc changes its behavior ↵Joshua Nelson-3/+12
around documenting re-exports
2020-08-30Auto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkovbors-2/+0
Fix intra-doc links for cross-crate re-exports of default trait methods The original fix for this was very simple: https://github.com/rust-lang/rust/pull/58972 ignored `extern_traits` because before https://github.com/rust-lang/rust/issues/65983 was fixed, they would always fail to resolve, giving spurious warnings. So the first commit just 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. However, that brought up a much more thorny problem. `rustc_resolve` started giving 'error: cannot find a built-in macro with name `cfg`' when documenting `libproc_macro` (I still haven't been able to reproduce on anything smaller than the full standard library). The chain of events looked like this (thanks @eddyb for the help debugging!): 0. `x.py build --stage 1` builds the standard library and creates a sysroot 1. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above) 2. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros 3. `rustdoc` later tries to resolve some path in a doc link 4. suggestion logic fires and loads "extern prelude" crates by name 5. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros `rustc_resolve` gives the error after step 5. However, `rustdoc` doesn't need suggestions at all - `resolve_str_path_error` completely discards the `ResolutionError`! The fix implemented in this PR is to skip the suggestion logic for `resolve_ast_path`: pass `record_used: false` and skip `lookup_import_candidates` when `record_used` isn't set. It's possible that if/when https://github.com/rust-lang/rust/issues/74207 is implemented this will need a more in-depth fix which returns a `ResolutionError` from `compile_macro`, to allow rustdoc to reuse the suggestions from rustc_resolve. However, that's a much larger change and there's no need for it yet, so I haven't implemented it here. Fixes https://github.com/rust-lang/rust/issues/73829. r? @GuillaumeGomez
2020-08-30Auto merge of #76093 - jyn514:prim-assoc-items, r=Manishearthbors-0/+5
Fix intra-doc links for associated constants Previously, only associated functions would be resolved. Fixes the issues in https://github.com/rust-lang/rust/pull/75969#discussion_r477898003. I'm a little uncomfortable hard-coding the string constants, but it looks like that's how it's done elsewhere. I might make a follow-up PR at some point putting it in one place. Not sure how to test associated types, since AFAIK there aren't any on primitives. r? @Manishearth
2020-08-29Fix intra-doc links for associated constantsJoshua Nelson-0/+5
Previously, only associated functions would be resolved.
2020-08-29Auto merge of #75775 - matklad:rustc-lexer-rustdoc-highlight, r=GuillaumeGomezbors-6/+6
Use rustc_lexer for rustdoc syntax highlighting r? @ghost
2020-08-29rustdoc: Fix intra-doc links for cross-crate re-exports of traitsJoshua Nelson-2/+0
#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[WIP] Fix intra-doc links on pub re-exportsJoshua Nelson-0/+8
This removes the incorrect error, but doesn't show the documentation anywhere.
2020-08-28Rollup merge of #75330 - Nemo157:improve-doc-cfg-features, r=GuillaumeGomezPietro Albini-5/+21
Improve rendering of crate features via doc(cfg) The current rendering of crate features with `doc(cfg(feature = ".."))` is verbose and unwieldy for users, `doc(cfg(target_feature = ".."))` is special-cased to make it render nicely, and a similar rendering can be applied to `doc(cfg(feature))` to make it easier for users to read. I also added special casing of `all`/`any` cfgs consisting of just `feature`/`target-feature` to remove the repetitive "target/crate feature" prefix. The downside of this current rendering is that there is no distinction between `feature` and `target_feature` in the shorthand display. IMO this is ok, or if anything `target_feature` should have a more verbose shorthand, because `doc(cfg(feature = ".."))` usage is going to vastly outstrip `doc(cfg(target_feature = ".."))` usage in non-stdlib crates when it eventually stabilizes (or even before that given the number of crates using `cfg_attr(docsrs)` like constructs). ## Previously <img width="259" alt="Screenshot 2020-08-09 at 13 32 42" src="https://user-images.githubusercontent.com/81079/89731110-d090c000-da44-11ea-96fa-56adc6339123.png"> <img width="438" alt="image" src="https://user-images.githubusercontent.com/81079/89731116-d7b7ce00-da44-11ea-87c6-022d192d6eca.png"> <img width="765" alt="image" src="https://user-images.githubusercontent.com/81079/89731152-24030e00-da45-11ea-9552-1c270bff2729.png"> <img width="671" alt="image" src="https://user-images.githubusercontent.com/81079/89731158-28c7c200-da45-11ea-8acb-97d8a4ce00eb.png"> ## Now <img width="216" alt="image" src="https://user-images.githubusercontent.com/81079/89731123-e1d9cc80-da44-11ea-82a8-5900bd9448a5.png"> <img width="433" alt="image" src="https://user-images.githubusercontent.com/81079/89731127-e8684400-da44-11ea-9d18-572fd810f19f.png"> <img width="606" alt="image" src="https://user-images.githubusercontent.com/81079/89731162-2feed000-da45-11ea-98d2-8a88c364d903.png"> <img width="669" alt="image" src="https://user-images.githubusercontent.com/81079/89731991-ccb46c00-da4b-11ea-9416-cd20a3193826.png"> cc #43781
2020-08-27Remove dependency on StringReader from rustdoc highlighterAleksey Kladov-6/+6
rustc_lexer is the lossless lexer, which is a better fit for approximate syntax highlighting. As a side-effect, we can now syntax-highlight even broken code.
2020-08-23Update primitive test to match the new behaviorJoshua Nelson-8/+8
2020-08-22rustdoc: Add support for associated items even outside the impl itselfJoshua Nelson-0/+86
Previously, associated items would only be available for linking directly on the `impl Trait for Type`. Now they can be used anywhere. - Make `item` for resolve mandatory - Refactor resolving associated items into a separate function - Remove broken trait_item logic - Don't skip the type namespace for associated items - Only call `variant_field` for `TypeNS` - Add test for associated items - Use exhaustive matches instead of wildcards Wildcards caused several bugs while implementing this.
2020-08-19Add test for f32 and f64 methodsJoshua Nelson-2/+20
2020-08-19Add a testJoshua Nelson-0/+14
2020-08-18Add long cfg description to tooltip on short descriptionWim Looman-1/+17
2020-08-17Resolve true and false as booleansJoshua Nelson-0/+10
2020-08-12Auto merge of #75205 - Aaron1011:fix/auto-trait-proj-ice, r=nikomatsakisbors-0/+25
Handle projection predicates in the param env for auto-trait docs Fixes #72213 Any predicates in the param env are guaranteed to hold, so we don't need to do any additional processing of them if we come across them as sub-obligations of a different predicate. This allows us to avoid adding the same predicate to the computed ParamEnv multiple times (but with different regions each time), which causes an ambiguity error during fulfillment.
2020-08-10Auto merge of #74936 - GuillaumeGomez:const-rustc_const_unstable, r=jyn514bors-0/+9
Don't print "const" keyword on non-nightly build if rustc_const_unstable is used on the item Fixes #74579.
2020-08-10Add test for rustc_const_unstable on methodsGuillaume Gomez-0/+9
2020-08-09Give precedence to primitives over modulesJoshua Nelson-1/+6
This has less surprising behavior when there is a module with the same name as a primitive in scope.
2020-08-09Render longhand multiple crate/target features nicerWim Looman-2/+2
2020-08-09Improve rendering of crate features via doc(cfg)Wim Looman-5/+5
2020-08-08Rollup merge of #75237 - nbdd0121:rustdoc, r=jyn514Yuki Okushi-0/+54
Display elided lifetime for non-reference type in doc In edition 2018 we encourage writing `<'_>` explicitly, so rustdoc should display like such as well. Fixes #75225 ~~Somehow when I run the compiled rustdoc using `cargo +stage2 doc` on other crates, it correctly produces `<'_>`, but I couldn't get the std doc to do the same with `./x.py doc --stage 2`. Might this be related to the recent change to x.py about how the doc is built?~~
2020-08-08Cross-crate doc inlining test case for elided lifetimeGary Guo-14/+22
2020-08-07Display elided lifetime for external pathsGary Guo-0/+13
2020-08-07Display elided lifetime for non-reference type in docGary Guo-0/+33
2020-08-06Fix outdated codeJoshua Nelson-3/+3
2020-08-06Improve testsJoshua Nelson-2/+11
2020-08-05Handle projection predicates in the param env for auto-trait docsAaron Hill-0/+25
Fixes #72213 Any predicates in the param env are guaranteed to hold, so we don't need to do any additional processing of them if we come across them as sub-obligations of a different predicate. This allows us to avoid adding the same predicate to the computed ParamEnv multiple times (but with different regions each time), which causes an ambiguity error during fulfillment.
2020-08-02Don't mark associated items as traitsJoshua Nelson-0/+3
This caused the following false positive: ``` warning: unresolved link to `Default::default` --> /home/joshua/rustc2/default.rs:1:14 | 1 | /// Link to [Default::default()] | ^^^^^^^^^^^^^^^^^^ | = note: `#[warn(broken_intra_doc_links)]` on by default note: this item resolved to a trait, which did not match the disambiguator 'fn' --> /home/joshua/rustc2/default.rs:1:14 | 1 | /// Link to [Default::default()] | ^^^^^^^^^^^^^^^^^^ ```
2020-08-01Rollup merge of #74992 - lcnr:fix-generic-param-order, r=GuillaumeGomezManish Goregaokar-2/+2
fix rustdoc generic param order fixes #61292 r? @varkor cc @GuillaumeGomez
2020-07-31fix rustdoc generic param orderBastian Kauschke-2/+2
2020-07-30intra_doc_resolution_failures -> broken_intra_doc_linksManish Goregaokar-27/+27
2020-07-30Rename to intra_doc_resolution_failuresManish Goregaokar-27/+27
2020-07-29Rename usage of intra_doc_link_resolution_failureManish Goregaokar-27/+27
2020-07-29handle ConstEquate in rustdocBastian Kauschke-0/+18
2020-07-19Only skip impls of foreign unstable traitsMark Rousskov-0/+37
Previously unstable impls were skipped, which meant that any impl with an unstable method would get skipped.
2020-07-17Add test for module ambiguityManish Goregaokar-0/+18
2020-07-16Update src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rsManish Goregaokar-2/+2
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-07-16Add test for doc(hidden) intra-doc cross-crate reexportsManish Goregaokar-0/+29
2020-07-16Rollup merge of #74351 - lzutao:remove-rustc-internal-compiler-warns, ↵Manish Goregaokar-4/+6
r=Mark-Simulacrum Do not render unstable items for rustc doc See the zulip conversion: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/rustc.20doc.3A.20.22internal.20compiler.20API.22.20warns.20are.20everywhere!/near/203850782 Before: ![image](https://user-images.githubusercontent.com/15225902/87501971-9cff8780-c68a-11ea-93b4-ea53ce18a77b.png) After: ![image](https://user-images.githubusercontent.com/15225902/87501985-a7218600-c68a-11ea-81c0-a6b5b120832c.png) Nothing changes in unstable items of std: Before: ![image](https://user-images.githubusercontent.com/15225902/87502004-b7d1fc00-c68a-11ea-9224-a27a1d2a81d6.png) After: ![image](https://user-images.githubusercontent.com/15225902/87502018-c0c2cd80-c68a-11ea-9773-4c63158025cb.png) Closes #54682
2020-07-16Fix invalid lintJoshua Nelson-11/+11
intra_doc_resolution_failure is not a lint.
2020-07-16Add (broken and ignored) test for #73829Joshua Nelson-2/+4