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

Fix wildcard type annotation #11

Merged
merged 2 commits into from
Nov 11, 2023
Merged

Conversation

pratapsingh1729
Copy link
Contributor

This should fix #10. I added a small test, which passes for me.

@parno
Copy link
Contributor

parno commented Nov 10, 2023

Thanks for putting this together! This is very niche, but I think a potentially slightly better fix might be to, in verus.pest replace

infer_type = {
    "_"
}

with

infer_type = {
    underscore_str
}

Then the original code in lib.rs ought to do the right thing. It probably doesn't make a big difference, but I think that if the original code happened to be:

let x : /* I wonder what this is*/ _ = bar();

then your fix would move the comment after the underscore.

@pratapsingh1729
Copy link
Contributor Author

Ah interesting. I can fix this later today

@pratapsingh1729 pratapsingh1729 requested review from parno and removed request for jaybosamiya November 10, 2023 19:01
@pratapsingh1729
Copy link
Contributor Author

Changed the code to handle this. I tried adding a test for the case where there is a comment before the underscore, but that test failed to match rustfmt, as follows.

Input:

fn blahblah() {
let x: /* I wonder what this is*/ _ = bar();
}

verusfmt output:

fn blahblah() {
    let x:   /* I wonder what this is*/ _ = bar();
}

rustfmt output:

fn blahblah() {
    let x: /* I wonder what this is*/ _ = bar();
}

Note that verusfmt inserts an extra space ' ' character before the comment. Not sure if we care about this

@parno
Copy link
Contributor

parno commented Nov 11, 2023

No, I officially don't care :) I think we can probably just omit this test, or move it to the snap-test.rs file. Thanks for trying to do the due diligence though!

@pratapsingh1729 pratapsingh1729 merged commit c021b73 into main Nov 11, 2023
2 checks passed
@pratapsingh1729 pratapsingh1729 deleted the pratap-fix-wildcard-annot branch November 11, 2023 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wildcard type annotations on let-bindings are removed
2 participants