about summary refs log tree commit diff
path: root/src/librustdoc/passes/calculate_doc_coverage.rs
AgeCommit message (Collapse)AuthorLines
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-1/+1
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
2025-04-25Rollup merge of #137096 - ehuss:stabilize-doctest-xcompile, r=fmeaseMatthias Krüger-1/+1
Stabilize flags for doctest cross compilation This makes the following changes in preparation for supporting doctest cross-compiling in cargo: - Renames `--runtool` and `--runtool-arg` to `--test-runtool` and `--test-runtool-arg` to maintain consistency with other `--test-*` arguments. - Stabilizes the `--test-runtool` and `--test-runtool-arg`. These are needed in order to support cargo's `target.runner` option which specifies a runner to execute a cross-compiled doctest (for example, qemu). - Stabilizes the `--enable-per-target-ignores` flag by removing it and making it unconditionally enabled. This makes it possible to disable a doctest on a per-target basis, which I think will be helpful for rolling out this feature. These changes were suggested in https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/stabilizing.20doctest.20xcompile/near/409281127 The intent is to stabilize the doctest-xcompile feature in cargo. This will help ensure that for projects that do cross-compile testing that their doctests are also covered. Currently there is a somewhat surprising behavior that they are ignored. Closes https://github.com/rust-lang/rust/issues/64245 try-job: x86_64-msvc-1
2025-04-03Remove `LintExpectationId` from `Level` variantsOli Scherer-1/+1
2025-04-03Make LevelAndSource a structOli Scherer-3/+4
2025-03-27Remove and stabilize --enable-per-target-ignoresEric Huss-1/+1
This removes the `--enable-per-target-ignores` and enables it unconditionally.
2025-03-18Move `hir::Item::ident` into `hir::ItemKind`.Nicholas Nethercote-1/+1
`hir::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, Trait`, TraitAalis`. - It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`, `Impl`. - For `Use`, it is non-empty for `UseKind::Single` and empty for `UseKind::{Glob,ListStem}`. All of this is quite non-obvious; the only documentation is a single comment saying "The name might be a dummy name in case of anonymous items". Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - A similar transformation makes sense for `ast::Item`, but this is already a big change. That can be done later. - Lots of assertions are added to item lowering to ensure that identifiers are empty/non-empty as expected. These will be removable when `ast::Item` is done later. - `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does. - `lower_use_tree` is significantly simpler. No more confusing `&mut Ident` to deal with. - `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's used with `unwrap` in a few places; sometimes it's hard to tell exactly which item kinds might occur. None of these unwraps fail on the test suite. It's conceivable that some might fail on alternative input. We can deal with those if/when they happen. - In `trait_path` the `find_map`/`if let` is replaced with a loop, and things end up much clearer that way. - `named_span` no longer checks for an empty name; instead the call site now checks for a missing identifier if necessary. - `maybe_inline_local` doesn't need the `glob` argument, it can be computed in-function from the `renamed` argument. - `arbitrary_source_item_ordering::check_mod` had a big `if` statement that was just getting the ident from the item kinds that had one. It could be mostly replaced by a single call to the new `ItemKind::ident` method. - `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size, and that's what matters, because `ItemKind` only occurs within `Item`.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-1/+1
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2024-11-28Fix new clippy lintsGuillaume Gomez-2/+2
2024-11-04Fix invalid coverage computation when `--output-format=json` is enabledGuillaume Gomez-0/+1
2024-10-14Delay ambiguous intra-doc link resolution after `Cache` has been populatedGuillaume Gomez-1/+1
2024-09-25rm higher-ranked lifetimes from `DocVisitor`Lukas Markeffsky-1/+1
This allows the visitor to borrow from the visitees.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-07rustdoc: use a single box to store Attributes and ItemKindMichael Howell-1/+1
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-8/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-05-01Stabilize `custom_code_classes_in_docs` featureGuillaume Gomez-8/+1
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