Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3585706

Browse files
author
crw5996
committed
Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into fix-optional-arg-condensing
2 parents 8c9a988 + 4484609 commit 3585706

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+461
-297
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ matrix:
4141
- env: INTEGRATION=crater
4242
# Doesn't build
4343
- env: INTEGRATION=futures-rs
44+
# Doesn't build - seems to be because of an option
45+
- env: INTEGRATION=packed_simd
46+
# Weird bug I can't reproduce: #2969
47+
- env: INTEGRATION=rand
4448
# Test failure
4549
- env: INTEGRATION=rust-clippy
4650
# Build failure

Cargo.lock

Lines changed: 44 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustfmt-nightly"
4-
version = "0.99.2"
4+
version = "0.99.4"
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-nursery/rustfmt"
@@ -47,9 +47,9 @@ env_logger = "0.5"
4747
getopts = "0.2"
4848
derive-new = "0.5"
4949
cargo_metadata = "0.6"
50-
rustc-ap-rustc_target = "230.0.0"
51-
rustc-ap-syntax = "230.0.0"
52-
rustc-ap-syntax_pos = "230.0.0"
50+
rustc-ap-rustc_target = "237.0.0"
51+
rustc-ap-syntax = "237.0.0"
52+
rustc-ap-syntax_pos = "237.0.0"
5353
failure = "0.1.1"
5454

5555
[dev-dependencies]

src/attr.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use utils::{count_newlines, mk_sp};
2222

2323
use std::borrow::Cow;
2424
use syntax::ast;
25-
use syntax::codemap::{BytePos, Span, DUMMY_SP};
25+
use syntax::source_map::{BytePos, Span, DUMMY_SP};
2626

2727
/// Returns attributes on the given statement.
2828
pub fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
@@ -217,11 +217,8 @@ impl Rewrite for ast::MetaItem {
217217
ast::MetaItemKind::List(ref list) => {
218218
let path = rewrite_path(context, PathContext::Type, None, &self.ident, shape)?;
219219

220-
let snippet = context.snippet(self.span);
221-
// 2 = )] (this might go wrong if there is whitespace between the brackets, but
222-
// it's close enough).
223-
let snippet = snippet[..snippet.len() - 2].trim();
224-
let trailing_comma = if snippet.ends_with(',') { "," } else { "" };
220+
let has_comma = ::expr::span_ends_with_comma(context, self.span);
221+
let trailing_comma = if has_comma { "," } else { "" };
225222
let combine = list.len() == 1 && match list[0].node {
226223
ast::NestedMetaItemKind::Literal(..) => false,
227224
ast::NestedMetaItemKind::MetaItem(ref inner_meta_item) => {

src/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn make_opts() -> Options {
160160

161161
fn is_nightly() -> bool {
162162
option_env!("CFG_RELEASE_CHANNEL")
163-
.map(|c| c == "nightly")
163+
.map(|c| c == "nightly" || c == "dev")
164164
.unwrap_or(false)
165165
}
166166

src/chains.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@
6565
//! .qux
6666
//! ```
6767
68-
use codemap::SpanUtils;
6968
use comment::rewrite_comment;
7069
use config::IndentStyle;
7170
use expr::rewrite_call;
7271
use lists::{extract_post_comment, extract_pre_comment, get_comment_end};
7372
use macros::convert_try_mac;
7473
use rewrite::{Rewrite, RewriteContext};
7574
use shape::Shape;
75+
use source_map::SpanUtils;
7676
use utils::{
7777
first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width,
7878
wrap_str,
@@ -82,7 +82,7 @@ use std::borrow::Cow;
8282
use std::cmp::min;
8383
use std::iter;
8484

85-
use syntax::codemap::{BytePos, Span};
85+
use syntax::source_map::{BytePos, Span};
8686
use syntax::{ast, ptr};
8787

8888
pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {

src/closures.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
// except according to those terms.
1010

1111
use config::lists::*;
12-
use syntax::codemap::Span;
1312
use syntax::parse::classify;
13+
use syntax::source_map::Span;
1414
use syntax::{ast, ptr};
1515

16-
use codemap::SpanUtils;
1716
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};
1817
use items::{span_hi_for_arg, span_lo_for_arg};
1918
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
2019
use rewrite::{Rewrite, RewriteContext};
2120
use shape::Shape;
21+
use source_map::SpanUtils;
2222
use utils::{last_line_width, left_most_sub_expr, stmt_expr};
2323

2424
// This module is pretty messy because of the rules around closures and blocks:
@@ -51,7 +51,7 @@ pub fn rewrite_closure(
5151

5252
if let ast::ExprKind::Block(ref block, _) = body.node {
5353
// The body of the closure is an empty block.
54-
if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) {
54+
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) {
5555
return body
5656
.rewrite(context, shape)
5757
.map(|s| format!("{} {}", prefix, s));
@@ -114,7 +114,7 @@ fn get_inner_expr<'a>(
114114
fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext) -> bool {
115115
is_unsafe_block(block)
116116
|| block.stmts.len() > 1
117-
|| block_contains_comment(block, context.codemap)
117+
|| block_contains_comment(block, context.source_map)
118118
|| prefix.contains('\n')
119119
}
120120

@@ -173,7 +173,7 @@ fn rewrite_closure_expr(
173173
match expr.node {
174174
ast::ExprKind::Match(..)
175175
| ast::ExprKind::Block(..)
176-
| ast::ExprKind::Catch(..)
176+
| ast::ExprKind::TryBlock(..)
177177
| ast::ExprKind::Loop(..)
178178
| ast::ExprKind::Struct(..) => true,
179179

@@ -304,7 +304,7 @@ pub fn rewrite_last_closure(
304304
let body = match body.node {
305305
ast::ExprKind::Block(ref block, _)
306306
if !is_unsafe_block(block)
307-
&& is_simple_block(block, Some(&body.attrs), context.codemap) =>
307+
&& is_simple_block(block, Some(&body.attrs), context.source_map) =>
308308
{
309309
stmt_expr(&block.stmts[0]).unwrap_or(body)
310310
}

0 commit comments

Comments
 (0)