about summary refs log tree commit diff
path: root/src/librustdoc/doctest
AgeCommit message (Collapse)AuthorLines
2025-03-10Rollup merge of #138281 - saethlin:mergeable-doctests-stacksize, ↵Matthias Krüger-9/+10
r=GuillaumeGomez Fix O(tests) stack usage in edition 2024 mergeable doctests Fixes https://github.com/rust-lang/rust/issues/138248 The important change here is that we are not passing a potentially-large array by value. Between the fact that `TestFn` cannot be `Clone` and `test_main` takes a `Vec<TestDescAndFn>`, the only way to call `test::test_main` without O(tests) stack use is to call `Vec::push` many times. The normal test harness does not have this problem because it calls `test_main_static` or `test_main_static_abort`, which take `&[TestDescAndFn]`. Changing `test::test_main` to take a slice is not a simple change, so I'm avoiding doing it here.
2025-03-10rustdoc: Gate unstable `doc(cfg())` predicatesclubby789-1/+1
2025-03-10Fix O(tests) stack usage in edition 2024 mergeable doctestsBen Kimock-9/+10
2025-03-10doctests: build test bundle and harness separatelyMichael Howell-12/+25
This prevents the included test case from getting at nightly-only features when run on stable. The harness builds with RUSTC_BOOTSTRAP, but the bundle doesn't.
2025-03-07Rollup merge of #138107 - yotamofek:pr/rustdoc/clippy, r=GuillaumeGomezMatthias Krüger-2/+2
`librustdoc`: clippy fixes First commit is all machine-generated fixes, next two are some more lints fixed by hand/misc. cleanups Inspired by the redundant `.and_then()` added in https://github.com/rust-lang/rust/pull/137320 , and [this comment](https://github.com/rust-lang/rust/pull/138090#discussion_r1983111856) r? ```@GuillaumeGomez```
2025-03-06`x clippy src/librustdoc --fix`Yotam Ofek-2/+2
2025-03-06`librustdoc`: flatten nested ifsYotam Ofek-3/+2
2025-02-28Fully qualify `Result` in generated doctest codeGuillaume Gomez-2/+2
2025-02-24Fix rustdoc and clippyJana Dönszelmann-1/+1
2025-02-18Rollup merge of #136599 - yotamofek:pr/rustdoc-more-joined, r=GuillaumeGomezMatthias Krüger-6/+10
librustdoc: more usages of `Joined::joined` Some missed opportunities from #136244 r? ```@GuillaumeGomez``` since you reviewed the last one (feel free to re-assign, of course 😊) First two commits are just drive-by cleanups
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-1/+1
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-17librustdoc: more usages of `Joined::joined`Yotam Ofek-6/+10
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-3/+3
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-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-5/+5
2025-01-29Improve code and add missing docs for new `doctest::extracted` moduleGuillaume Gomez-1/+10
2025-01-29Move extracted doctest code and types into its own fileGuillaume Gomez-0/+132
2025-01-13rustdoc: Eliminate `AttributesExt`Noah Lev-1/+3
The new code is more explicit and avoids trait magic that added needless complexity to this part of rustdoc.
2025-01-12rustdoc: Extract `AttributesExt::cfg` trait method as functionNoah Lev-3/+2
It's never overridden, so it shouldn't be on the trait.
2024-12-25Improve rustdoc codeGuillaume Gomez-1/+1
2024-12-20Move test into the `tests.rs` fileGuillaume Gomez-0/+22
2024-12-16Rollup merge of #134260 - GuillaumeGomez:doctest-attrs, r=notriddleMatthias Krüger-18/+42
Correctly handle comments in attributes in doctests source code Fixes https://github.com/rust-lang/rust/issues/134221. The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute. r? ``@notriddle``
2024-12-16Remove unneeded handling of backlines in doctest attributesGuillaume Gomez-2/+0
2024-12-16Also handle cases where attributes are unclosedGuillaume Gomez-16/+40
2024-12-15Add hir::AttributeJonathan Dönszelmann-1/+1
2024-12-13Correctly handle comments in attributes in doctests source codeGuillaume Gomez-0/+2
2024-11-28Fix new clippy lintsGuillaume Gomez-1/+1
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 #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-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-24Do not consider nested functions as `main` function even if named `main` in ↵Guillaume Gomez-4/+11
doctests
2024-10-15Rollup merge of #131095 - GuillaumeGomez:switch-to-env-variables, r=notriddleMatthias Krüger-26/+16
Use environment variables instead of command line arguments for merged doctests Fixes [#130796](https://github.com/rust-lang/rust/issues/130796). Before merging this one, let's first ensure it has a smaller impact compared to command line arguments (results can be seen [here](https://github.com/rust-lang/rust/pull/130285)). I'll start a crater run once CI passed. cc ``@ehuss`` r? ``@notriddle``
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-3/+3
2024-10-03Rollup merge of #130419 - nnethercote:streamline-HirCollector, r=GuillaumeGomezMatthias Krüger-20/+10
Streamline `HirCollector` r? `@GuillaumeGomez`
2024-10-01Remove usage of `allow(unused)` attribute on `no_run` doctestsGuillaume Gomez-4/+0
2024-10-01Use environment variables instead of command line arguments for merged doctestsGuillaume Gomez-26/+16
2024-09-28Rename `standalone` doctest attribute into `standalone-crate`Guillaume Gomez-1/+1
2024-09-25Remove `HirCollector::map`.Nicholas Nethercote-11/+4
Because `rustc_middle::hir::map::Map` is a trivial wrapper around `TyCtxt`, and `HirCollector` has a `TyCtxt` field.
2024-09-25Remove `HirCollector::sess`.Nicholas Nethercote-10/+7
It's redundant w.r.t. `HirCollector::tcx`. This removes the unnecessary `'a` lifetime.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-11/+11
2024-09-19rustdoc: use the correct span for doctestsMichael Howell-11/+2
2024-09-07librustdoc::config: removed Input from OptionsEtomicBomb-6/+5
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-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-4/+6
2024-08-20Remove unneeded conversion to `DefId` for `ExtraInfo`Guillaume Gomez-1/+1
2024-08-17Remove useless attributes in merged doctest generated codeGuillaume Gomez-4/+0
2024-08-13Run fmtGuillaume Gomez-6/+7
2024-08-13Move `is_multiple_tests` argument into `RunnableDocTest`Guillaume Gomez-7/+3
2024-08-13Unify naming of `DocTest`Guillaume Gomez-18/+17
2024-08-13Remove need for `unsafe` code in merged doctestsGuillaume Gomez-5/+10