about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-10-30 19:31:39 -0700
committerGitHub <noreply@github.com>2022-10-30 19:31:39 -0700
commitc61a32aff24653868c903f86c4e152ab39c220ac (patch)
treee4b30a9c64d0ec9135ef9faaa629c3096cece0b0 /src/test
parent16ca46297b34f924d8d082e8b7ae9ba4d87c66e2 (diff)
parent3195388e82892fdcdd7351d67ead8eca45a66f90 (diff)
downloadrust-c61a32aff24653868c903f86c4e152ab39c220ac.tar.gz
rust-c61a32aff24653868c903f86c4e152ab39c220ac.zip
Rollup merge of #103746 - notriddle:notriddle/incoherent-dyn-trait, r=GuillaumeGomez
rustdoc: add support for incoherent impls on structs and traits

Fixes #103170
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc/auxiliary/incoherent-impl-types.rs7
-rw-r--r--src/test/rustdoc/rustc-incoherent-impls.rs28
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/rustdoc/auxiliary/incoherent-impl-types.rs b/src/test/rustdoc/auxiliary/incoherent-impl-types.rs
new file mode 100644
index 00000000000..fc51e42e500
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/incoherent-impl-types.rs
@@ -0,0 +1,7 @@
+#![feature(rustc_attrs)]
+
+#[rustc_has_incoherent_inherent_impls]
+pub trait FooTrait {}
+
+#[rustc_has_incoherent_inherent_impls]
+pub struct FooStruct;
diff --git a/src/test/rustdoc/rustc-incoherent-impls.rs b/src/test/rustdoc/rustc-incoherent-impls.rs
new file mode 100644
index 00000000000..3fdefbecc54
--- /dev/null
+++ b/src/test/rustdoc/rustc-incoherent-impls.rs
@@ -0,0 +1,28 @@
+// aux-build:incoherent-impl-types.rs
+// build-aux-docs
+
+#![crate_name = "foo"]
+#![feature(rustc_attrs)]
+
+extern crate incoherent_impl_types;
+
+// The only way this actually shows up is if the type gets inlined.
+#[doc(inline)]
+pub use incoherent_impl_types::FooTrait;
+
+// @has foo/trait.FooTrait.html
+// @count - '//section[@id="method.do_something"]' 1
+impl dyn FooTrait {
+    #[rustc_allow_incoherent_impl]
+    pub fn do_something() {}
+}
+
+#[doc(inline)]
+pub use incoherent_impl_types::FooStruct;
+
+// @has foo/struct.FooStruct.html
+// @count - '//section[@id="method.do_something"]' 1
+impl FooStruct {
+    #[rustc_allow_incoherent_impl]
+    pub fn do_something() {}
+}