compiler: Print valid -Zmir-enable-passes names if invalid name is used#156059
compiler: Print valid -Zmir-enable-passes names if invalid name is used#156059Enselic wants to merge 1 commit intorust-lang:mainfrom
-Zmir-enable-passes names if invalid name is used#156059Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| #[derive(Diagnostic)] | ||
| #[diag("valid MIR pass names are: {$valid_passes}")] | ||
| pub(crate) struct ValidPassNames { | ||
| pub(crate) valid_passes: String, |
There was a problem hiding this comment.
Could we use &str here?
There was a problem hiding this comment.
We could maybe create a complicated macro to generate the string we want at compile time, but IMHO that would be unnecessarily complicated, because we only need to allocate this string on error code paths (when the user passes an invalid MIR pass name). And doing it at runtime is simpler by probably two orders of magnitude.
There was a problem hiding this comment.
Good idea. What do you think about using DiagSymbolList<&'a str>? We'd have
pub(crate) struct ValidPassNames<'a> {
pub(crate) valid_passes: DiagSymbolList<&'a str>,
}which would give diagnostics like this:
note: valid MIR pass names are: `AbortUnwindingCalls`, ..., `UnreachablePropagation`, and `Validator`
…used If a user passes an invalid name to `-Zmir-enable-passes`, print the valid names as a note. The diagnostic is duplicated, but that is not introduced by this commit. In other words, we don't make matters worse. The existing "is unknown and will be ignored" diagnostic is already duplicated. To avoid the annoyance of having to keep blessing test output, completely normalize away the list of names in the test.
compiler: Print valid `-Zmir-enable-passes` names if invalid name is used If a user passes an invalid name to `-Zmir-enable-passes`, print the valid names as a note. To avoid the annoyance of having to keep blessing test output, completely normalize away the list of names in the test. The diagnostic is duplicated, but that is not introduced by this commit. In other words, we don't make matters worse. The existing "is unknown and will be ignored" diagnostic is already duplicated, as can be seen in the existing test stderr. The output is on one long line, but that makes normalization in tests easier, and I don't think we have to overdo this. We can let terminals wrap the line. <details> <summary>Click to expand current output</summary> `note: valid MIR pass names are: AbortUnwindingCalls, AddCallGuards, AddMovesForPackedDrops, AddRetag, CheckAlignment, CheckCallRecursion, CheckConstItemMutation, CheckDropRecursion, CheckEnums, CheckForceInline, CheckInlineAlwaysTargetFeature, CheckLiveDrops, CheckNull, CheckPackedRef, CleanupPostBorrowck, CopyProp, CtfeLimit, DataflowConstProp, DeadStoreElimination-final, DeadStoreElimination-initial, Derefer, DestinationPropagation, EarlyOtherwiseBranch, ElaborateBoxDerefs, ElaborateDrops, EnumSizeOpt, EraseDerefTemps, ForceInline, FunctionItemReferences, GVN, ImpossiblePredicates, Inline, InstSimplify-after-simplifycfg, InstSimplify-before-inline, InstrumentCoverage, JumpThreading, KnownPanicsLint, LowerIntrinsics, LowerSliceLenCalls, Marker, MatchBranchSimplification, MentionedItems, MultipleReturnTerminators, PostAnalysisNormalize, PreCodegen, PromoteTemps, ReferencePropagation, RemoveNoopLandingPads, RemovePlaceMention, RemoveStorageMarkers, RemoveUninitDrops, RemoveUnneededDrops, RemoveZsts, ReorderBasicBlocks, ReorderLocals, RequiredConstsVisitor, SanityCheck, ScalarReplacementOfAggregates, SimplifyCfg-after-unreachable-enum-branching, SimplifyCfg-final, SimplifyCfg-initial, SimplifyCfg-make_shim, SimplifyCfg-post-analysis, SimplifyCfg-pre-optimizations, SimplifyCfg-promote-consts, SimplifyCfg-remove-false-edges, SimplifyComparisonIntegral, SimplifyConstCondition-after-const-prop, SimplifyConstCondition-after-inst-simplify, SimplifyConstCondition-final, SimplifyLocals-after-value-numbering, SimplifyLocals-before-const-prop, SimplifyLocals-final, SingleUseConsts, SsaRangePropagation, StateTransform, StripDebugInfo, Subtyper, UnreachableEnumBranching, UnreachablePropagation, Validator` </details>
…uwer Rollup of 9 pull requests Successful merges: - #156030 (Make stable hashing names consistent (part 1)) - #156020 (Improve source code for `librustdoc/visit_ast.rs`) - #156021 (Clean up some traits) - #156028 (Add a `Local::arg(i)` helper constructor) - #156037 (Add AcceptContext::expect_no_args) - #156040 (Add missing alias to mailmap) - #156048 (Make `diverging_type_vars` a vec of `TyVid`) - #156053 (Reuse CTFE MIR for constructors.) - #156059 (compiler: Print valid `-Zmir-enable-passes` names if invalid name is used) Failed merges: - #155940 (refactor rustc_on_unimplemented's filtering) - #156065 (Remove unused spans from AttributeKind)
If a user passes an invalid name to
-Zmir-enable-passes, print the valid names as a note.To avoid the annoyance of having to keep blessing test output, completely normalize away the list of names in the test.
The diagnostic is duplicated, but that is not introduced by this commit. In other words, we don't make matters worse. The existing "is unknown and will be ignored" diagnostic is already duplicated, as can be seen in the existing test stderr.
The output is on one long line, but that makes normalization in tests easier, and I don't think we have to overdo this. We can let terminals wrap the line.
Click to expand current output
note: valid MIR pass names are: AbortUnwindingCalls, AddCallGuards, AddMovesForPackedDrops, AddRetag, CheckAlignment, CheckCallRecursion, CheckConstItemMutation, CheckDropRecursion, CheckEnums, CheckForceInline, CheckInlineAlwaysTargetFeature, CheckLiveDrops, CheckNull, CheckPackedRef, CleanupPostBorrowck, CopyProp, CtfeLimit, DataflowConstProp, DeadStoreElimination-final, DeadStoreElimination-initial, Derefer, DestinationPropagation, EarlyOtherwiseBranch, ElaborateBoxDerefs, ElaborateDrops, EnumSizeOpt, EraseDerefTemps, ForceInline, FunctionItemReferences, GVN, ImpossiblePredicates, Inline, InstSimplify-after-simplifycfg, InstSimplify-before-inline, InstrumentCoverage, JumpThreading, KnownPanicsLint, LowerIntrinsics, LowerSliceLenCalls, Marker, MatchBranchSimplification, MentionedItems, MultipleReturnTerminators, PostAnalysisNormalize, PreCodegen, PromoteTemps, ReferencePropagation, RemoveNoopLandingPads, RemovePlaceMention, RemoveStorageMarkers, RemoveUninitDrops, RemoveUnneededDrops, RemoveZsts, ReorderBasicBlocks, ReorderLocals, RequiredConstsVisitor, SanityCheck, ScalarReplacementOfAggregates, SimplifyCfg-after-unreachable-enum-branching, SimplifyCfg-final, SimplifyCfg-initial, SimplifyCfg-make_shim, SimplifyCfg-post-analysis, SimplifyCfg-pre-optimizations, SimplifyCfg-promote-consts, SimplifyCfg-remove-false-edges, SimplifyComparisonIntegral, SimplifyConstCondition-after-const-prop, SimplifyConstCondition-after-inst-simplify, SimplifyConstCondition-final, SimplifyLocals-after-value-numbering, SimplifyLocals-before-const-prop, SimplifyLocals-final, SingleUseConsts, SsaRangePropagation, StateTransform, StripDebugInfo, Subtyper, UnreachableEnumBranching, UnreachablePropagation, Validator