Skip to content

Conversation

@abakst
Copy link
Contributor

@abakst abakst commented Dec 23, 2025

Given main.c

int main() {
  assert(0);
  return 0;
}

and header.h:

void assert(int x);

and compile_commands.json derived from

clang -c -include header.h main.c

c2rust transpile compile_commands.json panics in TypedAstContext::include_path because the include path for header.h is None.

This PR fixes the panic by first checking if the root include is not None.

@abakst
Copy link
Contributor Author

abakst commented Dec 23, 2025

I would happily add a regression test, but I'm not sure exactly where to put it.

Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would happily add a regression test, but I'm not sure exactly where to put it.

Our testing infrastructure isn't very well setup to test custom compile commands, so I'm not sure this is easily testable, but I think it's simple enough to not need a test. Also, this seems to be in a cfg!(debug_assertions), so are you also encountering this error in a release build?

Otherwise it LGTM besides whatever rustfmt is complaining about.

@abakst
Copy link
Contributor Author

abakst commented Dec 23, 2025

I would happily add a regression test, but I'm not sure exactly where to put it.

Our testing infrastructure isn't very well setup to test custom compile commands, so I'm not sure this is easily testable, but I think it's simple enough to not need a test. Also, this seems to be in a cfg!(debug_assertions), so are you also encountering this error in a release build?

Otherwise it LGTM besides whatever rustfmt is complaining about.

No this was in a debug build. Thanks!

@abakst
Copy link
Contributor Author

abakst commented Dec 24, 2025

@kkysen apologies but do I re-trigger the CI actions so that I can merge?

@kkysen kkysen force-pushed the abakst/empty-include-path branch from 396d587 to 5e1c3a7 Compare December 27, 2025 00:33
Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kkysen apologies but do I re-trigger the CI actions so that I can merge?

I have to approve it manually, I think since you're a first-time contributor.

I also squashed the formatting commits so CI is green on each commit.

@kkysen kkysen merged commit e4a13ca into immunant:master Dec 27, 2025
6 checks passed
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.

2 participants