rustdoc: add support for cross-crate higher-ranked types
This commit is contained in:
parent
67de1509f3
commit
ace85f0ae3
3 changed files with 39 additions and 1 deletions
|
@ -2226,6 +2226,11 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::Bound(_, ref ty) => match ty.kind {
|
||||||
|
ty::BoundTyKind::Param(_, name) => Generic(name),
|
||||||
|
ty::BoundTyKind::Anon => panic!("unexpected anonymous bound type variable"),
|
||||||
|
},
|
||||||
|
|
||||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
|
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
|
||||||
// If it's already in the same alias, don't get an infinite loop.
|
// If it's already in the same alias, don't get an infinite loop.
|
||||||
if cx.current_type_aliases.contains_key(&def_id) {
|
if cx.current_type_aliases.contains_key(&def_id) {
|
||||||
|
@ -2254,7 +2259,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
||||||
|
|
||||||
ty::Closure(..) => panic!("Closure"),
|
ty::Closure(..) => panic!("Closure"),
|
||||||
ty::Generator(..) => panic!("Generator"),
|
ty::Generator(..) => panic!("Generator"),
|
||||||
ty::Bound(..) => panic!("Bound"),
|
|
||||||
ty::Placeholder(..) => panic!("Placeholder"),
|
ty::Placeholder(..) => panic!("Placeholder"),
|
||||||
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
||||||
ty::Infer(..) => panic!("Infer"),
|
ty::Infer(..) => panic!("Infer"),
|
||||||
|
@ -3097,6 +3101,17 @@ fn clean_bound_vars<'tcx>(
|
||||||
{
|
{
|
||||||
Some(GenericParamDef::lifetime(name))
|
Some(GenericParamDef::lifetime(name))
|
||||||
}
|
}
|
||||||
|
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(did, name)) => Some(GenericParamDef {
|
||||||
|
name,
|
||||||
|
kind: GenericParamDefKind::Type {
|
||||||
|
did,
|
||||||
|
bounds: Vec::new(),
|
||||||
|
default: None,
|
||||||
|
synthetic: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// FIXME(non_lifetime_binders): Support higher-ranked const parameters.
|
||||||
|
ty::BoundVariableKind::Const => None,
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|
10
tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs
Normal file
10
tests/rustdoc/inline_cross/auxiliary/non_lifetime_binders.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#![feature(non_lifetime_binders)]
|
||||||
|
|
||||||
|
pub trait Trait<T> {}
|
||||||
|
|
||||||
|
pub fn f(_: impl for<T> Trait<T>) {}
|
||||||
|
|
||||||
|
pub fn g<T>(_: T)
|
||||||
|
where
|
||||||
|
T: for<U> Trait<U>,
|
||||||
|
{}
|
13
tests/rustdoc/inline_cross/non_lifetime_binders.rs
Normal file
13
tests/rustdoc/inline_cross/non_lifetime_binders.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// aux-crate:non_lifetime_binders=non_lifetime_binders.rs
|
||||||
|
// edition: 2021
|
||||||
|
#![crate_name = "user"]
|
||||||
|
|
||||||
|
// @has user/fn.f.html
|
||||||
|
// @has - '//pre[@class="rust item-decl"]' "f(_: impl for<T> Trait<T>)"
|
||||||
|
pub use non_lifetime_binders::f;
|
||||||
|
|
||||||
|
// @has user/fn.g.html
|
||||||
|
// @has - '//pre[@class="rust item-decl"]' "g<T>(_: T)\
|
||||||
|
// where \
|
||||||
|
// T: for<U> Trait<U>"
|
||||||
|
pub use non_lifetime_binders::g;
|
Loading…
Add table
Add a link
Reference in a new issue