The default case of a switch is not its last case

tx0/c:default-not-laststrictwarningstyle

What it finds

A default in the middle of the cases is easy to miss, and a reader looking for what happens to unlisted values expects it at the end.

From the rule's source, default_not_last.rs.

Example from the rule's tests
int pick(int n){  switch (n) {  default:tx0 reports: default is not the last case of the switch    return 0;  case 1:    return 1;  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c:default-not-last" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/c:default-not-last] reason="..."

tx0 explain tx0/c:default-not-last shows the same in the terminal. Found a false positive? Report it.