Skip to content

Commit 13b672a

Browse files
authored
Merge pull request #1661 from alexcrichton/fix-nightly
Fix parsing of `final` on Nightly Rust
2 parents a3ddd09 + 4f86653 commit 13b672a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

crates/macro-support/src/parser.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ macro_rules! attrgen {
4141
(indexing_setter, IndexingSetter(Span)),
4242
(indexing_deleter, IndexingDeleter(Span)),
4343
(structural, Structural(Span)),
44-
(final_("final"), Final(Span)),
44+
(r#final, Final(Span)),
4545
(readonly, Readonly(Span)),
4646
(js_name, JsName(Span, String, Span)),
4747
(js_class, JsClass(Span, String, Span)),
@@ -57,7 +57,7 @@ macro_rules! attrgen {
5757
}
5858

5959
macro_rules! methods {
60-
($(($name:ident $(($other:tt))*, $variant:ident($($contents:tt)*)),)*) => {
60+
($(($name:ident, $variant:ident($($contents:tt)*)),)*) => {
6161
$(methods!(@method $name, $variant($($contents)*));)*
6262

6363
#[cfg(feature = "strict-macro")]
@@ -200,7 +200,7 @@ impl Parse for BindgenAttrs {
200200
}
201201

202202
macro_rules! gen_bindgen_attr {
203-
($(($method:ident $(($other:tt))*, $($variants:tt)*),)*) => {
203+
($(($method:ident, $($variants:tt)*),)*) => {
204204
/// The possible attributes in the `#[wasm_bindgen]`.
205205
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
206206
pub enum BindgenAttr {
@@ -216,11 +216,13 @@ impl Parse for BindgenAttr {
216216
let attr: AnyIdent = input.parse()?;
217217
let attr = attr.0;
218218
let attr_span = attr.span();
219+
let attr_string = attr.to_string();
220+
let raw_attr_string = format!("r#{}", attr_string);
219221

220222
macro_rules! parsers {
221-
($(($name:ident $(($other:tt))*, $($contents:tt)*),)*) => {
223+
($(($name:ident, $($contents:tt)*),)*) => {
222224
$(
223-
if attr == parsers!(@attrname $name $($other)*) {
225+
if attr_string == stringify!($name) || raw_attr_string == stringify!($name) {
224226
parsers!(
225227
@parser
226228
$($contents)*
@@ -269,9 +271,6 @@ impl Parse for BindgenAttr {
269271
};
270272
return Ok(BindgenAttr::$variant(attr_span, val, span))
271273
});
272-
273-
(@attrname $a:ident $b:tt) => ($b);
274-
(@attrname $a:ident) => (stringify!($a));
275274
}
276275

277276
attrgen!(parsers);
@@ -490,7 +489,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
490489
ShortHash(data)
491490
)
492491
};
493-
if let Some(span) = opts.final_() {
492+
if let Some(span) = opts.r#final() {
494493
if opts.structural().is_some() {
495494
let msg = "cannot specify both `structural` and `final`";
496495
return Err(Diagnostic::span_error(*span, msg));
@@ -502,7 +501,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
502501
js_ret,
503502
catch,
504503
variadic,
505-
structural: opts.structural().is_some() || opts.final_().is_none(),
504+
structural: opts.structural().is_some() || opts.r#final().is_none(),
506505
rust_name: self.ident.clone(),
507506
shim: Ident::new(&shim, Span::call_site()),
508507
doc_comment: None,

0 commit comments

Comments
 (0)