Repository navigation
A default trait method an impl inherits is lowered with the module (#3343); code is generated for the functions a program reaches (#3351) - #3359
Merged
Conversation
added 2 commits
November 16, 2026 01:51
…cisions for a declaration, reached or not (#3351)
This was referenced Nov 16, 2026
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.
#3343: default trait method bodies are the module's. The body an impl inherits from its trait was built inside codegen (
generate_default_trait_method_for_implmade its ownMirBuilder), after every check on MIR had run. It is now lowered in the MIR phase (lower_default_trait_method_bodies, over the set Sema checks, in its order) and codegen takes it from the module.BUG: anonymous expression lacks retained MIR; it runs.with analyzelists these bodies (select:stage=mir,kind=body), soaudit:resolutionand the validators read them. The validators, seeing them for the first time, refused the old construction twice (no parameter count; a unit return assigned into ani32slot); the new lowering records the count and lowers a unit body as an ordinary function does.#3351: codegen skips the declared functions nothing reaches.
mir_unreached_functionswalks from the roots (main, entry/test/bench/hook functions, a function with a calling-convention attribute, the functions codegen calls by name, every trait impl method, and every body that is not a declared function's own) over the functions each body's MIR names, plus the functions a global's initializer names. Codegen leaves an unreached function an external declaration.mainkeeps everything. An analysis generates everything (its facts are per declaration;deep-debug-tool-testsasks for the matrix of a methodmainnever calls).sema_codegen_named_fns), and codegen refuses a name not on it.Measured. LLVM time for a 31-line test that imports
Sema: 12.6 s -> 4.2 s (dev compiler).internals-testslane: 337 s -> 260 s. Battery wall 805 s. Battery: GREEN.Tests:
behav_3343_default_method_body_is_the_modules(the closure; a function only the default body names),behav_3343_analysis_sees_default_method_bodies.Closes #3343.