about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2024-11-10Add Unicode block-drawing compiler output supportEsteban Küber-1/+13
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-10Update minifer version to `0.3.2`Guillaume Gomez-1/+1
2024-11-10ensure that all publicly reachable const fn have const stability infoRalf Jung-3/+1
2024-11-09Rollup merge of #132754 - Zalathar:opts, r=GuillaumeGomez,jieyouxuMatthias Krüger-460/+465
Simplify the internal API for declaring command-line options The internal APIs for declaring command-line options are old, and intimidatingly complex. This PR replaces them with a single function that takes explicit `stability` and `kind` arguments, making it easier to see how each option is handled, and whether it is treated as stable or unstable. We also don't appear to have any tests for the output of `rustc --help` and similar, so I've added a run-make test to verify that this PR doesn't change any output. (There is already a similar run-make test for rustdoc's help output.) --- The librustdoc changes are simply adjusting to updated compiler APIs; no functional change intended. --- A side-effect of these changes is that rustfmt can once again format the entirety of these option declaration lists, which it was not doing before.
2024-11-07Rollup merge of #132739 - GuillaumeGomez:cleanup-scrape-code, r=notriddleJubilee-11/+22
Fix `librustdoc/scrape_examples.rs` formatting Still working on the intra-doc link feature. This time I encountered this file and it bothered me a bit so fixing formatting. :3 r? ````@notriddle````
2024-11-08Simplify command-line-argument declarations in librustdocZalathar-458/+463
2024-11-08Use a method to apply `RustcOptGroup` to `getopts::Options`Zalathar-2/+2
2024-11-07Fix file formattingGuillaume Gomez-11/+22
2024-11-06Auto merge of #132703 - GuillaumeGomez:rollup-tfuef34, r=GuillaumeGomezbors-7/+3
Rollup of 3 pull requests Successful merges: - #132617 (Fix an extra newline in rendered std doc) - #132698 (Remove unneeded fields in `scrape_examples::FindCalls`) - #132700 (add note not to re-report crashes from `crashes` tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-06Remove unneeded fields in `scrape_examples::FindCalls`Guillaume Gomez-7/+3
2024-11-06Clean middle generics using paren sugar if trait has rustc_paren_sugarMichael Goulet-1/+1
2024-11-05Auto merge of #132580 - compiler-errors:globs, r=Noratriebbors-16/+20
Remove unnecessary pub enum glob-imports from `rustc_middle::ty` We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly. `@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`. This PR is a bit large, but it's just naming. The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine. r? `@noratrieb` or reassign
2024-11-04Rename `DocContext::is_json` into `DocContext::is_json_output`Guillaume Gomez-8/+8
2024-11-04Fix invalid coverage computation when `--output-format=json` is enabledGuillaume Gomez-6/+14
2024-11-04ty::BrK -> ty::BoundRegionKind::KMichael Goulet-4/+8
2024-11-04ty::KContainer -> ty::AssocItemContainer::KMichael Goulet-12/+12
2024-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-2/+2
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-8/+8
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-11-02Rollup merge of #132481 - lukas-code:doc-stab3, r=GuillaumeGomezMatthias Krüger-17/+57
rustdoc: skip stability inheritance for some item kinds For some item kinds it's incorrect to inherit their parent's stability, because they might be accessible without referring to the parent directly -- This PR removes the stability inheritance for these items and reverts their displayed stability to that before https://github.com/rust-lang/rust/pull/130798. Impl items, both inherent and trait impls, have a stability, but it is ignored when checking for enabled features. However, impl items are automatically unstable if they're nested inside an unstable module -- this caused the children of impl to inherit the instability and lead to https://github.com/rust-lang/rust/issues/132440. Furthermore, for associated items only the stability of the associated item itself is checked and not that of its parent impl. This is true even for trait impls and we have [relied on this behavior in the standard library in the past](https://doc.rust-lang.org/1.37.0/std/slice/trait.SliceConcatExt.html#tymethod.concat), so these also shouldn't inherit the impl's stability. I've also removed the stability inheritance for primitives and keywords so that viewing e.g. [the `i32` docs on `core`](https://doc.rust-lang.org/nightly/core/primitive.i32.html) will no longer show "since 1.6.0". Note that we currently don't annotate stability for the keyword docs, but if we start doing so in the future then this is probably more correct. fixes (after backport) https://github.com/rust-lang/rust/issues/132440
2024-11-02rustdoc: skip stability inheritance for some item kindsLukas Markeffsky-17/+57
2024-11-01rustdoc: Directly use rustc_abi instead of reexportsJubilee Young-20/+19
rustc_target reexports a lot of things that are in rustc_abi, but that will be over soon and now is probably a good time to switch. Uses of rustc_target remain where they inquire about the target tuple.
2024-10-31Adjust ranking so that duplicates count against rankMichael Howell-14/+11
2024-10-30Rollup merge of #132210 - notriddle:notriddle/doctest-span-hack, ↵Jubilee-1/+13
r=GuillaumeGomez rustdoc: make doctest span tweak a 2024 edition change Fixes #132203 This is a compatibility hack, because I think the new behavior is better. When an A `include_str!` B, and B `include_str!` C, the path to C should be resolved relative to B, not A. That's how `include!` itself works, so that's how `include_str!` with should work.
2024-10-30Rollup merge of #129383 - cjgillot:opaque-noremap, ↵Jubilee-1/+1
r=compiler-errors,petrochenkov Remap impl-trait lifetimes on HIR instead of AST lowering Current AST->HIR lowering goes out of its way to remap lifetimes for opaque types. This is complicated and leaks into upstream and downstream code. This PR stops trying to be clever during lowering, and prefers to do this remapping during the HIR->ty lowering. The remapping computation easily fits into the bound var resolution code. Its result can be used in by `generics_of` and `hir_ty_lowering::new_opaque` to add the proper parameters and arguments. See an example on the doc for query `opaque_captured_lifetimes`. Based on https://github.com/rust-lang/rust/pull/129244/ Fixes https://github.com/rust-lang/rust/issues/125249 Fixes https://github.com/rust-lang/rust/issues/126850 cc `@compiler-errors` `@spastorino` r? `@petrochenkov`
2024-10-30rustdoc-search: simplify rules for generics and type paramsMichael Howell-91/+335
This commit is a response to feedback on the displayed type signatures results, by making generics act stricter. Generics are tightened by making order significant. This means `Vec<Allocator>` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result<A, B>` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected. Find the discussion on: * <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149> * <https://github.com/rust-lang/rust/pull/124544#issuecomment-2204272265> * <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search/near/476841363>
2024-10-30rustdoc-search: show types signatures in resultsMichael Howell-85/+627
2024-10-30rustdoc-search: use correct type annotationsMichael Howell-2/+2
2024-10-30rustdoc-search: pass original names through ASTMichael Howell-20/+26
2024-10-30rustdoc-search: simplify the checkTypes fast pathMichael Howell-26/+11
This reduces code size while still matching the common case for plain, concrete types.
2024-10-30rustdoc-search: add type param names to indexMichael Howell-7/+39
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-1/+1
2024-10-30Rollup merge of #131096 - GuillaumeGomez:rm-no_unused, r=notriddle许杰友 Jieyou Xu (Joe)-4/+0
rustdoc: Remove usage of `allow(unused)` attribute on `no_run` merged doctests Fixes [#130681](https://github.com/rust-lang/rust/issues/130681). It fixes the behaviour difference with the current doctests. r? ``@notriddle``
2024-10-29update toolslcnr-8/+7
2024-10-28Rollup merge of #132258 - GuillaumeGomez:variant-structfields-margins, ↵Jubilee-1/+1
r=notriddle [rustdoc] Unify variant struct fields margins with struct fields As discussed in https://github.com/rust-lang/rust/pull/132220. | before | after | |-|-| | ![image](https://github.com/user-attachments/assets/d8d8336d-7fe4-45fb-a5a5-36a4023223f5) | ![Screenshot from 2024-10-28 11-17-24](https://github.com/user-attachments/assets/9d0d9633-b857-45b4-9217-7d0d1aa8f770) | r? ```@notriddle```
2024-10-28rustdoc: Use accessors to interrogate type layoutsJubilee Young-4/+4
2024-10-28Unify variant struct fields margins with struct fieldsGuillaume Gomez-1/+1
2024-10-26Rollup merge of #132192 - petrochenkov:macfa, r=compiler-errorsJubilee-25/+9
expand: Stop using artificial `ast::Item` for macros loaded from metadata You don't need a full `Item` for that, and not using a piece of AST helps with https://github.com/rust-lang/rust/pull/131808.
2024-10-26Rollup merge of #132183 - GuillaumeGomez:code-in-docblock, r=notriddleJubilee-1/+1
Fix code HTML items making big blocks if too long Encountered this bug randomly where `code` item in docblocks would look like this: ![Screenshot from 2024-10-26 15-44-46](https://github.com/user-attachments/assets/a9c1df9d-5007-49eb-a7dd-a2c381b2511e) With this fix it looks like this: ![image](https://github.com/user-attachments/assets/ea918595-5434-4781-b68c-6abd38689365) r? ``@notriddle``
2024-10-26Rollup merge of #132123 - lolbinarycat:rustdoc-search-foreign-func, r=notriddleJubilee-1/+4
allow type-based search on foreign functions fixes https://github.com/rust-lang/rust/issues/131804 preferably will be merged after #129708, but that may take a while to be approved due to being a new feature, whereas this is definitely a bug, and should be fixed.
2024-10-26rustdoc: make doctest span tweak a 2024 edition changeMichael Howell-1/+13
Fixes #132203 This is a compatibility hack, because I think the new behavior is better. When an A `include_str!` B, and B `include_str!` C, the path to C should be resolved relative to B, not A. That's how `include!` itself works, so that's how `include_str!` with should work.
2024-10-26expand: Stop using artificial `ast::Item` for macros loaded from metadataVadim Petrochenkov-25/+9
2024-10-26Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillotbors-2/+2
(Big performance change) Do not run lints that cannot emit Before this change, adding a lint was a difficult matter because it always had some overhead involved. This was because all lints would run, no matter their default level, or if the user had `#![allow]`ed them. This PR changes that. This change would improve both the Rust lint infrastructure and Clippy, but Clippy will see the most benefit, as it has about 900 registered lints (and growing!) So yeah, with this little patch we filter all lints pre-linting, and remove any lint that is either: - Manually `#![allow]`ed in the whole crate, - Allowed in the command line, or - Not manually enabled with `#[warn]` or similar, and its default level is `Allow` As some lints **need** to run, this PR also adds **loadbearing lints**. On a lint declaration, you can use the ``@eval_always` = true` marker to label it as loadbearing. A loadbearing lint will never be filtered (it will always run) Fixes #106983
2024-10-26Fix code HTML items making big blocks if too longGuillaume Gomez-1/+1
2024-10-26Rollup merge of #132168 - fee1-dead-contrib:fxclean, r=compiler-errorsMatthias Krüger-1/+0
Effects cleanup - removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers r? compiler-errors
2024-10-26Effects cleanupDeadbeef-1/+0
- removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
2024-10-25tcx.is_const_fn doesn't work the way it is described, remove itRalf Jung-2/+2
Then we can rename the _raw functions to drop their suffix, and instead explicitly use is_stable_const_fn for the few cases where that is really what you want.
2024-10-25Re-do recursive const stability checksRalf Jung-12/+9
Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
2024-10-25allow type-based search on foreign functionsbinarycat-1/+4
fixes https://github.com/rust-lang/rust/issues/131804
2024-10-25Auto merge of #132105 - GuillaumeGomez:doctest-nested-main, r=notriddlebors-4/+11
[rustdoc] Do not consider nested functions as main function even if named `main` in doctests Fixes #131893. If a nested function is called `main`, it is not considered as the entry point of the program. Therefore, doctests should not consider such functions as such either. r? `@notriddle`
2024-10-24Rollup merge of #132115 - bash:rustdoc-fake-variadic-wrapper, ↵Jubilee-0/+18
r=GuillaumeGomez,notriddle rustdoc: Extend fake_variadic to "wrapped" tuples This allows impls such as `impl QueryData for OneOf<(T,)>` to be displayed as variadic: `impl QueryData for OneOf<(T₁, T₂, …, Tₙ)>`. See question on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/Make.20.60.23.5Bdoc.28fake_variadic.29.5D.60.20more.20useful).