mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
fix pattern types rendering in rustdoc
This commit is contained in:
@@ -1808,7 +1808,15 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
|
||||
BorrowedRef { lifetime, mutability: m.mutbl, type_: Box::new(clean_ty(m.ty, cx)) }
|
||||
}
|
||||
TyKind::Slice(ty) => Slice(Box::new(clean_ty(ty, cx))),
|
||||
TyKind::Pat(ty, pat) => Type::Pat(Box::new(clean_ty(ty, cx)), format!("{pat:?}").into()),
|
||||
TyKind::Pat(inner_ty, pat) => {
|
||||
// Local HIR pattern types should print the same way as cross-crate inlined ones,
|
||||
// so lower to the canonical `rustc_middle::ty::Pattern` representation first.
|
||||
let pat = match lower_ty(cx.tcx, ty).kind() {
|
||||
ty::Pat(_, pat) => format!("{pat:?}").into_boxed_str(),
|
||||
_ => format!("{pat:?}").into(),
|
||||
};
|
||||
Type::Pat(Box::new(clean_ty(inner_ty, cx)), pat)
|
||||
}
|
||||
TyKind::FieldOf(ty, hir::TyFieldPath { variant, field }) => {
|
||||
let field_str = if let Some(variant) = variant {
|
||||
format!("{variant}.{field}")
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#![feature(pattern_types, pattern_type_macro)]
|
||||
#![crate_name = "pattern_types_implementors"]
|
||||
|
||||
use std::pat::pattern_type;
|
||||
|
||||
pub trait MyTrait {}
|
||||
|
||||
impl MyTrait for pattern_type!(*const u8 is !null) {}
|
||||
|
||||
//@ has pattern_types_implementors/trait.MyTrait.html
|
||||
//@ has - '//*[@id="implementors-list"]/*[@class="impl"]' 'impl MyTrait for *const u8 is !null'
|
||||
//@ !has - '//*[@id="implementors-list"]/*[@class="impl"]' 'TyPat {'
|
||||
Reference in New Issue
Block a user