提交 1fe6160c 编写于 作者: S Shotaro Yamada

Fix ICE with `impl Trait` in type bounds

上级 3620456f
......@@ -1725,7 +1725,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
let mut impl_trait_proj =
FxHashMap::<u32, Vec<(DefId, String, Ty<'tcx>)>>::default();
let mut where_predicates = preds.predicates.iter()
let where_predicates = preds.predicates.iter()
.flat_map(|(p, _)| {
let mut projection = None;
let param_idx = (|| {
......@@ -1747,10 +1747,10 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
None
})();
let p = p.clean(cx)?;
if let Some(param_idx) = param_idx {
if let Some(b) = impl_trait.get_mut(&param_idx.into()) {
let p = p.clean(cx)?;
b.extend(
p.get_bounds()
.into_iter()
......@@ -1805,6 +1805,13 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
cx.impl_trait_bounds.borrow_mut().insert(param, bounds);
}
// Now that `cx.impl_trait_bounds` is populated, we can process
// remaining predicates which could contain `impl Trait`.
let mut where_predicates = where_predicates
.into_iter()
.flat_map(|p| p.clean(cx))
.collect::<Vec<_>>();
// Type parameters and have a Sized bound by default unless removed with
// ?Sized. Scan through the predicates and mark any type parameter with
// a Sized bound, removing the bounds as we find them.
......
......@@ -9,6 +9,8 @@ pub fn func2<T>(
pub fn func3(_x: impl Iterator<Item = impl Iterator<Item = u8>> + Clone) {}
pub fn func4<T: Iterator<Item = impl Clone>>(_x: T) {}
pub struct Foo;
impl Foo {
......
......@@ -20,6 +20,12 @@
// @!has - '//pre[@class="rust fn"]' 'where'
pub use impl_trait_aux::func3;
// @has impl_trait/fn.func4.html
// @has - '//pre[@class="rust fn"]' "func4<T>("
// @has - '//pre[@class="rust fn"]' "T: Iterator<Item = impl Clone>,"
pub use impl_trait_aux::func4;
// @has impl_trait/struct.Foo.html
// @has - '//code[@id="method.v"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)"
// @!has - '//code[@id="method.v"]' 'where'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册