about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustdoc/formats/cache.rs10
-rw-r--r--src/test/rustdoc-js/foreign-type-path.js9
-rw-r--r--src/test/rustdoc-js/foreign-type-path.rs13
3 files changed, 23 insertions, 9 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index 862f0ecd0de..9dc30d8a189 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -288,15 +288,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
                             // for where the type was defined. On the other
                             // hand, `paths` always has the right
                             // information if present.
-                            Some(&(
-                                ref fqp,
-                                ItemType::Trait
-                                | ItemType::Struct
-                                | ItemType::Union
-                                | ItemType::Enum
-                                | ItemType::Typedef,
-                            )) => Some(&fqp[..fqp.len() - 1]),
-                            Some(..) => Some(&*self.cache.stack),
+                            Some(&(ref fqp, _)) => Some(&fqp[..fqp.len() - 1]),
                             None => None,
                         };
                         ((Some(*last), path), true)
diff --git a/src/test/rustdoc-js/foreign-type-path.js b/src/test/rustdoc-js/foreign-type-path.js
new file mode 100644
index 00000000000..334761badca
--- /dev/null
+++ b/src/test/rustdoc-js/foreign-type-path.js
@@ -0,0 +1,9 @@
+const QUERY = 'MyForeignType::my_method';
+
+const EXPECTED = {
+    'others': [
+        // Test case for https://github.com/rust-lang/rust/pull/96887#pullrequestreview-967154358
+        // Validates that the parent path for a foreign type method is correct.
+        { 'path': 'foreign_type_path::aaaaaaa::MyForeignType', 'name': 'my_method' },
+    ],
+};
diff --git a/src/test/rustdoc-js/foreign-type-path.rs b/src/test/rustdoc-js/foreign-type-path.rs
new file mode 100644
index 00000000000..83400104ea7
--- /dev/null
+++ b/src/test/rustdoc-js/foreign-type-path.rs
@@ -0,0 +1,13 @@
+#![feature(extern_types)]
+
+pub mod aaaaaaa {
+
+    extern {
+        pub type MyForeignType;
+    }
+
+    impl MyForeignType {
+        pub fn my_method() {}
+    }
+
+}