File tree 3 files changed +7
-3
lines changed
c2rust-transpile/src/translator
3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -403,7 +403,11 @@ pub fn stmts_block(mut stmts: Vec<Stmt>) -> P<Block> {
403
403
// values.
404
404
fn mk_linkage ( in_extern_block : bool , new_name : & str , old_name : & str ) -> Builder {
405
405
if new_name == old_name {
406
- mk ( ) // Don't touch my name Rust!
406
+ if in_extern_block {
407
+ mk ( ) // There is no mangling by default in extern blocks anymore
408
+ } else {
409
+ mk ( ) . single_attr ( "no_mangle" ) // Don't touch my name Rust!
410
+ }
407
411
} else if in_extern_block {
408
412
mk ( ) . str_attr ( "link_name" , old_name) // Look for this name
409
413
} else {
Original file line number Diff line number Diff line change @@ -52,6 +52,6 @@ pub fn test_fn_attrs() {
52
52
53
53
if cfg ! ( not( target_os = "macos" ) ) {
54
54
// aliased_fn is aliased to the inline_extern function
55
- assert ! ( src. contains( "#[no_mangle] \n #[link_name = \" inline_extern\" ]\n fn aliased_fn();" ) ) ;
55
+ assert ! ( src. contains( "extern \" C \" { \n #[link_name = \" inline_extern\" ]\n fn aliased_fn();" ) ) ;
56
56
}
57
57
}
Original file line number Diff line number Diff line change @@ -50,6 +50,6 @@ pub fn test_sectioned_used_static() {
50
50
51
51
// This static is pub, but we want to ensure it has attributes applied
52
52
assert ! ( src. contains( "#[link_section = \" fb\" ]\n pub static mut rust_initialized_extern: libc::c_int = 1 as libc::c_int;" ) ) ;
53
- assert ! ( src. contains( "#[no_mangle] \n #[link_name = \" no_attrs\" ]\n static mut rust_aliased_static: libc::c_int;" ) )
53
+ assert ! ( src. contains( "extern \" C \" { \n #[link_name = \" no_attrs\" ]\n static mut rust_aliased_static: libc::c_int;" ) )
54
54
}
55
55
}
You can’t perform that action at this time.
0 commit comments