Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
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
|
@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. |
|
|
…nit, r=Mark-Simulacrum Clean up `ModuleConfig` initialization Because it's currently a mess. r? @Mark-Simulacrum
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
…t, r=Mark-Simulacrum Clean up `ModuleConfig` initialization Because it's currently a mess. r? @Mark-Simulacrum
|
@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
f9c0ea2
into
rust-lang:master
Because it's currently a mess.
r? @Mark-Simulacrum