File tree Expand file tree Collapse file tree 6 files changed +43
-11
lines changed Expand file tree Collapse file tree 6 files changed +43
-11
lines changed Original file line number Diff line number Diff line change @@ -768,13 +768,13 @@ impl Item {
768
768
. iter ( )
769
769
. filter_map ( |attr| match attr {
770
770
hir:: Attribute :: Parsed ( AttributeKind :: LinkSection { name, .. } ) => {
771
- Some ( format ! ( "#[link_section = \" {name}\" ]" ) )
771
+ Some ( format ! ( "#[unsafe( link_section = \" {name}\" ) ]" ) )
772
772
}
773
773
hir:: Attribute :: Parsed ( AttributeKind :: NoMangle ( ..) ) => {
774
- Some ( "#[no_mangle]" . to_string ( ) )
774
+ Some ( "#[unsafe( no_mangle) ]" . to_string ( ) )
775
775
}
776
776
hir:: Attribute :: Parsed ( AttributeKind :: ExportName { name, .. } ) => {
777
- Some ( format ! ( "#[export_name = \" {name}\" ]" ) )
777
+ Some ( format ! ( "#[unsafe( export_name = \" {name}\" ) ]" ) )
778
778
}
779
779
hir:: Attribute :: Parsed ( AttributeKind :: NonExhaustive ( ..) ) => {
780
780
Some ( "#[non_exhaustive]" . to_string ( ) )
Original file line number Diff line number Diff line change 1
1
#![ crate_name = "foo" ]
2
2
3
3
//@ 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") ]
7
7
pub 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 2
2
//@ edition:2021
3
3
#![ crate_name = "re_export" ]
4
4
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) ]'
6
6
pub use thingymod:: thingy as thingy2;
7
7
8
8
mod thingymod {
Original file line number Diff line number Diff line change
1
+ //@ edition: 2024
1
2
#![ crate_name = "foo" ]
2
3
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) ]
5
6
pub extern "C" fn f ( ) { }
6
7
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" ) ]
9
10
pub extern "C" fn g ( ) { }
10
11
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
+
11
16
//@ has foo/struct.Repr.html '//pre[@class="rust item-decl"]' '#[repr(C, align(8))]'
12
17
#[ repr( C , align( 8 ) ) ]
13
18
pub struct Repr ;
You can’t perform that action at this time.
0 commit comments