Skip to content

Commit 019f43e

Browse files
authored
Rollup merge of #113028 - fmease:rustdoc-x-crate-itiap-clean-term, r=notriddle
rustdoc: handle assoc const equalities in cross-crate impl-Trait-in-arg-pos Fixes FIXME (the added test previously lead to an ICE). `@rustbot` label A-cross-crate-reexports
2 parents 96ab7e6 + 247aa06 commit 019f43e

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/librustdoc/clean/mod.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,10 @@ fn clean_ty_generics<'tcx>(
791791
})
792792
.collect::<ThinVec<GenericParamDef>>();
793793

794-
// param index -> [(trait DefId, associated type name & generics, type, higher-ranked params)]
794+
// param index -> [(trait DefId, associated type name & generics, term, higher-ranked params)]
795795
let mut impl_trait_proj = FxHashMap::<
796796
u32,
797-
Vec<(DefId, PathSegment, ty::Binder<'_, Ty<'_>>, Vec<GenericParamDef>)>,
797+
Vec<(DefId, PathSegment, ty::Binder<'_, ty::Term<'_>>, Vec<GenericParamDef>)>,
798798
>::default();
799799

800800
let where_predicates = preds
@@ -852,11 +852,10 @@ fn clean_ty_generics<'tcx>(
852852
.as_ref()
853853
.and_then(|(lhs, rhs): &(Type, _)| Some((lhs.projection()?, rhs)))
854854
{
855-
// FIXME(...): Remove this unwrap()
856855
impl_trait_proj.entry(param_idx).or_default().push((
857856
trait_did,
858857
name,
859-
rhs.map_bound(|rhs| rhs.ty().unwrap()),
858+
*rhs,
860859
p.get_bound_params()
861860
.into_iter()
862861
.flatten()
@@ -879,15 +878,8 @@ fn clean_ty_generics<'tcx>(
879878
let crate::core::ImplTraitParam::ParamIndex(idx) = param else { unreachable!() };
880879
if let Some(proj) = impl_trait_proj.remove(&idx) {
881880
for (trait_did, name, rhs, bound_params) in proj {
882-
let rhs = clean_middle_ty(rhs, cx, None, None);
883-
simplify::merge_bounds(
884-
cx,
885-
&mut bounds,
886-
bound_params,
887-
trait_did,
888-
name,
889-
&Term::Type(rhs),
890-
);
881+
let rhs = clean_middle_term(rhs, cx);
882+
simplify::merge_bounds(cx, &mut bounds, bound_params, trait_did, name, &rhs);
891883
}
892884
}
893885

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// aux-crate:assoc_const_equality=assoc-const-equality.rs
2+
// edition:2021
3+
4+
#![crate_name = "user"]
5+
6+
// @has user/fn.accept.html
7+
// @has - '//pre[@class="rust item-decl"]' 'fn accept(_: impl Trait<K = 0>)'
8+
pub use assoc_const_equality::accept;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(associated_const_equality)]
2+
3+
pub fn accept(_: impl Trait<K = 0>) {}
4+
5+
pub trait Trait {
6+
const K: i32;
7+
}

0 commit comments

Comments
 (0)