mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-20 11:37:32 +00:00
Clean middle RPITITs correctly in rustdoc
This commit is contained in:
parent
289b2b8cf9
commit
def755edab
@ -415,6 +415,16 @@ fn clean_projection<'tcx>(
|
|||||||
cx: &mut DocContext<'tcx>,
|
cx: &mut DocContext<'tcx>,
|
||||||
def_id: Option<DefId>,
|
def_id: Option<DefId>,
|
||||||
) -> Type {
|
) -> Type {
|
||||||
|
if cx.tcx.def_kind(ty.item_def_id) == DefKind::ImplTraitPlaceholder {
|
||||||
|
let bounds = cx
|
||||||
|
.tcx
|
||||||
|
.explicit_item_bounds(ty.item_def_id)
|
||||||
|
.iter()
|
||||||
|
.map(|(bound, _)| EarlyBinder(*bound).subst(cx.tcx, ty.substs))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
return clean_middle_opaque_bounds(cx, bounds);
|
||||||
|
}
|
||||||
|
|
||||||
let trait_ = clean_trait_ref_with_bindings(cx, ty.trait_ref(cx.tcx), ThinVec::new());
|
let trait_ = clean_trait_ref_with_bindings(cx, ty.trait_ref(cx.tcx), ThinVec::new());
|
||||||
let self_type = clean_middle_ty(ty.self_ty(), cx, None);
|
let self_type = clean_middle_ty(ty.self_ty(), cx, None);
|
||||||
let self_def_id = if let Some(def_id) = def_id {
|
let self_def_id = if let Some(def_id) = def_id {
|
||||||
@ -1715,6 +1725,23 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|(bound, _)| EarlyBinder(*bound).subst(cx.tcx, substs))
|
.map(|(bound, _)| EarlyBinder(*bound).subst(cx.tcx, substs))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
clean_middle_opaque_bounds(cx, bounds)
|
||||||
|
}
|
||||||
|
|
||||||
|
ty::Closure(..) => panic!("Closure"),
|
||||||
|
ty::Generator(..) => panic!("Generator"),
|
||||||
|
ty::Bound(..) => panic!("Bound"),
|
||||||
|
ty::Placeholder(..) => panic!("Placeholder"),
|
||||||
|
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
||||||
|
ty::Infer(..) => panic!("Infer"),
|
||||||
|
ty::Error(_) => panic!("Error"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clean_middle_opaque_bounds<'tcx>(
|
||||||
|
cx: &mut DocContext<'tcx>,
|
||||||
|
bounds: Vec<ty::Predicate<'tcx>>,
|
||||||
|
) -> Type {
|
||||||
let mut regions = vec![];
|
let mut regions = vec![];
|
||||||
let mut has_sized = false;
|
let mut has_sized = false;
|
||||||
let mut bounds = bounds
|
let mut bounds = bounds
|
||||||
@ -1742,8 +1769,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||||||
let bindings: ThinVec<_> = bounds
|
let bindings: ThinVec<_> = bounds
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|bound| {
|
.filter_map(|bound| {
|
||||||
if let ty::PredicateKind::Projection(proj) = bound.kind().skip_binder()
|
if let ty::PredicateKind::Projection(proj) = bound.kind().skip_binder() {
|
||||||
{
|
|
||||||
if proj.projection_ty.trait_ref(cx.tcx) == trait_ref.skip_binder() {
|
if proj.projection_ty.trait_ref(cx.tcx) == trait_ref.skip_binder() {
|
||||||
Some(TypeBinding {
|
Some(TypeBinding {
|
||||||
assoc: projection_to_path_segment(proj.projection_ty, cx),
|
assoc: projection_to_path_segment(proj.projection_ty, cx),
|
||||||
@ -1768,16 +1794,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||||||
bounds.insert(0, GenericBound::maybe_sized(cx));
|
bounds.insert(0, GenericBound::maybe_sized(cx));
|
||||||
}
|
}
|
||||||
ImplTrait(bounds)
|
ImplTrait(bounds)
|
||||||
}
|
|
||||||
|
|
||||||
ty::Closure(..) => panic!("Closure"),
|
|
||||||
ty::Generator(..) => panic!("Generator"),
|
|
||||||
ty::Bound(..) => panic!("Bound"),
|
|
||||||
ty::Placeholder(..) => panic!("Placeholder"),
|
|
||||||
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
|
||||||
ty::Infer(..) => panic!("Infer"),
|
|
||||||
ty::Error(_) => panic!("Error"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clean_field<'tcx>(field: &hir::FieldDef<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
|
pub(crate) fn clean_field<'tcx>(field: &hir::FieldDef<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
|
||||||
|
16
src/test/rustdoc/async-trait.rs
Normal file
16
src/test/rustdoc/async-trait.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// aux-build:async-trait-dep.rs
|
||||||
|
// edition:2021
|
||||||
|
|
||||||
|
#![feature(async_fn_in_trait)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
extern crate async_trait_dep;
|
||||||
|
|
||||||
|
pub struct Oink {}
|
||||||
|
|
||||||
|
// @has 'async_trait/struct.Oink.html' '//h4[@class="code-header"]' "async fn woof()"
|
||||||
|
impl async_trait_dep::Meow for Oink {
|
||||||
|
async fn woof() {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
9
src/test/rustdoc/auxiliary/async-trait-dep.rs
Normal file
9
src/test/rustdoc/auxiliary/async-trait-dep.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// edition:2021
|
||||||
|
|
||||||
|
#![feature(async_fn_in_trait)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
pub trait Meow {
|
||||||
|
/// Who's a good dog?
|
||||||
|
async fn woof();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user