Skip to content

unexpected token in input when proptest! in file #6747

Closed

Description

@Eh2406

I just updated my rust analyzer, and now every file (at least in this project) gets the error unexpected token in input. The project is https://github.com/pubgrub-rs/pubgrub, and @lnicola can reproduce. They think it is the use of proptest!. I don't know how to be more helpful.

cc https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/unexpected.20token.20in.20input

Activity

  1. crumblingstatue commented on Dec 8, 2020

    @crumblingstatue

    I don't know if it's the same bug, but my advent of code project also has unexpected token in input in every solution in src/bin because of the macro usage. And they all have incorrect span information, pointing to the first line.
    https://github.com/crumblingstatue/advent-of-code

  2. Eh2406 commented on Dec 8, 2020

    @Eh2406
    Author

    BTW the suggestion here https://www.reddit.com/r/rust/comments/k8fo7w/rustanalyzer_changelog_54/gexzaem/?utm_source=reddit&utm_medium=web2x&context=3 got the meseges to go way so I can use rust-analyzer untill this is fixed.

  3. tensor-programming commented on Dec 8, 2020

    @tensor-programming

    Had the same issue; can confirm that the suggestion removes the problem for now. In my case, the error was could not convert tokens and this is for a very simple macro that just uses concat!, file!() and line!() to create a simple error code.

    #[macro_export]
    macro_rules! line_error {
        () => {
            concat!("Error at ", file!(), ":", line!())
        };
        ($str:expr) => {
            concat!($str, " @", file!(), ":", line!())
        };
    }
    

    At least doing this gets rid of all of the red in my project:

    "rust-analyzer.diagnostics.disabled": [
        "macro-error"
      ]
    
  4. jonas-schievink commented on Dec 8, 2020

    @jonas-schievink
    Contributor

    Heh, looks like that's because concat! doesn't like the integer produced by line!().

  5. added 2 commits that reference this issue on Dec 8, 2020
  6. jonas-schievink commented on Dec 8, 2020

    @jonas-schievink
    Contributor

    The concat! issue, as well as the misplaced diagnostics, are now fixed.

  7. lnicola commented on Dec 9, 2020

    @lnicola
    Member

    This seems to work fine now:

    image

    There might still be some resolution errors on the enum variants in Term::is_positive, but that's a different issue.

  8. Eh2406 commented on Dec 14, 2020

    @Eh2406
    Author

    I just updated my version of rust-analyzer and removed the change in settings. And this is still happening. It is no longer every file, it is no longer at the top. But every call to proptest! gets unexpected token in input.

  9. lnicola commented on Dec 14, 2020

    @lnicola
    Member

    Repro:

    macro_rules! foo {
        () => {{
            concat!(module_path!(), "::");
        }};
    }
    
    fn main() {
        foo! {}
    }
  10. added
    S-actionableSomeone could pick this issue up and work on it right now
    on Dec 14, 2020
  11. jonas-schievink commented on Dec 14, 2020

    @jonas-schievink
    Contributor

    Even just concat!(module_path!(), "::"); is enough

  12. jonas-schievink commented on Dec 14, 2020

    @jonas-schievink
    Contributor

    Oh, we simply do not implement module_path!().

  13. added a commit that references this issue on Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-macromacro expansionS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions