-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up ModuleConfig
initialization
#70644
Clean up ModuleConfig
initialization
#70644
Conversation
The condition checks if `sess.opts.output_types` doesn't contain `OutputType::Assembly` within a match arm that is only reached if `sess.opts.output_types` contains `OutputType::Assembly`.
The middle commit is difficult to review, apologies for that. Note that the old |
There are three `ModuleConfigs`, one for each `ModuleKind`. The code to initialized them is spaghetti imperative code that sets each field to a default value and then modifies many fields in complicated ways. This makes it very hard to tell what value ends up in each field in each config. For example, the `modules_config.emit_pre_lto_bc` field is set twice, which means it can be set to true and then incorrectly set back to false. (This probably hasn't been noticed because it happens in a very obscure case.) This commit changes the code to a declarative style in which `ModuleConfig::new` initializes all fields and then they are never changed again. This is slightly more concise and much easier to read. (And it fixes the abovementioned `emit_pre_lto_bc` error as well.)
That way it matches `ModuleKind::Regular`.
b1ec6ab
to
5131c69
Compare
@bors r+ Thanks! The code is much better now, even if still a bit confusing, but I think that's fairly unavoidable for this sort of thing. |
📌 Commit 5131c69 has been approved by |
…nit, r=Mark-Simulacrum Clean up `ModuleConfig` initialization Because it's currently a mess. r? @Mark-Simulacrum
⌛ Testing commit 5131c69 with merge 071b3426de7f4a0c693aca72266c4ebcdbfcecdd... |
@bors retry yield |
Rollup of 5 pull requests Successful merges: - rust-lang#70644 (Clean up `ModuleConfig` initialization) - rust-lang#70937 (Fix staticlib name for *-pc-windows-gnu targets) - rust-lang#70996 (Add or_insert_with_key to Entry of HashMap/BTreeMap) - rust-lang#71020 (Store UNICODE_VERSION as a tuple) - rust-lang#71021 (Use write!-style syntax for MIR assert terminator) Failed merges: r? @ghost
Because it's currently a mess.
r? @Mark-Simulacrum