1
Fork 0
Commit graph

34 commits

Author SHA1 Message Date
Matthias Krüger
cbf26629c4
Rollup merge of #139913 - fmease:rustdoc-fix-fn-param-handling, r=GuillaumeGomez
rustdoc/clean: Fix lowering of fn params (fixes correctness & HIR vs. middle parity regressions)

**(0)** PR #136411 aimed to stop rendering unnamed params of fn ptr types as underscores in the common case (e.g., `fn(_: i32)` → `fn(i32)`) to make the rendered output stylistically more conventional.

**(0.a)** However, since the cleaning fn that the PR modified is also used for lowering the HIR params of foreign fns and required assoc fns in traits, it accidentally butchered the rendering of the latter two:

```rs
pub trait Trait { fn assoc_fn(_: i32); } // as well as (Rust 2015 only): fn assoc_fn(i32);
unsafe extern "C" { pub fn foreign_fn(_: i32); }

// Since 1.86 the fns above gets mis-rendered as:
pub fn assoc_fn(: i32) // <-- BUTCHERED
pub unsafe extern "C" fn foreign_fn(: i32) // <-- BUTCHERED
```

**(0.b)** Furthermore, it broke parity with middle cleaning (which includes inlined cross-crate re-exports) re-regressing parts of #44306 I once fixed in PR #103885.

**(1)** Lastly, PR #139035 introduced an ICE triggered by the following input file:

```rs
trait Trait { fn anon(()) {} } // internal error: entered unreachable code
```

---

This PR fixes all of these regressions and in the first commit renames several types and fns to be more ~~correct~~ descriptive and legible.

~~It also refactors `Param.name` to be of type `Option<Symbol>` instead `Symbol` (where `None` ~ `kw::Empty`), so rendering mistakes like that can no longer creep in like that (ignoring tests). CC #137978.~~ Independently done in PR #139846 a day prior.
2025-04-18 05:16:31 +02:00
León Orell Valerian Liehr
82ff0a0e6a
rustdoc: Properly clean fn params in all contexts 2025-04-17 08:55:53 +02:00
León Orell Valerian Liehr
9f548e298d
Support inlined cross-crate re-exported trait aliases 2025-04-17 02:35:05 +02:00
Pietro Albini
cd371b90e2
replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
Yotam Ofek
0881dba5d3 Move "unused_exter_crate" test from rustdoc-ui to rustdoc 2025-02-27 13:22:46 +00:00
Michael Goulet
aac741a465 Unsafe binder support in rustdoc 2024-12-31 01:08:43 +00:00
Michael Goulet
da2054f389 Add cross-crate precise capturing support to rustdoc 2024-07-17 11:06:10 -04:00
Guillaume Gomez
1b67035579 Update tests/rustdoc to new test syntax 2024-06-24 11:08:41 +02:00
Michael Howell
b5923a95a8 Move tests into appropriate subdirectories 2024-05-21 21:21:26 -07:00
Michael Goulet
dbfed2c43e Add failing test for cross-crate enum in type alias 2024-05-19 20:13:18 -04:00
Michael Howell
ecbe327e71 rustdoc: move tests into applicable subdirectories 2024-04-15 15:22:04 -07:00
Michael Howell
381a0e3cb0 Move ice tests to rustdoc-ui 2024-04-15 15:11:49 -07:00
Guillaume Gomez
4dd05e6424 Add regression test for link generation on foreign macro in jump to defintion feature 2024-02-27 16:20:11 +01:00
Michael Howell
24aa348586 Add test cases for inlining compiler-private items
Closes #106421

This was already fixed by
f5d43a052b, but now the test cases are
added.
2024-02-24 15:38:55 -07:00
许杰友 Jieyou Xu (Joe)
6e48b96692
[AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
Michael Howell
35830fe218 rustdoc: rename issue-\d+.rs tests to have meaningful names (part 5) 2024-01-03 15:33:12 -07:00
Michael Howell
fdde5c77a8 rustdoc: move ICE tests to ui 2023-11-23 14:54:19 -07:00
Michael Howell
69dc19043b Rename issue-\d+.rs tests to have meaningful names 2023-10-16 18:01:02 -07:00
Michael Goulet
59315b8a63 Stabilize AFIT and RPITIT 2023-10-13 21:01:36 +00:00
Guillaume Gomez
bd59fc603f Add tests for enum discriminant value display with repr 2023-10-11 23:44:12 +02:00
bors
be581d9f82 Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmease
[rustdoc] Show enum discrimant if it is a C-like variant

Fixes https://github.com/rust-lang/rust/issues/101337.

We currently display values for associated constant items in traits:

![image](03e566ec-c670-47b4-8ca2-b982baa7a0f4)

And we also display constant values like [here](file:///home/imperio/rust/rust/build/x86_64-unknown-linux-gnu/doc/std/f32/consts/constant.E.html).

I think that for coherency, we should display values of C-like enum variants.

With this change, it looks like this:

![image](b53fbbe0-bdb1-4289-8537-f2dd4988e9ac)

As for the display of the constant value itself, I used what we already have to keep coherency.

We display the C-like variants value in the following scenario:
 1. It is a C-like variant with a value set => all the time
 2. It is a C-like variant without a value set: All other variants are C-like variants and at least one them has its value set.

Here is the result in code:

```rust
// Ax and Bx value will be displayed.
enum A {
    Ax = 12,
    Bx,
}

// Ax and Bx value will not be displayed
enum B {
    Ax,
    Bx,
}

// Bx value will not be displayed
enum C {
    Ax(u32),
    Bx,
}

// Bx value will not be displayed, Cx value will be displayed.
#[repr(u32)]
enum D {
    Ax(u32),
    Bx,
    Cx = 12,
}
```

r? `@notriddle`
2023-10-09 13:18:47 +00:00
Guillaume Gomez
b0badc17cd Add cross-crate C-like variant test 2023-10-07 14:37:47 +02:00
Michael Howell
9266270ef5 Rename issue-\d+.rs tests to have meaningful names 2023-10-04 12:58:06 -07:00
Urgau
6b3bba8c3e rustdoc: handle typedef inner type when doing cross-crate inlining 2023-08-26 00:15:02 +02:00
bors
9339f446a5 Auto merge of #113374 - GuillaumeGomez:private-to-public-path, r=notriddle,fmease
[rustdoc] If re-export is private, get the next item until a public one is found or expose the private item directly

Fixes #81141.

If we have:

```rust
use Private as Something;

pub fn foo() -> Something {}
```

Then `Something` will be replaced by `Private`.

r? `@notriddle`
2023-07-27 15:56:50 +00:00
Guillaume Gomez
51eb0c3b36 Fix regression for private in public 2023-07-26 15:29:45 +02:00
Guillaume Gomez
7150e35c92 Add regression test for #113982 2023-07-24 16:32:06 +02:00
Guillaume Gomez
1af48beed7 Add rustdoc tests for lazy_type_alias 2023-06-21 13:45:00 +02:00
Oli Scherer
f263f88bea Split out a separate feature gate for impl trait in associated types 2023-04-12 16:17:31 +00:00
Guillaume Gomez
3ef8d2d607 Update tests for rustc_doc_primitive 2023-03-30 22:56:52 +02:00
Roland Strasser
71a147df1f rustdoc: trait bound formatting
rustdoc: fix item-spacer

rustdoc: use proper comment style

rustdoc: change formatting where clauses for traits

rustdoc: remove semicolon from provided methods

update provided methods formatting
2023-02-04 19:10:04 +01:00
Michael Howell
7080f80e8b rustdoc: remove unnecessary wrapper div.item-decl from HTML 2023-01-30 11:06:18 -07:00
Michael Howell
3a3f70c94e rustdoc: remove redundant item kind class from .item-decl > pre
This class originated in the very first commit of `rustdoc_ng`, and was used
to add a color border around the item decl based on its kind.

4fd061c426/src/rustdoc_ng/html/static/main.css (L102-L106)

The item decl no longer has a border, and there aren't any
kind-specific styles in modern rustdoc's rendering of this UI item.

Most of this commit is updating test cases so that they use `item-decl` to
find the `<pre>` tag instead of relying on the fact that the class name
had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
2023-01-14 11:34:03 -07:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00