about summary refs log tree commit diff
path: root/src/test/rustdoc
AgeCommit message (Collapse)AuthorLines
2021-05-16Add test for trait toggle locationJacob Hoffman-Andrews-0/+7
2021-05-11Disable layout docs for type aliases for nowCamelid-4/+0
There are issues with computing layout for type aliases; see #85103. Once the issues are fixed, we should re-enable layout docs for them.
2021-05-11Add note to docs when layout cannot be computedCamelid-1/+9
This should prevent confusion about why generic types don't have layout docs.
2021-05-11Add test case for zero-sized typesCamelid-0/+4
2021-05-11Make test more specificCamelid-1/+1
2021-05-11Only show type layout info if `--show-type-layout` is passedCamelid-0/+6
2021-05-11Show memory layout for type aliasesCamelid-1/+2
At first you might think "why not just click through to the aliased type?", but if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute the layout of a generic type). So I think it's still useful to show layout info for type aliases.
2021-05-11Add test for memory layout informationCamelid-0/+43
2021-05-10Auto merge of #85074 - GuillaumeGomez:end-toggle-migration, r=jshabors-10/+10
Migrate top doc and non-exhaustive toggles to details tag Fixes #83332. r? `@jsha`
2021-05-10Update rustdoc testGuillaume Gomez-10/+10
2021-05-07Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkovDylan DPC-0/+8
Unify rustc and rustdoc parsing of `cfg()` This extracts a new `parse_cfg` function that's used between both. - Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)] #[doc(cfg(y))]`. Previously it would be completely ignored. - Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)] #[doc(cfg(x))]`. Previously, the cfg would be ignored. - Pass the cfg predicate through to rustc_expand to be validated Technically this is a breaking change, but doc_cfg is still nightly so I don't think it matters. Fixes https://github.com/rust-lang/rust/issues/84437. r? `````````@petrochenkov`````````
2021-05-03Make match in `register_res` easier to readJoshua Nelson-0/+4
- Don't duplicate DefKind -> ItemType handling; that's a good way to get bugs - Use exhaustive match - Add comments This found that register_res is very wrong in at least one way: if it registers a Res for `Variant`, it should also register one for `Field`. But I don't know whether the one for Variant should be removed or Field added. Maybe someone has ideas?
2021-05-03Unify rustc and rustdoc parsing of `cfg()`Joshua Nelson-0/+8
This extracts a new `parse_cfg` function that's used between both. - Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)] #[doc(cfg(y))]`. Previously it would be completely ignored. - Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)] #[doc(cfg(x))]`. Previously, the cfg would be ignored. - Pass the cfg predicate through to rustc_expand to be validated Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-05-03Rollup merge of #84832 - Stupremee:dont-print-vis-in-external-traits, r=jyn514Dylan DPC-0/+11
Do not print visibility in external traits This PR fixes the bug that caused traits, which were re-exported, having visibility modifiers in front of methods, which is invalid. It would be nice to add a test for this, but I don't even know if tests with multiple crates are possible. Resolves #81274
2021-05-03Rollup merge of #84811 - scottmcm:rustdoc-trait-alias-fix, r=jyn514Dylan DPC-0/+15
RustDoc: Fix bounds linking trait.Foo instead of traitalias.Foo Fixes #84782 The code was assuming `Trait` when adding bounds to the cache, so add a check on the DefId to see what its kind really is. r? `@jyn514` Before: ![image](https://user-images.githubusercontent.com/18526288/116775611-6a751e80-aa53-11eb-84d0-ed6b7782be3c.png) After: ![image](https://user-images.githubusercontent.com/18526288/116802227-d19cdc80-ab00-11eb-8133-7b34dd750da2.png)
2021-05-02PR feedbackScott McMurray-5/+9
2021-05-02Do not print visibility in external traitsJustus K-0/+11
2021-05-02Update testsGuillaume Gomez-30/+42
2021-05-01RustDoc: Fix bounds linking trait.Foo instead of traitalias.FooScott McMurray-0/+11
2021-04-28rustdoc: update auto_aliases test case with data-aliases attributeMichael Howell-1/+1
2021-04-27Update impl DOM testGuillaume Gomez-5/+5
2021-04-27Add test for new DOM for empty implsGuillaume Gomez-0/+19
2021-04-24Rollup merge of #84320 - jsha:details-implementors, ↵Yuki Okushi-42/+42
r=Manishearth,Nemo157,GuillaumeGomez Use details tag for trait implementors. Part of #83332 and following on from #83337 and #83355. This removes one category of JS-generated toggles (implementors), and replaces them with a `<details>` tag. This simplifies the JS, and fixes some bugs where things that were supposed to be hidden by the toggle were not hidden. Compare https://hoffman-andrews.com/rust/details-implementors/std/io/trait.Read.html#impl-Read vs https://doc.rust-lang.org/nightly/std/io/trait.Read.html#implementors. This introduces a `left: -23px` to put the toggle in the correct place, matching the current style for `.collapse-toggle`. It's worth noting this introduces a slight behavior change: since the entire line is now a `<summary>`, any part of the line is clickable. So for instance, in `impl Read for File`, clicking `impl` or `for` will collapse / expand the docs. Clicking `Read` or `File` still links to the appropriate documentation as before.
2021-04-24Rollup merge of #84321 - Swatinem:subvariant-details, r=GuillaumeGomezYuki Okushi-1/+2
rustdoc: Convert sub-variant toggle to HTML Instead of creating a JS toggle, this injects details/summary for sub-variants of enums. This also fixes the CSS so that the toggle button does not jump when expanding/collapsing. Takes inspiration from #83337 and should be considered part of #83332. Not quite sure if the `.sub-variant` selectors could be further simplified? AFAICS it is only used in that place, and that does not seem to allow any recursion.
2021-04-20Just merge all of the <title> tests into oneSmitty-7/+8
2021-04-20Add test for title of root page in item-title.rsSmitty-3/+2
2021-04-20Merge mod-title and item-title testsSmitty-12/+1
2021-04-20Write Rustdoc titles like "x in crate::mod - Rust"Smitty-0/+48
This makes Rustdoc titles for items read like "x in cratename::blah::foo - Rust". Title for modules and other non-items are unchanged, and still read like "doccratenameconst::blah::foo - Rust". This makes managing several open Rustdoc tabs easier. Closes #84371.
2021-04-19rustdoc: use details tag for trait implementorsJacob Hoffman-Andrews-42/+42
This switches from JS-generated toggles to using the HTML <details> tag for expanding and collapsing entries in the "Implementors" section.
2021-04-19rustdoc: Convert sub-variant toggle to HTMLArpad Borsos-1/+2
Instead of creating a JS toggle, this injects details/summary for sub-variants of enums. This also fixes the CSS so that the toggle button does not jump when expanding/collapsing.
2021-04-18Test Deprecated, Portability, and Unstable.Tor Hovland-3/+76
2021-04-18Now also displays portability tags.Tor Hovland-7/+22
2021-04-18Added a test.Tor Hovland-0/+21
2021-04-17rustdoc: use more precise relative URLSMichael Howell-135/+150
Instead of using a depth counter and adding "../" to get to the top, this commit makes rustdoc actually compare the path of what it's linking from to the path that it's linking to. This makes the resulting HTML shorter. Here's a comparison of one of the largest (non-source) files in the Rust standard library docs (about 4% improvement before gzipping). $ wc -c struct.Wrapping.old.html struct.Wrapping.new.html 2387389 struct.Wrapping.old.html 2298538 struct.Wrapping.new.html Most if it can be efficiently gzipped away. $ wc -c struct.Wrapping.old.html.gz struct.Wrapping.new.html.gz 70679 struct.Wrapping.old.html.gz 70050 struct.Wrapping.new.html.gz But it also makes a difference in the final DOM size, reducing it from 91MiB to 82MiB.
2021-04-16Auto merge of #84074 - notriddle:rustdoc-macro-visibility, r=jyn514bors-0/+17
rustdoc: clean up and test macro visibility print This fixes the overly-complex invariant mentioned in <https://github.com/rust-lang/rust/pull/83237#issuecomment-815346570>, where the macro source can't have any links in it only because the cache hasn't been populated yet.
2021-04-16Rollup merge of #83337 - Manishearth:item-hide, r=GuillaumeGomezDylan DPC-8/+163
rustdoc: Hide item contents, not items This tweaks rustdoc to hide item contents instead of items, and only when there are too many of them. This means that users will _always_ see the type parameters, and will _often_ see fields/etc as long as they are small. Traits have some heuristics for hiding only the methods or only the methods and the consts, since the associated types are super important. I'm happy to play around with the heuristics here; we could potentially make it so that structs/enums/etc are always hidden but traits will try really hard to show type aliases. This needs a test, but you can see it rendered at https://manishearth.net/sand/doc_render/bar/ <details> <summary> Code example </summary> ```rust pub struct PubStruct { pub a: usize, pub b: usize, } pub struct BigPubStruct { pub a: usize, pub b: usize, pub c: usize, pub d: usize, pub e: usize, pub f: usize, } pub union BigUnion { pub a: usize, pub b: usize, pub c: usize, pub d: usize, pub e: usize, pub f: usize, } pub union Union { pub a: usize, pub b: usize, pub c: usize, } pub struct PrivStruct { a: usize, b: usize, } pub enum Enum { A, B, C, D { a: u8, b: u8 } } pub enum LargeEnum { A, B, C, D, E, F, G, H, I, J } pub trait Trait { type A; #[must_use] fn foo(); fn bar(); } pub trait GinormousTrait { type A; type B; type C; type D; type E; type F; const N: usize = 1; #[must_use] fn foo(); fn bar(); } pub trait HugeTrait { type A; const M: usize = 1; const N: usize = 1; const O: usize = 1; const P: usize = 1; const Q: usize = 1; #[must_use] fn foo(); fn bar(); } pub trait BigTrait { type A; #[must_use] fn foo(); fn bar(); fn baz(); fn quux(); fn frob(); fn greeble(); } #[macro_export] macro_rules! foo { (a) => {a}; } ``` </details> Fixes https://github.com/rust-lang/rust/issues/82114
2021-04-13remove line length ignoreFrançois Mockers-2/+0
2021-04-13forgot test assertions for default methodFrançois Mockers-0/+2
2021-04-13add testFrançois Mockers-0/+65
2021-04-12Update attribute testsManish Goregaokar-8/+8
2021-04-12Add test for item hidingManish Goregaokar-0/+155
2021-04-10Preprocess intra-doc links consistentlyJoshua Nelson-1/+14
Previously, rustdoc would panic on links to external crates if they were surrounded by backticks.
2021-04-10rustdoc: clean up and test macro visibility printMichael Howell-0/+17
This fixes the overly-complex invariant mentioned in <https://github.com/rust-lang/rust/pull/83237#issuecomment-815346570>, where the macro source can't have any links in it only because the cache hasn't been populated yet.
2021-04-06Rollup merge of #83849 - jyn514:intra-doc-cleanup, r=bugadaniYuki Okushi-2/+13
rustdoc: Cleanup handling of associated items for intra-doc links Helps with https://github.com/rust-lang/rust/issues/83761 (right now the uses of the resolver are all intermingled with uses of the tyctxt). Best reviewed one commit at a time. r? ```@bugadani``` maybe? Feel free to reassign :)
2021-04-05Use more appropriate return type for `resolve_associated_item`Joshua Nelson-2/+13
Previously, the types looked like this: - None means this is not an associated item (but may be a variant field) - Some(Err) means this is known to be an error. I think the only way that can happen is if it resolved and but you had your own anchor. - Some(Ok(_, None)) was impossible. Now, this returns a nested Option and does the error handling and fiddling with the side channel in the caller. As a side-effect, it also removes duplicate error handling. This has one small change in behavior, which is that `resolve_primitive_associated_item` now goes through `variant_field` if it fails to resolve something. This is not ideal, but since it will be quickly rejected anyway, I think the performance hit is worth the cleanup. This also fixes a bug where struct fields would forget to set the side channel, adds a test for the bug, and ignores `private_intra_doc_links` in rustc_resolve (since it's always documented with --document-private-items).
2021-04-05Rollup merge of #83865 - camelid:disamb-err-fix, r=jyn514Dylan DPC-0/+6
Don't report disambiguator error if link would have been ignored Fixes #83859. This prevents us from warning on links such as `<hello@example.com>`. Note that we still warn on links such as `<hello@localhost>` because they have no dots in them. However, the links will still work, even though a warning is reported. r? ````@jyn514````
2021-04-05Rollup merge of #83863 - eggyal:issue-83852, r=jyn514Dylan DPC-0/+10
Render destructured struct function param names as underscore Fixes #83852 r? ````@GuillaumeGomez````
2021-04-05Renamed testAlan Egerton-0/+0
2021-04-04Don't report disambiguator error if link would have been ignoredCamelid-0/+6
This prevents us from warning on links such as `<hello@example.com>`. Note that we still warn on links such as `<hello@localhost>` because they have no dots in them. However, the links will still work, even though a warning is reported.
2021-04-04Render destructured struct function param names as underscore.Alan Egerton-0/+10
Fixes #83852 r? `@GuillaumeGomez`