File tree Expand file tree Collapse file tree 7 files changed +30
-46
lines changed
src/librustdoc/html/render Expand file tree Collapse file tree 7 files changed +30
-46
lines changed Original file line number Diff line number Diff line change @@ -2936,13 +2936,13 @@ fn render_attributes_in_code(
29362936 prefix,
29372937 match attr {
29382938 hir:: Attribute :: Parsed ( AttributeKind :: LinkSection { name, .. } ) => {
2939- Cow :: Owned ( format ! ( "#[unsafe(link_section = \" {name }\" )]" ) )
2939+ Cow :: Owned ( format ! ( "#[unsafe(link_section = \" {}\" )]" , Escape ( name . as_str ( ) ) ) )
29402940 }
29412941 hir:: Attribute :: Parsed ( AttributeKind :: NoMangle ( ..) ) => {
29422942 Cow :: Borrowed ( "#[unsafe(no_mangle)]" )
29432943 }
29442944 hir:: Attribute :: Parsed ( AttributeKind :: ExportName { name, .. } ) => {
2945- Cow :: Owned ( format ! ( "#[unsafe(export_name = \" {name }\" )]" ) )
2945+ Cow :: Owned ( format ! ( "#[unsafe(export_name = \" {}\" )]" , Escape ( name . as_str ( ) ) ) )
29462946 }
29472947 hir:: Attribute :: Parsed ( AttributeKind :: NonExhaustive ( ..) ) => {
29482948 Cow :: Borrowed ( "#[non_exhaustive]" )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ pub extern "C" fn f() {}
99#[ unsafe( export_name = "bar" ) ]
1010pub extern "C" fn g ( ) { }
1111
12+ //@ has foo/fn.escape.html '//*[@class="code-attribute"]' \
13+ // '#[unsafe(export_name = "<script>alert()</script>")]'
14+ #[ unsafe( export_name = "<script>alert()</script>" ) ]
15+ pub extern "C" fn escape ( ) { }
16+
1217//@ has foo/fn.example.html '//*[@class="code-attribute"]' '#[unsafe(link_section = ".text")]'
1318#[ unsafe( link_section = ".text" ) ]
1419pub extern "C" fn example ( ) { }
Original file line number Diff line number Diff line change 1+ // Ensure that we render attributes on inlined cross-crate re-exported items.
2+
13//@ aux-crate:attributes=attributes.rs
24//@ edition:2021
35#![ crate_name = "user" ]
46
5- //@ has 'user/struct.NonExhaustive.html'
6- //@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[non_exhaustive]'
7+ //@ has 'user/fn.no_mangle.html' '//pre[@class="rust item-decl"]' '#[unsafe(no_mangle)]'
8+ pub use attributes:: no_mangle;
9+
10+ //@ has 'user/fn.link_section.html' '//pre[@class="rust item-decl"]' \
11+ // '#[unsafe(link_section = ".here")]'
12+ pub use attributes:: link_section;
13+
14+ //@ has 'user/fn.export_name.html' '//pre[@class="rust item-decl"]' \
15+ // '#[unsafe(export_name = "exonym")]'
16+ pub use attributes:: export_name;
17+
18+ //@ has 'user/struct.NonExhaustive.html' '//pre[@class="rust item-decl"]' '#[non_exhaustive]'
719pub use attributes:: NonExhaustive ;
Original file line number Diff line number Diff line change 1+ #[ unsafe( no_mangle) ]
2+ pub fn no_mangle ( ) { }
3+
4+ #[ unsafe( link_section = ".here" ) ]
5+ pub fn link_section ( ) { }
6+
7+ #[ unsafe( export_name = "exonym" ) ]
8+ pub fn export_name ( ) { }
9+
110#[ non_exhaustive]
211pub struct NonExhaustive ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments