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

Rust: allow arrays in function parameters #2612

Merged
merged 1 commit into from Aug 9, 2020

Conversation

simias
Copy link

@simias simias commented Aug 8, 2020

I noticed that ctags wouldn't generate a function entry for a signature like:

fn foo(arr: [u32; 3]) {}

The problem was that the parser stopped as soon as a ';' was encountered, probably assuming that it would be a statement delimiter and not an array type.

The fix is to keep track of brackets and ignore ';' if we have at least one opened bracket.

While I was at it I also reject the signature if the brackets aren't balanced, which means that the parser is now a little more strict than it was before and a (broken) function like this one will now be rejected:

fn bad(p: &[u32) {}

@coveralls
Copy link

coveralls commented Aug 9, 2020

Coverage Status

Coverage increased (+0.002%) to 86.843% when pulling 2920975 on simias:fix/rust-array-param into c77c95a on universal-ctags:master.

@codecov
Copy link

codecov bot commented Aug 9, 2020

Codecov Report

Merging #2612 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2612   +/-   ##
=======================================
  Coverage   86.73%   86.73%           
=======================================
  Files         183      183           
  Lines       38787    38793    +6     
=======================================
+ Hits        33643    33649    +6     
  Misses       5144     5144           
Impacted Files Coverage Δ
parsers/rust.c 91.43% <100.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c77c95a...2920975. Read the comment docs.

@masatake
Copy link
Member

masatake commented Aug 9, 2020

The change looks fine to me.
Could you add a test case for this?
See https://docs.ctags.io/en/latest/units.html to know how to write a test case.
See also files under Units/parser-rust.r.
See also commit 4ab2053 as an example.
You don't have to add Makefile.am, Makefile.in and Makefile. They are generated by autogen.sh and configure.

Thank you.

@simias
Copy link
Author

simias commented Aug 9, 2020

Hello @masatake and thank you for the feedback.

The 2nd commit adds a test for array parameters the existing rust-test_input test: 6300265

Do you want me to create a new test specifically for this change?

@simias
Copy link
Author

simias commented Aug 9, 2020

I just squashed the two commits for simplicity.

@masatake masatake self-assigned this Aug 9, 2020
@masatake masatake merged commit 3292b1f into universal-ctags:master Aug 9, 2020
@masatake
Copy link
Member

masatake commented Aug 9, 2020

Thank you.

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.

None yet

3 participants