Skip to content
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

regression: failed to parse proc-macro input #61470

Closed
Mark-Simulacrum opened this issue Jun 2, 2019 · 4 comments
Closed

regression: failed to parse proc-macro input #61470

Mark-Simulacrum opened this issue Jun 2, 2019 · 4 comments
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Mark-Simulacrum
Copy link
Member

cc @dtolnay -- possibly related to syn?

root is termfest, cc @agatan

@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Jun 2, 2019
@dtolnay
Copy link
Member

dtolnay commented Jun 2, 2019

This is due to 1.36 passing literals in macro input differently than previous releases, and the repo in the crater report pinning an old version of syn (September 2016) that does not parse the new syntax.

@dtolnay
Copy link
Member

dtolnay commented Jun 2, 2019

Minimized:

#!/bin/bash

cargo new repro

echo >>repro/Cargo.toml '
[lib]
proc-macro = true
'

echo >repro/src/lib.rs '
extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro_derive(D)]
pub fn m(input: TokenStream) -> TokenStream {
    assert_eq!(input.to_string(), "pub enum E { V = 0, }");
    TokenStream::new()
}
'

echo >repro/src/main.rs '
#[derive(repro::D)]
pub enum E { V = 0x0 }
fn main() {}
'

set -x
cargo +stable check --manifest-path repro/Cargo.toml
cargo +beta check --manifest-path repro/Cargo.toml
     Created binary (application) `repro` package
+ cargo +stable check --manifest-path repro/Cargo.toml
   Compiling repro v0.1.0 (/git/repro/repro)
    Finished dev [unoptimized + debuginfo] target(s) in 0.44s
+ cargo +beta check --manifest-path repro/Cargo.toml
   Compiling repro v0.1.0 (/git/repro/repro)
error: proc-macro derive panicked
 --> src/main.rs:2:10
  |
2 | #[derive(repro::D)]
  |          ^^^^^^^^
  |
  = help: message: assertion failed: `(left == right)`
            left: `"pub enum E { V = 0x0, }"`,
           right: `"pub enum E { V = 0, }"`

error: aborting due to previous error

@petrochenkov
Copy link
Contributor

The change is expected and was introduced in #60679.

Literals, for example hexadecimal literals like 0x0 in the reproduction, are now passed to proc macros precisely (without normalizing to 0) even if they go through "token -> AST -> token" conversion.

Proc macros should be ready to deal with hexadecimal literals because they could previously get them from tokens not going through "token -> AST -> token" conversion (e.g. from fn-like macros).
Looks like the new versions of syn work with literals correctly (#61470 (comment)), so the issue is with an outdated dependency in agatan/squeeze-rs.

@petrochenkov petrochenkov removed their assignment Jun 3, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Jun 4, 2019

triage: Based on @petrochenkov 's analysis above, and the fact that agatan/squeeze-rs itself does not appear to be maintained, I'm going to just accept this as acceptable fallout from PR #60679 and close this ticket, without attempting to post a PR to update the dependency on agatan/squeeze-rs.

@pnkfelix pnkfelix closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants