Skip to content

Commit cef1c0d

Browse files
authored
preparation for potential rustfmt 1.4.19 (#4283)
2 parents c1e9b7b + bf359c6 commit cef1c0d

File tree

13 files changed

+170
-164
lines changed

13 files changed

+170
-164
lines changed

Cargo.lock

+130-132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustfmt-nightly"
4-
version = "1.4.18"
4+
version = "1.4.19"
55
authors = ["Nicholas Cameron <[email protected]>", "The Rustfmt developers"]
66
description = "Tool to find and fix Rust formatting issues"
77
repository = "https://github.com/rust-lang/rustfmt"
@@ -66,36 +66,36 @@ rustc-workspace-hack = "1.0.0"
6666

6767
[dependencies.rustc_ast]
6868
package = "rustc-ap-rustc_ast"
69-
version = "664.0.0"
69+
version = "669.0.0"
7070

7171
[dependencies.rustc_ast_pretty]
7272
package = "rustc-ap-rustc_ast_pretty"
73-
version = "664.0.0"
73+
version = "669.0.0"
7474

7575
[dependencies.rustc_attr]
7676
package = "rustc-ap-rustc_attr"
77-
version = "664.0.0"
77+
version = "669.0.0"
7878

7979
[dependencies.rustc_data_structures]
8080
package = "rustc-ap-rustc_data_structures"
81-
version = "664.0.0"
81+
version = "669.0.0"
8282

8383
[dependencies.rustc_errors]
8484
package = "rustc-ap-rustc_errors"
85-
version = "664.0.0"
85+
version = "669.0.0"
8686

8787
[dependencies.rustc_expand]
8888
package = "rustc-ap-rustc_expand"
89-
version = "664.0.0"
89+
version = "669.0.0"
9090

9191
[dependencies.rustc_parse]
9292
package = "rustc-ap-rustc_parse"
93-
version = "664.0.0"
93+
version = "669.0.0"
9494

9595
[dependencies.rustc_session]
9696
package = "rustc-ap-rustc_session"
97-
version = "664.0.0"
97+
version = "669.0.0"
9898

9999
[dependencies.rustc_span]
100100
package = "rustc-ap-rustc_span"
101-
version = "664.0.0"
101+
version = "669.0.0"

src/chains.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl ChainItemKind {
145145

146146
fn from_ast(context: &RewriteContext<'_>, expr: &ast::Expr) -> (ChainItemKind, Span) {
147147
let (kind, span) = match expr.kind {
148-
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
148+
ast::ExprKind::MethodCall(ref segment, ref expressions, _) => {
149149
let types = if let Some(ref generic_args) = segment.args {
150150
if let ast::GenericArgs::AngleBracketed(ref data) = **generic_args {
151151
data.args
@@ -399,7 +399,7 @@ impl Chain {
399399
// is a try! macro, we'll convert it to shorthand when the option is set.
400400
fn pop_expr_chain(expr: &ast::Expr, context: &RewriteContext<'_>) -> Option<ast::Expr> {
401401
match expr.kind {
402-
ast::ExprKind::MethodCall(_, ref expressions) => {
402+
ast::ExprKind::MethodCall(_, ref expressions, _) => {
403403
Some(Self::convert_try(&expressions[0], context))
404404
}
405405
ast::ExprKind::Field(ref subexpr, _)

src/config/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ mod test {
481481

482482
#[test]
483483
fn test_valid_license_template_path() {
484+
if !crate::is_nightly_channel!() {
485+
return;
486+
}
484487
let toml = r#"license_template_path = "tests/license-template/lt.txt""#;
485488
let config = Config::from_toml(toml, Path::new("")).unwrap();
486489
assert!(config.license_template.is_some());

src/formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'b, T: Write + 'b> Session<'b, T> {
2929
return Err(ErrorKind::VersionMismatch);
3030
}
3131

32-
rustc_ast::with_globals(self.config.edition().to_libsyntax_pos_edition(), || {
32+
rustc_ast::with_session_globals(self.config.edition().to_libsyntax_pos_edition(), || {
3333
if self.config.disable_all_formatting() {
3434
// When the input is from stdin, echo back the input.
3535
if let Input::Text(ref buf) = input {

src/items.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -595,23 +595,16 @@ impl<'a> FmtVisitor<'a> {
595595
}
596596

597597
fn is_type(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
598-
match ty {
599-
None => true,
600-
Some(lty) => match lty.kind.opaque_top_hack() {
601-
None => true,
602-
Some(_) => false,
603-
},
598+
if let Some(lty) = ty {
599+
if let ast::TyKind::ImplTrait(..) = lty.kind {
600+
return false;
601+
}
604602
}
603+
true
605604
}
606605

607606
fn is_opaque(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
608-
match ty {
609-
None => false,
610-
Some(lty) => match lty.kind.opaque_top_hack() {
611-
None => false,
612-
Some(_) => true,
613-
},
614-
}
607+
!is_type(ty)
615608
}
616609

617610
fn both_type(

src/matches.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl<'a> ArmWrapper<'a> {
4545
impl<'a> Spanned for ArmWrapper<'a> {
4646
fn span(&self) -> Span {
4747
if let Some(lo) = self.beginning_vert {
48+
let lo = std::cmp::min(lo, self.arm.span().lo());
4849
mk_sp(lo, self.arm.span().hi())
4950
} else {
5051
self.arm.span()

src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl Rewrite for ast::GenericParam {
560560
_ => (),
561561
}
562562

563-
if let rustc_ast::ast::GenericParamKind::Const { ref ty } = &self.kind {
563+
if let rustc_ast::ast::GenericParamKind::Const { ref ty, .. } = &self.kind {
564564
result.push_str("const ");
565565
result.push_str(rewrite_ident(context, self.ident));
566566
result.push_str(": ");

src/visitor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -671,15 +671,15 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
671671
};
672672
let rewrite = match ty {
673673
None => rewrite_associated(),
674-
Some(ty) => match ty.kind.opaque_top_hack() {
675-
Some(generic_bounds) => rewrite_opaque_impl_type(
674+
Some(ty) => match ty.kind {
675+
ast::TyKind::ImplTrait(_, ref bounds) => rewrite_opaque_impl_type(
676676
&self.get_context(),
677677
ii.ident,
678678
generics,
679-
generic_bounds,
679+
bounds,
680680
self.block_indent,
681681
),
682-
None => rewrite_associated(),
682+
_ => rewrite_associated(),
683683
},
684684
};
685685
self.push_rewrite(ii.span, rewrite);

tests/config/issue-3779.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
unstable_features = true
21
ignore = [
32
"tests/**/issue-3779/ice.rs"
43
]

tests/source/issue-3779/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// rustfmt-unstable: true
12
// rustfmt-config: issue-3779.toml
23

34
#[path = "ice.rs"]

tests/target/issue-3779/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// rustfmt-unstable: true
12
// rustfmt-config: issue-3779.toml
23

34
#[path = "ice.rs"]

tests/target/issue-3974.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn emulate_foreign_item() {
2+
match link_name {
3+
// A comment here will duplicate the attribute
4+
#[rustfmt::skip]
5+
| "pthread_mutexattr_init"
6+
| "pthread_mutexattr_settype"
7+
| "pthread_mutex_init"
8+
=> {}
9+
}
10+
}

0 commit comments

Comments
 (0)