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

include_file does not work if any of the modules does not declare a package #1001

Closed
MixusMinimax opened this issue Mar 13, 2024 · 1 comment · Fixed by #1002
Closed

include_file does not work if any of the modules does not declare a package #1001

MixusMinimax opened this issue Mar 13, 2024 · 1 comment · Fixed by #1002

Comments

@MixusMinimax
Copy link
Contributor

a simple .proto file with no package will result in a Module object with an empty vector.

However, the following code is called 1035 in lib.rs of prost-build:

self.write_includes(
    modules.keys().collect(),
    &mut file,
    0,
    if target_is_env { None } else { Some(&target) },
)?;

That function starts at depth 0, meaning it tries to check modules whether module.part(0) is equal to something, which panics, as that vector is empty:

let modident = entries[0].part(depth);
let matching: Vec<&Module> = entries
    .iter()
    .filter(|&v| v.part(depth) == modident)
    .copied()
    .collect();
MixusMinimax added a commit to MixusMinimax/prost that referenced this issue Mar 13, 2024
MixusMinimax added a commit to MixusMinimax/prost that referenced this issue Mar 13, 2024
MixusMinimax added a commit to MixusMinimax/prost that referenced this issue Mar 13, 2024
MixusMinimax added a commit to MixusMinimax/prost that referenced this issue Mar 13, 2024
@MixusMinimax
Copy link
Contributor Author

I have created a pull request at #1002!

github-merge-queue bot pushed a commit that referenced this issue May 5, 2024
* fix #1001 and add tests

* add alloc:: imports

* rewrite write_includes to allow for empty modules.

* create test fixture for `write_includes`

* fix lints, remove line feeds

* fixes after merge master

* remove some duplicate tests and alter existing ones to test write_includes

* more test

* module.rs Module::starts_with visibility
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 a pull request may close this issue.

1 participant