refactor: refuse to run transforms on crates that do not compile#1898
Closed
thedataking wants to merge 1 commit into
Closed
refactor: refuse to run transforms on crates that do not compile#1898thedataking wants to merge 1 commit into
thedataking wants to merge 1 commit into
Conversation
c2rust-refactor runs the rustc analysis passes before applying a transform, but discarded the result (`let _result = tcx.analysis(())`). When the input crate has type errors, the transform then operates on incomplete typeck tables: it may silently emit rewrites derived from bogus types, or panic on an internal invariant far from the actual problem. Because each transform in a sequence consumes the previous one's output, one transform that produces an invalid crate poisons every transform that runs after it. This surfaced while adding libgit2 to the integration testsuite. libgit2 compiles its test sources with GIT_DEPRECATE_HARD but its library sources without it, so several public structs legitimately have two incompatible declarations within one crate (a member that is a function pointer in one view is a reserved void pointer in the other). The reorganize_definitions transform, which merges duplicate declarations by name, produced an ill-typed crate from that input, but the failure CI reported was a "mismatched key trees" panic in remove_literal_suffixes, three transforms later, which took considerable effort to trace back to the transform actually at fault. Check the analysis result and exit with an error instead, so a transform sequence stops at the transform that broke the crate and rustc's diagnostics point at the real breakage.
9956765 to
6865219
Compare
Contributor
Author
|
Withdrawing this: the refactor tool intentionally supports running commands on crates that do not compile (e.g. |
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.
c2rust-refactor runs the rustc analysis passes before applying a transform, but discarded the result (
let _result = tcx.analysis(())). When the input crate has type errors, the transform then operates on incomplete typeck tables: it may silently emit rewrites derived from bogus types, or panic on an internal invariant far from the actual problem. Because each transform in a sequence consumes the previous one's output, one transform that produces an invalid crate poisons every transform that runs after it.This surfaced while adding libgit2 to the integration testsuite (#1861). libgit2 compiles its test sources with
GIT_DEPRECATE_HARDbut its library sources without it, so several public structs legitimately have two incompatible declarations within one crate (a member that is a function pointer in one view is a reserved void pointer in the other). Thereorganize_definitionstransform, which merges duplicate declarations by name, produced an ill-typed crate from that input, but the failure CI reported was a "mismatched key trees" panic inremove_literal_suffixes, three transforms later, which took considerable effort to trace back to the transform actually at fault.Check the analysis result and exit with an error instead, so a transform sequence stops at the transform that broke the crate and rustc's diagnostics point at the real breakage.