Skip to content

Commit e0f92bb

Browse files
authored
Rollup merge of rust-lang#139688 - rust-lang:notriddle/io-result-unbox, r=GuillaumeGomez
rustdoc-search: add unbox flag to Result aliases Fixes rust-lang#139665
2 parents 096369d + e013cf8 commit e0f92bb

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

compiler/rustc_passes/src/check_attr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11091109
ItemKind::Trait(_, _, _, generics, _, items)
11101110
if generics.params.len() != 0
11111111
|| items.iter().any(|item| matches!(item.kind, AssocItemKind::Type)) => {}
1112+
ItemKind::TyAlias(_, _, generics) if generics.params.len() != 0 => {}
11121113
_ => {
11131114
self.dcx().emit_err(errors::DocSearchUnboxInvalid { span: meta.span() });
11141115
}

library/std/src/io/error.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use crate::{error, fmt, result, sys};
4848
/// }
4949
/// ```
5050
#[stable(feature = "rust1", since = "1.0.0")]
51+
#[cfg_attr(not(bootstrap), doc(search_unbox))]
5152
pub type Result<T> = result::Result<T, Error>;
5253

5354
/// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and

library/std/src/thread/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,7 @@ impl fmt::Debug for Thread {
16761676
/// [`Result`]: crate::result::Result
16771677
/// [`std::panic::resume_unwind`]: crate::panic::resume_unwind
16781678
#[stable(feature = "rust1", since = "1.0.0")]
1679+
#[cfg_attr(not(bootstrap), doc(search_unbox))]
16791680
pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
16801681

16811682
// This packet is used to communicate the return value between the spawned
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// exact-check
2+
3+
// Test case for https://github.com/rust-lang/rust/issues/139665
4+
// make sure that std::io::Result and std::thread::Result get unboxed
5+
6+
const EXPECTED = [
7+
{
8+
query: "File -> Metadata",
9+
others: [
10+
{ path: "std::fs::File", name: "metadata" },
11+
{ path: "std::fs::File", name: "metadata_at" },
12+
]
13+
},
14+
{
15+
query: "JoinHandle<T> -> T",
16+
others: [
17+
{ path: "std::thread::JoinHandle", name: "join" },
18+
]
19+
},
20+
];

tests/rustdoc-js/generics-unbox.js

+6
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ const EXPECTED = [
3131
{ 'path': 'generics_unbox', 'name': 'beta' },
3232
],
3333
},
34+
{
35+
'query': '-> Sigma',
36+
'others': [
37+
{ 'path': 'generics_unbox', 'name': 'delta' },
38+
],
39+
},
3440
];

tests/rustdoc-js/generics-unbox.rs

+12
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ pub fn beta<T, U>(_: Inside<T>) -> Out<Out3<T, U>, Out4<U, T>> {
4242
pub fn gamma<T, U>(_: Inside<T>) -> Out<Out3<U, T>, Out4<T, U>> {
4343
loop {}
4444
}
45+
46+
pub fn delta(_: i32) -> Epsilon<Sigma> {
47+
loop {}
48+
}
49+
50+
#[doc(search_unbox)]
51+
pub struct Theta<T>(T);
52+
53+
#[doc(search_unbox)]
54+
pub type Epsilon<T> = Theta<T>;
55+
56+
pub struct Sigma;

0 commit comments

Comments
 (0)