about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-16 07:24:40 +0900
committerGitHub <noreply@github.com>2022-06-16 07:24:40 +0900
commit4ee78a686facf95eb640fc00d5b92d4e9281e81c (patch)
treeba451d17fb0ed0b8beba3ff15aee2fc49b4de334 /src/test
parent52afa3a70c2f5fad0c61f06497b13b66490b97a8 (diff)
parent99cd9cae10fd7c9db35f3047a7f376bdb2d13f66 (diff)
downloadrust-4ee78a686facf95eb640fc00d5b92d4e9281e81c.tar.gz
rust-4ee78a686facf95eb640fc00d5b92d4e9281e81c.zip
Rollup merge of #98053 - GuillaumeGomez:fix-generic-impl-json-ice, r=notriddle
Fix generic impl rustdoc json output

Fixes #97986.

The problem in case of generic trait impl is that the trait's items are the same for all the types afterward. But since they're the same, it's safe for rustdoc-json to just ignore them.

A little representation of what's going on:

```rust
trait T {
    fn f(); // <- defid 0
}

impl<Y> T for Y {
    fn f() {} // <- defid 1
}

struct S; // <- defid 1 (since it matches `impl<Y> T for Y`
```

cc ```@Urgau```

r? ```@CraftSpider```
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc-json/generic_impl.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/rustdoc-json/generic_impl.rs b/src/test/rustdoc-json/generic_impl.rs
new file mode 100644
index 00000000000..ac68ba578b6
--- /dev/null
+++ b/src/test/rustdoc-json/generic_impl.rs
@@ -0,0 +1,24 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/97986>.
+
+// @has generic_impl.json
+// @has - "$.index[*][?(@.name=='f')]"
+// @has - "$.index[*][?(@.name=='AssocTy')]"
+// @has - "$.index[*][?(@.name=='AssocConst')]"
+
+pub mod m {
+    pub struct S;
+}
+
+pub trait F {
+    type AssocTy;
+    const AssocConst: usize;
+    fn f() -> m::S;
+}
+
+impl<T> F for T {
+    type AssocTy = u32;
+    const AssocConst: usize = 0;
+    fn f() -> m::S {
+        m::S
+    }
+}