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

preparation for potential rustfmt 1.4.19 #4283

Merged
merged 5 commits into from
Jul 21, 2020
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
262 changes: 130 additions & 132 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

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

[dependencies.rustc_ast]
package = "rustc-ap-rustc_ast"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_ast_pretty]
package = "rustc-ap-rustc_ast_pretty"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_attr]
package = "rustc-ap-rustc_attr"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_data_structures]
package = "rustc-ap-rustc_data_structures"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_errors]
package = "rustc-ap-rustc_errors"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_expand]
package = "rustc-ap-rustc_expand"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_parse]
package = "rustc-ap-rustc_parse"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_session]
package = "rustc-ap-rustc_session"
version = "664.0.0"
version = "669.0.0"

[dependencies.rustc_span]
package = "rustc-ap-rustc_span"
version = "664.0.0"
version = "669.0.0"
4 changes: 2 additions & 2 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl ChainItemKind {

fn from_ast(context: &RewriteContext<'_>, expr: &ast::Expr) -> (ChainItemKind, Span) {
let (kind, span) = match expr.kind {
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
ast::ExprKind::MethodCall(ref segment, ref expressions, _) => {
let types = if let Some(ref generic_args) = segment.args {
if let ast::GenericArgs::AngleBracketed(ref data) = **generic_args {
data.args
Expand Down Expand Up @@ -399,7 +399,7 @@ impl Chain {
// is a try! macro, we'll convert it to shorthand when the option is set.
fn pop_expr_chain(expr: &ast::Expr, context: &RewriteContext<'_>) -> Option<ast::Expr> {
match expr.kind {
ast::ExprKind::MethodCall(_, ref expressions) => {
ast::ExprKind::MethodCall(_, ref expressions, _) => {
Some(Self::convert_try(&expressions[0], context))
}
ast::ExprKind::Field(ref subexpr, _)
Expand Down
3 changes: 3 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ mod test {

#[test]
fn test_valid_license_template_path() {
if !crate::is_nightly_channel!() {
return;
}
let toml = r#"license_template_path = "tests/license-template/lt.txt""#;
let config = Config::from_toml(toml, Path::new("")).unwrap();
assert!(config.license_template.is_some());
Expand Down
2 changes: 1 addition & 1 deletion src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<'b, T: Write + 'b> Session<'b, T> {
return Err(ErrorKind::VersionMismatch);
}

rustc_ast::with_globals(self.config.edition().to_libsyntax_pos_edition(), || {
rustc_ast::with_session_globals(self.config.edition().to_libsyntax_pos_edition(), || {
if self.config.disable_all_formatting() {
// When the input is from stdin, echo back the input.
if let Input::Text(ref buf) = input {
Expand Down
19 changes: 6 additions & 13 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,23 +595,16 @@ impl<'a> FmtVisitor<'a> {
}

fn is_type(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
match ty {
None => true,
Some(lty) => match lty.kind.opaque_top_hack() {
None => true,
Some(_) => false,
},
if let Some(lty) = ty {
if let ast::TyKind::ImplTrait(..) = lty.kind {
return false;
}
}
true
}

fn is_opaque(ty: &Option<rustc_ast::ptr::P<ast::Ty>>) -> bool {
match ty {
None => false,
Some(lty) => match lty.kind.opaque_top_hack() {
None => false,
Some(_) => true,
},
}
!is_type(ty)
}

fn both_type(
Expand Down
1 change: 1 addition & 0 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl<'a> ArmWrapper<'a> {
impl<'a> Spanned for ArmWrapper<'a> {
fn span(&self) -> Span {
if let Some(lo) = self.beginning_vert {
let lo = std::cmp::min(lo, self.arm.span().lo());
mk_sp(lo, self.arm.span().hi())
} else {
self.arm.span()
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl Rewrite for ast::GenericParam {
_ => (),
}

if let rustc_ast::ast::GenericParamKind::Const { ref ty } = &self.kind {
if let rustc_ast::ast::GenericParamKind::Const { ref ty, .. } = &self.kind {
result.push_str("const ");
result.push_str(rewrite_ident(context, self.ident));
result.push_str(": ");
Expand Down
8 changes: 4 additions & 4 deletions src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,15 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
};
let rewrite = match ty {
None => rewrite_associated(),
Some(ty) => match ty.kind.opaque_top_hack() {
Some(generic_bounds) => rewrite_opaque_impl_type(
Some(ty) => match ty.kind {
ast::TyKind::ImplTrait(_, ref bounds) => rewrite_opaque_impl_type(
&self.get_context(),
ii.ident,
generics,
generic_bounds,
bounds,
self.block_indent,
),
None => rewrite_associated(),
_ => rewrite_associated(),
},
};
self.push_rewrite(ii.span, rewrite);
Expand Down
1 change: 0 additions & 1 deletion tests/config/issue-3779.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
unstable_features = true
ignore = [
"tests/**/issue-3779/ice.rs"
]
1 change: 1 addition & 0 deletions tests/source/issue-3779/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// rustfmt-unstable: true
// rustfmt-config: issue-3779.toml

#[path = "ice.rs"]
Expand Down
1 change: 1 addition & 0 deletions tests/target/issue-3779/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// rustfmt-unstable: true
// rustfmt-config: issue-3779.toml

#[path = "ice.rs"]
Expand Down
10 changes: 10 additions & 0 deletions tests/target/issue-3974.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn emulate_foreign_item() {
match link_name {
// A comment here will duplicate the attribute
#[rustfmt::skip]
| "pthread_mutexattr_init"
| "pthread_mutexattr_settype"
| "pthread_mutex_init"
=> {}
}
}