File tree Expand file tree Collapse file tree 2 files changed +24
-19
lines changed
compiler/rustc_resolve/src Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -207,8 +207,10 @@ pub fn attrs_to_doc_fragments<'a, A: AttributeExt + Clone + 'a>(
207
207
attrs : impl Iterator < Item = ( & ' a A , Option < DefId > ) > ,
208
208
doc_only : bool ,
209
209
) -> ( Vec < DocFragment > , ThinVec < A > ) {
210
- let mut doc_fragments = Vec :: new ( ) ;
211
- let mut other_attrs = ThinVec :: < A > :: new ( ) ;
210
+ let ( min_size, max_size) = attrs. size_hint ( ) ;
211
+ let size_hint = max_size. unwrap_or ( min_size) ;
212
+ let mut doc_fragments = Vec :: with_capacity ( size_hint) ;
213
+ let mut other_attrs = ThinVec :: < A > :: with_capacity ( if doc_only { 0 } else { size_hint } ) ;
212
214
for ( attr, item_id) in attrs {
213
215
if let Some ( ( doc_str, comment_kind) ) = attr. doc_str_and_comment_kind ( ) {
214
216
let doc = beautify_doc_string ( doc_str, comment_kind) ;
@@ -230,6 +232,9 @@ pub fn attrs_to_doc_fragments<'a, A: AttributeExt + Clone + 'a>(
230
232
}
231
233
}
232
234
235
+ doc_fragments. shrink_to_fit ( ) ;
236
+ other_attrs. shrink_to_fit ( ) ;
237
+
233
238
unindent_doc_fragments ( & mut doc_fragments) ;
234
239
235
240
( doc_fragments, other_attrs)
Original file line number Diff line number Diff line change @@ -572,30 +572,30 @@ pub(crate) fn build_impl(
572
572
super :: build_deref_target_impls ( cx, & trait_items, ret) ;
573
573
}
574
574
575
- // Return if the trait itself or any types of the generic parameters are doc(hidden).
576
- let mut stack: Vec < & Type > = vec ! [ & for_] ;
575
+ if !document_hidden {
576
+ // Return if the trait itself or any types of the generic parameters are doc(hidden).
577
+ let mut stack: Vec < & Type > = vec ! [ & for_] ;
577
578
578
- if let Some ( did) = trait_. as_ref ( ) . map ( |t| t. def_id ( ) )
579
- && !document_hidden
580
- && tcx. is_doc_hidden ( did)
581
- {
582
- return ;
583
- }
584
-
585
- if let Some ( generics) = trait_. as_ref ( ) . and_then ( |t| t. generics ( ) ) {
586
- stack. extend ( generics) ;
587
- }
588
-
589
- while let Some ( ty) = stack. pop ( ) {
590
- if let Some ( did) = ty. def_id ( & cx. cache )
591
- && !document_hidden
579
+ if let Some ( did) = trait_. as_ref ( ) . map ( |t| t. def_id ( ) )
592
580
&& tcx. is_doc_hidden ( did)
593
581
{
594
582
return ;
595
583
}
596
- if let Some ( generics) = ty. generics ( ) {
584
+
585
+ if let Some ( generics) = trait_. as_ref ( ) . and_then ( |t| t. generics ( ) ) {
597
586
stack. extend ( generics) ;
598
587
}
588
+
589
+ while let Some ( ty) = stack. pop ( ) {
590
+ if let Some ( did) = ty. def_id ( & cx. cache )
591
+ && tcx. is_doc_hidden ( did)
592
+ {
593
+ return ;
594
+ }
595
+ if let Some ( generics) = ty. generics ( ) {
596
+ stack. extend ( generics) ;
597
+ }
598
+ }
599
599
}
600
600
601
601
if let Some ( did) = trait_. as_ref ( ) . map ( |t| t. def_id ( ) ) {
You can’t perform that action at this time.
0 commit comments