Skip to content

compiletest: Add testing for lint machinery at runtime - #157721

Open
clubby789 wants to merge 2 commits into
rust-lang:mainfrom
clubby789:test-lint-machinery
Open

compiletest: Add testing for lint machinery at runtime#157721
clubby789 wants to merge 2 commits into
rust-lang:mainfrom
clubby789:test-lint-machinery

Conversation

@clubby789

@clubby789 clubby789 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

While implementing #157707, I noticed that we don't have 'runtime' tests for the diagnostic machinery (i.e. we test the derive macros themselves, but not their output when emitted). This introduces a new way to test this machinery.

  • Add //@ aux-lint: file.rs, which builds a lint library in auxiliary/file.rs
  • Lint libraries link with rustc_private, and export a extern "C" fn register_lints(...)
  • A new compiletest-lint-driver wraps rustc and installs the provided lints when building the test

Included is a simple demo lint for example

AI Disclosure: I used an LLM to plan out the broad structure of the machinery and identify issues; all code in this PR is written by hand

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants