File tree Expand file tree Collapse file tree 7 files changed +46
-14
lines changed Expand file tree Collapse file tree 7 files changed +46
-14
lines changed Original file line number Diff line number Diff line change @@ -768,13 +768,13 @@ impl Item {
768768 . iter ( )
769769 . filter_map ( |attr| match attr {
770770 hir:: Attribute :: Parsed ( AttributeKind :: LinkSection { name, .. } ) => {
771- Some ( format ! ( "#[link_section = \" {name}\" ]" ) )
771+ Some ( format ! ( "#[unsafe( link_section = \" {name}\" ) ]" ) )
772772 }
773773 hir:: Attribute :: Parsed ( AttributeKind :: NoMangle ( ..) ) => {
774- Some ( "#[no_mangle]" . to_string ( ) )
774+ Some ( "#[unsafe( no_mangle) ]" . to_string ( ) )
775775 }
776776 hir:: Attribute :: Parsed ( AttributeKind :: ExportName { name, .. } ) => {
777- Some ( format ! ( "#[export_name = \" {name}\" ]" ) )
777+ Some ( format ! ( "#[unsafe( export_name = \" {name}\" ) ]" ) )
778778 }
779779 hir:: Attribute :: Parsed ( AttributeKind :: NonExhaustive ( ..) ) => {
780780 Some ( "#[non_exhaustive]" . to_string ( ) )
Original file line number Diff line number Diff line change 11#![ crate_name = "foo" ]
22
33//@ has 'foo/fn.f.html'
4- //@ has - //*[@'class="rust item-decl"]' '#[export_name = "f"] pub fn f()'
5- #[ export_name = "\
6- f"]
4+ //@ has - //*[@'class="rust item-decl"]' '#[unsafe( export_name = "f") ] pub fn f()'
5+ #[ unsafe ( export_name = "\
6+ f") ]
77pub fn f ( ) { }
Original file line number Diff line number Diff line change 1+ //@ edition: 2021
2+ #![ crate_name = "foo" ]
3+
4+ //@ has foo/fn.f.html '//pre[@class="rust item-decl"]' '#[unsafe(no_mangle)]'
5+ #[ no_mangle]
6+ pub extern "C" fn f ( ) { }
7+
8+ //@ has foo/fn.g.html '//pre[@class="rust item-decl"]' '#[unsafe(export_name = "bar")]'
9+ #[ export_name = "bar" ]
10+ pub extern "C" fn g ( ) { }
11+
12+ //@ has foo/fn.example.html '//pre[@class="rust item-decl"]' '#[unsafe(link_section = ".text")]'
13+ #[ link_section = ".text" ]
14+ pub extern "C" fn example ( ) { }
Original file line number Diff line number Diff line change 1+ // Tests that attributes are correctly copied onto a re-exported item.
2+ //@ edition:2024
3+ #![ crate_name = "re_export" ]
4+
5+ //@ has 're_export/fn.thingy2.html' '//pre[@class="rust item-decl"]' '#[unsafe(no_mangle)]'
6+ pub use thingymod:: thingy as thingy2;
7+
8+ mod thingymod {
9+ #[ unsafe( no_mangle) ]
10+ pub fn thingy ( ) {
11+
12+ }
13+ }
Original file line number Diff line number Diff line change 22//@ edition:2021
33#![ crate_name = "re_export" ]
44
5- //@ has 're_export/fn.thingy2.html' '//pre[@class="rust item-decl"]' '#[no_mangle]'
5+ //@ has 're_export/fn.thingy2.html' '//pre[@class="rust item-decl"]' '#[unsafe( no_mangle) ]'
66pub use thingymod:: thingy as thingy2;
77
88mod thingymod {
Original file line number Diff line number Diff line change 1+ //@ edition: 2024
12#![ crate_name = "foo" ]
23
3- //@ has foo/fn.f.html '//pre[@class="rust item-decl"]' '#[no_mangle]'
4- #[ no_mangle]
4+ //@ has foo/fn.f.html '//pre[@class="rust item-decl"]' '#[unsafe( no_mangle) ]'
5+ #[ unsafe ( no_mangle) ]
56pub extern "C" fn f ( ) { }
67
7- //@ has foo/fn.g.html '//pre[@class="rust item-decl"]' '#[export_name = "bar"]'
8- #[ export_name = "bar" ]
8+ //@ has foo/fn.g.html '//pre[@class="rust item-decl"]' '#[unsafe( export_name = "bar") ]'
9+ #[ unsafe ( export_name = "bar" ) ]
910pub extern "C" fn g ( ) { }
1011
12+ //@ has foo/fn.example.html '//pre[@class="rust item-decl"]' '#[unsafe(link_section = ".text")]'
13+ #[ unsafe( link_section = ".text" ) ]
14+ pub extern "C" fn example ( ) { }
15+
1116//@ has foo/struct.Repr.html '//pre[@class="rust item-decl"]' '#[repr(C, align(8))]'
1217#[ repr( C , align( 8 ) ) ]
1318pub struct Repr ;
Original file line number Diff line number Diff line change 44
55extern crate reexports_attrs;
66
7- //@ has 'foo/fn.f0.html' '//pre[@class="rust item-decl"]' '#[no_mangle]'
7+ //@ has 'foo/fn.f0.html' '//pre[@class="rust item-decl"]' '#[unsafe( no_mangle) ]'
88pub use reexports_attrs:: f0;
99
10- //@ has 'foo/fn.f1.html' '//pre[@class="rust item-decl"]' '#[link_section = ".here"]'
10+ //@ has 'foo/fn.f1.html' '//pre[@class="rust item-decl"]' '#[unsafe( link_section = ".here") ]'
1111pub use reexports_attrs:: f1;
1212
13- //@ has 'foo/fn.f2.html' '//pre[@class="rust item-decl"]' '#[export_name = "f2export"]'
13+ //@ has 'foo/fn.f2.html' '//pre[@class="rust item-decl"]' '#[unsafe( export_name = "f2export") ]'
1414pub use reexports_attrs:: f2;
1515
1616//@ has 'foo/enum.T0.html' '//pre[@class="rust item-decl"]' '#[repr(u8)]'
You can’t perform that action at this time.
0 commit comments