Skip to content

Commit a4c8128

Browse files
committed
make an impossible case a bug!
1 parent aebc133 commit a4c8128

File tree

1 file changed

+8
-3
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+8
-3
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2719,10 +2719,15 @@ fn handle_cli_linker_flavors(
27192719
// adding an argument to the `cc` invocation to use the `use_ld` given linker.
27202720
let use_ld = match &cg.linker_flavor {
27212721
Some(LinkerFlavorCli::Gcc { use_ld }) => {
2722-
// Ensure `gcc` is the currently selected flavor. Error out cleanly, as `-Zgcc-ld` does
2723-
// if that happens, but this should be unreachable.
2722+
// Ensure `gcc` is the currently selected flavor.
2723+
//
2724+
// This should be the case as long as this piece of code stays downstream from the CLI
2725+
// linker-flavor lowering, and the actual `LinkerFlavor` is not changed or overriden by
2726+
// the time the order-independent options are added to the command args.
2727+
//
2728+
// If that changes by mistake (or intentionally) in the future, we panic.
27242729
if LinkerFlavor::Gcc != flavor {
2725-
sess.fatal(
2730+
bug!(
27262731
"`-Clinker-flavor=gcc:*` flag is used even though the \
27272732
linker flavor is not `gcc`",
27282733
);

0 commit comments

Comments
 (0)