about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2024-02-09Unify item relative path computation in one functionGuillaume Gomez-27/+18
2024-02-09Correctly generate path for non-local items in source code pagesGuillaume Gomez-64/+165
2024-02-08Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgrbors-20/+35
Rollup of 9 pull requests Successful merges: - #119592 (resolve: Unload speculatively resolved crates before freezing cstore) - #120103 (Make it so that async-fn-in-trait is compatible with a concrete future in implementation) - #120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s) - #120214 (match lowering: consistently lower bindings deepest-first) - #120688 (GVN: also turn moves into copies with projections) - #120702 (docs: also check the inline stmt during redundant link check) - #120727 (exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered") - #120734 (Add `SubdiagnosticMessageOp` as a trait alias.) - #120739 (improve pretty printing for associated items in trait objects) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-08Rollup merge of #120702 - bvanjoi:fix-120444, r=notriddleMatthias Krüger-18/+33
docs: also check the inline stmt during redundant link check Fixes #120444 This issue was brought about by querying `root::webdavfs::A`, a key that doesn't exist in `doc_link_resolutions`. To avoid a panic, I've altered the gating mechanism to allow this lint pass to be skipped. I'm not certain if this is the best solution. An alternative approach might be to leverage other info from the name resolutions instead of `doc_link_resolutions`. After all, all we need is to get the resolution from a combination of `(module, name)`. However, I believe they would yield the same outcome, both skipping this lint.
2024-02-08Rollup merge of #120206 - petrochenkov:somehir, r=compiler-errorsMatthias Krüger-2/+2
hir: Make sure all `HirId`s have corresponding HIR `Node`s And then remove `tcx.opt_hir_node(hir_id)` in favor of `tcx.hir_node(hir_id)`.
2024-02-08Auto merge of #120579 - GuillaumeGomez:prevent-running-unneeded-code, ↵bors-0/+8
r=notriddle Prevent running some code if it is already in the map I realized that a lot of duplicates were being run through this function. Might be better to prevent them from computing all the information if it's already in the cache. r? `@notriddle`
2024-02-07Use correct param env when building and cleaning items in librustdocMichael Goulet-24/+56
2024-02-07rustdoc: remove `unchecked_claim_error_was_emitted` call in `main_args`.Nicholas Nethercote-102/+54
`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-02-07rustdoc: make `main` more like rustc's.Nicholas Nethercote-20/+10
By making non-unicode arguments a fatal error instead of a warning, we don't need to handle what comes after, which avoids the need for an `unchecked_claim_error_was_emitted` call.
2024-02-07docs: also check the inline stmt during redundant link checkbohan-18/+33
2024-02-07hir: Remove `fn opt_hir_id` and `fn opt_span`Vadim Petrochenkov-2/+2
2024-02-06Rollup merge of #120575 - nnethercote:simplify-codegen-diag-handling, r=estebankMatthias Krüger-1/+1
Simplify codegen diagnostic handling Some nice improvements. Details in the individual commit logs. r? ````@estebank````
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+2
2024-02-06Invert diagnostic lints.Nicholas Nethercote-0/+2
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-02-05Make `Emitter::emit_diagnostic` consuming.Nicholas Nethercote-1/+1
All the other `emit`/`emit_diagnostic` methods were recently made consuming (e.g. #119606), but this one wasn't. But it makes sense to. Much of this is straightforward, and lots of `clone` calls are avoided. There are a couple of tricky bits. - `Emitter::primary_span_formatted` no longer takes a `Diagnostic` and returns a pair. Instead it takes the two fields from `Diagnostic` that it used (`span` and `suggestions`) as `&mut`, and modifies them. This is necessary to avoid the cloning of `diag.children` in two emitters. - `from_errors_diagnostic` is rearranged so various uses of `diag` occur before the consuming `emit_diagnostic` call.
2024-02-05Rollup merge of #120641 - klensy:copypaste-me, r=notriddleMatthias Krüger-10/+21
rustdoc: trait.impl, type.impl: sort impls to make it not depend on serialization order Can be tested by running `cargo doc` with different rust versions on some crate and comparing `doc` folders: files in `trait.impl` and `type.impl` will sometimes have different order of impls.
2024-02-04Prevent running some code if it is already in the mapGuillaume Gomez-0/+8
2024-02-04rustdoc: trait.impl, type.impl: sort impls to make it not depend on ↵klensy-10/+21
serialization order
2024-02-01Fix handling of `doc_auto_cfg` feature for `cfg` attributes on glob reexportGuillaume Gomez-1/+1
2024-01-31rustdoc: Correctly handle long crate names on mobileGuillaume Gomez-7/+2
2024-01-31Rollup merge of #120501 - GuillaumeGomez:glob-reexport-attr-merge-bugfix, ↵Nadrieril-1/+19
r=notriddle rustdoc: Correctly handle attribute merge if this is a glob reexport Fixes #120487. The regression was introduced in https://github.com/rust-lang/rust/pull/113091. Only non-glob reexports should have been impacted. cc `````@Nemo157````` r? `````@notriddle`````
2024-01-30rustdoc: Correctly handle attribute merge if this is a glob reexportGuillaume Gomez-1/+19
2024-01-30Rollup merge of #117906 - GuillaumeGomez:improve-crate-name-hover, ↵Guillaume Gomez-4/+2
r=fmease,notriddle Improve display of crate name when hovered Currently when we hover the crate name, the background is stuck to the version and to the logo (when there is one): ![Screenshot from 2023-11-14 11-42-39](https://github.com/rust-lang/rust/assets/3050060/717190cd-483d-45a1-a462-e9ba342d4376) ![Screenshot from 2023-11-14 11-43-19](https://github.com/rust-lang/rust/assets/3050060/23f8bc9b-1304-4f91-ae1e-96bc508e9da6) I find it very unpleasant so I reduced the padding size and increased the margin (left and top) to keep the same positioning but not making it stuck anymore: ![Screenshot from 2024-01-29 20-40-11](https://github.com/rust-lang/rust/assets/3050060/82cf266c-7f99-4a46-a62b-ebe2445f52be) ![Screenshot from 2024-01-29 20-48-01](https://github.com/rust-lang/rust/assets/3050060/e7097c10-6e09-4bdc-a37f-070b6dac671d) [online docs](https://rustdoc.crud.net/imperio/improve-crate-name-hover/std/index.html) r? `@notriddle`
2024-01-30Rollup merge of #120250 - chadnorvell:rustdoc-xss, r=notriddleGuillaume Gomez-1/+9
rustdoc: Prevent JS injection from localStorage It turns out that you can execute arbitrary JavaScript on the rustdocs settings page. Here's how: 1. Open `settings.html` on a rustdocs site. 2. Set "preferred light theme" to "dark" to initialize the corresponding localStorage value. 3. Plant a payload by executing this in your browser's dev console: ``Object.keys(localStorage).forEach(key=>localStorage.setItem(key,`javascript:alert()//*/javascript:javascript:"/*'/*\`/*--></noscript></title></textarea></style></template></noembed></script><html " onmouseover=/*&lt;svg/*/onload=alert()onload=alert()//><svg onload=alert()><svg onload=alert()>*/</style><script>alert()</script><style>`));`` 4. Refresh the page -- you should see an alert. This could be particularly dangerous if rustdocs are deployed on a domain hosting some other application. Malicious code could circumvent `same-origin` policies and do mischievous things with user data. This change ensures that only defined themes can actually be selected (arbitrary strings from localStorage will not be written to the document), and for good measure sanitizes the theme name.
2024-01-29Improve display of crate name when hoveredGuillaume Gomez-4/+2
2024-01-29rustdoc: Prevent JS injection from localStorageChad Norvell-1/+9
2024-01-29Rollup merge of #120428 - petrochenkov:somehir2, r=compiler-errorsDylan DPC-1/+1
hir: Two preparatory changes for #120206 cc https://github.com/rust-lang/rust/pull/120206 r? ```@compiler-errors```
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-3/+4
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-28hir: Use `InferArg` in `ArrayLen::Infer`Vadim Petrochenkov-1/+1
2024-01-26Rollup merge of #103522 - Dylan-DPC:76118/array-methods-stab, r=dtolnayMatthias Krüger-1/+0
stabilise array methods Closes #76118 Stabilises the remaining array methods FCP is yet to be carried out for this There wasn't a clear consensus on the naming, but all the other alternatives had some flaws as discussed in the tracking issue and there was a silence on this issue for a year
2024-01-25Rollup merge of #120288 - clubby789:bump-askama, r=GuillaumeGomezMatthias Krüger-7/+7
Bump `askama` version Ran into this while looking at #112865 and thought it would be useful to fix it now. Some more details in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Askama.20parser.20changes)
2024-01-24Bump `askama` versionclubby789-7/+7
2024-01-23Rollup merge of #112806 - kadiwa4:collect_intra_doc_links, r=notriddleLeón Orell Valerian Liehr-64/+39
Small code improvements in `collect_intra_doc_links.rs` Makes some of the code more readable by shortening it, and removes some unnecessary bounds checks.
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-11/+11
2024-01-23Rename `TyCtxt::struct_lint_node` as `TyCtxt::node_lint`.Nicholas Nethercote-1/+1
2024-01-22Auto merge of #120080 - cuviper:128-align-packed, r=nikicbors-1/+1
Pack u128 in the compiler to mitigate new alignment This is based on #116672, adding a new `#[repr(packed(8))]` wrapper on `u128` to avoid changing any of the compiler's size assertions. This is needed in two places: * `SwitchTargets`, otherwise its `SmallVec<[u128; 1]>` gets padded up to 32 bytes. * `LitKind::Int`, so that entire `enum` can stay 24 bytes. * This change definitely has far-reaching effects though, since it's public.
2024-01-22Rollup merge of #119986 - nnethercote:fix-error-counting, ↵Matthias Krüger-3/+5
r=compiler-errors,oli-obk Fix error counting There is some messiness in how errors get counted. Here are some cleanups. r? `@compiler-errors`
2024-01-22Rollup merge of #119746 - notriddle:notriddle/resize-close-modals, r=fmeaseMatthias Krüger-0/+1
rustdoc: hide modals when resizing the sidebar Follow-up for https://github.com/rust-lang/rust/pull/119477#discussion_r1439085011 CC `@lukas-code`
2024-01-22Tweak error counting.Nicholas Nethercote-3/+5
We have several methods indicating the presence of errors, lint errors, and delayed bugs. I find it frustrating that it's very unclear which one you should use in any particular spot. This commit attempts to instill a basic principle of "use the least general one possible", because that reflects reality in practice -- `has_errors` is the least general one and has by far the most uses (esp. via `abort_if_errors`). Specifics: - Add some comments giving some usage guidelines. - Prefer `has_errors` to comparing `err_count` to zero. - Remove `has_errors_or_span_delayed_bugs` because it's a weird one: in the cases where we need to count delayed bugs, we should really be counting lint errors as well. - Rename `is_compilation_going_to_fail` as `has_errors_or_lint_errors_or_span_delayed_bugs`, for consistency with `has_errors` and `has_errors_or_lint_errors`. - Change a few other `has_errors_or_lint_errors` calls to `has_errors`, as per the "least general" principle. This didn't turn out to be as neat as I hoped when I started, but I think it's still an improvement.
2024-01-20Fix impl stripped in rustdoc HTML whereas it should not be in case the impl ↵Guillaume Gomez-12/+19
is implemented on a type alias
2024-01-19Pack the u128 in LitKind::IntJosh Stone-1/+1
2024-01-19Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddleMatthias Krüger-83/+139
[rustdoc] Allows links in headings Reopening of https://github.com/rust-lang/rust/pull/94360. # Explanations Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this: ![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3) <details> <summary>previous version</summary> ![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee) </details> Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it. You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html). cc `@camelid` r? `@notriddle`
2024-01-18Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasperMatthias Krüger-5/+6
replace `track_errors` usages with bubbling up `ErrorGuaranteed` more of the same as https://github.com/rust-lang/rust/pull/117449 (removing `track_errors`)
2024-01-17Make crate_inherent_impls fallible and stop using `track_errors` for itOli Scherer-5/+6
2024-01-17Add `PatKind::Err`Lieselotte-1/+3
2024-01-13Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, ↵bors-4/+5
r=Nilstrieb Suggest Upgrading Compiler for Gated Features This PR addresses #117318 I have a few questions: 1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag a. How can I handle the changing message in the tests? 3. Do we want to only show this message when the compiler is old? a. How can we determine when the compiler is old? I'll wait until we figure out the message to bless the tests
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-4/+5
2024-01-13Rollup merge of #119898 - compiler-errors:error-reporting, r=oli-obkMatthias Krüger-1/+0
Remove unused `ErrorReporting` variant from overflow handling r? oli-obk
2024-01-12Remove unused ErrorReporting variant from overflow handlingMichael Goulet-1/+0
2024-01-12Delegation implementation: step 1Bryanskiy-1/+1