Skip to content

Commit ed9faee

Browse files
authored
Rollup merge of #96887 - notriddle:notriddle/as-raw-fd, r=jsha
rustdoc: correct path to type alias methods Fixes #83991
2 parents 81c0a2d + 9dc5ac8 commit ed9faee

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

src/librustdoc/formats/cache.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
288288
// for where the type was defined. On the other
289289
// hand, `paths` always has the right
290290
// information if present.
291-
Some(&(
292-
ref fqp,
293-
ItemType::Trait
294-
| ItemType::Struct
295-
| ItemType::Union
296-
| ItemType::Enum,
297-
)) => Some(&fqp[..fqp.len() - 1]),
298-
Some(..) => Some(&*self.cache.stack),
291+
Some(&(ref fqp, _)) => Some(&fqp[..fqp.len() - 1]),
299292
None => None,
300293
};
301294
((Some(*last), path), true)

src/test/rustdoc-js-std/asrawfd.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ignore-order
2+
3+
const QUERY = 'RawFd::as_raw_fd';
4+
5+
const EXPECTED = {
6+
'others': [
7+
// Reproduction test for https://github.com/rust-lang/rust/issues/78724
8+
// Validate that type alias methods get the correct path.
9+
{ 'path': 'std::os::unix::io::AsRawFd', 'name': 'as_raw_fd' },
10+
{ 'path': 'std::os::wasi::io::AsRawFd', 'name': 'as_raw_fd' },
11+
{ 'path': 'std::os::linux::process::PidFd', 'name': 'as_raw_fd' },
12+
{ 'path': 'std::os::unix::io::RawFd', 'name': 'as_raw_fd' },
13+
],
14+
};
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const QUERY = 'MyForeignType::my_method';
2+
3+
const EXPECTED = {
4+
'others': [
5+
// Test case for https://github.com/rust-lang/rust/pull/96887#pullrequestreview-967154358
6+
// Validates that the parent path for a foreign type method is correct.
7+
{ 'path': 'foreign_type_path::aaaaaaa::MyForeignType', 'name': 'my_method' },
8+
],
9+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(extern_types)]
2+
3+
pub mod aaaaaaa {
4+
5+
extern {
6+
pub type MyForeignType;
7+
}
8+
9+
impl MyForeignType {
10+
pub fn my_method() {}
11+
}
12+
13+
}

0 commit comments

Comments
 (0)