about summary refs log tree commit diff
path: root/src/librustdoc/config.rs
AgeCommit message (Collapse)AuthorLines
2025-03-12Use materialize_sysroot in rustdocbjorn3-4/+1
2025-03-12Don't return an error from get_or_default_sysrootbjorn3-3/+1
All callers unwrap the result.
2025-03-12Make opts.maybe_sysroot non-optionalbjorn3-0/+4
build_session_options always uses materialize_sysroot anyway.
2025-03-06`librustdoc`: flatten nested ifsYotam Ofek-8/+8
2025-02-26Add rustdoc support for `--emit=dep-info[=path]`Guillaume Gomez-6/+22
2025-02-05Auto merge of #136253 - notriddle:notriddle/aot-minify, r=GuillaumeGomezbors-2/+2
rustdoc: run css and html minifier at build instead of runtime This way, adding a bunch of comments to the JS files won't make rustdoc slower. Meant to address https://github.com/rust-lang/rust/pull/136161#issuecomment-2622069453
2025-02-03Auto merge of #133138 - azhogin:azhogin/target-modifiers, r=davidtwco,saethlinbors-4/+5
Target modifiers (special marked options) are recorded in metainfo Target modifiers (special marked options) are recorded in metainfo and compared to be equal in different linked crates. PR for this RFC: https://github.com/rust-lang/rfcs/pull/3716 Option may be marked as `TARGET_MODIFIER`, example: `regparm: Option<u32> = (None, parse_opt_number, [TRACKED TARGET_MODIFIER]`. If an TARGET_MODIFIER-marked option has non-default value, it will be recorded in crate metainfo as a `Vec<TargetModifier>`: ``` pub struct TargetModifier { pub opt: OptionsTargetModifiers, pub value_name: String, } ``` OptionsTargetModifiers is a macro-generated enum. Option value code (for comparison) is generated using `Debug` trait. Error example: ``` error: mixing `-Zregparm` will cause an ABI mismatch in crate `incompatible_regparm` --> $DIR/incompatible_regparm.rs:10:1 | LL | #![crate_type = "lib"] | ^ | = help: the `-Zregparm` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: `-Zregparm=1` in this crate is incompatible with `-Zregparm=2` in dependency `wrong_regparm` = help: set `-Zregparm=2` in this crate or `-Zregparm=1` in `wrong_regparm` = help: if you are sure this will not cause problems, use `-Cunsafe-allow-abi-mismatch=regparm` to silence this error error: aborting due to 1 previous error ``` `-Cunsafe-allow-abi-mismatch=regparm,reg-struct-return` to disable list of flags.
2025-02-02Target modifiers (special marked options) are recorded in metainfo and ↵Andrew Zhogin-4/+5
compared to be equal in different crates
2025-01-29rustdoc: run css and html minifier at build instead of runtimeMichael Howell-2/+2
This way, adding a bunch of comments to the JS files won't make rustdoc slower.
2025-01-29Improve check for `--output-format` combinations and add ui regression testGuillaume Gomez-31/+35
2025-01-29Improve code and add missing docs for new `doctest::extracted` moduleGuillaume Gomez-6/+4
2025-01-29Mention the tracking issue of `--output-format=doctest`Guillaume Gomez-0/+2
2025-01-29Add new output-formatGuillaume Gomez-2/+12
2025-01-11re-add --disable-minification to rustdocbinarycat-0/+6
this also makes the rust.docs-minification option work as advertised in config.toml nothing fancy this time, this is intended to be perma-unstable. it's only really here for the benefit of rustdoc devs. mitegates https://github.com/rust-lang/rust/issues/135345
2024-12-20Add `--doctest-compilation-args` option to allow passing arguments to ↵Guillaume Gomez-0/+5
doctest compilation
2024-11-28Fix new clippy lintsGuillaume Gomez-2/+2
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-2/+2
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-09-07rfc#3662 changes under unstable flagsEtomicBomb-4/+105
* All new functionality is under unstable options * Adds `--merge=shared|none|finalize` flags * Adds `--parts-out-dir=<crate specific directory>` for `--merge=none` to write cross-crate info file for a single crate * Adds `--include-parts-dir=<previously specified directory>` for `--merge=finalize` to write cross-crate info files * update tests/run-make/rustdoc-default-output/rmake.rs golden
2024-09-07librustdoc::config: removed Input from OptionsEtomicBomb-12/+6
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-08-29Fix clippy lintsGuillaume Gomez-3/+3
2024-08-15Rollup merge of #128963 - GuillaumeGomez:output-to-stdout, r=aDotInTheVoidMatthias Krüger-5/+10
Add possibility to generate rustdoc JSON output to stdout Fixes #127165. I think it's likely common to want to get rustdoc json output directly instead of reading it from a file so I added this option to allow it. It's unstable and only works with `--output-format=json`. r? `@aDotInTheVoid`
2024-08-13Emit a warning instead of an error if `--generate-link-to-definition` is ↵Guillaume Gomez-3/+5
used with other output formats than HTML
2024-08-12Add possibility to generate rustdoc JSON output to stdoutGuillaume Gomez-5/+10
2024-08-08Split `ColorConfig` off of `HumanReadableErrorType`Esteban Küber-2/+3
The previous setup tied two unrelated things together. Splitting these two is a better model.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-13/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-7/+9
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-09rustdoc: Add support for --remap-path-prefixEdward Shen-0/+26
Adds --remap-path-prefix as an unstable option. This is implemented to mimic the behavior of rustc's --remap-path-prefix but with minor adjustments. This flag similarly takes in two paths, a prefix to replace and a replacement string.
2024-05-18Auto merge of #124611 - Urgau:rustdoc-stdin, r=GuillaumeGomezbors-14/+37
Add `-` (stdin) support in rustdoc This PR adds support for the special `-` input which threats the input as coming from *stdin* instead of being a filepath. Doing this also makes `rustdoc` consistent with `rustc` and ~~every~~ other tools. Full [motivation](https://github.com/rust-lang/rust/pull/124611#issuecomment-2094234876). Fixes https://github.com/rust-lang/rust/issues/123671 r? `@fmease`
2024-05-07rustdoc: use stability, instead of features, to decide what to showMichael Howell-4/+0
To decide if internal items should be inlined in a doc page, check if the crate is itself internal, rather than if it has the rustc_private feature flag. The standard library uses internal items, but is not itself internal and should not show internal items on its docs pages.
2024-05-04Simplify `markdown_input` fn and subsequent logicUrgau-4/+3
2024-05-04Add `-` (stdin) support to rustdocUrgau-13/+37
2024-04-23Mark @RUSTC_BUILTIN search path usage as unstableLukas Wirth-1/+10
2024-03-25Make sysroot mandatory for rustdocLukas Wirth-1/+8
2024-03-25Make use of sysroot in librustdoc/config.rs for builtin:$pathLukas Wirth-2/+2
2024-03-25Implement `-L builtin:$path`Lukas Wirth-2/+6
2024-03-15rustdoc: add `--test-builder-wrapper` argumentTravis Finkenauer-0/+7
Instead of executing the test builder directly, the test builder wrapper will be called with test builder as the first argument and subsequent arguments. This is similar to cargo's RUSTC_WRAPPER argument. The `--test-builder-wrapper` argument can be passed multiple times to allow "nesting" of wrappers.
2024-02-17Fix missing trait impls for type in rustc docsShoyu Vanilla-0/+4
2024-02-07rustdoc: remove `unchecked_claim_error_was_emitted` call in `main_args`.Nicholas Nethercote-64/+32
`main_args` calls `from_matches`, which does lots of initialization. If anything goes wrong, `from_matches` emits an error message and returns `Err(1)` (or `Err(3)`). `main_args` then turns the `Err(1)` into `Err(ErrorGuaranteed)`, because that's what `catch_with_exit_code` requires on error. But `catch_with_exit_code` doesn't do anything with the `ErrorGuaranteed`, it just exits with `EXIT_FAILURE`. We can avoid the creation of the `ErrorGuaranteed` (which requires an undesirable `unchecked_claim_error_was_emitted` call), by changing `from_matches` to instead eagerly abort if anything goes wrong. The behaviour from the user's point of view is the same: an early abort with an `EXIT_FAILURE` exit code. And we can also simplify `from_matches` to return an `Option` instead of a `Result`: - Old `Err(0)` case --> `None` - Old `Err(_)` case --> fatal error. This requires similar changes to `ScrapeExamplesOptions::new` and `load_call_locations`.
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-5/+5
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Shorten some error invocations.Nicholas Nethercote-12/+12
- `struct_foo` + `emit` -> `foo` - `create_foo` + `emit` -> `emit_foo` I have made recent commits in other PRs that have removed some of these shortcuts for combinations with few uses, e.g. `struct_span_err_with_code`. But for the remaining combinations that have high levels of use, we might as well use them wherever possible.
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-5/+5
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2023-12-23Rename `EarlyDiagCtxt` methods to match `DiagCtxt`.Nicholas Nethercote-1/+1
- `early_error_no_abort` -> `early_err` - `early_error` -> `early_fatal` - `early_struct_error` -> `early_struct_fatal`
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-26/+26
2023-12-18Rename many `EarlyDiagCtxt` arguments.Nicholas Nethercote-15/+15
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-3/+3
2023-12-18Rename `new_handler` as `new_dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.Nicholas Nethercote-2/+2
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-1/+1