Skip to content

Commit d93440c

Browse files
authored
Rollup merge of rust-lang#48473 - GuillaumeGomez:rustdoc-auto-trait-impl-fix, r=QuietMisdreavus
Fix auto trait impl rustdoc ice Fixes rust-lang#48463. r? @QuietMisdreavus
2 parents b106016 + 23dc694 commit d93440c

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/librustdoc/clean/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
2525
AdtKind::Struct => Def::Struct,
2626
AdtKind::Enum => Def::Enum,
2727
AdtKind::Union => Def::Union,
28-
},
28+
}
2929
_ => panic!("Unexpected type {:?}", def_id),
3030
};
3131

src/librustdoc/clean/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,11 @@ fn build_deref_target_impls(cx: &DocContext,
34283428
let primitive = match *target {
34293429
ResolvedPath { did, .. } if did.is_local() => continue,
34303430
ResolvedPath { did, .. } => {
3431-
ret.extend(inline::build_impls(cx, did, true));
3431+
// We set the last parameter to false to avoid looking for auto-impls for traits
3432+
// and therefore avoid an ICE.
3433+
// The reason behind this is that auto-traits don't propagate through Deref so
3434+
// we're not supposed to synthesise impls for them.
3435+
ret.extend(inline::build_impls(cx, did, false));
34323436
continue
34333437
}
34343438
_ => match target.primitive_type() {
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test for https://github.com./rust-lang/rust/issues/48463 issue.
12+
13+
use std::any::Any;
14+
use std::ops::Deref;
15+
16+
pub struct AnyValue {
17+
val: Box<Any>,
18+
}
19+
20+
impl Deref for AnyValue {
21+
type Target = Any;
22+
23+
fn deref(&self) -> &Any {
24+
&*self.val
25+
}
26+
}

0 commit comments

Comments
 (0)