Skip to content

Commit ff6c15f

Browse files
committed
Touch up PR 1529
1 parent 393b1c0 commit ff6c15f

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

gen/src/write.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,13 @@ fn write_cxx_function_shim<'a>(out: &mut OutFile<'a>, efn: &'a ExternFn) {
779779
write_indirect_return_type_space(out, efn.ret.as_ref().unwrap());
780780
write!(out, "*return$");
781781
}
782-
if efn.lang == Lang::CxxUnwind {
783-
writeln!(out, ") {{");
784-
} else {
785-
writeln!(out, ") noexcept {{");
782+
write!(out, ")");
783+
match efn.lang {
784+
Lang::Cxx => write!(out, " noexcept"),
785+
Lang::CxxUnwind => {}
786+
Lang::Rust => unreachable!(),
786787
}
788+
writeln!(out, " {{");
787789
write!(out, " ");
788790
write_return_type(out, &efn.ret);
789791
match &efn.receiver {

macro/src/expand.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::syntax::qualified::QualifiedName;
77
use crate::syntax::report::Errors;
88
use crate::syntax::symbol::Symbol;
99
use crate::syntax::{
10-
self, check, mangle, Api, Doc, Enum, ExternFn, ExternType, Impl, Lifetimes, Pair, Signature,
11-
Struct, Trait, Type, TypeAlias, Types,
10+
self, check, mangle, Api, Doc, Enum, ExternFn, ExternType, Impl, Lang, Lifetimes, Pair,
11+
Signature, Struct, Trait, Type, TypeAlias, Types,
1212
};
1313
use crate::type_id::Crate;
1414
use crate::{derive, generics};
@@ -733,13 +733,13 @@ fn expand_cxx_function_shim(efn: &ExternFn, types: &Types) -> TokenStream {
733733
let ident = &efn.name.rust;
734734
let generics = &efn.generics;
735735
let arg_list = quote_spanned!(efn.paren_token.span=> (#(#all_args,)*));
736-
let calling_conv = if let syntax::Lang::CxxUnwind = efn.lang {
737-
quote_spanned!(span => extern "C-unwind")
738-
} else {
739-
quote_spanned!(span => extern "C")
736+
let calling_conv = match efn.lang {
737+
Lang::Cxx => quote_spanned!(span=> "C"),
738+
Lang::CxxUnwind => quote_spanned!(span=> "C-unwind"),
739+
Lang::Rust => unreachable!(),
740740
};
741741
let fn_body = quote_spanned!(span=> {
742-
#UnsafeExtern #calling_conv {
742+
#UnsafeExtern extern #calling_conv {
743743
#decl
744744
}
745745
#trampolines
@@ -810,17 +810,17 @@ fn expand_function_pointer_trampoline(
810810
&efn.attrs,
811811
body_span,
812812
);
813-
let var = &var.rust;
814-
let calling_conv = if let syntax::Lang::CxxUnwind = efn.lang {
815-
quote!(extern "C-unwind")
816-
} else {
817-
quote!(extern "C")
813+
let calling_conv = match efn.lang {
814+
Lang::Cxx => "C",
815+
Lang::CxxUnwind => "C-unwind",
816+
Lang::Rust => unreachable!(),
818817
};
818+
let var = &var.rust;
819819

820820
quote! {
821821
let #var = ::cxx::private::FatFunction {
822822
trampoline: {
823-
#UnsafeExtern #calling_conv {
823+
#UnsafeExtern extern #calling_conv {
824824
#[link_name = #c_trampoline]
825825
fn trampoline();
826826
}

0 commit comments

Comments
 (0)