Skip to content

Conversation

@abakst
Copy link

@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
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
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
Author

abakst commented Dec 24, 2025

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

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