Add support for trailing colons in slice expressions (#3077)

This commit is contained in:
Charlie Marsh
2023-02-20 18:24:32 -05:00
committed by GitHub
parent 7d4e513a82
commit ce8953442d
5 changed files with 29 additions and 2 deletions

View File

@@ -218,6 +218,17 @@ fn format_slice(
write!(f, [space()])?;
}
write!(f, [step.format()])?;
} else {
let magic_trailing_colon = expr
.trivia
.iter()
.any(|c| matches!(c.kind, TriviaKind::MagicTrailingColon));
if magic_trailing_colon {
if !is_simple && upper.is_some() {
write!(f, [space()])?;
}
write!(f, [text(":")])?;
}
}
Ok(())