about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-02-23 18:06:05 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-02-24 01:23:54 +0100
commit23dc694c42954499105072cb2c9a3a0006e56d7e (patch)
tree9e6b96d8681aaa51175b81653c1d8a42c10b953d
parent063deba92e44809125a433ca6e6c1ad0993313bf (diff)
downloadrust-23dc694c42954499105072cb2c9a3a0006e56d7e.tar.gz
rust-23dc694c42954499105072cb2c9a3a0006e56d7e.zip
Fix auto trait impl rustdoc ice
-rw-r--r--src/librustdoc/clean/auto_trait.rs2
-rw-r--r--src/librustdoc/clean/mod.rs6
-rw-r--r--src/test/rustdoc/auto-impl-for-trait.rs26
3 files changed, 32 insertions, 2 deletions
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs
index f1bba0e8361..3654de6fb2e 100644
--- a/src/librustdoc/clean/auto_trait.rs
+++ b/src/librustdoc/clean/auto_trait.rs
@@ -25,7 +25,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
                 AdtKind::Struct => Def::Struct,
                 AdtKind::Enum => Def::Enum,
                 AdtKind::Union => Def::Union,
-            },
+            }
             _ => panic!("Unexpected type {:?}", def_id),
         };
 
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 4543b246b83..870b5383852 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -3428,7 +3428,11 @@ fn build_deref_target_impls(cx: &DocContext,
         let primitive = match *target {
             ResolvedPath { did, .. } if did.is_local() => continue,
             ResolvedPath { did, .. } => {
-                ret.extend(inline::build_impls(cx, did, true));
+                // We set the last parameter to false to avoid looking for auto-impls for traits
+                // and therefore avoid an ICE.
+                // The reason behind this is that auto-traits don't propagate through Deref so
+                // we're not supposed to synthesise impls for them.
+                ret.extend(inline::build_impls(cx, did, false));
                 continue
             }
             _ => match target.primitive_type() {
diff --git a/src/test/rustdoc/auto-impl-for-trait.rs b/src/test/rustdoc/auto-impl-for-trait.rs
new file mode 100644
index 00000000000..3cd6e7aa4b3
--- /dev/null
+++ b/src/test/rustdoc/auto-impl-for-trait.rs
@@ -0,0 +1,26 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test for https://github.com/rust-lang/rust/issues/48463 issue.
+
+use std::any::Any;
+use std::ops::Deref;
+
+pub struct AnyValue {
+    val: Box<Any>,
+}
+
+impl Deref for AnyValue {
+    type Target = Any;
+
+    fn deref(&self) -> &Any {
+        &*self.val
+    }
+}