@@ -48,7 +48,6 @@ use std::str;
48
48
use std:: string:: ToString ;
49
49
50
50
use askama:: Template ;
51
- use rustc_ast_pretty:: pprust;
52
51
use rustc_attr:: { ConstStability , Deprecation , StabilityLevel } ;
53
52
use rustc_data_structures:: captures:: Captures ;
54
53
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -1021,76 +1020,6 @@ fn render_assoc_item(
1021
1020
}
1022
1021
}
1023
1022
1024
- const ALLOWED_ATTRIBUTES : & [ Symbol ] =
1025
- & [ sym:: export_name, sym:: link_section, sym:: no_mangle, sym:: repr, sym:: non_exhaustive] ;
1026
-
1027
- fn attributes ( it : & clean:: Item , tcx : TyCtxt < ' _ > ) -> Vec < String > {
1028
- use rustc_abi:: IntegerType ;
1029
- use rustc_middle:: ty:: ReprFlags ;
1030
-
1031
- let mut attrs: Vec < String > = it
1032
- . attrs
1033
- . other_attrs
1034
- . iter ( )
1035
- . filter_map ( |attr| {
1036
- if ALLOWED_ATTRIBUTES . contains ( & attr. name_or_empty ( ) ) {
1037
- Some (
1038
- pprust:: attribute_to_string ( attr)
1039
- . replace ( "\\ \n " , "" )
1040
- . replace ( '\n' , "" )
1041
- . replace ( " " , " " ) ,
1042
- )
1043
- } else {
1044
- None
1045
- }
1046
- } )
1047
- . collect ( ) ;
1048
- if let Some ( def_id) = it. item_id . as_def_id ( ) &&
1049
- !def_id. is_local ( ) &&
1050
- // This check is needed because `adt_def` will panic if not a compatible type otherwise...
1051
- matches ! ( it. type_( ) , ItemType :: Struct | ItemType :: Enum | ItemType :: Union )
1052
- {
1053
- let repr = tcx. adt_def ( def_id) . repr ( ) ;
1054
- let mut out = Vec :: new ( ) ;
1055
- if repr. flags . contains ( ReprFlags :: IS_C ) {
1056
- out. push ( "C" ) ;
1057
- }
1058
- if repr. flags . contains ( ReprFlags :: IS_TRANSPARENT ) {
1059
- out. push ( "transparent" ) ;
1060
- }
1061
- if repr. flags . contains ( ReprFlags :: IS_SIMD ) {
1062
- out. push ( "simd" ) ;
1063
- }
1064
- let pack_s;
1065
- if let Some ( pack) = repr. pack {
1066
- pack_s = format ! ( "packed({})" , pack. bytes( ) ) ;
1067
- out. push ( & pack_s) ;
1068
- }
1069
- let align_s;
1070
- if let Some ( align) = repr. align {
1071
- align_s = format ! ( "align({})" , align. bytes( ) ) ;
1072
- out. push ( & align_s) ;
1073
- }
1074
- let int_s;
1075
- if let Some ( int) = repr. int {
1076
- int_s = match int {
1077
- IntegerType :: Pointer ( is_signed) => {
1078
- format ! ( "{}size" , if is_signed { 'i' } else { 'u' } )
1079
- }
1080
- IntegerType :: Fixed ( size, is_signed) => {
1081
- format ! ( "{}{}" , if is_signed { 'i' } else { 'u' } , size. size( ) . bytes( ) * 8 )
1082
- }
1083
- } ;
1084
- out. push ( & int_s) ;
1085
- }
1086
- if out. is_empty ( ) {
1087
- return Vec :: new ( ) ;
1088
- }
1089
- attrs. push ( format ! ( "#[repr({})]" , out. join( ", " ) ) ) ;
1090
- }
1091
- attrs
1092
- }
1093
-
1094
1023
// When an attribute is rendered inside a `<pre>` tag, it is formatted using
1095
1024
// a whitespace prefix and newline.
1096
1025
fn render_attributes_in_pre < ' a , ' b : ' a > (
@@ -1099,7 +1028,7 @@ fn render_attributes_in_pre<'a, 'b: 'a>(
1099
1028
tcx : TyCtxt < ' b > ,
1100
1029
) -> impl fmt:: Display + Captures < ' a > + Captures < ' b > {
1101
1030
crate :: html:: format:: display_fn ( move |f| {
1102
- for a in attributes ( it , tcx ) {
1031
+ for a in it . attributes ( tcx , false ) {
1103
1032
writeln ! ( f, "{}{}" , prefix, a) ?;
1104
1033
}
1105
1034
Ok ( ( ) )
@@ -1109,7 +1038,7 @@ fn render_attributes_in_pre<'a, 'b: 'a>(
1109
1038
// When an attribute is rendered inside a <code> tag, it is formatted using
1110
1039
// a div to produce a newline after it.
1111
1040
fn render_attributes_in_code ( w : & mut Buffer , it : & clean:: Item , tcx : TyCtxt < ' _ > ) {
1112
- for a in attributes ( it , tcx ) {
1041
+ for a in it . attributes ( tcx , false ) {
1113
1042
write ! ( w, "<div class=\" code-attribute\" >{}</div>" , a) ;
1114
1043
}
1115
1044
}
0 commit comments