@@ -48,7 +48,6 @@ use std::str;
4848use std:: string:: ToString ;
4949
5050use askama:: Template ;
51- use rustc_ast_pretty:: pprust;
5251use rustc_attr:: { ConstStability , Deprecation , StabilityLevel } ;
5352use rustc_data_structures:: captures:: Captures ;
5453use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -1021,76 +1020,6 @@ fn render_assoc_item(
10211020 }
10221021}
10231022
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-
10941023// When an attribute is rendered inside a `<pre>` tag, it is formatted using
10951024// a whitespace prefix and newline.
10961025fn render_attributes_in_pre < ' a , ' b : ' a > (
@@ -1099,7 +1028,7 @@ fn render_attributes_in_pre<'a, 'b: 'a>(
10991028 tcx : TyCtxt < ' b > ,
11001029) -> impl fmt:: Display + Captures < ' a > + Captures < ' b > {
11011030 crate :: html:: format:: display_fn ( move |f| {
1102- for a in attributes ( it , tcx ) {
1031+ for a in it . attributes ( tcx , false ) {
11031032 writeln ! ( f, "{}{}" , prefix, a) ?;
11041033 }
11051034 Ok ( ( ) )
@@ -1109,7 +1038,7 @@ fn render_attributes_in_pre<'a, 'b: 'a>(
11091038// When an attribute is rendered inside a <code> tag, it is formatted using
11101039// a div to produce a newline after it.
11111040fn 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 ) {
11131042 write ! ( w, "<div class=\" code-attribute\" >{}</div>" , a) ;
11141043 }
11151044}
0 commit comments