about summary refs log tree commit diff
path: root/src/librustdoc/core.rs
AgeCommit message (Collapse)AuthorLines
2025-08-23Do macro expansion at AST level rather than HIRGuillaume Gomez-2/+11
2025-07-27rustdoc: save target modifiersMiguel Ojeda-0/+2
`rustdoc` was filling a `target_modifiers` variable, but it was not using the result. In turn, that means that trying to use a dependency that set a target modifier fails. For instance, running: ```sh RUSTC_BOOTSTRAP=1 rustc --edition=2024 --target=aarch64-unknown-none-softfloat --sysroot=/dev/null --emit=metadata -Zfixed-x18 --crate-type rlib --crate-name core $(rustc --print sysroot)/lib/rustlib/src/rust/library/core/src/lib.rs echo '#![allow(internal_features)] ' | RUSTC_BOOTSTRAP=1 rustdoc --edition=2021 --target=aarch64-unknown-none-softfloat --sysroot=/dev/null -Zfixed-x18 --extern core=libcore.rmeta - ``` will fail with: ```text error: mixing `-Zfixed-x18` will cause an ABI mismatch in crate `rust_out` | = help: the `-Zfixed-x18` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: unset `-Zfixed-x18` in this crate is incompatible with `-Zfixed-x18=` in dependency `core` = help: set `-Zfixed-x18=` in this crate or unset `-Zfixed-x18` in `core` = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=fixed-x18` to silence this error ``` Thus save the targets modifiers in `Options` to then pass it to the session options, so that eventually the diff can be performed as expected in `report_incompatible_target_modifiers()`. Fixes: https://github.com/rust-lang/rust/issues/144521 Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-07-02avoid suggesting traits from private dependenciesJeremy Smart-1/+1
2025-06-20Rollup merge of #142650 - camsteffen:refactor-translator, r=petrochenkovTrevor Gross-6/+3
Refactor Translator My main motivation was to simplify the usage of `SilentEmitter` for users like rustfmt. A few refactoring opportunities arose along the way. * Replace `Translate` trait with `Translator` struct * Replace `Emitter: Translate` with `Emitter::translator` * Split `SilentEmitter` into `FatalOnlyEmitter` and `SilentEmitter`
2025-06-19Extract Translator structCameron Steffen-6/+3
2025-06-18Reduce uses of `hir_crate`.Camille GILLOT-2/+0
2025-06-03Run wfcheck in one big loop instead of per moduleOli Scherer-3/+1
2025-04-18Rollup merge of #139615 - nnethercote:rm-name_or_empty, r=jdonszelmannMatthias Krüger-3/+1
Remove `name_or_empty` Another step towards #137978. r? ``@jdonszelmann``
2025-04-17Support inlined cross-crate re-exported trait aliasesLeón Orell Valerian Liehr-2/+2
2025-04-17Replace infallible `name_or_empty` methods with fallible `name` methods.Nicholas Nethercote-3/+1
I'm removing empty identifiers everywhere, because in practice they always mean "no identifier" rather than "empty identifier". (An empty identifier is impossible.) It's better to use `Option` to mean "no identifier" because you then can't forget about the "no identifier" possibility. Some specifics: - When testing an attribute for a single name, the commit uses the `has_name` method. - When testing an attribute for multiple names, the commit uses the new `has_any_name` method. - When using `match` on an attribute, the match arms now have `Some` on them. In the tests, we now avoid printing empty identifiers by not printing the identifier in the `error:` line at all, instead letting the carets point out the problem.
2025-04-10Allow drivers to supply a list of extra symbols to internAlex Macleod-0/+1
2025-03-12Make opts.maybe_sysroot non-optionalbjorn3-2/+2
build_session_options always uses materialize_sysroot anyway.
2025-03-07Remove highlighting of spans on `-Zteach`Esteban Küber-1/+0
`-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
2025-03-07Rollup merge of #138111 - estebank:use-dfv, r=nnethercoteMatthias Krüger-1/+1
Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType` Wanted to see where `#![feature(default_field_values)]` could be used in the codebase. These three seemed like no-brainers. There are a bunch of more places where we could remove manual `Default` impls, but they `derive` other traits that rely on `syn`, which [doesn't yet support `default_field_values`](https://github.com/dtolnay/syn/issues/1774).
2025-03-03Use default field values for `ErrorOutputType`Esteban Küber-1/+1
Remove manual `Default` impl from `config::ErrorOutputType`.
2025-02-26Add rustdoc support for `--emit=dep-info[=path]`Guillaume Gomez-6/+18
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-4/+3
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17Remove `TyCtxt::hir_krate`.Nicholas Nethercote-1/+1
It's a trivial wrapper around the `hir_crate` query with a small number of uses.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-2/+2
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
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`.
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-4/+3
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-04Rollup merge of #134807 - poliorcetics:ab/push-skpynvsmwkll, r=camelidMatthias Krüger-1/+1
fix(rustdoc): always use a channel when linking to doc.rust-lang.org Closes #131971 I manually checked the resulting links One issue is that this will create `nightly/...` links in places that formerly linked to stable, is that ok ? (the `slice` and `array` links in the search help notably)
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-4/+3
2025-02-01Rename `tcx.ensure()` to `tcx.ensure_ok()`Zalathar-2/+2
2025-01-30fix(rustdoc): always use a channel when linking to doc.rust-lang.orgAlexis (Poliorcetics) Bourget-1/+1
2025-01-25Auto merge of #119286 - jyn514:linker-output, r=bjorn3bors-1/+1
show linker output even if the linker succeeds Show stderr and stderr by default, controlled by a new `linker_messages` lint. fixes https://github.com/rust-lang/rust/issues/83436. fixes https://github.com/rust-lang/rust/issues/38206. cc https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408986134 <!-- try-job: dist-x86_64-msvc --> try-job: aarch64-apple r? `@bjorn3`
2025-01-23Remove the need to manually call set_using_internal_featuresbjorn3-4/+3
2025-01-20don't ICE when emitting linker errors during `-Z link-only`jyn-1/+1
note that this still ICEs when passed `-Z link-only --error-format json` because i can't be bothered to fix it right now
2024-12-06Remove all threading through of ErrorGuaranteed from the driverbjorn3-9/+5
It was inconsistently done (sometimes even within a single function) and most of the rest of the compiler uses fatal errors instead, which need to be caught using catch_with_exit_code anyway. Using fatal errors instead of ErrorGuaranteed everywhere in the driver simplifies things a bit.
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-1/+8
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-11Auto merge of #126597 - estebank:unicode-output, r=fmeasebors-1/+8
Add Unicode block-drawing compiler output support Add nightly-only theming support to rustc output using Unicode box drawing characters instead of ASCII-art to draw the terminal UI. In order to enable, the flags `-Zunstable-options=yes --error-format=human-unicode` must be passed in. After: ``` error: foo ╭▸ test.rs:3:3 │ 3 │ X0 Y0 Z0 │ ┌───╿──│──┘ │ ┌│───│──┘ │ ┏││━━━┙ │ ┃││ 4 │ ┃││ X1 Y1 Z1 5 │ ┃││ X2 Y2 Z2 │ ┃│└────╿──│──┘ `Z` label │ ┃└─────│──┤ │ ┗━━━━━━┥ `Y` is a good letter too │ `X` is a good letter ╰╴ note: bar ╭▸ test.rs:4:3 │ 4 │ ┏ X1 Y1 Z1 5 │ ┃ X2 Y2 Z2 6 │ ┃ X3 Y3 Z3 │ ┗━━━━━━━━━━┛ ├ note: bar ╰ note: baz note: qux ╭▸ test.rs:4:3 │ 4 │ X1 Y1 Z1 ╰╴ ━━━━━━━━ ``` Before: ``` error: foo --> test.rs:3:3 | 3 | X0 Y0 Z0 | ___^__-__- | |___|__| | ||___| | ||| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label | ||_____|__| | |______| `Y` is a good letter too | `X` is a good letter | note: bar --> test.rs:4:3 | 4 | / X1 Y1 Z1 5 | | X2 Y2 Z2 6 | | X3 Y3 Z3 | |__________^ = note: bar = note: baz note: qux --> test.rs:4:3 | 4 | X1 Y1 Z1 | ^^^^^^^^ ``` After: ![rustc output with unicode box drawing characters](https://github.com/rust-lang/rust/assets/1606434/d210b79a-6579-4407-9706-ba8edc6e9f25) Before: ![current rustc output with ASCII art](https://github.com/rust-lang/rust/assets/1606434/5aecccf8-a6ee-4469-8b39-72fb0d979a9f)
2024-11-10Add Unicode block-drawing compiler output supportEsteban Küber-1/+8
Add nightly-only theming support to rustc output using Unicode box drawing characters instead of ASCII-art to draw the terminal UI: After: ``` error: foo ╭▸ test.rs:3:3 │ 3 │ X0 Y0 Z0 │ ┌───╿──│──┘ │ ┌│───│──┘ │ ┏││━━━┙ │ ┃││ 4 │ ┃││ X1 Y1 Z1 5 │ ┃││ X2 Y2 Z2 │ ┃│└────╿──│──┘ `Z` label │ ┃└─────│──┤ │ ┗━━━━━━┥ `Y` is a good letter too │ `X` is a good letter ╰╴ note: bar ╭▸ test.rs:4:3 │ 4 │ ┏ X1 Y1 Z1 5 │ ┃ X2 Y2 Z2 6 │ ┃ X3 Y3 Z3 │ ┗━━━━━━━━━━┛ ├ note: bar ╰ note: baz note: qux ╭▸ test.rs:4:3 │ 4 │ X1 Y1 Z1 ╰╴ ━━━━━━━━ ``` Before: ``` error: foo --> test.rs:3:3 | 3 | X0 Y0 Z0 | ___^__-__- | |___|__| | ||___| | ||| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label | ||_____|__| | |______| `Y` is a good letter too | `X` is a good letter | note: bar --> test.rs:4:3 | 4 | / X1 Y1 Z1 5 | | X2 Y2 Z2 6 | | X3 Y3 Z3 | |__________^ = note: bar = note: baz note: qux --> test.rs:4:3 | 4 | X1 Y1 Z1 | ^^^^^^^^ ```
2024-11-04Rename `DocContext::is_json` into `DocContext::is_json_output`Guillaume Gomez-2/+2
2024-11-04Fix invalid coverage computation when `--output-format=json` is enabledGuillaume Gomez-0/+7
2024-10-22Rollup merge of #131732 - m4tx:fix-82824, r=davidtwcoMatthias Krüger-37/+2
Add doc(plugins), doc(passes), etc. to INVALID_DOC_ATTRIBUTES This fixes #82824.
2024-10-15Add doc(plugins), doc(passes), etc. to INVALID_DOC_ATTRIBUTESMateusz Maćkowski-37/+2
2024-10-14Delay ambiguous intra-doc link resolution after `Cache` has been populatedGuillaume Gomez-4/+20
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-2/+2
2024-09-25de-rc external traitsLukas Markeffsky-4/+2
Don't keep the `external_traits` as shared mutable data between the `DocContext` and `clean::Crate`. Instead, move the data over when necessary. This allows us to get rid of a borrowck hack in the `DocVisitor`.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-09-17Rollup merge of #129988 - arnaudgolfouse:modify-locale_resources, r=davidtwcoMatthias Krüger-1/+1
Use `Vec` in `rustc_interface::Config::locale_resources` This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-09-07librustdoc::config: removed Input from OptionsEtomicBomb-2/+2
The `librustdoc::config::Options` struct no longer includes `rustc_session::config::Input`. This is so that Input can be optional. In rfc#3662, the crate input is not required if `--merge=finalize`. Replacing Input with Option<Input> was decided against. In most places that Input is needed, it should be statically known to not be optional (means fewer unwraps). We just want to have an Input-free Options in librustdoc::main_args, where we can run the write shared procedure.
2024-09-05Use a `Vec` in `rustc_interface::Config::locale_resources`arnaudgolfouse-1/+1
This allows a third-party tool to injects its own resources, when receiving the config via `rustc_driver::Callbacks::config`.
2024-08-31Rollup merge of #129774 - nnethercote:rm-extern-crate-tracing-remainder, ↵Matthias Krüger-0/+1
r=GuillaumeGomez Remove `#[macro_use] extern crate tracing` from rustdoc and rustfmt A follow-up to #129767 and earlier PRs doing this for `rustc_*` crates. r? ```@GuillaumeGomez```
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-08-29Fix clippy lintsGuillaume Gomez-1/+1
2024-08-08review commentsEsteban Küber-1/+1
2024-08-08Split `ColorConfig` off of `HumanReadableErrorType`Esteban Küber-3/+4
The previous setup tied two unrelated things together. Splitting these two is a better model.
2024-08-06Fix rustdoc missing handling of `remap-path-prefix` optionGuillaume Gomez-0/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-13/+12
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.