Skip to content

Commit

Permalink
Merge pull request #1661 from alexcrichton/fix-nightly
Browse files Browse the repository at this point in the history
Fix parsing of `final` on Nightly Rust
  • Loading branch information
alexcrichton authored Jul 12, 2019
2 parents a3ddd09 + 4f86653 commit 13b672a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions crates/macro-support/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ macro_rules! attrgen {
(indexing_setter, IndexingSetter(Span)),
(indexing_deleter, IndexingDeleter(Span)),
(structural, Structural(Span)),
(final_("final"), Final(Span)),
(r#final, Final(Span)),
(readonly, Readonly(Span)),
(js_name, JsName(Span, String, Span)),
(js_class, JsClass(Span, String, Span)),
Expand All @@ -57,7 +57,7 @@ macro_rules! attrgen {
}

macro_rules! methods {
($(($name:ident $(($other:tt))*, $variant:ident($($contents:tt)*)),)*) => {
($(($name:ident, $variant:ident($($contents:tt)*)),)*) => {
$(methods!(@method $name, $variant($($contents)*));)*

#[cfg(feature = "strict-macro")]
Expand Down Expand Up @@ -200,7 +200,7 @@ impl Parse for BindgenAttrs {
}

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

macro_rules! parsers {
($(($name:ident $(($other:tt))*, $($contents:tt)*),)*) => {
($(($name:ident, $($contents:tt)*),)*) => {
$(
if attr == parsers!(@attrname $name $($other)*) {
if attr_string == stringify!($name) || raw_attr_string == stringify!($name) {
parsers!(
@parser
$($contents)*
Expand Down Expand Up @@ -269,9 +271,6 @@ impl Parse for BindgenAttr {
};
return Ok(BindgenAttr::$variant(attr_span, val, span))
});

(@attrname $a:ident $b:tt) => ($b);
(@attrname $a:ident) => (stringify!($a));
}

attrgen!(parsers);
Expand Down Expand Up @@ -490,7 +489,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
ShortHash(data)
)
};
if let Some(span) = opts.final_() {
if let Some(span) = opts.r#final() {
if opts.structural().is_some() {
let msg = "cannot specify both `structural` and `final`";
return Err(Diagnostic::span_error(*span, msg));
Expand All @@ -502,7 +501,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
js_ret,
catch,
variadic,
structural: opts.structural().is_some() || opts.final_().is_none(),
structural: opts.structural().is_some() || opts.r#final().is_none(),
rust_name: self.ident.clone(),
shim: Ident::new(&shim, Span::call_site()),
doc_comment: None,
Expand Down

0 comments on commit 13b672a

Please sign in to comment.