summary refs log tree commit diff
path: root/tests/rustdoc-json
AgeCommit message (Collapse)AuthorLines
2025-06-22Port `#[must_use]` to new attribute parsing infrastructureJonathan Brouwer-2/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-21rustdoc_json: represent generic args consistently.Nicholas Nethercote-2/+2
They show up in three places: once as `Option<Box<GenericArgs>>`, once as `Box<GenericArgs>`, and once as `GenericArgs`. The first option is best. It is more compact because generic args are often missing. This commit changes the latter two to the former. Example output, before and after, for the `AssocItemConstraint` change: ``` {"name":"Offset","args":{"angle_bracketed":{"args":[],"constraints":[]}},"binding":{...}} {"name":"Offset","args":null,"binding":{...}} ``` Example output, before and after, for the `Type::QualifiedPath` change: ``` {"qualified_path":{"name":"Offset","args":{"angle_bracketed":{"args":[],"constraints":[]}}, ...}} {"qualified_path":{"name":"Offset","args":null, ...}} ``` This reduces JSON output size, but not by much (e.g. 0.5%), because `AssocItemConstraint` and `Type::QualifiedPath` are uncommon.
2025-06-21rustdoc_json: Fix handling of paths with no generic args.Nicholas Nethercote-1/+1
A path without generic args, like `Reader`, currently has JSON produced like this: ``` {"path":"Reader","id":286,"args":{"angle_bracketed":{"args":[],"constraints":[]}}} ``` Even though `types::Path::args` is `Option` and allows for "no args", instead it gets represented as "empty args". (More like `Reader<>` than `Reader`.) This is due to a problem in `clean::Path::from_clean`. It only produces `None` if the path is an empty string. This commit changes it to also produce `None` if there are no generic args. The example above becomes: ``` {"path":"Reader","id":286,"args":null} ``` I looked at a few examples and saw this reduce the size of the JSON output by 3-9%. The commit also adds an assertion that non-final segments don't have any generics; something the old code was implicitly relying on. Note: the original sin here is that `clean::PathSegment::args` is not an `Option`, unlike `{ast,hir}::PathSegment::args`. I want to fix that, but it can be done separately.
2025-06-21rustdoc_json: Add a test for some `GenericArgs` cases.Nicholas Nethercote-0/+20
2025-06-17fix clippyJana Dönszelmann-3/+3
2025-06-16rustdoc: `{Meta,Pointee,}Sized` in non-minicoreDavid Wood-4/+16
Some rustdoc tests are `no_core` and need to have `MetaSized` and `PointeeSized` added to them.
2025-06-09rustdoc-json: Rearrange deck chairs in ABI testingJubilee Young-24/+38
We move the vectorcall ABI tests into their own file which is now only run on x86-64, while replacing them with rust-cold ABI tests so that aarch64 hosts continue to test an unstable ABI. A better solution might be cross-compiling or something but I really don't have time for that right now.
2025-05-28Stabilise `repr128`beetrees-3/+0
2025-05-22rustdoc JSON: Don't apply `#[repr]` privacy heuristicsLeón Orell Valerian Liehr-37/+4
2025-05-21rustdoc-json: Remove false docs and add test for inline attributeAlona Enraght-Moony-0/+11
The docs about how `#[inline]` was represented isn't true. Updates the comment, and adds a test. CC https://www.github.com/rust-lang/rust/issues/137645
2025-05-07rustdoc-json: Remove newlines from attributesAlona Enraght-Moony-12/+12
2025-05-03Improve hir pretty-printing of attributes.Nicholas Nethercote-12/+12
2025-04-21Rollup merge of #140076 - aDotInTheVoid:jsondocline, r=GuillaumeGomezChris Denton-1/+1
jsondocck: Require command is at start of line In one place we use `///``@``` instead of `//``@`.`` The test-runner allowed it, but it probably shouldn't. Ran into by ``@lolbinarycat`` in https://github.com/rust-lang/rust/pull/132748#issuecomment-2816469322: ``` error: unknown disambiguator `?(` ##[error] --> /checkout/tests/rustdoc-json/fns/return_type_alias.rs:3:25 | 3 | ///@ set foo = "$.index[?(``@.name=='Foo')].id"`` | ^^ | ``` Maybe it's also worth erroring on this like we added in #137103 r? ``@GuillaumeGomez``
2025-04-20jsondocck: Require command is at start of lineAlona Enraght-Moony-1/+1
2025-04-20rustdoc-json: Improve test for auto-trait implsAlona Enraght-Moony-2/+4
2025-04-18Add regression test for span 1-indexed checkGuillaume Gomez-2/+6
2025-04-15rustdoc: Output target feature informationWill Glynn-0/+132
`#[target_feature]` attributes refer to a target-specific list of features. Enabling certain features can imply enabling other features. Certain features are always enabled on certain targets, since they are required by the target's ABI. Features can also be enabled indirectly based on other compiler flags. Feature information is ultimately known to `rustc`. Rather than force external tools to track it -- which may be wildly impractical due to `-C target-cpu` -- have `rustdoc` output `rustc`'s feature data.
2025-03-31rustdoc-json: Add test for #[automatically_derived] attributeAlona Enraght-Moony-0/+13
2025-03-22rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.Predrag Gruevski-31/+47
2025-03-21tests/rustdoc-json: change assertions to use RFC 9535 jsonpathAlona Enraght-Moony-25/+25
2025-03-21tests/rustdoc-json: replace `$.paths[*][?` with `$.paths[?`Alona Enraght-Moony-6/+6
This fixes all 3 of these tests. Done automatically in VSCode.
2025-03-21tests/rustdoc-json: replace `$.index[*][?` with `$.index[?`Alona Enraght-Moony-1155/+1155
Done automatically with VSCode.
2025-03-18Rollup merge of #138569 - aDotInTheVoid:reprdoc-json, r=GuillaumeGomezMatthias Krüger-0/+163
rustdoc-json: Add tests for `#[repr(...)]` Works towards #137645 and #81359 Based on #138018, but with only the test changes. CC ```@obi1kenobi``` r? ```@GuillaumeGomez```
2025-03-16rustdoc-json: Don't also include `#[deprecated]` in `Item::attrs`Alona Enraght-Moony-8/+8
2025-03-16rustdoc-json: Add tests for `#[deprecated(...)]`Alona Enraght-Moony-0/+38
2025-03-16rustdoc-json: Add tests for `#[repr(...)]`Alona Enraght-Moony-0/+163
Co-authored-by: Predrag Gruevski <obi1kenobi82@gmail.com>
2025-03-15Add RTN support to rustdocMichael Goulet-0/+18
2025-03-13Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-arg, ↵Matthias Krüger-3/+3
r=aDotInTheVoid,compiler-errors make precise capturing args in rustdoc Json typed close #137616 This PR includes below changes. - Add `rustc_hir::PreciseCapturingArgKind` which allows the query system to return a arg's data. - Add `rustdoc::clean::types::PreciseCapturingArg` and change to use it. - Add `rustdoc-json-types::PreciseCapturingArg` and change to use it. - Update `tests/rustdoc-json/impl-trait-precise-capturing.rs`. - Bump `rustdoc_json_types::FORMAT_VERSION`.
2025-03-10make precise capturing args in rustdoc Json typedmorine0122-3/+3
2025-03-10Fix pretty printing of parsed attrs in hir_prettyMichael Goulet-2/+2
2025-03-05rustdoc: Add attribute-related tests for rustdoc JSON.Predrag Gruevski-0/+58
2025-03-03Always allow rustdoc-json tests to contain long linesNoratrieb-72/+0
The rustdoc-json test syntax often requires very long lines, so the checks for long lines aren't really useful.
2025-02-24Fix rustdoc and clippyJana Dönszelmann-2/+2
2025-02-04Add missing lang items in no_core tests in rustdocMichael Goulet-1/+4
2025-01-22rustdoc-json: Rename `Path::name` to `path`, and give it path (again).Alona Enraght-Moony-15/+110
Closes https://github.com/rust-lang/rust/issues/135600 Effectivly reverts https://github.com/rust-lang/rust/pull/134880
2025-01-14Rollup merge of #134880 - as1100k-forks:fix-rustdoc-json-path-name, ↵Matthias Krüger-1/+1
r=aDotInTheVoid Made `Path::name` only have item name rather than full name Closes #134853 This PR makes `Path::name` to only have item name rather than full name, i.e. with the following code ```rust pub mod foo { pub struct Bar; } pub fn get_bar() -> foo::Bar { foo::Bar } ``` and running `./rustdoc ./demo.rs -wjson -Zunstable-options` gives: ```json { "41": { "id": 41, "name": "get_bar", "inner": { "function": { "sig": { "inputs": [], "output": { "resolved_path": { "name": "Bar", "id": 0, "args": { "angle_bracketed": { "args": [], "constraints": [] } } } } } } } } } ``` _Information which isn't useful here was trimmed_ r? aDotInTheVoid
2025-01-14Made `Path::name` only have item name rather than full nameAditya Kumar-1/+1
2025-01-10rustdoc-json: Include items in stripped modules in `Crate::paths`.Alona Enraght-Moony-0/+11
2024-12-17Remove `rustc::existing_doc_keyword` lint.Nicholas Nethercote-5/+5
`CheckAttrVisitor::check_doc_keyword` checks `#[doc(keyword = "..")]` attributes to ensure they are on an empty module, and that the value is a non-empty identifier. The `rustc::existing_doc_keyword` lint checks these attributes to ensure that the value is the name of a keyword. It's silly to have two different checking mechanisms for these attributes. This commit does the following. - Changes `check_doc_keyword` to check that the value is the name of a keyword (avoiding the need for the identifier check, which removes a dependency on `rustc_lexer`). - Removes the lint. - Updates tests accordingly. There is one hack: the `SelfTy` FIXME case used to used to be handled by disabling the lint, but now is handled with a special case in `is_doc_keyword`. That hack will go away if/when the FIXME is fixed. Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2024-12-02Rollup merge of #133721 - aDotInTheVoid:rdj-dyn-link, r=GuillaumeGomezGuillaume Gomez-0/+15
rustdoc-json: Add test for `impl Trait for dyn Trait` Found while investigating #133719 Helps with #81359 r? `@GuillaumeGomez`
2024-12-01rustdoc-json: Add test for `impl Trait for dyn Trait`Alona Enraght-Moony-0/+15
2024-12-01rustdoc-json: Include safety of `static`sAlona Enraght-Moony-0/+41
2024-12-01rustdoc-json: Add tests for `static`sAlona Enraght-Moony-0/+10
2024-10-22Rename Receiver -> LegacyReceiverAdrian Taylor-2/+2
As part of the "arbitrary self types v2" project, we are going to replace the current `Receiver` trait with a new mechanism based on a new, different `Receiver` trait. This PR renames the old trait to get it out the way. Naming is hard. Options considered included: * HardCodedReceiver (because it should only be used for things in the standard library, and hence is sort-of hard coded) * LegacyReceiver * TargetLessReceiver * OldReceiver These are all bad names, but fortunately this will be temporary. Assuming the new mechanism proceeds to stabilization as intended, the legacy trait will be removed altogether. Although we expect this trait to be used only in the standard library, we suspect it may be in use elsehwere, so we're landing this change separately to identify any surprising breakages. It's known that this trait is used within the Rust for Linux project; a patch is in progress to remove their dependency. This is a part of the arbitrary self types v2 project, https://github.com/rust-lang/rfcs/pull/3519 https://github.com/rust-lang/rust/issues/44874 r? @wesleywiser
2024-10-16rustdoc-JSON: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-19/+19
2024-10-11Remove unadornedMichael Goulet-1/+1
2024-10-10rustdoc-json: Add tests for unsafe/safe extern blocks (RFC 3484)Alona Enraght-Moony-0/+17
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+5
2024-09-01rustdoc: normalise type/field names in rustdoc-json-types/jsondoclintschvv31n-245/+245
2024-08-31Rollup merge of #129123 - aDotInTheVoid:rustdoc-json-self, r=fmeaseMatthias Krüger-0/+58
rustdoc-json: Add test for `Self` type Inspired by #128471, the rustdoc-json suite had no tests in place for the `Self` type. This PR adds one. I've also manually checked locally that this test passes on 29e924841f06bb181d87494eba2783761bc1ddec, confirming that adding `clean::Type::SelfTy` didn't change the JSON output. (potentially adding a self type to json (insead of (ab)using generic) is tracked in #128522) Updates #81359 r? ````````@fmease````````