about summary refs log tree commit diff
path: root/src/librustdoc/passes/calculate_doc_coverage.rs
AgeCommit message (Collapse)AuthorLines
2023-09-17Don't emit an error if the `custom_code_classes_in_docs` feature is disabled ↵Guillaume Gomez-1/+8
when its syntax is used.
2023-08-16Use more named format argsGuillaume Gomez-2/+4
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-3/+3
2023-05-22rustdoc: Cleanup doc string collapsingVadim Petrochenkov-7/+1
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+0
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-01-26rustdoc: Stop using `HirId`sVadim Petrochenkov-7/+1
Use `LocalDefId`s instead
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-2/+2
2022-08-13make clean::Item::span return option instead of dummy spanMichael Goulet-8/+10
2022-05-24fix simple clippy lintsklensy-1/+1
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-1/+1
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-16Rename `def_id` into `item_id` when the type is `ItemId` for readabilityGuillaume Gomez-3/+3
2021-12-15Add module documentation for rustdoc passesJacob Hoffman-Andrews-0/+1
These are currently documented at https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#hot-potato but can easily go out of date. We'd like to document them in place and link to https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/passes/index.html
2021-10-31Convert many impls of `DocFolder` to `DocVisitor`Noah Lev-11/+12
Many of `DocFolder`'s impls didn't actually transform the syntax tree, so they can be visitors instead.
2021-10-02rustdoc: Improve doctest pass's name and module's nameNoah Lev-1/+1
As the docs at the top of the file say, it is an overloaded pass and actually runs two lints.
2021-09-10Don't require documentation for fields in an enum tuple variant or for tuple ↵Guillaume Gomez-3/+37
struct fields.
2021-07-05rustdoc: Rename `expect_real` to `expect_def_id`, remove `Item::is_fake`Justus K-2/+2
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-3/+3
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-08Remove `FakeDefId::expect_local()`Camelid-1/+7
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-05Use local and remapped paths where appropriateAndy Wang-2/+2
2021-05-05Remove impl Display for FileName and add FileNameDisplay wrapper typeAndy Wang-1/+1
2021-04-24Get rid of `item.span`Joshua Nelson-1/+1
- Remove `span` field, adding `Item::span()` instead - Special-case `Impl` and `Module` items - Use dummy spans for primitive items
2021-04-24Do the hard part firstJoshua Nelson-1/+1
The only bit failing was the module, so change that before removing the `span` field.
2021-04-09rustdoc: Don't generate blanket impls when running --show-coverageJoshua Nelson-43/+7
get_blanket_impls is the slowest part of rustdoc, and the coverage pass completely ignores blanket impls. This stops running it at all, and also removes some unnecessary checks in `calculate_doc_coverage` that ignored the impl anyway. We don't currently measure --show-coverage in perf.rlo, but I tested this locally on cargo and it brought the time down from 2.9 to 1.6 seconds.
2021-03-24Rework rustdoc const typeGuillaume Gomez-3/+7
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-05Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make ↵Guillaume Gomez-1/+1
transition over hir::ItemKind simpler
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-1/+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-7/+3
This should hopefully allow for less interior mutability.
2021-01-28rustdoc: Remove unnecessary optionalCamelid-1/+1
Previously, the HTML output format was represented by both `Some(OutputFormat::Html)` and `None` so there's no need to have an optional. Instead, `OutputFormat::Html` is explicitly the default and we no longer have a "tri-state enum".
2021-01-27Remove CACHE_KEY globalGuillaume Gomez-2/+7
2021-01-02Improve code for DocFragment reworkGuillaume Gomez-6/+1
2021-01-02End of rework of Attributes structGuillaume Gomez-1/+1
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-12Calculate span info on-demand instead of ahead of timeJoshua Nelson-9/+6
This should *vastly* reduce memory usage.
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-1/+1
This gives warnings about dead code.
2020-11-14Rename ItemEnum -> ItemKind, inner -> kindJoshua Nelson-1/+1
2020-10-12Improve lint level handlingGuillaume Gomez-1/+3
2020-10-12Apply same treatment to MISSING_DOC_CODE_EXAMPLESGuillaume Gomez-2/+3
2020-10-12Inherit lint level from parentsGuillaume Gomez-23/+17
2020-10-12rustdoc: skip allow missing doc in cover. reportRoman-2/+19
During the document coverage reporting with ```bash rustdoc something.rs -Z unstable-options --show-coverage ``` the coverage report also includes parts of the code that are marked with `#[allow(missing_docs)]`, which outputs lower numbers in the coverage report even though these parts should be ignored for the calculation. Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-03Change DocFragments from enum variant fields to structs with a nested enumJoshua Nelson-1/+6
This makes the code a lot easier to work with. It also makes it easier to add new fields without updating each variant and `match` individually. - Name the `Kind` variant after `DocFragmentKind` from `collapse_docs` - Remove unneeded impls
2020-08-21Unify checks for lint missing_doc_code_examples and --show-coverageGuillaume Gomez-15/+2
2020-08-21Show line even if there is no code examplesGuillaume Gomez-5/+3
2020-08-21Ignore more kind of items for doc examplesGuillaume Gomez-0/+4
2020-08-20fmtGuillaume Gomez-11/+2