Commit graph

80 commits

Author SHA1 Message Date
Chris Denton
df9e15e69f
Rollup merge of #140076 - aDotInTheVoid:jsondocline, r=GuillaumeGomez
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-21 18:53:19 +00:00
Alona Enraght-Moony
fd4a093a4e jsondocck: Require command is at start of line 2025-04-20 11:37:00 +00:00
Alona Enraght-Moony
c7e976eb1e rustdoc-json: Improve test for auto-trait impls 2025-04-20 11:28:16 +00:00
Guillaume Gomez
ba9a008d90 Add regression test for span 1-indexed check 2025-04-18 20:32:40 +02:00
Will Glynn
8c50f95cf0 rustdoc: Output target feature information
`#[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-04-15 21:26:14 -05:00
Alona Enraght-Moony
7feac15ca7 rustdoc-json: Add test for #[automatically_derived] attribute 2025-03-31 20:42:49 +00:00
Predrag Gruevski
bafdbcadd5 rustdoc: Use own logic to print #[repr(..)] attributes in JSON output. 2025-03-22 18:47:12 +00:00
Alona Enraght-Moony
13335e313c tests/rustdoc-json: change assertions to use RFC 9535 jsonpath 2025-03-21 00:48:09 +00:00
Alona Enraght-Moony
42631d8027 tests/rustdoc-json: replace $.paths[*][? with $.paths[?
This fixes all 3 of these tests. Done automatically in VSCode.
2025-03-21 00:48:09 +00:00
Alona Enraght-Moony
7ab71c417b tests/rustdoc-json: replace $.index[*][? with $.index[?
Done automatically with VSCode.
2025-03-21 00:48:09 +00:00
Matthias Krüger
bf98654e6c
Rollup merge of #138569 - aDotInTheVoid:reprdoc-json, r=GuillaumeGomez
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-18 10:09:30 +01:00
Alona Enraght-Moony
677489fb3e rustdoc-json: Don't also include #[deprecated] in Item::attrs 2025-03-16 21:27:54 +00:00
Alona Enraght-Moony
2ff28159d3 rustdoc-json: Add tests for #[deprecated(...)] 2025-03-16 21:09:46 +00:00
Alona Enraght-Moony
f5ecb74bf9 rustdoc-json: Add tests for #[repr(...)]
Co-authored-by: Predrag Gruevski <obi1kenobi82@gmail.com>
2025-03-16 20:28:17 +00:00
Michael Goulet
e3ac1fa81a Add RTN support to rustdoc 2025-03-15 18:13:27 +00:00
Matthias Krüger
1a7d2b9219
Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-arg, 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-13 11:28:26 +01:00
morine0122
112f7b01a1 make precise capturing args in rustdoc Json typed 2025-03-10 21:40:09 +09:00
Michael Goulet
279377f87a Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
Predrag Gruevski
e07d9a8200 rustdoc: Add attribute-related tests for rustdoc JSON. 2025-03-05 04:46:14 +00:00
Noratrieb
dfed028e78 Always allow rustdoc-json tests to contain long lines
The rustdoc-json test syntax often requires very long lines, so the checks
for long lines aren't really useful.
2025-03-03 19:59:54 +01:00
Jana Dönszelmann
f321f107e3
Fix rustdoc and clippy 2025-02-24 14:31:19 +01:00
Michael Goulet
36839759ce Add missing lang items in no_core tests in rustdoc 2025-02-04 01:05:31 +00:00
Alona Enraght-Moony
9c0e32bcd2 rustdoc-json: Rename Path::name to path, and give it path (again).
Closes https://github.com/rust-lang/rust/issues/135600

Effectivly reverts https://github.com/rust-lang/rust/pull/134880
2025-01-22 19:29:48 +00:00
Matthias Krüger
ca9a9d2f35
Rollup merge of #134880 - as1100k-forks:fix-rustdoc-json-path-name, 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-14 19:25:05 +01:00
Aditya Kumar
2c4aee92fa
Made Path::name only have item name rather than full name 2025-01-14 06:03:43 +00:00
Alona Enraght-Moony
1fe3331899 rustdoc-json: Include items in stripped modules in Crate::paths. 2025-01-10 23:51:45 +00:00
Nicholas Nethercote
121e87bf14 Remove rustc::existing_doc_keyword lint.
`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-17 13:56:10 +11:00
Guillaume Gomez
7fdbde0e18
Rollup merge of #133721 - aDotInTheVoid:rdj-dyn-link, r=GuillaumeGomez
rustdoc-json: Add test for `impl Trait for dyn Trait`

Found while investigating #133719

Helps with #81359

r? `@GuillaumeGomez`
2024-12-02 17:36:05 +01:00
Alona Enraght-Moony
b5d73fc167 rustdoc-json: Add test for impl Trait for dyn Trait 2024-12-01 23:13:57 +00:00
Alona Enraght-Moony
f33dba0287 rustdoc-json: Include safety of statics 2024-12-01 21:39:58 +00:00
Alona Enraght-Moony
51ea7c12e7 rustdoc-json: Add tests for statics 2024-12-01 21:37:18 +00:00
Adrian Taylor
8f85b90ca6 Rename Receiver -> LegacyReceiver
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-22 12:55:16 +00:00
León Orell Valerian Liehr
2e6f3bd1d3
rustdoc-JSON: Rename "object safe" to "dyn compatible" 2024-10-16 23:00:49 +02:00
Michael Goulet
c085071631 Remove unadorned 2024-10-11 11:30:08 -04:00
Alona Enraght-Moony
8a9b67028c rustdoc-json: Add tests for unsafe/safe extern blocks (RFC 3484) 2024-10-10 20:53:57 +00:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
schvv31n
f2696ab4d3 rustdoc: normalise type/field names in rustdoc-json-types/jsondoclint 2024-09-01 23:58:08 +03:00
Matthias Krüger
defc245d06
Rollup merge of #129123 - aDotInTheVoid:rustdoc-json-self, r=fmease
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 29e924841f, 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````````
2024-08-31 10:08:52 +02:00
Michael Goulet
eae5b5c6e7 Stabilize opaque type precise capturing 2024-08-17 12:33:29 -04:00
Alona Enraght-Moony
6ed283bb34 rustdoc-json: Add test for Self type 2024-08-15 13:07:23 +00:00
Matthias Krüger
8789b95b67
Rollup merge of #128836 - its-the-shrimp:add_test_for_107278, r=aDotInTheVoid
rustdoc-json: add a test for impls on private & hidden types

Fixes #107278 (or rather just ensures it won't resurface)
r? ``@aDotInTheVoid``
2024-08-09 00:03:38 +02:00
schvv31n
1bf30eb5aa rustdoc-json: added a test for #107278 2024-08-08 17:55:52 +01:00
schvv31n
c2a0d9ca6e rustdoc: fixed #101105
modules are now stripped based on the same logic that's used to strip other item kinds
2024-08-08 17:13:15 +01:00
Matthias Krüger
376a6f9f43
Rollup merge of #128385 - its-the-shrimp:fix_114039, r=aDotInTheVoid
rustdoc-json: discard non-local inherent impls for primitives

Fixes #114039
at least it should
r? `@aDotInTheVoid`
2024-08-05 18:36:01 +02:00
schvv31n
7499e21a1e rustdoc-json: discard non-local inherent impls 2024-08-05 11:19:22 +01:00
Alona Enraght-Moony
52a49d94c7 rustdoc: Add test for impl_trait_in_accos_type 2024-08-01 15:48:22 +00:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
León Orell Valerian Liehr
633f41de09
Update all rustdoc-json/ tests to use the new style 2024-07-19 16:54:42 +02:00
Michael Goulet
bd135e487f Add rustdoc-json support for use<> 2024-07-12 05:24:51 -04:00
schvv31n
8e7314f6e0 rustdoc-json: add trait/type alias tests 2024-07-07 15:02:30 +01:00