Skip to content

Errnous "unexpected token in input"  #8828

@leehambley

Description

@leehambley

rust-analyzer version: fd109fb58 2021-05-10 stable

Given the following piece of test code:

    macro_rules! test_driver {
        ($driver_name:ident, $setup:expr) => {
            concat_idents!(
                test_name = "test_",
                $driver_name,
                "_driver_raises_malformed_error_when_migration_has_both_change_and_up_steps",
                {
                    #[test]
                    fn test_name() -> Result<(), String> {
                        let mut driver = $setup;
                        match driver.apply(&malformed_migration()) {
                            Ok(_) => Err(format!("engine did not report malformed error",)),
                            Err(e) => match e {
                                Error::MalformedMigration => Ok(()),
                                _ => Err(format!("Engine returned {:?}, unexpected", e)),
                            },
                        }?;
                        Ok(())
                    }
                }
            );
        };
    }

    // rust-analyzer bug here (?)
    // https://github.com/rust-analyzer/rust-analyzer/issues/6747
    test_driver!(noop_driver, { NoopDriver {} });
    test_driver!(succeed_or_fail_driver, { SucceedOrFailDriver {} });

image

This is the first time I wrote a macro, so very possible that I made a mistake, but I don't think so, as the example is more-or-less verbatim from the concat_idents crate docs.

I tried restarting the server, and confirmed that after a few seconds the error returns.

Googling led me to #6747, I don't see any other issues open now with "unexpected token in input" error.

I tried to reproduce minimally, but I cannot reproduce it. My best guess is that because Driver in my original example is a trait, something different happens?

Here is the repro case with simple empty structs, showing a clean vscode build, and the crate version for concat_idents

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionA-nameresname, path and module resolutionE-hardS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions