Skip to content

Commit 90e019b

Browse files
committed
Auto merge of #47083 - CAD97:issue-46976, r=nikomatsakis
Issue 46976 ICE is due to an empty path segments, so I set the path to be the same as the in band ty params symbol. (I think this is how regular generics end up being handled?) Pinging @cramertj, this is your code I'm editing here.
2 parents fdc6ca4 + 077ba8a commit 90e019b

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/librustc/hir/lowering.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,10 @@ impl<'a> LoweringContext<'a> {
995995
);
996996

997997
let hir_bounds = self.lower_bounds(bounds, itctx);
998+
// Set the name to `impl Bound1 + Bound2`
999+
let name = Symbol::intern(&pprust::ty_to_string(t));
9981000
self.in_band_ty_params.push(hir::TyParam {
999-
// Set the name to `impl Bound1 + Bound2`
1000-
name: Symbol::intern(&pprust::ty_to_string(t)),
1001+
name,
10011002
id: def_node_id,
10021003
bounds: hir_bounds,
10031004
default: None,
@@ -1009,7 +1010,7 @@ impl<'a> LoweringContext<'a> {
10091010
hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
10101011
span,
10111012
def: Def::TyParam(DefId::local(def_index)),
1012-
segments: vec![].into(),
1013+
segments: hir_vec![hir::PathSegment::from_name(name)],
10131014
})))
10141015
},
10151016
ImplTraitContext::Disallowed => {

src/librustdoc/html/render.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4136,7 +4136,11 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
41364136
match *clean_type {
41374137
clean::ResolvedPath { ref path, .. } => {
41384138
let segments = &path.segments;
4139-
Some(segments[segments.len() - 1].name.clone())
4139+
let path_segment = segments.into_iter().last().unwrap_or_else(|| panic!(
4140+
"get_index_type_name(clean_type: {:?}, accept_generic: {:?}) had length zero path",
4141+
clean_type, accept_generic
4142+
));
4143+
Some(path_segment.name.clone())
41404144
}
41414145
clean::Generic(ref s) if accept_generic => Some(s.clone()),
41424146
clean::Primitive(ref p) => Some(format!("{:?}", p)),

src/test/rustdoc/issue-46976.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2017 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+
#![feature(universal_impl_trait)]
12+
pub fn ice(f: impl Fn()) {}

0 commit comments

Comments
 (0)