Skip to content

Commit 0a9b09f

Browse files
authored
Rollup merge of #102831 - compiler-errors:rustdoc-norm-oops, r=jyn514
Don't use unnormalized type in `Ty::fn_sig` call in rustdoc `clean_middle_ty` Self-explanatory Fixes #102828
2 parents 24424d0 + 7dedb91 commit 0a9b09f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/librustdoc/clean/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1582,12 +1582,12 @@ fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
15821582
}
15831583

15841584
pub(crate) fn clean_middle_ty<'tcx>(
1585-
this: Ty<'tcx>,
1585+
ty: Ty<'tcx>,
15861586
cx: &mut DocContext<'tcx>,
15871587
def_id: Option<DefId>,
15881588
) -> Type {
1589-
trace!("cleaning type: {:?}", this);
1590-
let ty = normalize(cx, this).unwrap_or(this);
1589+
trace!("cleaning type: {:?}", ty);
1590+
let ty = normalize(cx, ty).unwrap_or(ty);
15911591
match *ty.kind() {
15921592
ty::Never => Primitive(PrimitiveType::Never),
15931593
ty::Bool => Primitive(PrimitiveType::Bool),
@@ -1610,7 +1610,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
16101610
type_: Box::new(clean_middle_ty(ty, cx, None)),
16111611
},
16121612
ty::FnDef(..) | ty::FnPtr(_) => {
1613-
let ty = cx.tcx.lift(this).expect("FnPtr lift failed");
16141613
let sig = ty.fn_sig(cx.tcx);
16151614
let decl = clean_fn_decl_from_did_and_sig(cx, None, sig);
16161615
BareFunction(Box::new(BareFunctionDecl {
@@ -1644,7 +1643,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
16441643
let did = obj
16451644
.principal_def_id()
16461645
.or_else(|| dids.next())
1647-
.unwrap_or_else(|| panic!("found trait object `{:?}` with no traits?", this));
1646+
.unwrap_or_else(|| panic!("found trait object `{:?}` with no traits?", ty));
16481647
let substs = match obj.principal() {
16491648
Some(principal) => principal.skip_binder().substs,
16501649
// marker traits have no substs.

src/test/rustdoc/normalize-assoc-item.rs

+13
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,24 @@ impl Trait for usize {
1111
type X = isize;
1212
}
1313

14+
impl Trait for () {
15+
type X = fn() -> i32;
16+
}
17+
18+
impl Trait for isize {
19+
type X = <() as Trait>::X;
20+
}
21+
1422
// @has 'normalize_assoc_item/fn.f.html' '//pre[@class="rust fn"]' 'pub fn f() -> isize'
1523
pub fn f() -> <usize as Trait>::X {
1624
0
1725
}
1826

27+
// @has 'normalize_assoc_item/fn.f2.html' '//pre[@class="rust fn"]' 'pub fn f2() -> fn() -> i32'
28+
pub fn f2() -> <isize as Trait>::X {
29+
todo!()
30+
}
31+
1932
pub struct S {
2033
// @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S, Global>'
2134
pub box_me_up: <S as Trait>::X,

0 commit comments

Comments
 (0)