about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2021-05-12Rollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jshaGuillaume Gomez-2/+2
Update documentation for SharedContext::maybe_collapsed_doc_value Fixes #85120. The `doc-collapse` was removed, however, the main crate is always "collapsed", meaning that this function is still needed. I updated the documentation instead to avoid misleading readers. r? `@jsha`
2021-05-12Rollup merge of #85117 - jsha:bubble-bubble-toil-and-trouble, r=GuillaumeGomezGuillaume Gomez-128/+138
Move global click handlers to per-element ones. In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplifies the code and avoids reimplementing the browser's bubbling functionality. As part of this change, change from a class to an id for help button. Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex). Demo at https://hoffman-andrews.com/rust/bubble-bubble-toil-and-trouble/std/string/struct.String.html Note: this conflicts with / depends on #85074. Once that's merged I'll rebase this and resolve conflicts. Part of #83332. Thanks to `@Manishearth` for the [suggestion to not reimplement bubbling](https://github.com/rust-lang/rust/issues/83332#issuecomment-803497509). r? `@GuillaumeGomez`
2021-05-12Use () for all_traits.Camille GILLOT-6/+5
2021-05-12Use () for privacy.Camille GILLOT-5/+3
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-28/+45
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12Fix indent in JS filesGuillaume Gomez-138/+140
2021-05-12Remove unused CSS rulesGuillaume Gomez-71/+2
2021-05-12Remove "loading content" which is now unnecessaryGuillaume Gomez-65/+8
2021-05-12Rollup merge of #85124 - jsha:trust-the-bool, r=GuillaumeGomezYuki Okushi-69/+64
rustdoc: remove explicit boolean comparisons. For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. An example of a style guide recommending this: https://airbnb.io/javascript/#comparison--shortcuts r? `@GuillaumeGomez`
2021-05-11Move global click handlers to per-element ones.Jacob Hoffman-Andrews-128/+138
In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplfies the code and avoids reimplementing the browser's bubbling functionality. As part of this change, change from a class to an id for help button. Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex).
2021-05-11rustdoc: remove explicit boolean comparisons.Jacob Hoffman-Andrews-69/+64
For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. Removed unused isType parameter from two functions.
2021-05-11Disable layout docs for type aliases for nowCamelid-2/+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-7/+26
This should prevent confusion about why generic types don't have layout docs.
2021-05-11Apply suggestions from code reviewCamelid-3/+4
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2021-05-11Add `tcx` local variableCamelid-3/+4
2021-05-11Fix a few small thingsCamelid-6/+6
2021-05-11Only show type layout info if `--show-type-layout` is passedCamelid-0/+15
2021-05-11Show memory layout for type aliasesCamelid-1/+4
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-11Include a warning in the layout docs that layout is unstableCamelid-3/+12
2021-05-11Remove FIXMECamelid-2/+4
Layout errors can occur with valid code, e.g. generic types.
2021-05-11rustdoc: Show basic type layout informationCamelid-3/+36
Right now it just shows the size.
2021-05-11Fix border radius for doc code blocks in rustdocGuillaume Gomez-2/+2
2021-05-10Rollup merge of #85148 - GuillaumeGomez:source-code-line-number, r=jshaGuillaume Gomez-19/+27
Fix source code line number display and make it clickable again Fixes https://github.com/rust-lang/rust/issues/85119. I used the same logic we're using for other codeblocks: putting the line number `<span>`s into the `example-wrap` directly and then add `display: inline-flex` on `example-wrap`. r? `@jsha`
2021-05-10Rollup merge of #85118 - GuillaumeGomez:clipboard-svg, r=Nemo157Guillaume Gomez-11/+49
Use an SVG image for clipboard instead of unicode character Linked to https://github.com/rust-lang/docs.rs/pull/1394. cc `@jsha` r? `@Nemo157`
2021-05-10Rollup merge of #84465 - jyn514:primitive, r=GuillaumeGomezGuillaume Gomez-8/+1
rustdoc: Implement `is_primitive` in terms of `primitive_type()` Previously, they disagreed about what types were primitives. r? `@GuillaumeGomez`
2021-05-10Use an SVG image for clipboard instead of unicode characterGuillaume Gomez-11/+49
2021-05-10Fix line number not being clickable on source pagesGuillaume Gomez-19/+27
2021-05-10rustc_session: Move more option building code from the `options!` macroVadim Petrochenkov-7/+3
2021-05-10Update documentation for SharedContext::maybe_collapsed_doc_valueGuillaume Gomez-2/+2
2021-05-10Auto merge of #85074 - GuillaumeGomez:end-toggle-migration, r=jshabors-217/+68
Migrate top doc and non-exhaustive toggles to details tag Fixes #83332. r? `@jsha`
2021-05-10End toggle migrationGuillaume Gomez-217/+68
2021-05-09add bootstrap cfgAliénore Bouttefeux-0/+2
2021-05-08Add `#[track_caller]` to `FakeDefId::expect_real()`Camelid-0/+1
Now, in the case that the function is not inlined, the panic location will be the caller's location, which is more helpful since the panic is not `expect_real()`'s fault.
2021-05-08Remove `FakeDefId::expect_local()`Camelid-20/+16
This function returned a fake `DefIndex`, with no indication that it was fake, when it was provided with a `FakeDefId::Fake`. Every use of the function uses the returned `DefIndex` in a call to `tcx.local_def_id_to_hir_id()`, which I'm pretty sure would panic if it were given a fake `DefIndex`. I removed the function and replaced all calls to it with a call to `expect_real()` followed by `DefId::expect_local()` (that's a function on the *real* `DefId`).
2021-05-08Auto merge of #84470 - jyn514:lints, r=GuillaumeGomezbors-8/+1
rustdoc: Stop special casing `broken_intra_doc_links` unnecessarily
2021-05-08Rollup merge of #85052 - jyn514:disambiguator, r=camelidDylan DPC-1/+4
rustdoc: Link to the docs on namespaces when an unknown disambiguator is found This was reverted in https://github.com/rust-lang/rust/pull/84950; this re-lands the changes, but without different behavior depending on the channel. r? `@camelid` cc `@pietroalbini`
2021-05-07rustdoc: Link to the docs on namespaces when an unknown disambiguator is foundJoshua Nelson-1/+4
2021-05-07Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkovDylan DPC-39/+27
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-07Rollup merge of #84953 - ↵Dylan DPC-31/+33
GuillaumeGomez:remove-unneeded-with_default_session_globals, r=jyn514 Remove unneeded call to with_default_session_globals in rustdoc highlight This was the origin of the `Span` bug in https://github.com/rust-lang/rust/pull/84176. cc `````@Aaron1011````` r? `````@jyn514`````
2021-05-05Update highlight testsGuillaume Gomez-11/+16
2021-05-05Remove unneeded call to with_default_session_globals in rustdoc highlightGuillaume Gomez-20/+17
2021-05-05Use local and remapped paths where appropriateAndy Wang-20/+18
2021-05-05Remove impl Display for FileName and add FileNameDisplay wrapper typeAndy Wang-1/+1
2021-05-05Make local_path in RealFileName::Remapped Option to be removed in exported ↵Andy Wang-16/+42
metadata
2021-05-05Rename RealFileName::Named to LocalPath and Devirtualized to RemappedAndy Wang-8/+1
2021-05-05Revert PR 83866Pietro Albini-35/+8
That PR caused multiple test failures when Rust's channel is changed from nightly to anything else. The commit will have to be landed again after the test suite is fixed.
2021-05-04rustdoc: Remove unnecessary `StripItem` wrapperJoshua Nelson-16/+9
2021-05-04Auto merge of #84707 - Stupremee:remove-fake-defids-in-rustdoc, ↵bors-255/+336
r=jyn514,GuillaumeGomez Get rid of fake `DefId`s in rustdoc Right now there are *many* errors left, but I wanted to show the current state since all that is left to do is fixing the errors. Resolves #83183 r? `@jyn514`
2021-05-04Add type to differentiate between fake and real DefId'sJustus K-255/+336
2021-05-04Auto merge of #84017 - Smittyvb:int-literal-underscores, r=jyn514bors-2/+62
Valid underscores in hex/octal/binary literal docs Currently hex/octal/binary literals with computed values are displayed like `0_xff_fff_fffu32`, which is invalid since underscores can't be in the middle of integer prefixes. This properly formats prefixed integers. This causes [`std::u32::MAX`](https://doc.rust-lang.org/std/u32/constant.MAX.html) to be displayed as ```rust pub const MAX: u32 = u32::MAX; // 0_xff_fff_fffu32 ``` This PR changes it to be displayed as: ```rust pub const MAX: u32 = u32::MAX; // 0xffff_ffffu32 ```