Skip to content

Commit d939e5a

Browse files
committed
Auto merge of rust-lang#103804 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum
[stable] 1.67.0 release Last minute backports: * rustdoc: add support for incoherent impls on structs and traits rust-lang#103746 r? `@ghost`
2 parents 90b3882 + 4bf5437 commit d939e5a

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

src/ci/channel

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
beta
1+
stable

src/librustdoc/clean/inline.rs

+15
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,21 @@ pub(crate) fn build_impls(
296296
for &did in tcx.inherent_impls(did).iter() {
297297
build_impl(cx, parent_module, did, attrs, ret);
298298
}
299+
300+
// This pretty much exists expressly for `dyn Error` traits that exist in the `alloc` crate.
301+
// See also:
302+
//
303+
// * https://github.com/rust-lang/rust/issues/103170 — where it didn't used to get documented
304+
// * https://github.com/rust-lang/rust/pull/99917 — where the feature got used
305+
// * https://github.com/rust-lang/rust/issues/53487 — overall tracking issue for Error
306+
if tcx.has_attr(did, sym::rustc_has_incoherent_inherent_impls) {
307+
use rustc_middle::ty::fast_reject::SimplifiedTypeGen::*;
308+
let type_ =
309+
if tcx.is_trait(did) { TraitSimplifiedType(did) } else { AdtSimplifiedType(did) };
310+
for &did in tcx.incoherent_impls(type_) {
311+
build_impl(cx, parent_module, did, attrs, ret);
312+
}
313+
}
299314
}
300315

301316
/// `parent_module` refers to the parent of the re-export, not the original item
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(rustc_attrs)]
2+
3+
#[rustc_has_incoherent_inherent_impls]
4+
pub trait FooTrait {}
5+
6+
#[rustc_has_incoherent_inherent_impls]
7+
pub struct FooStruct;
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// aux-build:incoherent-impl-types.rs
2+
// build-aux-docs
3+
4+
#![crate_name = "foo"]
5+
#![feature(rustc_attrs)]
6+
7+
extern crate incoherent_impl_types;
8+
9+
// The only way this actually shows up is if the type gets inlined.
10+
#[doc(inline)]
11+
pub use incoherent_impl_types::FooTrait;
12+
13+
// @has foo/trait.FooTrait.html
14+
// @count - '//section[@id="method.do_something"]' 1
15+
impl dyn FooTrait {
16+
#[rustc_allow_incoherent_impl]
17+
pub fn do_something() {}
18+
}
19+
20+
#[doc(inline)]
21+
pub use incoherent_impl_types::FooStruct;
22+
23+
// @has foo/struct.FooStruct.html
24+
// @count - '//section[@id="method.do_something"]' 1
25+
impl FooStruct {
26+
#[rustc_allow_incoherent_impl]
27+
pub fn do_something() {}
28+
}

0 commit comments

Comments
 (0)