summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2020-11-16Add test to ensure that no DOS backline (\r\n) doesn't create extra backline ↵Guillaume Gomez-14/+27
in source rendering
2020-11-16Ensure that the source code display is working with DOS backlineGuillaume Gomez-0/+2
2020-10-02Rollup merge of #76811 - GuillaumeGomez:doc-alias-name-restriction, ↵Jonas Schievink-1/+1
r=oli-obk,ollie27 Doc alias name restriction Fixes #76705.
2020-10-02Remove unneeded replaceGuillaume Gomez-1/+1
2020-09-29Auto merge of #77253 - jyn514:crate-link, r=Manishearthbors-1/+12
Resolve `crate` in intra-doc links properly across crates Closes https://github.com/rust-lang/rust/issues/77193; see https://github.com/rust-lang/rust/issues/77193#issuecomment-699065946 for an explanation of what's going on here. ~~This also fixes the BTreeMap docs that have been broken for a while; see the description on the second commit for why and how.~~ Nope, see the second commit for why the link had to be changed. r? `@Manishearth` cc `@dylni` `@dylni` note that this doesn't solve your original problem - now _both_ `with_code` and `crate::with_code` will be broken links. However this will fix a lot of other broken links (in particular I think https://docs.rs/sqlx/0.4.0-beta.1/sqlx/query/struct.Query.html is because of this bug). I'll open another issue for resolving additional docs in the new scope.
2020-09-28Rollup merge of #76474 - bjorn3:driver_selected_codegen, r=oli-obkRalf Jung-0/+2
Add option to pass a custom codegen backend from a driver This allows the driver to pass information to the codegen backend. For example the headcrab debugger may in the future want to use cg_clif to JIT code to be injected in the debuggee. This would PR make it possible to tell cg_clif which symbol can be found at which address and to tell it to inject the JITed code into the right process. This PR may also help with https://github.com/rust-lang/miri/pull/1540 by allowing miri to provide a codegen backend that only emits metadata and doesn't perform any codegen. cc @nbaksalyar (headcrab) cc @RalfJung (miri)
2020-09-27Resolve `crate` properly across cratesJoshua Nelson-1/+12
2020-09-27Separate `private_intra_doc_links` and `broken_intra_doc_links` into ↵Joshua Nelson-8/+13
separate lints This is not ideal because it means `deny(broken_intra_doc_links)` will no longer `deny(private_intra_doc_links)`. However, it can't be fixed with a new lint group, because `broken` is already in the `rustdoc` lint group; there would need to be a way to nest groups somehow. This also removes the early `return` so that the link will be generated even though it gives a warning.
2020-09-27Add option to pass a custom codegen backend from a driverbjorn3-0/+2
2020-09-27Auto merge of #76955 - jyn514:refactor-diagnostics, r=eucliobors-231/+204
Refactor and fix intra-doc link diagnostics, and fix links to primitives Closes https://github.com/rust-lang/rust/issues/76925, closes https://github.com/rust-lang/rust/issues/76693, closes https://github.com/rust-lang/rust/issues/76692. Originally I only meant to fix #76925. But the hack with `has_primitive` was so bad it was easier to fix the primitive issues than to try and work around it. Note that this still has one bug: `std::primitive::i32::MAX` does not resolve. However, this fixes the ICE so I'm fine with fixing the link in a later PR. This is part of a series of refactors to make #76467 possible. This is best reviewed commit-by-commit; it has detailed commit messages. r? `@euclio`
2020-09-25Rename `whence` to `span`Camelid-53/+53
It's called `span` elsewhere in the compiler and `span` is also less surprising. `whence` is whimsical, but not super clear :)
2020-09-25Rollup merge of #75438 - Cldfire:rustdoc/use-adaptive-svg-favicon, ↵Jonas Schievink-4/+34
r=GuillaumeGomez Use adaptive SVG favicon for rustdoc like other rust sites Use the theme-adaptive SVG favicon that was recently introduced [for the Rust site](https://github.com/rust-lang/www.rust-lang.org/pull/1185) (and others). (This PR is simply copied from the PR linked above, so see that for rationale.) Closes #72165. Before, Firefox on Linux: ![image](https://user-images.githubusercontent.com/13814214/89971811-34c0a900-dc2a-11ea-9aa6-a4aa9d66bed4.png) After, Firefox on Linux (`prefers-color-scheme` set to `dark` by setting `ui.systemUsesDarkTheme` to a number value of `1` in `about:config`): ![image](https://user-images.githubusercontent.com/13814214/89971842-515ce100-dc2a-11ea-92e8-c374aaaf6031.png)
2020-09-24Auto merge of #74430 - Manishearth:stabilize-intra-doc, r=Manishearthbors-8/+2
Stabilize intra-doc links Fixes https://github.com/rust-lang/rust/issues/43466 Thanks to the great work of `@jyn514` in getting the [cross-crate reexport issue](https://github.com/rust-lang/rust/issues/65983) in intra-rustdoc links fixed, I think we're now in a position to stabilize this feature. The tracking issue currently has two unresolved issues: - <s>behavior around doc(hidden): This is fixed in https://github.com/rust-lang/rust/pull/73365, which is just waiting for CI and should land tomorrow. It's also a pretty niche bug so while I expect it to land soon I don't think we need to block stabilization on it anyway.</s> - Non-identifier primitive types like slices: This was not a part of the original RFC anyway, and is a pretty niche use case The feature itself, sans https://github.com/rust-lang/rust/issues/65983, has been shipped on nightly for three years now, with people using it on docs.rs. https://github.com/rust-lang/rust/issues/65983 itself is not an overwhelmingly central bit of functionality; the reason we elected to block stabilization on it was that back in 2017 it was not possible to fix the issue without some major refactorings of resolve, and we did not want to stabilize something that had such a potentially unfixable bug. Given that we've fixed it, I see no reason to delay stabilization on this long awaited feature. It's possible that the latest patches have problems, however we _have_ done crater runs of some of the crucial parts. Furthermore, that's what the release trains are for, we will have a solid three months to let it ride the trains before it actually hits the stable compiler. r? `@rust-lang/rustdoc`
2020-09-23Use theme-adaptive SVG favicon from other Rust sitesJarek Samic-4/+34
2020-09-23Unify primitive errors with other intra-link errorsJoshua Nelson-34/+14
Now that `PrimTy::name()` exists, there's no need to carry around the name of the primitive that failed to resolve. This removes the variants special-casing primitives in favor of `NotResolved`. - Remove `NoPrimitiveImpl` and `NoPrimitiveAssocItem` - Remove hacky `has_primitive` check in `resolution_failure()` - Fixup a couple tests that I forgot to `--bless` before
2020-09-23Fix intra-doc links for primitivesJoshua Nelson-6/+14
- Add `PrimTy::name` and `PrimTy::name_str` - Use those new functions to distinguish between the name in scope and the canonical name - Fix diagnostics for primitive types - Add tests for primitives
2020-09-23Perform most diagnostic lookups in `resolution_failure`Joshua Nelson-206/+191
Previously, these were spread throughout the codebase. This had two drawbacks: 1. It caused the fast path to be slower: even if a link resolved, rustdoc would still perform various lookups for the error diagnostic. 2. It was inconsistent and didn't always give all diagnostics (https://github.com/rust-lang/rust/issues/76925) Now, diagnostics only perform expensive lookups in the error case. Additionally, the error handling is much more consistent, both in wording and behavior. - Remove `CannotHaveAssociatedItems`, `NotInScope`, `NoAssocItem`, and `NotAVariant` in favor of the more general `NotResolved` `resolution_failure` will now look up which of the four above categories is relevant, instead of requiring the rest of the code to be consistent and accurate in which it picked. - Remove unnecessary lookups throughout the intra-doc link pass. These are now done by `resolution_failure`. + Remove unnecessary `extra_fragment` argument to `variant_field()`; it was only used to do lookups on failure. + Remove various lookups related to associated items + Remove distinction between 'not in scope' and 'no associated item' - Don't perform unnecessary copies - Remove unused variables and code - Update tests - Note why looking at other namespaces is still necessary - 'has no inner item' -> 'contains no item' bless tests
2020-09-21Rollup merge of #76783 - lzutao:rd_impl_kind, r=GuillaumeGomezecstatic-morse-19/+22
Only get ImplKind::Impl once With this, the code panics in one place instead of two.
2020-09-18Auto merge of #76782 - lzutao:rd-cap, r=jyn514bors-6/+8
Specialize merge_attrs in good case Just a non-important micro-optimization. r? `@jyn514`
2020-09-18Calculate more correct capacity in merge_attrsLzu Tao-6/+8
Co-authored-by: jyn514 <joshua@yottadb.com>
2020-09-16Rollup merge of #76728 - jyn514:rustdoc-extern-crate, r=ehussTyler Mandry-2/+10
Add a comment why `extern crate` is necessary for rustdoc r? @ehuss From https://github.com/rust-lang/rust/pull/74293#discussion_r488335500.
2020-09-16Rollup merge of #76642 - GuillaumeGomez:ignored-private-doc-test, r=jyn514Tyler Mandry-10/+6
Do not lint ignored private doc tests Fixes #76457. r? @ehuss
2020-09-16Only get ImplKind::Impl onceLzu Tao-19/+22
2020-09-16Rollup merge of #76641 - nox:pointee-random-stuff, r=eddybRalf Jung-1/+1
Some cleanup changes and commenting r? @nikomatsakis Cc @eddyb
2020-09-16Rollup merge of #76689 - jyn514:update-pulldown, r=GuillaumeGomezDylan DPC-17/+21
Upgrade to pulldown-cmark 0.8.0 Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs! - Get rid of unnecessary `RefCell` - Fix duplicate warnings for broken implicit reference link - Remove unnecessary copy of links Closes https://github.com/rust-lang/rust/issues/73264, closes https://github.com/rust-lang/rust/issues/76687. r? @euclio I'm not sure if the switch away from `locate` fixes any open bugs - euclio mentioned some in https://github.com/raphlinus/pulldown-cmark/issues/165, but I didn't see any related issues open for rustdoc. Let me know if I missed one.
2020-09-15Add a comment why rustdoc loads crates from the sysrootJoshua Nelson-1/+5
2020-09-15Auto merge of #76684 - jyn514:refactor-intra-links, r=manishearthbors-631/+659
Refactor intra doc link code I got tired of `fold_item` being 500 lines long. This is best reviewed one commit at a time with whitespace changes hidden. There are no logic changes other than the last commit making a parameter checked by the caller instead of the callee. r? `@Manishearth`
2020-09-14Add a comment why `extern crate` is necessary for rustdocJoshua Nelson-2/+6
2020-09-14Auto merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514bors-9/+10
Ignore rustc_private items from std docs By ignoring rustc_private items for non local impl block, this may fix #74672 and fix #75588 . This might suppress #76529 if it is simple enough for backport.
2020-09-13Use `.as_str()` instead of `CowStr::Borrowed`Joshua Nelson-2/+2
2020-09-13Don't use `link.span` yetJoshua Nelson-1/+3
This shows the span of the _whole_ link, including the brackets. But rustdoc only wants to warn about the link text.
2020-09-13Stabilize intra-doc linksManish Goregaokar-8/+2
2020-09-13Upgrade to pulldown-cmark 0.8.0Joshua Nelson-17/+19
Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs! - Get rid of unnecessary `RefCell` - Fix duplicate warnings for broken implicit reference link - Remove unnecessary copy of links
2020-09-13Require `module_id` param to `resolve` to be non-emptyJoshua Nelson-295/+279
Previously, `resolve` would immediately check that `module_id` was non-empty and give an error if not. This had two downsides: - It introduced `Option`s everywhere, even if the calling function knew it had a valid module, and - It checked the module on each namespace, which is unnecessary: it only needed to be checked once. This makes the caller responsible for checking the module exists, making the code a lot simpler.
2020-09-13Refactor `resolve_with_disambiguator` into a separate functionJoshua Nelson-163/+190
2020-09-13allow concrete self types in constsBastian Kauschke-1/+1
2020-09-13Refactor `resolve_link` into a separate functionJoshua Nelson-325/+342
2020-09-13Auto merge of #76244 - vandenheuvel:remove__paramenv__def_id, r=nikomatsakisbors-1/+2
Removing the `def_id` field from hot `ParamEnv` to make it smaller This PR addresses https://github.com/rust-lang/rust/issues/74865.
2020-09-13Auto merge of #76623 - slightlyoutofphase:master, r=jyn514bors-5/+7
Use `is_unstable_const_fn` instead of `is_min_const_fn` in rustdoc where appropriate This closes #76501. Specifically, it allows for nightly users with the `#![feature(const_fn)]` flag enabled to still have their `const fn` declarations documented as such, while retaining the desired behavior that rustdoc *not* document functions that have the `rustc_const_unstable` attribute as `const`.
2020-09-13Ignore rustc_private items from std docsLzu Tao-9/+10
Apply suggestions from code review Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-12Don't emit an error on private doc tests when they're ignoredGuillaume Gomez-10/+6
2020-09-12Fix a typoAnthony Ramine-1/+1
2020-09-12Auto merge of #76632 - andjo403:updateDep, r=Mark-Simulacrumbors-1/+1
update the version of itertools and parking_lot this is to avoid compiling multiple version of the crates in rustc speeding up compilation of rustc an old version of parking_lot is still used in measureme but new version will not be released for some time see [zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/new.20release.20of.20measureme)
2020-09-12Rollup merge of #76297 - lcnr:const-ty-alias, r=varkorRalf Jung-10/+10
rustdoc: fix min_const_generics with ty::Param fixes #75913 r? @varkor cc @jyn514
2020-09-12update the version of itertools and parking_lotAndreas Jonson-1/+1
this is to avoid compiling multiple version of the crates in rustc
2020-09-12Auto merge of #75756 - jyn514:diagnostic-suggestions, r=estebankbors-167/+600
Improve suggestions for broken intra-doc links ~~Depends on #74489 and should not be merged before that PR.~~ Merged 🎉 ~~Depends on #75916 and should not be merged before.~~ Merged Fixes https://github.com/rust-lang/rust/issues/75305. This does a lot of different things 😆. - Add `PerNS::into_iter()` so I didn't have to keep rewriting hacks around it. Also add `PerNS::iter()` for consistency. Let me know if this should be `impl IntoIterator` instead. - Make `ResolutionFailure` an enum instead of a unit variant. This was most of the changes: everywhere that said `ErrorKind::ResolutionFailure` now has to say _why_ the link failed to resolve. - Store the resolution in case of an anchor failure. Previously this was implemented as variants on `AnchorFailure` which was prone to typos and had inconsistent output compared to the rest of the diagnostics. - Turn some `Err`ors into unwrap() or panic()s, because they're rustdoc bugs and not user error. These have comments as to why they're bugs (in particular this would have caught #76073 as a bug a while ago). - If an item is not in scope at all, say the first segment in the path that failed to resolve - If an item exists but not in the current namespaces, say that and suggests linking to that namespace. - If there is a partial resolution for an item (part of the segments resolved, but not all of them), say the partial resolution and why the following segment didn't resolve. - Add the `DefId` of associated items to `kind_side_channel` so it can be used for diagnostics (tl;dr of the hack: the rest of rustdoc expects the id of the item, but for diagnostics we need the associated item). - No longer suggests escaping the brackets for every link that failed to resolve; this was pretty obnoxious. Now it only suggests `\[ \]` if no segment resolved and there is no `::` in the link. - Add `Suggestion`, which says _what_ to prefix the link with, not just 'prefix with the item kind'. Places where this is currently buggy: <details><summary>All outdated</summary> ~~1. When the link has the wrong namespace:~~ Now fixed. <details> ```rust /// [type@S::h] impl S { pub fn h() {} } /// [type@T::g] pub trait T { fn g() {} } ``` ``` error: unresolved link to `T::g` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:53:6 | 53 | /// [type@T::g] | ^^^^^^^^^ | = note: this link partially resolves to the trait `T`, = note: `T` has no field, variant, or associated item named `g` error: unresolved link to `S::h` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:48:6 | 48 | /// [type@S::h] | ^^^^^^^^^ | = note: this link partially resolves to the struct `S`, = note: `S` has no field, variant, or associated item named `h` ``` Instead it should suggest changing the disambiguator, the way it currently does for macros: ``` error: unresolved link to `S` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:38:6 | 38 | /// [S!] | ^^ help: to link to the unit struct, use its disambiguator: `value@S` | = note: this link resolves to the unit struct `S`, which is not in the macro namespace ``` </details> 2. ~~Associated items for values. It says that the value isn't in scope; instead it should say that values can't have associated items.~~ Fixed. <details> ``` error: unresolved link to `f::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:14:6 | 14 | /// [f::A] | ^^^^ | = note: no item named `f` is in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` ``` This is _mostly_ fixed, it now says ```rust warning: unresolved link to `f::A` --> /home/joshua/test-rustdoc/f.rs:1:6 | 1 | /// [f::A] | ^^^^ | = note: this link partially resolves to the function `f` = note: `f` is a function, not a module ``` 'function, not a module' seems awfully terse when what I actually mean is '`::` isn't allowed here', though. </details> It looks a lot nicer now, it says ``` error: unresolved link to `f::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:13:6 | 13 | /// [f::A] | ^^^^ | = note: `f` is a function, not a module or type, and cannot have associated items ``` 3. ~~I'm also not very happy with the second note for this error:~~ <details> ``` error: unresolved link to `S::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:19:6 | 19 | /// [S::A] | ^^^^ | = note: this link partially resolves to the struct `S`, = note: `S` has no field, variant, or associated item named `A` ``` but I'm not sure how better to word it. I ended up going with 'no `A` in `S`' to match `rustc_resolve` but that seems terse as well. </details> This now says ``` error: unresolved link to `S::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:17:6 | 17 | /// [S::A] | ^^^^ | = note: the struct `S` has no field or associated item named `A` ``` which I think looks pretty good :) 4. This is minor, but it would be nice to say that `path` wasn't found instead of the full thing: ``` error: unresolved link to `path::to::nonexistent::module` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:8:6 | 8 | /// [path::to::nonexistent::module] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` It will now look at most 3 paths up (so it reports `path::to` as not in scope), but it doesn't work with arbitrarily many paths. </details> ~~I recommend only reviewing the last few commits - the first 7 are all from #74489.~~ Rebased so that only the relevant commits are shown. Let me know if I should squash the history some more. r? `@estebank`
2020-09-11Fix formatting for tidySlightlyOutOfPhase-1/+2
2020-09-11Check basic constness before unstable constnessSlightlyOutOfPhase-2/+3
2020-09-11Use `is_unstable_const_fn` where appropriateSlightlyOutOfPhase-5/+5
2020-09-11Name the current moduleJoshua Nelson-2/+3
'not in scope' -> 'not in `module`'