Repository navigation
In-compiler invariants (check-invariants.patch, rustc-verify13) and invariant-sweep; findings 56-57 - #41
Merged
Conversation
…S: query results without inference variables, no error types in an error-free compile, symbols distinct from upstream exports, metadata records written once, LLVM vs layout sizes and rustc's layout sanity checks in release, argument lists against generics, valid spans), built as rustc-verify13; mirth-lab invariant-sweep; findings 56-57 (metadata written twice); regen-patches.sh regenerates the new patch, without Python Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QXiEXbESemwqMLYKaWLDbT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2 of leaning on mirth more: invariants checked inside rustc on every compilation.
The patch
docs/hunt/check-invariants.patchis applied last on the verify-reuse stack and is built into~/mirth-work/rustc-verify13.RUSTC_CHECK_INVARIANTSset, each violation printsrustc-invariant: <property>: <details>and compilation continues.RUSTC_CHECK_INVARIANTS=selftestalso lists which checks ran. For Check reuse and report untracked reads inside rustc; findings 6 and 7 #18 it lists which queries' results are checked and which aren't.TypeVisitable,EarlyBinder, references,Option/Result, canonical responses, typeck node types, borrowck hidden types, clauses, impl headers, layouts). 99 of the ~200 query kinds a small program runs are checked.type_of,fn_sig.SymbolAlreadyDefined)debug_assert_args_compatibleand the alias variant); violations are reported instead of raising a bug.lo <= hi, andlois inside its file.debug_assert!onlyrustc/regen-patches.shregenerates the new patch alongside the others; its embedded Python is replaced bysed. Checked by regenerating the stack:verify-reuse.patchis identical apart from the length of the abbreviated index hashes.The sweep
mirth-lab invariant-sweepcompiles each standalone UI test with the variable set (codegen for tests that build). An ICE that happens only with the variable set counts as a finding.Results:
Findings (
docs/hunt/metadata-written-twice.md, facts only):encode_def_idscallsencode_info_for_mod(CRATE_DEF_ID), then reaches the root again in its loop).encode_mirrecordsmir_coroutine_witnessesinsideif encode_optand again at the end of the loop).std's 8.0 MB.rmeta, 1,384 ofcore's, and 226 of a 16.5 KB async library's. With the fix, the invariant reports nothing.Findings 56–57 may need renumbering if other branches merge first.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QXiEXbESemwqMLYKaWLDbT