about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristopher Durham <cad97@cad97.com>2017-12-23 22:45:39 -0500
committerChristopher Durham <cad97@cad97.com>2017-12-30 21:41:58 -0500
commitd4077ad62152f1e1f1137afbdae76fcecee6fad0 (patch)
tree5a900caa7372dd69a807aae18ee97944195fdfa0
parent8d4da4f4c4f097e6a95264cc527da64bfc133b0f (diff)
Hard break for rust-lang/rust#46976
-rw-r--r--src/librustdoc/html/render.rs6
-rw-r--r--src/test/rustdoc/issue-46976.rs12
2 files changed, 17 insertions, 1 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 3be44f30958..d0329a04206 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -4130,7 +4130,11 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
     match *clean_type {
         clean::ResolvedPath { ref path, .. } => {
             let segments = &path.segments;
-            Some(segments[segments.len() - 1].name.clone())
+            let path_segment = segments.into_iter().last().unwrap_or_else(|| panic!(
+                "get_index_type_name(clean_type: {:?}, accept_generic: {:?}) had length zero path",
+                clean_type, accept_generic
+            ));
+            Some(path_segment.name.clone())
         }
         clean::Generic(ref s) if accept_generic => Some(s.clone()),
         clean::Primitive(ref p) => Some(format!("{:?}", p)),
diff --git a/src/test/rustdoc/issue-46976.rs b/src/test/rustdoc/issue-46976.rs
new file mode 100644
index 00000000000..0df80fe3bd7
--- /dev/null
+++ b/src/test/rustdoc/issue-46976.rs
@@ -0,0 +1,12 @@
+// Copyright 2017 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.
+
+#![feature(universal_impl_trait)]
+pub fn ice(f: impl Fn()) {}