Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare v1.4.24 release #4514

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## [Unreleased]

## [1.4.22] 2020-10-30
## [1.4.24] 2020-11-05

### Changed

- Block wrapped match arm bodies containing a single macro call expression are no longer flattened ([#4496](https://github.com/rust-lang/rustfmt/pull/4496)). This allows programmer discretion so that the block wrapping can be preserved in cases where needed to prevent issues in expansion, such as with trailing semicolons, and aligns with updated [Style Guide guidance](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#macro-call-expressions) for such scenarios.

### Fixed
- Remove useless `deprecated` attribute on a trait impl block in the rustfmt lib, as these now trigger errors ([rust-lang/rust/#78626](https://github.com/rust-lang/rust/pull/78626))

## [1.4.23] 2020-10-30

### Changed

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "rustfmt-nightly"
version = "1.4.23"
version = "1.4.24"
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
description = "Tool to find and fix Rust formatting issues"
repository = "https://github.com/rust-lang/rustfmt"
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ impl FormatReport {
}
}

#[deprecated(note = "Use FormatReportFormatter instead")]
/// Deprecated - Use FormatReportFormatter instead
// https://github.com/rust-lang/rust/issues/78625
// https://github.com/rust-lang/rust/issues/39935
impl fmt::Display for FormatReport {
// Prints all the formatting errors.
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
Expand Down
12 changes: 11 additions & 1 deletion src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ fn rewrite_match_arm(
)
}

fn stmt_is_expr_mac(stmt: &ast::Stmt) -> bool {
if let ast::StmtKind::Expr(expr) = &stmt.kind {
if let ast::ExprKind::MacCall(_) = &expr.kind {
return true;
}
}
false
}

fn block_can_be_flattened<'a>(
context: &RewriteContext<'_>,
expr: &'a ast::Expr,
Expand All @@ -292,7 +301,8 @@ fn block_can_be_flattened<'a>(
ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block)
&& !context.inside_macro()
&& is_simple_block(context, block, Some(&expr.attrs)) =>
&& is_simple_block(context, block, Some(&expr.attrs))
&& !stmt_is_expr_mac(&block.stmts[0]) =>
Comment on lines +304 to +305
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently we haven't backported support for comments in arm guards to v1.x which is why this was removed in 7c24c1e

{
Some(&*block)
}
Expand Down
4 changes: 3 additions & 1 deletion tests/target/configs/match_arm_blocks/false.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ fn main() {
match lorem {
true =>
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
false => println!("{}", sit),
false => {
println!("{}", sit)
}
}
}
4 changes: 3 additions & 1 deletion tests/target/configs/match_arm_blocks/true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ fn main() {
true => {
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
}
false => println!("{}", sit),
false => {
println!("{}", sit)
}
}
}
4 changes: 3 additions & 1 deletion tests/target/issue-2936.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ impl Something for AStruct {
let err: &CStr = match err.kind {
ParseErrorKind::Custom(StyleParseErrorKind::MediaQueryExpectedFeatureName(
..,
)) => cstr!("PEMQExpectedFeatureName"),
)) => {
cstr!("PEMQExpectedFeatureName")
}
};
}
};
Expand Down
12 changes: 9 additions & 3 deletions tests/target/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ fn issue355() {
a => println!("a", b),
b => vec![1, 2],
c => vec![3; 4],
d => println!("a", b),
e => vec![1, 2],
f => vec![3; 4],
d => {
println!("a", b)
}
e => {
vec![1, 2]
}
f => {
vec![3; 4]
}
h => println!("a", b), // h comment
i => vec![1, 2], // i comment
j => vec![3; 4], // j comment
Expand Down