syn icon indicating copy to clipboard operation
syn copied to clipboard

Failure when parsing anonymous parameters

Open Nemo157 opened this issue 5 years ago • 2 comments

This snippet of code from dtoa fails parsing with syn 1.0.13:

pub trait Floating {
    fn write<W: io::Write>(self, W) -> io::Result<usize>;
}

Giving the error Error("expected `:`"). This is valid code in edition 2015, edition 2018 has made it a hard error, here's a playground which compiles successfully with the code, and shows the error from syn.

I have also locally tested defining an identity proc-macro-attribute which attempts to parse whatever it's applied to as an syn::Item. That also fails with the same error message.

Nemo157 avatar Jan 10 '20 12:01 Nemo157

See-also #733. Recent versions of syn don't handle parsing edition 2015-only code. Version 0.13.0 is also out-of-date, the latest version is 1.0.13.

mystor avatar Jan 10 '20 18:01 mystor

Whoops, I meant 1.0.13.

If syn isn’t planning to support edition 2015 code it would be good to note that somewhere. I did take a quick look through the docs to try and figure out if it was a purposeful omission.

Nemo157 avatar Jan 10 '20 18:01 Nemo157

Closing as a duplicate of #733. I don't plan to change how this is parsed.

Regarding documentation, I am skeptical that this would come up often enough to be worth dedicating documentation to.

dtolnay avatar Dec 01 '22 01:12 dtolnay