Skip to content

Commit 81067b1

Browse files
authored
Merge pull request rust-lang#3317 from fyrchik/fix/edition
transition to Rust 2018
2 parents bfcfaf1 + ece629b commit 81067b1

39 files changed

+311
-296
lines changed

Diff for: build.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ fn main() {
3535
// (git not installed or if this is not a git repository) just return an empty string.
3636
fn commit_info() -> String {
3737
match (channel(), commit_hash(), commit_date()) {
38-
(channel, Some(hash), Some(date)) => {
39-
format!("{} ({} {})", channel, hash.trim_end(), date)
40-
}
38+
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash.trim_end(), date),
4139
_ => String::new(),
4240
}
4341
}

Diff for: src/attr.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010

1111
//! Format attributes and meta items.
1212
13-
use comment::{contains_comment, rewrite_doc_comment, CommentStyle};
14-
use config::lists::*;
15-
use config::IndentStyle;
16-
use expr::rewrite_literal;
17-
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
18-
use overflow;
19-
use rewrite::{Rewrite, RewriteContext};
20-
use shape::Shape;
21-
use types::{rewrite_path, PathContext};
22-
use utils::{count_newlines, mk_sp};
23-
2413
use syntax::ast;
2514
use syntax::source_map::{BytePos, Span, DUMMY_SP};
2615

16+
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};
17+
use crate::config::lists::*;
18+
use crate::config::IndentStyle;
19+
use crate::expr::rewrite_literal;
20+
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
21+
use crate::overflow;
22+
use crate::rewrite::{Rewrite, RewriteContext};
23+
use crate::shape::Shape;
24+
use crate::types::{rewrite_path, PathContext};
25+
use crate::utils::{count_newlines, mk_sp};
26+
2727
/// Returns attributes on the given statement.
2828
pub fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
2929
match stmt.node {
@@ -216,7 +216,7 @@ impl Rewrite for ast::MetaItem {
216216
}
217217
ast::MetaItemKind::List(ref list) => {
218218
let path = rewrite_path(context, PathContext::Type, None, &self.ident, shape)?;
219-
let has_trailing_comma = ::expr::span_ends_with_comma(context, self.span);
219+
let has_trailing_comma = crate::expr::span_ends_with_comma(context, self.span);
220220
overflow::rewrite_with_parens(
221221
context,
222222
&path,
@@ -383,7 +383,7 @@ impl<'a> Rewrite for [ast::Attribute] {
383383
if let Some(missing_span) = missing_span {
384384
let snippet = context.snippet(missing_span);
385385
let (mla, mlb) = has_newlines_before_after_comment(snippet);
386-
let comment = ::comment::recover_missing_comment_in_span(
386+
let comment = crate::comment::recover_missing_comment_in_span(
387387
missing_span,
388388
shape.with_max_width(context.config),
389389
context,
@@ -418,7 +418,7 @@ impl<'a> Rewrite for [ast::Attribute] {
418418
.get(derives.len())
419419
.map(|next| mk_sp(attrs[derives.len() - 1].span.hi(), next.span.lo()));
420420
if let Some(missing_span) = missing_span {
421-
let comment = ::comment::recover_missing_comment_in_span(
421+
let comment = crate::comment::recover_missing_comment_in_span(
422422
missing_span,
423423
shape.with_max_width(context.config),
424424
context,
@@ -451,7 +451,7 @@ impl<'a> Rewrite for [ast::Attribute] {
451451
.get(1)
452452
.map(|next| mk_sp(attrs[0].span.hi(), next.span.lo()));
453453
if let Some(missing_span) = missing_span {
454-
let comment = ::comment::recover_missing_comment_in_span(
454+
let comment = crate::comment::recover_missing_comment_in_span(
455455
missing_span,
456456
shape.with_max_width(context.config),
457457
context,

Diff for: src/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use failure::err_msg;
2424

2525
use getopts::{Matches, Options};
2626

27-
use rustfmt::{
27+
use crate::rustfmt::{
2828
load_config, CliOptions, Color, Config, Edition, EmitMode, ErrorKind, FileLines, FileName,
2929
Input, Session, Verbosity,
3030
};

Diff for: src/chains.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@
6565
//! .qux
6666
//! ```
6767
68-
use comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
69-
use config::IndentStyle;
70-
use expr::rewrite_call;
71-
use lists::extract_pre_comment;
72-
use macros::convert_try_mac;
73-
use rewrite::{Rewrite, RewriteContext};
74-
use shape::Shape;
75-
use source_map::SpanUtils;
76-
use utils::{
77-
self, first_line_width, last_line_extendable, last_line_width, mk_sp, rewrite_ident,
78-
trimmed_last_line_width, wrap_str,
79-
};
80-
8168
use std::borrow::Cow;
8269
use std::cmp::min;
8370

8471
use syntax::source_map::{BytePos, Span};
8572
use syntax::{ast, ptr};
8673

74+
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
75+
use crate::config::IndentStyle;
76+
use crate::expr::rewrite_call;
77+
use crate::lists::extract_pre_comment;
78+
use crate::macros::convert_try_mac;
79+
use crate::rewrite::{Rewrite, RewriteContext};
80+
use crate::shape::Shape;
81+
use crate::source_map::SpanUtils;
82+
use crate::utils::{
83+
self, first_line_width, last_line_extendable, last_line_width, mk_sp, rewrite_ident,
84+
trimmed_last_line_width, wrap_str,
85+
};
86+
8787
pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {
8888
let chain = Chain::from_ast(expr, context);
8989
debug!("rewrite_chain {:?} {:?}", chain, shape);

Diff for: src/checkstyle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use std::io::{self, Write};
1212
use std::path::Path;
1313

14-
use rustfmt_diff::{DiffLine, Mismatch};
14+
use crate::rustfmt_diff::{DiffLine, Mismatch};
1515

1616
/// The checkstyle header - should be emitted before the output of Rustfmt.
1717
///

Diff for: src/closures.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use config::lists::*;
1211
use syntax::parse::classify;
1312
use syntax::source_map::Span;
1413
use syntax::{ast, ptr};
1514

16-
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond};
17-
use items::{span_hi_for_arg, span_lo_for_arg};
18-
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
19-
use overflow::OverflowableItem;
20-
use rewrite::{Rewrite, RewriteContext};
21-
use shape::Shape;
22-
use source_map::SpanUtils;
23-
use utils::{last_line_width, left_most_sub_expr, stmt_expr, NodeIdExt};
15+
use crate::config::lists::*;
16+
use crate::expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond};
17+
use crate::items::{span_hi_for_arg, span_lo_for_arg};
18+
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
19+
use crate::overflow::OverflowableItem;
20+
use crate::rewrite::{Rewrite, RewriteContext};
21+
use crate::shape::Shape;
22+
use crate::source_map::SpanUtils;
23+
use crate::utils::{last_line_width, left_most_sub_expr, stmt_expr, NodeIdExt};
2424

2525
// This module is pretty messy because of the rules around closures and blocks:
2626
// FIXME - the below is probably no longer true in full.
@@ -159,7 +159,8 @@ fn rewrite_closure_with_block(
159159
span: body.span,
160160
recovered: false,
161161
};
162-
let block = ::expr::rewrite_block_with_visitor(context, "", &block, None, None, shape, false)?;
162+
let block =
163+
crate::expr::rewrite_block_with_visitor(context, "", &block, None, None, shape, false)?;
163164
Some(format!("{} {}", prefix, block))
164165
}
165166

Diff for: src/comment.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ use std::{self, borrow::Cow, iter};
1515
use itertools::{multipeek, MultiPeek};
1616
use syntax::source_map::Span;
1717

18-
use config::Config;
19-
use rewrite::RewriteContext;
20-
use shape::{Indent, Shape};
21-
use string::{rewrite_string, StringFormat};
22-
use utils::{
18+
use crate::config::Config;
19+
use crate::rewrite::RewriteContext;
20+
use crate::shape::{Indent, Shape};
21+
use crate::string::{rewrite_string, StringFormat};
22+
use crate::utils::{
2323
count_newlines, first_line_width, last_line_width, trim_left_preserve_layout, unicode_str_width,
2424
};
25-
use {ErrorKind, FormattingError};
25+
use crate::{ErrorKind, FormattingError};
2626

2727
fn is_custom_comment(comment: &str) -> bool {
2828
if !comment.starts_with("//") {
@@ -657,7 +657,7 @@ impl<'a> CommentRewrite<'a> {
657657
_ => {
658658
let mut config = self.fmt.config.clone();
659659
config.set().wrap_comments(false);
660-
match ::format_code_block(&self.code_block_buffer, &config) {
660+
match crate::format_code_block(&self.code_block_buffer, &config) {
661661
Some(ref s) => trim_custom_comment_prefix(&s.snippet),
662662
None => trim_custom_comment_prefix(&self.code_block_buffer),
663663
}
@@ -1672,7 +1672,7 @@ fn remove_comment_header(comment: &str) -> &str {
16721672
#[cfg(test)]
16731673
mod test {
16741674
use super::*;
1675-
use shape::{Indent, Shape};
1675+
use crate::shape::{Indent, Shape};
16761676

16771677
#[test]
16781678
fn char_classes() {
@@ -1733,11 +1733,11 @@ mod test {
17331733
#[test]
17341734
#[rustfmt::skip]
17351735
fn format_doc_comments() {
1736-
let mut wrap_normalize_config: ::config::Config = Default::default();
1736+
let mut wrap_normalize_config: crate::config::Config = Default::default();
17371737
wrap_normalize_config.set().wrap_comments(true);
17381738
wrap_normalize_config.set().normalize_comments(true);
17391739

1740-
let mut wrap_config: ::config::Config = Default::default();
1740+
let mut wrap_config: crate::config::Config = Default::default();
17411741
wrap_config.set().wrap_comments(true);
17421742

17431743
let comment = rewrite_comment(" //test",

Diff for: src/config/config_type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use config::file_lines::FileLines;
12-
use config::options::{IgnoreList, WidthHeuristics};
11+
use crate::config::file_lines::FileLines;
12+
use crate::config::options::{IgnoreList, WidthHeuristics};
1313

1414
/// Trait for types that can be used in `Config`.
1515
pub trait ConfigType: Sized {

Diff for: src/config/lists.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
//! Configuration options related to rewriting a list.
1212
13-
use config::config_type::ConfigType;
14-
use config::IndentStyle;
13+
use crate::config::config_type::ConfigType;
14+
use crate::config::IndentStyle;
1515

1616
/// The definitive formatting tactic for lists.
1717
#[derive(Eq, PartialEq, Debug, Copy, Clone)]

Diff for: src/config/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use regex::Regex;
1211
use std::cell::Cell;
1312
use std::default::Default;
1413
use std::fs::File;
1514
use std::io::{Error, ErrorKind, Read};
1615
use std::path::{Path, PathBuf};
1716
use std::{env, fs};
1817

19-
use config::config_type::ConfigType;
20-
pub use config::file_lines::{FileLines, FileName, Range};
21-
pub use config::lists::*;
22-
pub use config::options::*;
18+
use regex::Regex;
19+
20+
use crate::config::config_type::ConfigType;
21+
pub use crate::config::file_lines::{FileLines, FileName, Range};
22+
pub use crate::config::lists::*;
23+
pub use crate::config::options::*;
2324

2425
#[macro_use]
2526
pub mod config_type;

Diff for: src/config/options.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use config::config_type::ConfigType;
12-
use config::lists::*;
13-
use config::{Config, FileName};
11+
use std::collections::HashSet;
12+
use std::path::{Path, PathBuf};
1413

1514
use atty;
1615

17-
use std::collections::HashSet;
18-
use std::path::{Path, PathBuf};
16+
use crate::config::config_type::ConfigType;
17+
use crate::config::lists::*;
18+
use crate::config::{Config, FileName};
1919

2020
/// Macro that will stringify the enum variants or a provided textual repr
2121
#[macro_export]
@@ -169,7 +169,7 @@ impl NewlineStyle {
169169
/// If the style is set to `Auto` and `raw_input_text` contains no
170170
/// newlines, the `Native` style will be used.
171171
pub(crate) fn apply(self, formatted_text: &mut String, raw_input_text: &str) {
172-
use NewlineStyle::*;
172+
use crate::NewlineStyle::*;
173173
let mut style = self;
174174
if style == Auto {
175175
style = Self::auto_detect(raw_input_text);

Diff for: src/expr.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,40 @@
1111
use std::borrow::Cow;
1212
use std::cmp::min;
1313

14-
use config::lists::*;
1514
use syntax::parse::token::DelimToken;
1615
use syntax::source_map::{BytePos, SourceMap, Span};
1716
use syntax::{ast, ptr};
1817

19-
use chains::rewrite_chain;
20-
use closures;
21-
use comment::{
18+
use crate::chains::rewrite_chain;
19+
use crate::closures;
20+
use crate::comment::{
2221
combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
2322
rewrite_missing_comment, CharClasses, FindUncommented,
2423
};
25-
use config::{Config, ControlBraceStyle, IndentStyle, Version};
26-
use lists::{
24+
use crate::config::lists::*;
25+
use crate::config::{Config, ControlBraceStyle, IndentStyle, Version};
26+
use crate::lists::{
2727
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
2828
struct_lit_tactic, write_list, ListFormatting, ListItem, Separator,
2929
};
30-
use macros::{rewrite_macro, MacroPosition};
31-
use matches::rewrite_match;
32-
use overflow::{self, IntoOverflowableItem, OverflowableItem};
33-
use pairs::{rewrite_all_pairs, rewrite_pair, PairParts};
34-
use patterns::is_short_pattern;
35-
use rewrite::{Rewrite, RewriteContext};
36-
use shape::{Indent, Shape};
37-
use source_map::{LineRangeUtils, SpanUtils};
38-
use spanned::Spanned;
39-
use string::{rewrite_string, StringFormat};
40-
use types::{rewrite_path, PathContext};
41-
use utils::{
30+
use crate::macros::{rewrite_macro, MacroPosition};
31+
use crate::matches::rewrite_match;
32+
use crate::overflow::{self, IntoOverflowableItem, OverflowableItem};
33+
use crate::pairs::{rewrite_all_pairs, rewrite_pair, PairParts};
34+
use crate::patterns::is_short_pattern;
35+
use crate::rewrite::{Rewrite, RewriteContext};
36+
use crate::shape::{Indent, Shape};
37+
use crate::source_map::{LineRangeUtils, SpanUtils};
38+
use crate::spanned::Spanned;
39+
use crate::string::{rewrite_string, StringFormat};
40+
use crate::types::{rewrite_path, PathContext};
41+
use crate::utils::{
4242
colon_spaces, contains_skip, count_newlines, first_line_ends_with, inner_attributes,
4343
last_line_extendable, last_line_width, mk_sp, outer_attributes, ptr_vec_to_ref_vec,
4444
semicolon_for_expr, semicolon_for_stmt, wrap_str,
4545
};
46-
use vertical::rewrite_with_alignment;
47-
use visitor::FmtVisitor;
46+
use crate::vertical::rewrite_with_alignment;
47+
use crate::visitor::FmtVisitor;
4848

4949
impl Rewrite for ast::Expr {
5050
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {

Diff for: src/formatting.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use syntax::errors::{DiagnosticBuilder, Handler};
1212
use syntax::parse::{self, ParseSess};
1313
use syntax::source_map::{FilePathMapping, SourceMap, Span};
1414

15-
use comment::{CharClasses, FullCodeCharKind};
16-
use config::{Config, FileName, Verbosity};
17-
use issues::BadIssueSeeker;
18-
use visitor::{FmtVisitor, SnippetProvider};
19-
use {modules, source_file, ErrorKind, FormatReport, Input, Session};
15+
use crate::comment::{CharClasses, FullCodeCharKind};
16+
use crate::config::{Config, FileName, Verbosity};
17+
use crate::issues::BadIssueSeeker;
18+
use crate::visitor::{FmtVisitor, SnippetProvider};
19+
use crate::{modules, source_file, ErrorKind, FormatReport, Input, Session};
2020

2121
// A map of the files of a crate, with their new content
2222
pub(crate) type SourceFile = Vec<FileRecord>;
@@ -157,7 +157,7 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
157157

158158
debug_assert_eq!(
159159
visitor.line_number,
160-
::utils::count_newlines(&visitor.buffer)
160+
crate::utils::count_newlines(&visitor.buffer)
161161
);
162162

163163
// For some reason, the source_map does not include terminating

Diff for: src/git-rustfmt/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::str::FromStr;
2222

2323
use getopts::{Matches, Options};
2424

25-
use rustfmt::{load_config, CliOptions, Input, Session};
25+
use crate::rustfmt::{load_config, CliOptions, Input, Session};
2626

2727
fn prune_files(files: Vec<&str>) -> Vec<&str> {
2828
let prefixes: Vec<_> = files

0 commit comments

Comments
 (0)