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.
This commit is contained in:
commit
90e019bacd
3 changed files with 21 additions and 4 deletions
|
@ -995,9 +995,10 @@ impl<'a> LoweringContext<'a> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let hir_bounds = self.lower_bounds(bounds, itctx);
|
let hir_bounds = self.lower_bounds(bounds, itctx);
|
||||||
|
// Set the name to `impl Bound1 + Bound2`
|
||||||
|
let name = Symbol::intern(&pprust::ty_to_string(t));
|
||||||
self.in_band_ty_params.push(hir::TyParam {
|
self.in_band_ty_params.push(hir::TyParam {
|
||||||
// Set the name to `impl Bound1 + Bound2`
|
name,
|
||||||
name: Symbol::intern(&pprust::ty_to_string(t)),
|
|
||||||
id: def_node_id,
|
id: def_node_id,
|
||||||
bounds: hir_bounds,
|
bounds: hir_bounds,
|
||||||
default: None,
|
default: None,
|
||||||
|
@ -1009,7 +1010,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
|
hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
|
||||||
span,
|
span,
|
||||||
def: Def::TyParam(DefId::local(def_index)),
|
def: Def::TyParam(DefId::local(def_index)),
|
||||||
segments: vec![].into(),
|
segments: hir_vec![hir::PathSegment::from_name(name)],
|
||||||
})))
|
})))
|
||||||
},
|
},
|
||||||
ImplTraitContext::Disallowed => {
|
ImplTraitContext::Disallowed => {
|
||||||
|
|
|
@ -4136,7 +4136,11 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option
|
||||||
match *clean_type {
|
match *clean_type {
|
||||||
clean::ResolvedPath { ref path, .. } => {
|
clean::ResolvedPath { ref path, .. } => {
|
||||||
let segments = &path.segments;
|
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::Generic(ref s) if accept_generic => Some(s.clone()),
|
||||||
clean::Primitive(ref p) => Some(format!("{:?}", p)),
|
clean::Primitive(ref p) => Some(format!("{:?}", p)),
|
||||||
|
|
12
src/test/rustdoc/issue-46976.rs
Normal file
12
src/test/rustdoc/issue-46976.rs
Normal file
|
@ -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()) {}
|
Loading…
Add table
Add a link
Reference in a new issue