about summary refs log tree commit diff
path: root/src/librustdoc/passes/doc_test_lints.rs
AgeCommit message (Collapse)AuthorLines
2021-10-02rustdoc: Improve doctest pass's name and module's nameNoah Lev-141/+0
As the docs at the top of the file say, it is an overloaded pass and actually runs two lints.
2021-09-17Don't lint about missing code examples in derived traitsHans-0/+1
Fixes #81775
2021-09-09Allow missing code examples in trait impls.Hans Niklas Jacob-0/+20
2021-07-05Revert "rustdoc: Store DefId's in ItemId on heap for decreasing Item's size"Justus K-1/+1
This reverts commit 41a345d4c46dad1a98c9993bc78513415994e8ba.
2021-07-05rustdoc: Store DefId's in ItemId on heap for decreasing Item's sizeJustus K-1/+1
2021-07-05rustdoc: Rename `expect_real` to `expect_def_id`, remove `Item::is_fake`Justus K-4/+5
2021-05-08Remove `FakeDefId::expect_local()`Camelid-1/+3
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-04Add type to differentiate between fake and real DefId'sJustus K-2/+3
2021-04-24Add attr_span helper functionJoshua Nelson-3/+3
2021-03-21Rename `clean::Span::span()` to `clean::Span::inner()`Camelid-2/+2
Otherwise you get a lot of instances of `item.span.span()`, which is just plain confusing. `item.span.inner()` conveys the correct meaning of "get the type that `clean::Span` wraps".
2021-03-21Rename `clean::Item.source` to `span`Camelid-2/+2
Its type is called `clean::Span`, and also the name in the rest of rustdoc and rustc for this kind of field is `span`.
2021-03-07Rollup merge of #82402 - jyn514:module-cache-refcell, r=GuillaumeGomezYuki Okushi-1/+1
Remove RefCell around `module_trait_cache` This builds on https://github.com/rust-lang/rust/pull/82018 and should not be merged before. ## Don't require a `DocContext` for `report_diagnostic` This is needed for the next commit, which needs mutable access to the `cx` from within the `decorate` closure. - Change `as_local_hir_id` to an associated function, since it only needs a `TyCtxt` - Change `source_span_for_markdown_range` to only take a `TyCtxt` ## Remove RefCell around module_trait_cache This is mostly just changing lots of functions from `&DocContext` to `&mut DocContext`.
2021-03-05Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make ↵Guillaume Gomez-1/+1
transition over hir::ItemKind simpler
2021-03-04Use cache access levelsGuillaume Gomez-1/+1
2021-03-04No more need for borrow callGuillaume Gomez-1/+1
2021-03-04Pass TyCtxt directly instead of DocContext in ↵Guillaume Gomez-1/+1
librustdoc::visit_ast::inherits_doc_hidden
2021-03-04Move visibility check inside the should_have_doc_example functionGuillaume Gomez-17/+17
2021-03-04Don't warn for `missing_doc_examples` when item is #[doc(hidden)]Guillaume Gomez-1/+10
2021-03-04Don't require a `DocContext` for `report_diagnostic`Joshua Nelson-1/+1
This is needed for the next commit, which needs access to the `cx` from within the `decorate` closure. - Change `as_local_hir_id` to an associated function, since it only needs a `TyCtxt` - Change `source_span_for_markdown_range` to only take a `TyCtxt`
2021-03-04Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomezYuki Okushi-4/+3
Make rustdoc lints a tool lint instead of built-in - Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` (and similar for other rustdoc lints; I don't expect any others to be used frequently, though). - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests - Move lint machinery into a separate file - Add `declare_rustdoc_lint!` macro Unblocks https://github.com/rust-lang/rust/pull/80300, https://github.com/rust-lang/rust/pull/79816, https://github.com/rust-lang/rust/pull/80965. Makes the strangeness in https://github.com/rust-lang/rust/pull/77364 more apparent to the end user (note that `missing_docs` is *not* moved to rustdoc in this PR). Closes https://github.com/rust-lang/rust/issues/78786. ## Current status This is blocked on #82620 (see https://github.com/rust-lang/rust/pull/80527#issuecomment-787401519)
2021-03-01Move lint machinery into a separate fileJoshua Nelson-3/+3
2021-03-01Rename rustdoc lints to be a tool lint instead of built-in.Joshua Nelson-4/+3
- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests Otherwise, all `rustdoc::` lints would be ignored. - Register all existing lints as removed This unfortunately doesn't work with `register_renamed` because tool lints have not yet been registered when rustc is running. For similar reasons, `check_backwards_compat` doesn't work either. Call `register_removed` directly instead. - Fix fallout + Rustdoc lints for compiler/ + Rustdoc lints for library/ Note that this does *not* suggest `rustdoc::broken_intra_doc_links` for `rustdoc::intra_doc_link_resolution_failure`, since there was no time when the latter was valid.
2021-03-01Remove the dummy cache in `DocContext`Joshua Nelson-1/+1
The same information is available everywhere; the only reason the dummy cache was needed is because it waas previously stored in three different places. This consolidates the info a bit so the cache in `DocContext` is used throughout. As a bonus, it means `renderinfo` is used much much less. - Return a `Cache` from `run_global_ctxt`, not `RenderInfo` - Remove the unused `render_info` from `run_renderer` - Remove RefCell around `inlined` - Add intra-doc links
2021-02-22Remove many RefCells from DocContextCamelid-2/+1
I left some of them so this change doesn't balloon in size and because removing the RefCell in `DocContext.resolver` would require compiler changes. Thanks to `@jyn514` for making this a lot easier with #82020!
2021-02-16Take `&mut DocContext` in passesJoshua Nelson-11/+4
This should hopefully allow for less interior mutability.
2021-02-04Cleanup rustdoc pass descriptions a bitCamelid-2/+2
Also changed a couple of comments from "intra-doc-links" to "intra-doc links" (my understanding is that "intra-doc links" is the standard way to refer to them).
2020-12-29Auto merge of #80014 - jyn514:box-item-kind, r=nnethercotebors-1/+1
[rustdoc] Box ItemKind to reduce the size of `Item` This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 536 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 136 ``` This is an alternative to https://github.com/rust-lang/rust/pull/79967; I don't think it makes sense to make both changes. Helps with #79103.
2020-12-23Box ItemKind to reduce the size of `Item`Joshua Nelson-1/+1
This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280 ```
2020-12-21Rename rustc_middle::lint::LintSourcepierwill-2/+2
Rename rustc_middle::lint::LintSource to rustc_middle::lint::LintLevelSource.
2020-12-16Replace String with Symbol where possibleGuillaume Gomez-11/+12
2020-11-22Make `fold_item_recur` non-nullableJoshua Nelson-1/+1
This gets rid of a bunch of `unwrap()`s and makes it a little more clear what's going on. Originally I wanted to make `fold_item` non-nullable too, which would have been a lot nicer to work with, but unfortunately `stripper` does actually return `None` in some places. I might make a follow-up moving stripper to be special and not a pass so that passes can be non-nullable.
2020-11-15Make all rustdoc functions and structs crate-privateJoshua Nelson-4/+4
This gives warnings about dead code.
2020-11-15Rollup merge of #79041 - jyn514:inner-to-kind, r=petrochenkovJonas Schievink-1/+1
Rename clean::{ItemEnum -> ItemKind}, clean::Item::{inner -> kind} r? ````@petrochenkov```` cc ````@GuillaumeGomez```` Follow-up to https://github.com/rust-lang/rust/pull/77820#discussion_r502931757.
2020-11-14Rename ItemEnum -> ItemKind, inner -> kindJoshua Nelson-1/+1
2020-11-07Allow making `RUSTC_BOOTSTRAP` conditional on the crate nameJoshua Nelson-3/+1
The main change is that `UnstableOptions::from_environment` now requires an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how. Other major changes: - Added `Session::is_nightly_build()`, which uses the `crate_name` of the session - Added `nightly_options::match_is_nightly_build`, a convenience method for looking up `--crate-name` from CLI arguments. `Session::is_nightly_build()`should be preferred where possible, since it will take into account `#![crate_name]` (I think). - Added `unstable_features` to `rustdoc::RenderOptions` There is a user-facing change here: things like `RUSTC_BOOTSTRAP=0` no longer active nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway. - Add tests Check against `Cheat`, not whether nightly features are allowed. Nightly features are always allowed on the nightly channel. - Only call `is_nightly_build()` once within a function - Use booleans consistently for rustc_incremental Sessions can't be passed through threads, so `read_file` couldn't take a session. To be consistent, also take a boolean in `write_file_header`.
2020-10-12Improve lint level handlingGuillaume Gomez-1/+1
2020-10-12Apply same treatment to MISSING_DOC_CODE_EXAMPLESGuillaume Gomez-4/+11
2020-09-12Don't emit an error on private doc tests when they're ignoredGuillaume Gomez-10/+6
2020-08-27Rename rustdoc/test -> rustdoc/doctestAleksey Kladov-1/+1
This modules contains the implementation of doctests, and not the tests of rustdoc itself. This name is confusing, so let's rename it to doctest for clarity.
2020-08-26Fix swapped stability attributesJoshua Nelson-6/+6
This fixes a regression introduced in https://github.com/rust-lang/rust/pull/74855.
2020-08-21Unify checks for lint missing_doc_code_examples and --show-coverageGuillaume Gomez-7/+18
2020-08-18Add doc examples count for --show-coverageGuillaume Gomez-11/+17
2020-07-27private_items_doc_tests -> doc_test_lintsJoshua Nelson-0/+97