mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Add rustdoc support for use<> in (local) RPITs
This commit is contained in:
parent
5315cbe15b
commit
843f5dd93b
@ -2708,6 +2708,13 @@ impl PreciseCapturingArg<'_> {
|
|||||||
PreciseCapturingArg::Param(param) => param.hir_id,
|
PreciseCapturingArg::Param(param) => param.hir_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn name(self) -> Symbol {
|
||||||
|
match self {
|
||||||
|
PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
|
||||||
|
PreciseCapturingArg::Param(param) => param.ident.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// We need to have a [`Node`] for the [`HirId`] that we attach the type/const param
|
/// We need to have a [`Node`] for the [`HirId`] that we attach the type/const param
|
||||||
|
@ -228,8 +228,9 @@ fn clean_generic_bound<'tcx>(
|
|||||||
|
|
||||||
GenericBound::TraitBound(clean_poly_trait_ref(t, cx), modifier)
|
GenericBound::TraitBound(clean_poly_trait_ref(t, cx), modifier)
|
||||||
}
|
}
|
||||||
// FIXME(precise_capturing): Implement rustdoc support
|
hir::GenericBound::Use(args, ..) => {
|
||||||
hir::GenericBound::Use(..) => return None,
|
GenericBound::Use(args.iter().map(|arg| arg.name()).collect())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ pub(crate) fn merge_bounds(
|
|||||||
!bounds.iter_mut().any(|b| {
|
!bounds.iter_mut().any(|b| {
|
||||||
let trait_ref = match *b {
|
let trait_ref = match *b {
|
||||||
clean::GenericBound::TraitBound(ref mut tr, _) => tr,
|
clean::GenericBound::TraitBound(ref mut tr, _) => tr,
|
||||||
clean::GenericBound::Outlives(..) => return false,
|
clean::GenericBound::Outlives(..) | clean::GenericBound::Use(_) => return false,
|
||||||
};
|
};
|
||||||
// If this QPath's trait `trait_did` is the same as, or a supertrait
|
// If this QPath's trait `trait_did` is the same as, or a supertrait
|
||||||
// of, the bound's trait `did` then we can keep going, otherwise
|
// of, the bound's trait `did` then we can keep going, otherwise
|
||||||
|
@ -1244,6 +1244,8 @@ impl Eq for Attributes {}
|
|||||||
pub(crate) enum GenericBound {
|
pub(crate) enum GenericBound {
|
||||||
TraitBound(PolyTrait, hir::TraitBoundModifier),
|
TraitBound(PolyTrait, hir::TraitBoundModifier),
|
||||||
Outlives(Lifetime),
|
Outlives(Lifetime),
|
||||||
|
/// `use<'a, T>` precise-capturing bound syntax
|
||||||
|
Use(Vec<Symbol>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GenericBound {
|
impl GenericBound {
|
||||||
|
@ -412,6 +412,20 @@ impl clean::GenericBound {
|
|||||||
})?;
|
})?;
|
||||||
ty.print(cx).fmt(f)
|
ty.print(cx).fmt(f)
|
||||||
}
|
}
|
||||||
|
clean::GenericBound::Use(args) => {
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str("use<")?;
|
||||||
|
} else {
|
||||||
|
f.write_str("use<")?;
|
||||||
|
}
|
||||||
|
for (i, arg) in args.iter().enumerate() {
|
||||||
|
if i > 0 {
|
||||||
|
write!(f, ", ")?;
|
||||||
|
}
|
||||||
|
arg.fmt(f)?;
|
||||||
|
}
|
||||||
|
if f.alternate() { f.write_str(">") } else { f.write_str(">") }
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
tests/rustdoc/impl-trait-precise-capturing.rs
Normal file
14
tests/rustdoc/impl-trait-precise-capturing.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#![crate_name = "foo"]
|
||||||
|
#![feature(precise_capturing)]
|
||||||
|
|
||||||
|
//@ has foo/fn.two.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'b, 'a>"
|
||||||
|
pub fn two<'a, 'b, 'c>() -> impl Sized + use<'b, 'a /* no 'c */> {}
|
||||||
|
|
||||||
|
//@ has foo/fn.params.html '//section[@id="main-content"]//pre' "-> impl Sized + use<'a, T, N>"
|
||||||
|
pub fn params<'a, T, const N: usize>() -> impl Sized + use<'a, T, N> {}
|
||||||
|
|
||||||
|
//@ has foo/fn.none.html '//section[@id="main-content"]//pre' "-> impl Sized + use<>"
|
||||||
|
pub fn none() -> impl Sized + use<> {}
|
||||||
|
|
||||||
|
//@ has foo/fn.first.html '//section[@id="main-content"]//pre' "-> impl use<> + Sized"
|
||||||
|
pub fn first() -> impl use<> + Sized {}
|
Loading…
Reference in New Issue
Block a user