rust-lang / rust-lang/rust-bindgen

clang::Cursor should never be the null cursor

Open
#119 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

E-less-easy I-cleanup
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Right now we have various methods on clang::Cursor that return Options just because (I think?) we call underlying clang functions that return null if the cursor is the "null cursor" (see clang_getNullCursor and clang_isNull).

It would be better if these methods did not return Option and always returned a value, if clang::Cursor was never the null cursor, and the place(s) where we first get a cursor return an Option<Cursor> to handle the null cursor case. If we adopt these invariants, we should also assert them throught clang::Cursor methods.

What do you think @emilio?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the clang::Cursor wrapper and the places that create cursors; inspect how clang_getNullCursor and clang_isNull are handled. Done means cursor-producing entry points represent null cursors with Option, Cursor methods return non-Option values, and methods assert the non-null invariant.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.