@@ -33,6 +33,7 @@ macro_rules! attrgen {
3333 ( static_method_of, StaticMethodOf ( Span , Ident ) ) ,
3434 ( js_namespace, JsNamespace ( Span , Ident ) ) ,
3535 ( module, Module ( Span , String , Span ) ) ,
36+ ( raw_module, RawModule ( Span , String , Span ) ) ,
3637 ( inline_js, InlineJs ( Span , String , Span ) ) ,
3738 ( getter, Getter ( Span , Option <Ident >) ) ,
3839 ( setter, Setter ( Span , Option <Ident >) ) ,
@@ -1085,24 +1086,28 @@ impl MacroParse<BindgenAttrs> for syn::ItemForeignMod {
10851086 ) ) ;
10861087 }
10871088 }
1088- let module = match opts. module ( ) {
1089- Some ( ( name, span) ) => {
1090- if opts. inline_js ( ) . is_some ( ) {
1091- let msg = "cannot specify both `module` and `inline_js`" ;
1092- errors. push ( Diagnostic :: span_error ( span, msg) ) ;
1093- }
1094- ast:: ImportModule :: Named ( name. to_string ( ) , span)
1089+ let module = if let Some ( ( name, span) ) = opts. module ( ) {
1090+ if opts. inline_js ( ) . is_some ( ) {
1091+ let msg = "cannot specify both `module` and `inline_js`" ;
1092+ errors. push ( Diagnostic :: span_error ( span, msg) ) ;
10951093 }
1096- None => {
1097- match opts. inline_js ( ) {
1098- Some ( ( js, span) ) => {
1099- let i = program. inline_js . len ( ) ;
1100- program. inline_js . push ( js. to_string ( ) ) ;
1101- ast:: ImportModule :: Inline ( i, span)
1102- }
1103- None => ast:: ImportModule :: None
1104- }
1094+ if opts. raw_module ( ) . is_some ( ) {
1095+ let msg = "cannot specify both `module` and `raw_module`" ;
1096+ errors. push ( Diagnostic :: span_error ( span, msg) ) ;
11051097 }
1098+ ast:: ImportModule :: Named ( name. to_string ( ) , span)
1099+ } else if let Some ( ( name, span) ) = opts. raw_module ( ) {
1100+ if opts. inline_js ( ) . is_some ( ) {
1101+ let msg = "cannot specify both `raw_module` and `inline_js`" ;
1102+ errors. push ( Diagnostic :: span_error ( span, msg) ) ;
1103+ }
1104+ ast:: ImportModule :: RawNamed ( name. to_string ( ) , span)
1105+ } else if let Some ( ( js, span) ) = opts. inline_js ( ) {
1106+ let i = program. inline_js . len ( ) ;
1107+ program. inline_js . push ( js. to_string ( ) ) ;
1108+ ast:: ImportModule :: Inline ( i, span)
1109+ } else {
1110+ ast:: ImportModule :: None
11061111 } ;
11071112 for item in self . items . into_iter ( ) {
11081113 if let Err ( e) = item. macro_parse ( program, module. clone ( ) ) {
0 commit comments