Skip to content

Fix parsing of final on Nightly Rust #1661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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