From c60416ed2167716dd6e7141573fbc6dde42e09e3 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sat, 8 Feb 2020 22:21:37 -0600 Subject: [PATCH 1/3] deps: update rustc-ap to v642.0.0 --- Cargo.lock | 359 +++++++++++++++++++++++++------------ Cargo.toml | 36 +++- src/attr.rs | 13 +- src/chains.rs | 2 +- src/closures.rs | 6 +- src/comment.rs | 2 +- src/config/file_lines.rs | 11 +- src/config/options.rs | 6 +- src/expr.rs | 33 ++-- src/formatting.rs | 35 ++-- src/imports.rs | 7 +- src/items.rs | 174 +++++++++++------- src/lib.rs | 3 +- src/lists.rs | 2 +- src/macros.rs | 67 +++---- src/matches.rs | 4 +- src/missed_spans.rs | 2 +- src/modules.rs | 35 ++-- src/modules/visitor.rs | 11 +- src/overflow.rs | 4 +- src/patterns.rs | 45 ++--- src/reorder.rs | 9 +- src/rewrite.rs | 4 +- src/skip.rs | 9 +- src/source_file.rs | 10 +- src/source_map.rs | 2 +- src/spanned.rs | 9 +- src/stmt.rs | 2 +- src/types.rs | 20 +-- src/utils.rs | 32 ++-- src/vertical.rs | 2 +- src/visitor.rs | 214 ++++++++++++++-------- tests/source/issue-2916.rs | 2 + tests/target/issue-2916.rs | 2 +- 34 files changed, 736 insertions(+), 438 deletions(-) create mode 100644 tests/source/issue-2916.rs diff --git a/Cargo.lock b/Cargo.lock index 21517aa4b6d..094fcfd384b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,7 +42,7 @@ name = "atty" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -58,7 +58,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -68,7 +68,7 @@ version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -165,10 +165,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crossbeam-channel" -version = "0.3.9" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -210,6 +210,16 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam-utils" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "derive-new" version = "0.5.8" @@ -240,7 +250,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -314,7 +324,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -348,17 +358,17 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -390,19 +400,10 @@ version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -410,7 +411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.65" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -429,11 +430,31 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "measureme" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "memchr" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "memoffset" version = "0.5.1" @@ -452,7 +473,7 @@ name = "num_cpus" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -480,7 +501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -538,7 +559,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -596,23 +617,52 @@ dependencies = [ [[package]] name = "rustc-ap-arena" -version = "610.0.0" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-graphviz" -version = "610.0.0" +version = "642.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc-ap-rustc_ast_pretty" +version = "642.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-rustc_attr" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-ap-rustc_ast_pretty 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_feature 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_macros 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_session 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rustc-ap-rustc_data_structures" -version = "610.0.0" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -620,45 +670,63 @@ dependencies = [ "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "measureme 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-graphviz 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_index 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-graphviz 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_index 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon-core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_errors" -version = "610.0.0" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "termize 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-rustc_feature" +version = "642.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-ap-rustc_fs_util" +version = "642.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustc-ap-rustc_index" -version = "610.0.0" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_lexer" -version = "610.0.0" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -666,7 +734,7 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_macros" -version = "610.0.0" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -677,59 +745,96 @@ dependencies = [ ] [[package]] -name = "rustc-ap-rustc_target" -version = "610.0.0" +name = "rustc-ap-rustc_parse" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_index 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_ast_pretty 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_attr 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_feature 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_lexer 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_session 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rustc-ap-serialize" -version = "610.0.0" +name = "rustc-ap-rustc_session" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_feature 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_fs_util 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_index 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rustc-ap-syntax" -version = "610.0.0" +name = "rustc-ap-rustc_span" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_index 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_lexer 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_target 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-arena 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_index 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_macros 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rustc-ap-syntax_pos" -version = "610.0.0" +name = "rustc-ap-rustc_target" +version = "642.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-arena 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_index 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_macros 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_index 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_macros 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-serialize" +version = "642.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-ap-syntax" +version = "642.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_index 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_lexer 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_macros 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -791,7 +896,7 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "1.4.11" +version = "1.4.12" dependencies = [ "annotate-snippets 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytecount 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -802,14 +907,19 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", - "ignore 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "ignore 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_target 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_ast_pretty 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_parse 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_session 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-workspace-hack 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustfmt-config_proc_macro 0.2.0", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", @@ -892,6 +1002,11 @@ name = "smallvec" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "smallvec" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -954,21 +1069,20 @@ dependencies = [ ] [[package]] -name = "term_size" -version = "0.3.1" +name = "termcolor" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "termcolor" -version = "1.0.5" +name = "termize" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -987,6 +1101,14 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "toml" version = "0.5.3" @@ -995,6 +1117,14 @@ dependencies = [ "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-segmentation" version = "1.3.0" @@ -1035,11 +1165,6 @@ name = "wasi" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.8" @@ -1049,11 +1174,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -1103,11 +1223,12 @@ dependencies = [ "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" -"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +"checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" +"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "checksum derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "71f31892cd5c62e414316f2963c5689242c43d8e7bbcaaeca97e5e28c95d91d9" "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" @@ -1124,17 +1245,18 @@ dependencies = [ "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum ignore 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0ec16832258409d571aaef8273f3c3cc5b060d784e159d1a0f3b0017308f84a7" +"checksum ignore 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "522daefc3b69036f80c7d2990b28ff9e0471c683bad05ca258e0a01dd22c5a1e" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum measureme 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fef709d3257013bba7cff14fc504e07e80631d3fe0f6d38ce63b8f6510ccb932" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" @@ -1154,17 +1276,23 @@ dependencies = [ "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" -"checksum rustc-ap-arena 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7475f4c707269b56eb7144c53591e3cd6369a5aa1d66434829ea11df96d5e7e3" -"checksum rustc-ap-graphviz 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e59a55520f140a70a3e0fad80a36e807caa85e9d7016167b91a5b521ea929be" -"checksum rustc-ap-rustc_data_structures 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6420857d5a088f680ec1ba736ffba4ee9c1964b0d397e6318f38d461f4f7d5cb" -"checksum rustc-ap-rustc_errors 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8abfca0960131262254a91d02ff4903526a261ede730d7a2c75b4234c867cdc0" -"checksum rustc-ap-rustc_index 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5a395509dcb90a92c1479c085639594624e06b4ab3fc7c1b795b46a61f2d4f65" -"checksum rustc-ap-rustc_lexer 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "64eac8a0e6efb8f55292aa24be0208c7c0538236c613e79952fd1fa3d54bcf8e" -"checksum rustc-ap-rustc_macros 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f99795e8be4877e9e05d59f201e1740c1cf673364655def5848606d9e25b75af" -"checksum rustc-ap-rustc_target 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f22e21fdd8e1c0030f507158fa79b9f1e080e6241aba994d0f97c14a0a07a826" -"checksum rustc-ap-serialize 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1cd6ef5135408d62559866e79986ca261f4c1333253d500e5e66fe66d1432e" -"checksum rustc-ap-syntax 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61fc1c901d2cbd24cae95d7bc5a58aa7661ec3dc5320c78c32830a52a685c33c" -"checksum rustc-ap-syntax_pos 610.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "230534f638255853bb9f13987537e00a818435a0cc54b68d97221b6822c8f1bc" +"checksum rustc-ap-arena 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea82fa3d9a8add7422228ca1a2cbba0784fa8861f56148ff64da08b3c7921b03" +"checksum rustc-ap-graphviz 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "638d0b2b3bcf99824e0cb5a25dbc547b61dc20942e11daf6a97e981918aa18e5" +"checksum rustc-ap-rustc_ast_pretty 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d38bab04dd676dee6d2f9670506a18c31bfce38bf7f8420aa83eb1140ecde049" +"checksum rustc-ap-rustc_attr 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "10b843ba8b1ed43739133047673b9f6a54d3b3b4d328d69c6ea89ff971395f35" +"checksum rustc-ap-rustc_data_structures 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc3d1c6d0a80ab0c1df76405377cec0f3d5423fb5b0953a8eac70a2ad6c44df2" +"checksum rustc-ap-rustc_errors 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4909a1eca29331332257230f29120a8ff68c9e37d868c564fcd599e430cf8914" +"checksum rustc-ap-rustc_feature 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63ab887a181d795cf5fd3edadf367760deafb90aefb844f168ab5255266e3478" +"checksum rustc-ap-rustc_fs_util 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70814116df3c5fbec8f06f6a1d013ca481f620fd22a9475754e9bf3ee9ba70d8" +"checksum rustc-ap-rustc_index 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac1bf1d3cf3d119d41353d6fd229ef7272d5097bc0924de021c0294bf86d48bf" +"checksum rustc-ap-rustc_lexer 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4cda21a32cebdc11ec4f5393aa2fcde5ed1b2f673a8571e5a4dcdf07e4ae9cac" +"checksum rustc-ap-rustc_macros 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75c47b48ea51910ecfd853c9248a9bf4c767bc823449ab6a1d864dff65fbae16" +"checksum rustc-ap-rustc_parse 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abd88e89cd5b5d28dcd3a347a3d534c08627d9455570dc1a2d402cb8437b9d30" +"checksum rustc-ap-rustc_session 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8487b4575fbb2d1fc6f1cd61225efd108a4d36817e6fb9b643d57fcae9cb12" +"checksum rustc-ap-rustc_span 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f69746c0d4c21bf20a5bb2bd247261a1aa8631f04202d7303352942dde70d987" +"checksum rustc-ap-rustc_target 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bbc6ae09b5d42ec66edd520e8412e0615c53a7c93607fe33dc4abab60ba7c8b" +"checksum rustc-ap-serialize 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e13a1ead0252fc3d96da4c336a95950be6795f2b00c84a67ccadf26142f8cb41" +"checksum rustc-ap-syntax 642.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1f59f48ca3a2ec16a7e82e718ed5aadf9c9e08cf63015d28b4e774767524a6a" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc-rayon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f32767f90d938f1b7199a174ef249ae1924f6e5bbdb9d112fea141e016f25b3a" @@ -1181,6 +1309,7 @@ dependencies = [ "checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" "checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" +"checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4f66a4c0ddf7aee4677995697366de0749b0139057342eccbb609b12d0affc" @@ -1188,11 +1317,13 @@ dependencies = [ "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum term 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" -"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +"checksum termize 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1706be6b564323ce7092f5f7e6b118a14c8ef7ed0e69c8c5329c914a9f101295" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7aabe75941d914b72bf3e5d3932ed92ce0664d49d8432305a8b547c37227724" +"checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" @@ -1200,9 +1331,7 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 4d190c6800a..1cfa80de8bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustfmt-nightly" -version = "1.4.11" +version = "1.4.12" authors = ["Nicholas Cameron ", "The Rustfmt developers"] description = "Tool to find and fix Rust formatting issues" repository = "https://github.com/rust-lang/rustfmt" @@ -52,7 +52,7 @@ bytecount = "0.6" unicode-width = "0.1.5" unicode_categories = "0.1.1" dirs = "2.0.1" -ignore = "0.4.6" +ignore = "0.4.11" annotate-snippets = { version = "0.6", features = ["ansi_term"] } structopt = "0.3" rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" } @@ -62,17 +62,37 @@ rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" } # for more information. rustc-workspace-hack = "1.0.0" +[dependencies.rustc_ast_pretty] +package = "rustc-ap-rustc_ast_pretty" +version = "642.0.0" + +[dependencies.rustc_data_structures] +package = "rustc-ap-rustc_data_structures" +version = "642.0.0" + +[dependencies.rustc_errors] +package = "rustc-ap-rustc_errors" +version = "642.0.0" + +[dependencies.rustc_parse] +package = "rustc-ap-rustc_parse" +version = "642.0.0" + +[dependencies.rustc_session] +package = "rustc-ap-rustc_session" +version = "642.0.0" + +[dependencies.rustc_span] +package = "rustc-ap-rustc_span" +version = "642.0.0" + [dependencies.rustc_target] package = "rustc-ap-rustc_target" -version = "610.0.0" +version = "642.0.0" [dependencies.syntax] package = "rustc-ap-syntax" -version = "610.0.0" - -[dependencies.syntax_pos] -package = "rustc-ap-syntax_pos" -version = "610.0.0" +version = "642.0.0" [dev-dependencies] lazy_static = "1.0.0" diff --git a/src/attr.rs b/src/attr.rs index 63a01e56603..461f0ddf029 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -1,8 +1,7 @@ //! Format attributes and meta items. +use rustc_span::{symbol::sym, BytePos, Span, DUMMY_SP}; use syntax::ast; -use syntax::source_map::{BytePos, Span, DUMMY_SP}; -use syntax::symbol::sym; use self::doc_comment::DocCommentFormatter; use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle}; @@ -35,7 +34,7 @@ pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span { ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span, ast::StmtKind::Mac(ref mac) => { let (ref mac, _, _) = **mac; - mac.span + mac.span() } } } @@ -168,7 +167,7 @@ fn rewrite_initial_doc_comments( return Some((0, None)); } // Rewrite doc comments - let sugared_docs = take_while_with_pred(context, attrs, |a| a.is_sugared_doc); + let sugared_docs = take_while_with_pred(context, attrs, |a| a.is_doc_comment()); if !sugared_docs.is_empty() { let snippet = sugared_docs .iter() @@ -316,7 +315,7 @@ where impl Rewrite for ast::Attribute { fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option { let snippet = context.snippet(self.span); - if self.is_sugared_doc { + if self.is_doc_comment() { rewrite_doc_comment(snippet, shape.comment(context.config), context.config) } else { let should_skip = self @@ -438,7 +437,7 @@ impl<'a> Rewrite for [ast::Attribute] { )?; result.push_str(&comment); if let Some(next) = attrs.get(derives.len()) { - if next.is_sugared_doc { + if next.is_doc_comment() { let snippet = context.snippet(missing_span); let (_, mlb) = has_newlines_before_after_comment(snippet); result.push_str(&mlb); @@ -471,7 +470,7 @@ impl<'a> Rewrite for [ast::Attribute] { )?; result.push_str(&comment); if let Some(next) = attrs.get(1) { - if next.is_sugared_doc { + if next.is_doc_comment() { let snippet = context.snippet(missing_span); let (_, mlb) = has_newlines_before_after_comment(snippet); result.push_str(&mlb); diff --git a/src/chains.rs b/src/chains.rs index ff8d7214c54..a7a9127cbbd 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -58,7 +58,7 @@ use std::borrow::Cow; use std::cmp::min; -use syntax::source_map::{BytePos, Span}; +use rustc_span::{BytePos, Span}; use syntax::{ast, ptr}; use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar}; diff --git a/src/closures.rs b/src/closures.rs index ed5c577d933..18e867cabd1 100644 --- a/src/closures.rs +++ b/src/closures.rs @@ -1,4 +1,4 @@ -use syntax::source_map::Span; +use rustc_span::Span; use syntax::{ast, ptr}; use crate::attr::get_attrs_from_stmt; @@ -176,7 +176,7 @@ fn rewrite_closure_expr( | ast::ExprKind::Loop(..) | ast::ExprKind::Struct(..) => true, - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) @@ -382,7 +382,7 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool { match expr.kind { ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true, ast::ExprKind::Loop(..) if version == Version::Two => true, - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) diff --git a/src/comment.rs b/src/comment.rs index c721f07d019..5b46001ff7d 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -3,7 +3,7 @@ use std::{self, borrow::Cow, iter}; use itertools::{multipeek, MultiPeek}; -use syntax::source_map::Span; +use rustc_span::Span; use crate::config::Config; use crate::rewrite::RewriteContext; diff --git a/src/config/file_lines.rs b/src/config/file_lines.rs index f0dc6c66597..d0ef489e2ca 100644 --- a/src/config/file_lines.rs +++ b/src/config/file_lines.rs @@ -6,11 +6,10 @@ use std::path::PathBuf; use std::rc::Rc; use std::{cmp, fmt, iter, str}; +use rustc_span::{self, SourceFile}; use serde::{ser, Deserialize, Deserializer, Serialize, Serializer}; use serde_json as json; -use syntax::source_map::{self, SourceFile}; - /// A range of lines in a file, inclusive of both ends. pub struct LineRange { pub file: Rc, @@ -25,11 +24,11 @@ pub enum FileName { Stdin, } -impl From for FileName { - fn from(name: source_map::FileName) -> FileName { +impl From for FileName { + fn from(name: rustc_span::FileName) -> FileName { match name { - source_map::FileName::Real(p) => FileName::Real(p), - source_map::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin, + rustc_span::FileName::Real(p) => FileName::Real(p), + rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin, _ => unreachable!(), } } diff --git a/src/config/options.rs b/src/config/options.rs index 4a136f4b180..c9d51a5a71a 100644 --- a/src/config/options.rs +++ b/src/config/options.rs @@ -385,10 +385,10 @@ impl Default for Edition { } impl Edition { - pub(crate) fn to_libsyntax_pos_edition(self) -> syntax_pos::edition::Edition { + pub(crate) fn to_libsyntax_pos_edition(self) -> rustc_span::edition::Edition { match self { - Edition::Edition2015 => syntax_pos::edition::Edition::Edition2015, - Edition::Edition2018 => syntax_pos::edition::Edition::Edition2018, + Edition::Edition2015 => rustc_span::edition::Edition::Edition2015, + Edition::Edition2018 => rustc_span::edition::Edition::Edition2018, } } } diff --git a/src/expr.rs b/src/expr.rs index 851e1f70709..a694cc69ac6 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; use std::cmp::min; use itertools::Itertools; -use syntax::parse::token::{DelimToken, LitKind}; -use syntax::source_map::{BytePos, SourceMap, Span}; +use rustc_span::{source_map::SourceMap, BytePos, Span}; +use syntax::token::{DelimToken, LitKind}; use syntax::{ast, ptr}; use crate::chains::rewrite_chain; @@ -159,7 +159,7 @@ pub(crate) fn format_expr( ast::ExprKind::Path(ref qself, ref path) => { rewrite_path(context, PathContext::Expr, qself.as_ref(), path, shape) } - ast::ExprKind::Assign(ref lhs, ref rhs) => { + ast::ExprKind::Assign(ref lhs, ref rhs, _) => { rewrite_assignment(context, lhs, rhs, None, shape) } ast::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => { @@ -213,8 +213,8 @@ pub(crate) fn format_expr( rewrite_unary_prefix(context, "return ", &**expr, shape) } ast::ExprKind::Box(ref expr) => rewrite_unary_prefix(context, "box ", &**expr, shape), - ast::ExprKind::AddrOf(mutability, ref expr) => { - rewrite_expr_addrof(context, mutability, expr, shape) + ast::ExprKind::AddrOf(borrow_kind, mutability, ref expr) => { + rewrite_expr_addrof(context, borrow_kind, mutability, expr, shape) } ast::ExprKind::Cast(ref expr, ref ty) => rewrite_pair( &**expr, @@ -252,7 +252,7 @@ pub(crate) fn format_expr( fn needs_space_before_range(context: &RewriteContext<'_>, lhs: &ast::Expr) -> bool { match lhs.kind { ast::ExprKind::Lit(ref lit) => match lit.kind { - ast::LitKind::FloatUnsuffixed(..) => { + ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => { context.snippet(lit.span).ends_with('.') } _ => false, @@ -1268,7 +1268,7 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool { match expr.kind { ast::ExprKind::Lit(..) => true, ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1, - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Cast(ref expr, _) | ast::ExprKind::Field(ref expr, _) @@ -1314,8 +1314,12 @@ pub(crate) fn can_be_overflowed_expr( || (context.use_block_indent() && args_len == 1) } ast::ExprKind::Mac(ref mac) => { - match (mac.delim, context.config.overflow_delimited_expr()) { - (ast::MacDelimiter::Bracket, true) | (ast::MacDelimiter::Brace, true) => true, + match ( + syntax::ast::MacDelimiter::from_token(mac.args.delim()), + context.config.overflow_delimited_expr(), + ) { + (Some(ast::MacDelimiter::Bracket), true) + | (Some(ast::MacDelimiter::Brace), true) => true, _ => context.use_block_indent() && args_len == 1, } } @@ -1326,7 +1330,7 @@ pub(crate) fn can_be_overflowed_expr( } // Handle unary-like expressions - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) @@ -1338,7 +1342,7 @@ pub(crate) fn can_be_overflowed_expr( pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool { match expr.kind { ast::ExprKind::Call(..) | ast::ExprKind::Mac(..) => true, - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) @@ -1985,13 +1989,14 @@ pub(crate) fn prefer_next_line( fn rewrite_expr_addrof( context: &RewriteContext<'_>, + _borrow_kind: ast::BorrowKind, mutability: ast::Mutability, expr: &ast::Expr, shape: Shape, ) -> Option { let operator_str = match mutability { - ast::Mutability::Immutable => "&", - ast::Mutability::Mutable => "&mut ", + ast::Mutability::Not => "&", + ast::Mutability::Mut => "&mut ", }; rewrite_unary_prefix(context, operator_str, expr, shape) } @@ -1999,7 +2004,7 @@ fn rewrite_expr_addrof( pub(crate) fn is_method_call(expr: &ast::Expr) -> bool { match expr.kind { ast::ExprKind::MethodCall(..) => true, - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Cast(ref expr, _) | ast::ExprKind::Try(ref expr) diff --git a/src/formatting.rs b/src/formatting.rs index 2822a331260..0c273400695 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -7,11 +7,15 @@ use std::panic::{catch_unwind, AssertUnwindSafe}; use std::rc::Rc; use std::time::{Duration, Instant}; +use rustc_data_structures::sync::{Lrc, Send}; +use rustc_errors::emitter::{Emitter, EmitterWriter}; +use rustc_errors::{ColorConfig, Diagnostic, DiagnosticBuilder, Handler, Level as DiagnosticLevel}; +use rustc_session::parse::ParseSess; +use rustc_span::{ + source_map::{FilePathMapping, SourceMap}, + Span, DUMMY_SP, +}; use syntax::ast; -use syntax::errors::emitter::{ColorConfig, Emitter, EmitterWriter}; -use syntax::errors::{Diagnostic, DiagnosticBuilder, Handler}; -use syntax::parse::{self, ParseSess}; -use syntax::source_map::{FilePathMapping, SourceMap, Span, DUMMY_SP}; use self::newline_style::apply_newline_style; use crate::comment::{CharClasses, FullCodeCharKind}; @@ -108,7 +112,7 @@ fn format_project( let mut context = FormatContext::new(&krate, report, parse_session, config, handler); let files = modules::ModResolver::new( &context.parse_session, - directory_ownership.unwrap_or(parse::DirectoryOwnership::UnownedViaMod(true)), + directory_ownership.unwrap_or(rustc_parse::DirectoryOwnership::UnownedViaMod), !(input_is_stdin || config.skip_children()), ) .visit_crate(&krate) @@ -159,7 +163,8 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> { .lookup_char_pos(module.inner.lo()) .file; let big_snippet = source_file.src.as_ref().unwrap(); - let snippet_provider = SnippetProvider::new(source_file.start_pos, big_snippet); + let snippet_provider = + SnippetProvider::new(source_file.start_pos, source_file.end_pos, big_snippet); let mut visitor = FmtVisitor::from_source_map( &self.parse_session, &self.config, @@ -633,7 +638,7 @@ fn parse_crate( parse_session: &ParseSess, config: &Config, report: &mut FormatReport, - directory_ownership: Option, + directory_ownership: Option, can_reset_parser_errors: Rc>, ) -> Result { let input_is_stdin = input.is_text(); @@ -642,14 +647,14 @@ fn parse_crate( Input::File(ref file) => { // Use `new_sub_parser_from_file` when we the input is a submodule. Ok(if let Some(dir_own) = directory_ownership { - parse::new_sub_parser_from_file(parse_session, file, dir_own, None, DUMMY_SP) + rustc_parse::new_sub_parser_from_file(parse_session, file, dir_own, None, DUMMY_SP) } else { - parse::new_parser_from_file(parse_session, file) + rustc_parse::new_parser_from_file(parse_session, file) }) } - Input::Text(text) => parse::maybe_new_parser_from_source_str( + Input::Text(text) => rustc_parse::maybe_new_parser_from_source_str( parse_session, - syntax::source_map::FileName::Custom("stdin".to_owned()), + rustc_span::FileName::Custom("stdin".to_owned()), text, ) .map(|mut parser| { @@ -716,11 +721,14 @@ struct SilentOnIgnoredFilesEmitter { } impl Emitter for SilentOnIgnoredFilesEmitter { + fn source_map(&self) -> Option<&Lrc> { + None + } fn emit_diagnostic(&mut self, db: &Diagnostic) { if let Some(primary_span) = &db.span.primary_span() { let file_name = self.source_map.span_to_filename(*primary_span); match file_name { - syntax_pos::FileName::Real(ref path) => { + rustc_span::FileName::Real(ref path) => { if self .ignore_path_set .is_match(&FileName::Real(path.to_path_buf())) @@ -745,6 +753,9 @@ impl Emitter for SilentOnIgnoredFilesEmitter { struct SilentEmitter; impl Emitter for SilentEmitter { + fn source_map(&self) -> Option<&Lrc> { + None + } fn emit_diagnostic(&mut self, _db: &Diagnostic) {} } diff --git a/src/imports.rs b/src/imports.rs index 139301f537a..9c914ce476d 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -2,9 +2,8 @@ use std::borrow::Cow; use std::cmp::Ordering; use std::fmt; +use rustc_span::{source_map, symbol::sym, BytePos, Span, DUMMY_SP}; use syntax::ast::{self, UseTreeKind}; -use syntax::source_map::{self, BytePos, Span, DUMMY_SP}; -use syntax::symbol::sym; use crate::comment::combine_strs_with_missing_comments; use crate::config::lists::*; @@ -249,7 +248,7 @@ impl UseTree { let allow_extend = if attrs.len() == 1 { let line_len = attr_str.len() + 1 + use_str.len(); - !attrs.first().unwrap().is_sugared_doc + !attrs.first().unwrap().is_doc_comment() && context.config.inline_attribute_width() >= line_len } else { false @@ -849,7 +848,7 @@ impl Rewrite for UseTree { #[cfg(test)] mod test { use super::*; - use syntax::source_map::DUMMY_SP; + use rustc_span::DUMMY_SP; // Parse the path part of an import. This parser is not robust and is only // suitable for use in a test harness. diff --git a/src/items.rs b/src/items.rs index 64ed2d9294c..ed7b46c8e4f 100644 --- a/src/items.rs +++ b/src/items.rs @@ -4,10 +4,9 @@ use std::borrow::Cow; use std::cmp::{max, min, Ordering}; use regex::Regex; -use rustc_target::spec::abi; -use syntax::source_map::{self, BytePos, Span}; +use rustc_span::{source_map, symbol, BytePos, Span, DUMMY_SP}; use syntax::visit; -use syntax::{ast, ptr, symbol}; +use syntax::{ast, ptr}; use crate::attr::filter_inline_attrs; use crate::comment::{ @@ -34,7 +33,7 @@ use crate::visitor::FmtVisitor; const DEFAULT_VISIBILITY: ast::Visibility = source_map::Spanned { node: ast::VisibilityKind::Inherited, - span: source_map::DUMMY_SP, + span: DUMMY_SP, }; fn type_annotation_separator(config: &Config) -> &str { @@ -137,7 +136,11 @@ impl<'a> Item<'a> { fn from_foreign_mod(fm: &'a ast::ForeignMod, span: Span, config: &Config) -> Item<'a> { Item { keyword: "", - abi: format_abi(fm.abi, config.force_explicit_abi(), true), + abi: format_extern( + ast::Extern::from_abi(fm.abi), + config.force_explicit_abi(), + true, + ), vis: None, body: fm .items @@ -161,7 +164,7 @@ enum BodyElement<'a> { pub(crate) struct FnSig<'a> { decl: &'a ast::FnDecl, generics: &'a ast::Generics, - abi: abi::Abi, + ext: ast::Extern, is_async: Cow<'a, ast::IsAsync>, constness: ast::Constness, defaultness: ast::Defaultness, @@ -178,7 +181,7 @@ impl<'a> FnSig<'a> { FnSig { decl, generics, - abi: abi::Abi::Rust, + ext: ast::Extern::None, is_async: Cow::Owned(ast::IsAsync::NotAsync), constness: ast::Constness::NotConst, defaultness: ast::Defaultness::Final, @@ -188,7 +191,7 @@ impl<'a> FnSig<'a> { } pub(crate) fn from_method_sig( - method_sig: &'a ast::MethodSig, + method_sig: &'a ast::FnSig, generics: &'a ast::Generics, ) -> FnSig<'a> { FnSig { @@ -196,7 +199,7 @@ impl<'a> FnSig<'a> { is_async: Cow::Borrowed(&method_sig.header.asyncness.node), constness: method_sig.header.constness.node, defaultness: ast::Defaultness::Final, - abi: method_sig.header.abi, + ext: method_sig.header.ext, decl: &*method_sig.decl, generics, visibility: DEFAULT_VISIBILITY, @@ -210,24 +213,24 @@ impl<'a> FnSig<'a> { defaultness: ast::Defaultness, ) -> FnSig<'a> { match *fn_kind { - visit::FnKind::ItemFn(_, fn_header, visibility, _) => FnSig { - decl, - generics, - abi: fn_header.abi, - constness: fn_header.constness.node, - is_async: Cow::Borrowed(&fn_header.asyncness.node), - defaultness, - unsafety: fn_header.unsafety, - visibility: visibility.clone(), - }, - visit::FnKind::Method(_, method_sig, vis, _) => { - let mut fn_sig = FnSig::from_method_sig(method_sig, generics); - fn_sig.defaultness = defaultness; - if let Some(vis) = vis { + visit::FnKind::Fn(fn_ctxt, _, fn_sig, vis, _) => match fn_ctxt { + visit::FnCtxt::Assoc(..) => { + let mut fn_sig = FnSig::from_method_sig(fn_sig, generics); + fn_sig.defaultness = defaultness; fn_sig.visibility = vis.clone(); + fn_sig } - fn_sig - } + _ => FnSig { + decl, + generics, + ext: fn_sig.header.ext, + constness: fn_sig.header.constness.node, + is_async: Cow::Borrowed(&fn_sig.header.asyncness.node), + defaultness, + unsafety: fn_sig.header.unsafety, + visibility: vis.clone(), + }, + }, _ => unreachable!(), } } @@ -240,8 +243,8 @@ impl<'a> FnSig<'a> { result.push_str(format_constness(self.constness)); result.push_str(format_async(&self.is_async)); result.push_str(format_unsafety(self.unsafety)); - result.push_str(&format_abi( - self.abi, + result.push_str(&format_extern( + self.ext, context.config.force_explicit_abi(), false, )); @@ -327,7 +330,7 @@ impl<'a> FmtVisitor<'a> { &mut self, indent: Indent, ident: ast::Ident, - sig: &ast::MethodSig, + sig: &ast::FnSig, generics: &ast::Generics, span: Span, ) -> Option { @@ -575,7 +578,7 @@ impl<'a> FmtVisitor<'a> { combine_strs_with_missing_comments(&context, &attrs_str, &variant_body, span, shape, false) } - fn visit_impl_items(&mut self, items: &[ast::ImplItem]) { + fn visit_impl_items(&mut self, items: &[ptr::P]) { if self.get_context().config.reorder_impl_items() { // Create visitor for each items, then reorder them. let mut buffer = vec![]; @@ -584,27 +587,72 @@ impl<'a> FmtVisitor<'a> { buffer.push((self.buffer.clone(), item.clone())); self.buffer.clear(); } + + fn is_type(ty: &Option>) -> bool { + match ty { + None => true, + Some(lty) => match lty.kind.opaque_top_hack() { + None => true, + Some(_) => false, + }, + } + } + + fn is_opaque(ty: &Option>) -> bool { + match ty { + None => false, + Some(lty) => match lty.kind.opaque_top_hack() { + None => false, + Some(_) => true, + }, + } + } + + fn both_type( + a: &Option>, + b: &Option>, + ) -> bool { + is_type(a) && is_type(b) + } + + fn both_opaque( + a: &Option>, + b: &Option>, + ) -> bool { + is_opaque(a) && is_opaque(b) + } + + // In rustc-ap-v638 the `OpaqueTy` AssocItemKind variant was removed but + // we still need to differentiate to maintain sorting order. + // type -> opaque -> const -> macro -> method - use crate::ast::ImplItemKind::*; - fn need_empty_line(a: &ast::ImplItemKind, b: &ast::ImplItemKind) -> bool { + use crate::ast::AssocItemKind::*; + fn need_empty_line(a: &ast::AssocItemKind, b: &ast::AssocItemKind) -> bool { match (a, b) { - (TyAlias(..), TyAlias(..)) - | (Const(..), Const(..)) - | (OpaqueTy(..), OpaqueTy(..)) => false, + (TyAlias(_, ref lty), TyAlias(_, ref rty)) + if both_type(lty, rty) || both_opaque(lty, rty) => + { + false + } + (Const(..), Const(..)) => false, _ => true, } } buffer.sort_by(|(_, a), (_, b)| match (&a.kind, &b.kind) { - (TyAlias(..), TyAlias(..)) - | (Const(..), Const(..)) - | (Macro(..), Macro(..)) - | (OpaqueTy(..), OpaqueTy(..)) => a.ident.as_str().cmp(&b.ident.as_str()), - (Method(..), Method(..)) => a.span.lo().cmp(&b.span.lo()), + (TyAlias(_, ref lty), TyAlias(_, ref rty)) + if both_type(lty, rty) || both_opaque(lty, rty) => + { + a.ident.as_str().cmp(&b.ident.as_str()) + } + (Const(..), Const(..)) | (Macro(..), Macro(..)) => { + a.ident.as_str().cmp(&b.ident.as_str()) + } + (Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()), + (TyAlias(_, ref ty), _) if is_type(ty) => Ordering::Less, + (_, TyAlias(_, ref ty)) if is_type(ty) => Ordering::Greater, (TyAlias(..), _) => Ordering::Less, (_, TyAlias(..)) => Ordering::Greater, - (OpaqueTy(..), _) => Ordering::Less, - (_, OpaqueTy(..)) => Ordering::Greater, (Const(..), _) => Ordering::Less, (_, Const(..)) => Ordering::Greater, (Macro(..), _) => Ordering::Less, @@ -638,7 +686,13 @@ pub(crate) fn format_impl( item: &ast::Item, offset: Indent, ) -> Option { - if let ast::ItemKind::Impl(_, _, _, ref generics, _, ref self_ty, ref items) = item.kind { + if let ast::ItemKind::Impl { + ref generics, + ref self_ty, + ref items, + .. + } = item.kind + { let mut result = String::with_capacity(128); let ref_and_type = format_impl_ref_and_type(context, item, offset)?; let sep = offset.to_string_with_newline(context.config); @@ -695,7 +749,7 @@ pub(crate) fn format_impl( } } - if is_impl_single_line(context, items, &result, &where_clause_str, item)? { + if is_impl_single_line(context, items.as_slice(), &result, &where_clause_str, item)? { result.push_str(&where_clause_str); if where_clause_str.contains('\n') || last_line_contains_single_line_comment(&result) { // if the where_clause contains extra comments AND @@ -764,7 +818,7 @@ pub(crate) fn format_impl( fn is_impl_single_line( context: &RewriteContext<'_>, - items: &[ast::ImplItem], + items: &[ptr::P], result: &str, where_clause_str: &str, item: &ast::Item, @@ -786,15 +840,15 @@ fn format_impl_ref_and_type( item: &ast::Item, offset: Indent, ) -> Option { - if let ast::ItemKind::Impl( + if let ast::ItemKind::Impl { unsafety, polarity, defaultness, ref generics, - ref trait_ref, + of_trait: ref trait_ref, ref self_ty, - _, - ) = item.kind + .. + } = item.kind { let mut result = String::with_capacity(128); @@ -1662,9 +1716,7 @@ impl<'a> StaticParts<'a> { pub(crate) fn from_item(item: &'a ast::Item) -> Self { let (prefix, ty, mutability, expr) = match item.kind { ast::ItemKind::Static(ref ty, mutability, ref expr) => ("static", ty, mutability, expr), - ast::ItemKind::Const(ref ty, ref expr) => { - ("const", ty, ast::Mutability::Immutable, expr) - } + ast::ItemKind::Const(ref ty, ref expr) => ("const", ty, ast::Mutability::Not, expr), _ => unreachable!(), }; StaticParts { @@ -1679,9 +1731,9 @@ impl<'a> StaticParts<'a> { } } - pub(crate) fn from_trait_item(ti: &'a ast::TraitItem) -> Self { + pub(crate) fn from_trait_item(ti: &'a ast::AssocItem) -> Self { let (ty, expr_opt) = match ti.kind { - ast::TraitItemKind::Const(ref ty, ref expr_opt) => (ty, expr_opt), + ast::AssocItemKind::Const(ref ty, ref expr_opt) => (ty, expr_opt), _ => unreachable!(), }; StaticParts { @@ -1689,16 +1741,16 @@ impl<'a> StaticParts<'a> { vis: &DEFAULT_VISIBILITY, ident: ti.ident, ty, - mutability: ast::Mutability::Immutable, + mutability: ast::Mutability::Not, expr_opt: expr_opt.as_ref(), defaultness: None, span: ti.span, } } - pub(crate) fn from_impl_item(ii: &'a ast::ImplItem) -> Self { + pub(crate) fn from_impl_item(ii: &'a ast::AssocItem) -> Self { let (ty, expr) = match ii.kind { - ast::ImplItemKind::Const(ref ty, ref expr) => (ty, expr), + ast::AssocItemKind::Const(ref ty, ref expr) => (ty, expr), _ => unreachable!(), }; StaticParts { @@ -1706,8 +1758,8 @@ impl<'a> StaticParts<'a> { vis: &ii.vis, ident: ii.ident, ty, - mutability: ast::Mutability::Immutable, - expr_opt: Some(expr), + mutability: ast::Mutability::Not, + expr_opt: expr.as_ref(), defaultness: Some(ii.defaultness), span: ii.span, } @@ -3031,11 +3083,11 @@ impl Rewrite for ast::ForeignItem { let span = mk_sp(self.span.lo(), self.span.hi() - BytePos(1)); let item_str = match self.kind { - ast::ForeignItemKind::Fn(ref fn_decl, ref generics) => rewrite_fn_base( + ast::ForeignItemKind::Fn(ref fn_sig, ref generics, _) => rewrite_fn_base( context, shape.indent, self.ident, - &FnSig::new(fn_decl, generics, self.vis.clone()), + &FnSig::new(&fn_sig.decl, generics, self.vis.clone()), span, FnBraceStyle::None, ) @@ -3101,7 +3153,7 @@ fn rewrite_attrs( let allow_extend = if attrs.len() == 1 { let line_len = attrs_str.len() + 1 + item_str.len(); - !attrs.first().unwrap().is_sugared_doc + !attrs.first().unwrap().is_doc_comment() && context.config.inline_attribute_width() >= line_len } else { false diff --git a/src/lib.rs b/src/lib.rs index 31df6b1c72c..f0783b2ca36 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,8 @@ use std::rc::Rc; use failure::Fail; use ignore; -use syntax::{ast, parse::DirectoryOwnership}; +use rustc_parse::DirectoryOwnership; +use syntax::ast; use crate::comment::LineClasses; use crate::emitter::Emitter; diff --git a/src/lists.rs b/src/lists.rs index 077d08cb4e4..96a10924e25 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -3,7 +3,7 @@ use std::cmp; use std::iter::Peekable; -use syntax::source_map::BytePos; +use rustc_span::BytePos; use crate::comment::{find_comment_end, rewrite_comment, FindUncommented}; use crate::config::lists::*; diff --git a/src/macros.rs b/src/macros.rs index 8f509dd12c8..dea056928d9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -12,16 +12,12 @@ use std::collections::HashMap; use std::panic::{catch_unwind, AssertUnwindSafe}; -use syntax::parse::new_parser_from_tts; -use syntax::parse::parser::Parser; -use syntax::parse::token::{BinOpToken, DelimToken, Token, TokenKind}; -use syntax::print::pprust; -use syntax::source_map::{BytePos, Span}; -use syntax::symbol::kw; +use rustc_ast_pretty::pprust; +use rustc_parse::{new_parser_from_tts, parser::Parser}; +use rustc_span::{symbol::kw, BytePos, Span, Symbol, DUMMY_SP}; +use syntax::token::{BinOpToken, DelimToken, Token, TokenKind}; use syntax::tokenstream::{Cursor, TokenStream, TokenTree}; -use syntax::ThinVec; -use syntax::{ast, parse, ptr}; -use syntax_pos::{Symbol, DUMMY_SP}; +use syntax::{ast, ptr}; use crate::comment::{ contains_comment, CharClasses, FindUncommented, FullCodeCharKind, LineClasses, @@ -85,7 +81,7 @@ impl Rewrite for MacroArg { MacroArg::Ty(ref ty) => ty.rewrite(context, shape), MacroArg::Pat(ref pat) => pat.rewrite(context, shape), MacroArg::Item(ref item) => item.rewrite(context, shape), - MacroArg::Keyword(ident, _) => Some(ident.to_string()), + MacroArg::Keyword(ident, _) => Some(ident.name.to_string()), } } } @@ -114,23 +110,23 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option { parse_macro_arg!( Expr, - |parser: &mut parse::parser::Parser<'b>| parser.parse_expr(), + |parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_expr(), |x: ptr::P| Some(x) ); parse_macro_arg!( Ty, - |parser: &mut parse::parser::Parser<'b>| parser.parse_ty(), + |parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_ty(), |x: ptr::P| Some(x) ); parse_macro_arg!( Pat, - |parser: &mut parse::parser::Parser<'b>| parser.parse_pat(None), + |parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_pat(None), |x: ptr::P| Some(x) ); // `parse_item` returns `Option>`. parse_macro_arg!( Item, - |parser: &mut parse::parser::Parser<'b>| parser.parse_item(), + |parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_item(), |x: Option>| x ); @@ -147,7 +143,7 @@ fn rewrite_macro_name( // Avoid using pretty-printer in the common case. format!("{}!", rewrite_ident(context, path.segments[0].ident)) } else { - format!("{}!", path) + format!("{}!", pprust::path_to_string(path)) }; match extra_ident { Some(ident) if ident.name != kw::Invalid => format!("{} {}", name, ident), @@ -267,8 +263,8 @@ fn rewrite_macro_inner( original_style }; - let ts: TokenStream = mac.stream(); - let has_comment = contains_comment(context.snippet(mac.span)); + let ts = mac.args.inner_tokens(); + let has_comment = contains_comment(context.snippet(mac.span())); if ts.is_empty() && !has_comment { return match style { DelimToken::Paren if position == MacroPosition::Item => { @@ -302,7 +298,7 @@ fn rewrite_macro_inner( } else if let Some(arg) = parse_macro_arg(&mut parser) { arg_vec.push(arg); } else { - return return_macro_parse_failure_fallback(context, shape.indent, mac.span); + return return_macro_parse_failure_fallback(context, shape.indent, mac.span()); } match parser.token.kind { @@ -326,16 +322,16 @@ fn rewrite_macro_inner( return return_macro_parse_failure_fallback( context, shape.indent, - mac.span, + mac.span(), ); } } } } - return return_macro_parse_failure_fallback(context, shape.indent, mac.span); + return return_macro_parse_failure_fallback(context, shape.indent, mac.span()); } _ if arg_vec.last().map_or(false, MacroArg::is_item) => continue, - _ => return return_macro_parse_failure_fallback(context, shape.indent, mac.span), + _ => return return_macro_parse_failure_fallback(context, shape.indent, mac.span()), } parser.bump(); @@ -355,7 +351,7 @@ fn rewrite_macro_inner( shape, style, position, - mac.span, + mac.span(), ); } @@ -372,7 +368,7 @@ fn rewrite_macro_inner( ¯o_name, arg_vec.iter(), shape, - mac.span, + mac.span(), context.config.width_heuristics().fn_call_width, if trailing_comma { Some(SeparatorTactic::Always) @@ -409,7 +405,7 @@ fn rewrite_macro_inner( let rewrite = rewrite_array( macro_name, arg_vec.iter(), - mac.span, + mac.span(), context, shape, force_trailing_comma, @@ -427,7 +423,7 @@ fn rewrite_macro_inner( // For macro invocations with braces, always put a space between // the `macro_name!` and `{ /* macro_body */ }` but skip modifying // anything in between the braces (for now). - let snippet = context.snippet(mac.span).trim_start_matches(|c| c != '{'); + let snippet = context.snippet(mac.span()).trim_start_matches(|c| c != '{'); match trim_left_preserve_layout(snippet, shape.indent, &context.config) { Some(macro_body) => Some(format!("{} {}", macro_name, macro_body)), None => Some(format!("{} {}", macro_name, snippet)), @@ -492,7 +488,8 @@ pub(crate) fn rewrite_macro_def( return snippet; } - let mut parser = MacroParser::new(def.stream().into_trees()); + let ts = def.body.inner_tokens(); + let mut parser = MacroParser::new(ts.into_trees()); let parsed_def = match parser.parse() { Some(def) => def, None => return snippet, @@ -1190,23 +1187,24 @@ fn next_space(tok: &TokenKind) -> SpaceState { /// when the macro is not an instance of `try!` (or parsing the inner expression /// failed). pub(crate) fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext<'_>) -> Option { - if &mac.path.to_string() == "try" { - let ts: TokenStream = mac.tts.clone(); + let path = &pprust::path_to_string(&mac.path); + if path == "try" || path == "r#try" { + let ts = mac.args.inner_tokens(); let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect()); Some(ast::Expr { id: ast::NodeId::root(), // dummy value kind: ast::ExprKind::Try(parser.parse_expr().ok()?), - span: mac.span, // incorrect span, but shouldn't matter too much - attrs: ThinVec::new(), + span: mac.span(), // incorrect span, but shouldn't matter too much + attrs: ast::AttrVec::new(), }) } else { None } } -fn macro_style(mac: &ast::Mac, context: &RewriteContext<'_>) -> DelimToken { - let snippet = context.snippet(mac.span); +pub(crate) fn macro_style(mac: &ast::Mac, context: &RewriteContext<'_>) -> DelimToken { + let snippet = context.snippet(mac.span()); let paren_pos = snippet.find_uncommented("(").unwrap_or(usize::max_value()); let bracket_pos = snippet.find_uncommented("[").unwrap_or(usize::max_value()); let brace_pos = snippet.find_uncommented("{").unwrap_or(usize::max_value()); @@ -1454,7 +1452,10 @@ fn format_lazy_static( while parser.token.kind != TokenKind::Eof { // Parse a `lazy_static!` item. - let vis = crate::utils::format_visibility(context, &parse_or!(parse_visibility, false)); + let vis = crate::utils::format_visibility( + context, + &parse_or!(parse_visibility, rustc_parse::parser::FollowedByType::No), + ); parser.eat_keyword(kw::Static); parser.eat_keyword(kw::Ref); let id = parse_or!(parse_ident); diff --git a/src/matches.rs b/src/matches.rs index fcfb8055f01..954db40ae52 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -2,7 +2,7 @@ use std::iter::repeat; -use syntax::source_map::{BytePos, Span}; +use rustc_span::{BytePos, Span}; use syntax::{ast, ptr}; use crate::comment::{combine_strs_with_missing_comments, rewrite_comment}; @@ -565,7 +565,7 @@ fn can_flatten_block_around_this(body: &ast::Expr) -> bool { | ast::ExprKind::Mac(..) | ast::ExprKind::Struct(..) | ast::ExprKind::Tup(..) => true, - ast::ExprKind::AddrOf(_, ref expr) + ast::ExprKind::AddrOf(_, _, ref expr) | ast::ExprKind::Box(ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Unary(_, ref expr) diff --git a/src/missed_spans.rs b/src/missed_spans.rs index a957d3b3e30..99595436f89 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -1,4 +1,4 @@ -use syntax::source_map::{BytePos, Pos, Span}; +use rustc_span::{BytePos, Pos, Span}; use crate::comment::{is_last_comment_block, rewrite_comment, CodeCharKind, CommentCodeSlices}; use crate::config::file_lines::FileLines; diff --git a/src/modules.rs b/src/modules.rs index 568faa7194b..92db42de13f 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -2,15 +2,14 @@ use std::borrow::Cow; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; +use rustc_errors::{Diagnostic, PResult}; +use rustc_parse::{new_sub_parser_from_file, parser, DirectoryOwnership}; +use rustc_session::parse::ParseSess; +use rustc_span::symbol::{sym, Symbol}; +use rustc_span::{source_map, Span, DUMMY_SP}; use syntax::ast; -use syntax::attr; -use syntax::parse::{ - new_sub_parser_from_file, parser, token::TokenKind, DirectoryOwnership, PResult, ParseSess, -}; -use syntax::source_map::{self, Span}; -use syntax::symbol::sym; +use syntax::token::TokenKind; use syntax::visit::Visitor; -use syntax_pos::{self, symbol::Symbol, DUMMY_SP}; use crate::attr::MetaVisitor; use crate::config::FileName; @@ -36,8 +35,8 @@ struct Directory { } impl<'a> Directory { - fn to_syntax_directory(&'a self) -> syntax::parse::Directory<'a> { - syntax::parse::Directory { + fn to_syntax_directory(&'a self) -> rustc_parse::Directory<'a> { + rustc_parse::Directory { path: Cow::Borrowed(&self.path), ownership: self.ownership.clone(), } @@ -173,7 +172,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { } else { // An internal module (`mod foo { /* ... */ }`); if let Some(path) = find_path_value(&item.attrs) { - let path = Path::new(&path.as_str()).to_path_buf(); + let path = Path::new(&*path.as_str()).to_path_buf(); Ok(Some(SubModKind::InternalWithPath(path))) } else { Ok(Some(SubModKind::Internal(item))) @@ -273,7 +272,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { let relative = match self.directory.ownership { DirectoryOwnership::Owned { relative } => relative, - DirectoryOwnership::UnownedViaBlock | DirectoryOwnership::UnownedViaMod(_) => None, + DirectoryOwnership::UnownedViaBlock | DirectoryOwnership::UnownedViaMod => None, }; match parser::Parser::default_submod_path( mod_name, @@ -305,7 +304,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { fn push_inline_mod_directory(&mut self, id: ast::Ident, attrs: &[ast::Attribute]) { if let Some(path) = find_path_value(attrs) { - self.directory.path.push(&path.as_str()); + self.directory.path.push(&*path.as_str()); self.directory.ownership = DirectoryOwnership::Owned { relative: None }; } else { // We have to push on the current module name in the case of relative @@ -317,10 +316,10 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership { if let Some(ident) = relative.take() { // remove the relative offset - self.directory.path.push(ident.as_str()); + self.directory.path.push(&*ident.as_str()); } } - self.directory.path.push(&id.as_str()); + self.directory.path.push(&*id.as_str()); } } @@ -357,7 +356,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { if !actual_path.exists() { continue; } - let file_name = syntax_pos::FileName::Real(actual_path.clone()); + let file_name = rustc_span::FileName::Real(actual_path.clone()); if self .parse_sess .source_map() @@ -442,7 +441,11 @@ fn parse_inner_attributes<'a>(parser: &mut parser::Parser<'a>) -> PResult<'a, Ve } TokenKind::DocComment(s) => { // we need to get the position of this token before we bump. - let attr = attr::mk_sugared_doc_attr(s, parser.token.span); + let attr = syntax::attr::mk_doc_comment( + syntax::util::comments::doc_comment_style(&s.as_str()), + s, + parser.token.span, + ); if attr.style == ast::AttrStyle::Inner { attrs.push(attr); parser.bump(); diff --git a/src/modules/visitor.rs b/src/modules/visitor.rs index e9223ce9644..4ef1daf7475 100644 --- a/src/modules/visitor.rs +++ b/src/modules/visitor.rs @@ -1,9 +1,9 @@ +use rustc_parse::{stream_to_parser_with_base_dir, Directory}; +use rustc_session::parse::ParseSess; +use rustc_span::{symbol::kw, Symbol}; use syntax::ast; -use syntax::parse::token::{DelimToken, TokenKind}; -use syntax::parse::{stream_to_parser_with_base_dir, Directory, ParseSess}; -use syntax::symbol::kw; +use syntax::token::{DelimToken, TokenKind}; use syntax::visit::Visitor; -use syntax_pos::Symbol; use crate::attr::MetaVisitor; @@ -65,8 +65,9 @@ impl<'a, 'ast: 'a> CfgIfVisitor<'a> { } }; + let ts = mac.args.inner_tokens(); let mut parser = - stream_to_parser_with_base_dir(self.parse_sess, mac.tts.clone(), self.base_dir.clone()); + stream_to_parser_with_base_dir(self.parse_sess, ts.clone(), self.base_dir.clone()); parser.cfg_mods = false; let mut process_if_cfg = true; diff --git a/src/overflow.rs b/src/overflow.rs index 3b85c0b8e57..0ef1db20fa1 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -3,8 +3,8 @@ use std::cmp::min; use itertools::Itertools; -use syntax::parse::token::DelimToken; -use syntax::source_map::Span; +use rustc_span::Span; +use syntax::token::DelimToken; use syntax::{ast, ptr}; use crate::closures; diff --git a/src/patterns.rs b/src/patterns.rs index baa39dbbce6..1ef3bd5337b 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -1,6 +1,6 @@ +use rustc_span::{BytePos, Span}; use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax}; use syntax::ptr; -use syntax::source_map::{BytePos, Span}; use crate::comment::{combine_strs_with_missing_comments, FindUncommented}; use crate::config::lists::*; @@ -179,26 +179,29 @@ impl Rewrite for Pat { None } } - PatKind::Range(ref lhs, ref rhs, ref end_kind) => { - let infix = match end_kind.node { - RangeEnd::Included(RangeSyntax::DotDotDot) => "...", - RangeEnd::Included(RangeSyntax::DotDotEq) => "..=", - RangeEnd::Excluded => "..", - }; - let infix = if context.config.spaces_around_ranges() { - format!(" {} ", infix) - } else { - infix.to_owned() - }; - rewrite_pair( - &**lhs, - &**rhs, - PairParts::infix(&infix), - context, - shape, - SeparatorPlace::Front, - ) - } + PatKind::Range(ref lhs, ref rhs, ref end_kind) => match (lhs, rhs) { + (Some(lhs), Some(rhs)) => { + let infix = match end_kind.node { + RangeEnd::Included(RangeSyntax::DotDotDot) => "...", + RangeEnd::Included(RangeSyntax::DotDotEq) => "..=", + RangeEnd::Excluded => "..", + }; + let infix = if context.config.spaces_around_ranges() { + format!(" {} ", infix) + } else { + infix.to_owned() + }; + rewrite_pair( + &**lhs, + &**rhs, + PairParts::infix(&infix), + context, + shape, + SeparatorPlace::Front, + ) + } + (_, _) => unimplemented!(), + }, PatKind::Ref(ref pat, mutability) => { let prefix = format!("&{}", format_mutability(mutability)); rewrite_unary_prefix(context, &prefix, &**pat, shape) diff --git a/src/reorder.rs b/src/reorder.rs index 5a6a45118b9..4b607812c00 100644 --- a/src/reorder.rs +++ b/src/reorder.rs @@ -8,7 +8,8 @@ use std::cmp::{Ord, Ordering}; -use syntax::{ast, attr, source_map::Span, symbol::sym}; +use rustc_span::{symbol::sym, Span}; +use syntax::{ast, attr}; use crate::config::Config; use crate::imports::{merge_use_trees, UseTree}; @@ -30,10 +31,8 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering { (&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => { // `extern crate foo as bar;` // ^^^ Comparing this. - let a_orig_name = - a_name.map_or_else(|| a.ident.as_str(), syntax_pos::symbol::Symbol::as_str); - let b_orig_name = - b_name.map_or_else(|| b.ident.as_str(), syntax_pos::symbol::Symbol::as_str); + let a_orig_name = a_name.map_or_else(|| a.ident.as_str(), rustc_span::Symbol::as_str); + let b_orig_name = b_name.map_or_else(|| b.ident.as_str(), rustc_span::Symbol::as_str); let result = a_orig_name.cmp(&b_orig_name); if result != Ordering::Equal { return result; diff --git a/src/rewrite.rs b/src/rewrite.rs index 602512e87ce..fbae4bc7122 100644 --- a/src/rewrite.rs +++ b/src/rewrite.rs @@ -3,9 +3,9 @@ use std::cell::{Cell, RefCell}; use std::rc::Rc; -use syntax::parse::ParseSess; +use rustc_session::parse::ParseSess; +use rustc_span::{source_map::SourceMap, Span}; use syntax::ptr; -use syntax::source_map::{SourceMap, Span}; use crate::config::{Config, IndentStyle}; use crate::shape::Shape; diff --git a/src/skip.rs b/src/skip.rs index 6b4e04a7173..4972eb8c778 100644 --- a/src/skip.rs +++ b/src/skip.rs @@ -1,5 +1,6 @@ //! Module that contains skip related stuffs. +use rustc_ast_pretty::pprust; use syntax::ast; /// Take care of skip name stack. You can update it by attributes slice or @@ -45,7 +46,7 @@ pub(crate) fn is_skip_attr(segments: &[ast::PathSegment]) -> bool { segments[1].ident.to_string() == SKIP && ["macros", "attributes"] .iter() - .any(|&n| n == &segments[2].ident.name.as_str()) + .any(|&n| n == &pprust::path_segment_to_string(&segments[2])) } _ => false, } @@ -57,8 +58,10 @@ fn get_skip_names(kind: &str, attrs: &[ast::Attribute]) -> Vec { for attr in attrs { // syntax::ast::Path is implemented partialEq // but it is designed for segments.len() == 1 - if format!("{}", attr.path) != path { - continue; + if let ast::AttrKind::Normal(attr_item) = &attr.kind { + if pprust::path_to_string(&attr_item.path) != path { + continue; + } } if let Some(list) = attr.meta_item_list() { diff --git a/src/source_file.rs b/src/source_file.rs index b6764ee7464..4cb894e55b8 100644 --- a/src/source_file.rs +++ b/src/source_file.rs @@ -2,7 +2,7 @@ use std::fs; use std::io::{self, Write}; use std::path::Path; -use syntax::source_map::SourceMap; +use rustc_span::source_map::SourceMap; use crate::config::FileName; use crate::emitter::{self, Emitter}; @@ -65,11 +65,11 @@ where } } - impl From<&FileName> for syntax_pos::FileName { - fn from(filename: &FileName) -> syntax_pos::FileName { + impl From<&FileName> for rustc_span::FileName { + fn from(filename: &FileName) -> rustc_span::FileName { match filename { - FileName::Real(path) => syntax_pos::FileName::Real(path.to_owned()), - FileName::Stdin => syntax_pos::FileName::Custom("stdin".to_owned()), + FileName::Real(path) => rustc_span::FileName::Real(path.to_owned()), + FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()), } } } diff --git a/src/source_map.rs b/src/source_map.rs index b1ab83e7aba..c3a549d3b84 100644 --- a/src/source_map.rs +++ b/src/source_map.rs @@ -1,7 +1,7 @@ //! This module contains utilities that work with the `SourceMap` from `libsyntax`/`syntex_syntax`. //! This includes extension traits and methods for looking up spans and line ranges for AST nodes. -use syntax::source_map::{BytePos, SourceMap, Span}; +use rustc_span::{source_map::SourceMap, BytePos, Span}; use crate::comment::FindUncommented; use crate::config::file_lines::LineRange; diff --git a/src/spanned.rs b/src/spanned.rs index 8872e6df2da..b2a70dd5cec 100644 --- a/src/spanned.rs +++ b/src/spanned.rs @@ -1,9 +1,7 @@ use std::cmp::max; -use syntax::{ - ast, ptr, - source_map::{self, Span}, -}; +use rustc_span::{source_map, Span}; +use syntax::{ast, ptr}; use crate::macros::MacroArg; use crate::utils::{mk_sp, outer_attributes}; @@ -53,13 +51,12 @@ macro_rules! implement_spanned { } // Implement `Spanned` for structs with `attrs` field. +implement_spanned!(ast::AssocItem); implement_spanned!(ast::Expr); implement_spanned!(ast::Field); implement_spanned!(ast::ForeignItem); implement_spanned!(ast::Item); implement_spanned!(ast::Local); -implement_spanned!(ast::TraitItem); -implement_spanned!(ast::ImplItem); impl Spanned for ast::Stmt { fn span(&self) -> Span { diff --git a/src/stmt.rs b/src/stmt.rs index a7aa6de0b13..df22a5dfd02 100644 --- a/src/stmt.rs +++ b/src/stmt.rs @@ -1,5 +1,5 @@ +use rustc_span::Span; use syntax::ast; -use syntax_pos::Span; use crate::comment::recover_comment_removed; use crate::config::Version; diff --git a/src/types.rs b/src/types.rs index 3efe80fdb81..efc85efc5c4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,9 +1,8 @@ use std::iter::ExactSizeIterator; use std::ops::Deref; +use rustc_span::{symbol::kw, BytePos, Span}; use syntax::ast::{self, FunctionRetTy, Mutability}; -use syntax::source_map::{self, BytePos, Span}; -use syntax::symbol::kw; use crate::config::lists::*; use crate::config::{IndentStyle, TypeDensity, Version}; @@ -19,7 +18,7 @@ use crate::shape::Shape; use crate::source_map::SpanUtils; use crate::spanned::Spanned; use crate::utils::{ - colon_spaces, extra_offset, first_line_width, format_abi, format_mutability, + colon_spaces, extra_offset, first_line_width, format_extern, format_mutability, last_line_extendable, last_line_width, mk_sp, rewrite_ident, }; @@ -275,13 +274,9 @@ fn rewrite_segment( result.push_str(&generics_str) } ast::GenericArgs::Parenthesized(ref data) => { - let output = match data.output { - Some(ref ty) => FunctionRetTy::Ty(ty.clone()), - None => FunctionRetTy::Default(source_map::DUMMY_SP), - }; result.push_str(&format_function_type( data.inputs.iter().map(|x| &**x), - &output, + &data.output, false, data.span, context, @@ -528,6 +523,7 @@ impl Rewrite for ast::GenericBound { ast::TraitBoundModifier::Maybe => poly_trait_ref .rewrite(context, shape.offset_left(1)?) .map(|s| format!("?{}", s)), + _ => unimplemented!(), }; rewrite.map(|s| if has_paren { format!("({})", s) } else { s }) } @@ -634,8 +630,8 @@ impl Rewrite for ast::Ty { } ast::TyKind::Ptr(ref mt) => { let prefix = match mt.mutbl { - Mutability::Mutable => "*mut ", - Mutability::Immutable => "*const ", + Mutability::Mut => "*mut ", + Mutability::Not => "*const ", }; rewrite_unary_prefix(context, prefix, &*mt.ty, shape) @@ -783,8 +779,8 @@ fn rewrite_bare_fn( result.push_str(crate::utils::format_unsafety(bare_fn.unsafety)); - result.push_str(&format_abi( - bare_fn.abi, + result.push_str(&format_extern( + bare_fn.ext, context.config.force_explicit_abi(), false, )); diff --git a/src/utils.rs b/src/utils.rs index d01a0ff73ba..e0971c7d1bf 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,14 +1,13 @@ use std::borrow::Cow; +use rustc_ast_pretty::pprust; +use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext}; use rustc_target::spec::abi; use syntax::ast::{ self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility, VisibilityKind, }; use syntax::ptr; -use syntax::source_map::{BytePos, Span, SyntaxContext}; -use syntax::symbol::{sym, Symbol}; -use syntax_pos::ExpnId; use unicode_width::UnicodeWidthStr; use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses}; @@ -44,7 +43,7 @@ pub(crate) fn is_same_visibility(a: &Visibility, b: &Visibility) -> bool { ( VisibilityKind::Restricted { path: p, .. }, VisibilityKind::Restricted { path: q, .. }, - ) => p.to_string() == q.to_string(), + ) => pprust::path_to_string(p) == pprust::path_to_string(q), (VisibilityKind::Public, VisibilityKind::Public) | (VisibilityKind::Inherited, VisibilityKind::Inherited) | ( @@ -129,13 +128,25 @@ pub(crate) fn format_auto(is_auto: ast::IsAuto) -> &'static str { #[inline] pub(crate) fn format_mutability(mutability: ast::Mutability) -> &'static str { match mutability { - ast::Mutability::Mutable => "mut ", - ast::Mutability::Immutable => "", + ast::Mutability::Mut => "mut ", + ast::Mutability::Not => "", } } #[inline] -pub(crate) fn format_abi(abi: abi::Abi, explicit_abi: bool, is_mod: bool) -> Cow<'static, str> { +pub(crate) fn format_extern( + ext: ast::Extern, + explicit_abi: bool, + is_mod: bool, +) -> Cow<'static, str> { + let abi = match ext { + ast::Extern::None => abi::Abi::Rust, + ast::Extern::Implicit => abi::Abi::C, + ast::Extern::Explicit(abi) => { + abi::lookup(&abi.symbol_unescaped.as_str()).unwrap_or(abi::Abi::Rust) + } + }; + if abi == abi::Abi::Rust && !is_mod { Cow::from("") } else if abi == abi::Abi::C && !explicit_abi { @@ -243,8 +254,9 @@ pub(crate) fn last_line_extendable(s: &str) -> bool { fn is_skip(meta_item: &MetaItem) -> bool { match meta_item.kind { MetaItemKind::Word => { - let path_str = meta_item.path.to_string(); - path_str == skip_annotation().as_str() || path_str == depr_skip_annotation().as_str() + let path_str = pprust::path_to_string(&meta_item.path); + path_str == &*skip_annotation().as_str() + || path_str == &*depr_skip_annotation().as_str() } MetaItemKind::List(ref l) => { meta_item.check_name(sym::cfg_attr) && l.len() == 2 && is_skip_nested(&l[1]) @@ -420,7 +432,7 @@ pub(crate) fn left_most_sub_expr(e: &ast::Expr) -> &ast::Expr { | ast::ExprKind::Binary(_, ref e, _) | ast::ExprKind::Cast(ref e, _) | ast::ExprKind::Type(ref e, _) - | ast::ExprKind::Assign(ref e, _) + | ast::ExprKind::Assign(ref e, _, _) | ast::ExprKind::AssignOp(_, ref e, _) | ast::ExprKind::Field(ref e, _) | ast::ExprKind::Index(ref e, _) diff --git a/src/vertical.rs b/src/vertical.rs index 59b03789fb5..b932b0afa17 100644 --- a/src/vertical.rs +++ b/src/vertical.rs @@ -3,8 +3,8 @@ use std::cmp; use itertools::Itertools; +use rustc_span::{BytePos, Span}; use syntax::ast; -use syntax::source_map::{BytePos, Span}; use crate::comment::combine_strs_with_missing_comments; use crate::config::lists::*; diff --git a/src/visitor.rs b/src/visitor.rs index 15490798a6e..c6ae3b3be1e 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -1,8 +1,12 @@ use std::cell::{Cell, RefCell}; use std::rc::Rc; -use syntax::parse::ParseSess; -use syntax::source_map::{self, BytePos, Pos, SourceMap, Span}; +use rustc_session::parse::ParseSess; +use rustc_span::{ + source_map::{self, SourceMap}, + BytePos, Pos, Span, +}; +use syntax::token::DelimToken; use syntax::{ast, visit}; use crate::attr::*; @@ -16,7 +20,7 @@ use crate::items::{ rewrite_opaque_impl_type, rewrite_opaque_type, rewrite_type_alias, FnBraceStyle, FnSig, StaticParts, StructParts, }; -use crate::macros::{rewrite_macro, rewrite_macro_def, MacroPosition}; +use crate::macros::{macro_style, rewrite_macro, rewrite_macro_def, MacroPosition}; use crate::rewrite::{Rewrite, RewriteContext}; use crate::shape::{Indent, Shape}; use crate::skip::{is_skip_attr, SkipContext}; @@ -35,6 +39,8 @@ pub(crate) struct SnippetProvider<'a> { big_snippet: &'a str, /// A position of the start of `big_snippet`, used as an offset. start_pos: usize, + /// A end position of the file that this snippet lives. + end_pos: usize, } impl<'a> SnippetProvider<'a> { @@ -44,13 +50,19 @@ impl<'a> SnippetProvider<'a> { Some(&self.big_snippet[start_index..end_index]) } - pub(crate) fn new(start_pos: BytePos, big_snippet: &'a str) -> Self { + pub(crate) fn new(start_pos: BytePos, end_pos: BytePos, big_snippet: &'a str) -> Self { let start_pos = start_pos.to_usize(); + let end_pos = end_pos.to_usize(); SnippetProvider { big_snippet, start_pos, + end_pos, } } + + pub(crate) fn end_pos(&self) -> BytePos { + BytePos::from_usize(self.end_pos) + } } pub(crate) struct FmtVisitor<'a> { @@ -348,7 +360,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { let indent = self.block_indent; let block; let rewrite = match fk { - visit::FnKind::ItemFn(ident, _, _, b) | visit::FnKind::Method(ident, _, _, b) => { + visit::FnKind::Fn(_, ident, _, _, Some(ref b)) => { block = b; self.rewrite_fn_before_block( indent, @@ -357,7 +369,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { mk_sp(s.lo(), b.span.lo()), ) } - visit::FnKind::Closure(_) => unreachable!(), + _ => unreachable!(), }; if let Some((fn_str, fn_brace_style)) = rewrite { @@ -441,7 +453,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { if should_visit_node_again { match item.kind { ast::ItemKind::Use(ref tree) => self.format_import(item, tree), - ast::ItemKind::Impl(..) => { + ast::ItemKind::Impl { .. } => { let block_indent = self.block_indent; let rw = self.with_context(|ctx| format_impl(&ctx, item, block_indent)); self.push_rewrite(item.span, rw); @@ -495,39 +507,51 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => { self.visit_static(&StaticParts::from_item(item)); } - ast::ItemKind::Fn(ref decl, ref fn_header, ref generics, ref body) => { + ast::ItemKind::Fn(ref fn_signature, ref generics, ref body) => { let inner_attrs = inner_attributes(&item.attrs); + let fn_ctxt = match fn_signature.header.ext { + ast::Extern::None => visit::FnCtxt::Free, + _ => visit::FnCtxt::Foreign, + }; self.visit_fn( - visit::FnKind::ItemFn(item.ident, fn_header, &item.vis, body), + visit::FnKind::Fn( + fn_ctxt, + item.ident, + &fn_signature, + &item.vis, + body.as_deref(), + ), generics, - decl, + &fn_signature.decl, item.span, ast::Defaultness::Final, Some(&inner_attrs), ) } - ast::ItemKind::TyAlias(ref ty, ref generics) => { - let rewrite = rewrite_type_alias( - &self.get_context(), - self.block_indent, - item.ident, - ty, - generics, - &item.vis, - ); - self.push_rewrite(item.span, rewrite); - } - ast::ItemKind::OpaqueTy(ref generic_bounds, ref generics) => { - let rewrite = rewrite_opaque_type( - &self.get_context(), - self.block_indent, - item.ident, - generic_bounds, - generics, - &item.vis, - ); - self.push_rewrite(item.span, rewrite); - } + ast::ItemKind::TyAlias(ref ty, ref generics) => match ty.kind.opaque_top_hack() { + None => { + let rewrite = rewrite_type_alias( + &self.get_context(), + self.block_indent, + item.ident, + ty, + generics, + &item.vis, + ); + self.push_rewrite(item.span, rewrite); + } + Some(generic_bounds) => { + let rewrite = rewrite_opaque_type( + &self.get_context(), + self.block_indent, + item.ident, + generic_bounds, + generics, + &item.vis, + ); + self.push_rewrite(item.span, rewrite); + } + }, ast::ItemKind::GlobalAsm(..) => { let snippet = Some(self.snippet(item.span).to_owned()); self.push_rewrite(item.span, snippet); @@ -549,7 +573,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { self.skip_context = skip_context_saved; } - pub(crate) fn visit_trait_item(&mut self, ti: &ast::TraitItem) { + pub(crate) fn visit_trait_item(&mut self, ti: &ast::AssocItem) { skip_out_of_file_lines_range_visitor!(self, ti.span); if self.visit_attrs(&ti.attrs, ast::AttrStyle::Outer) { @@ -558,17 +582,19 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { } match ti.kind { - ast::TraitItemKind::Const(..) => self.visit_static(&StaticParts::from_trait_item(ti)), - ast::TraitItemKind::Method(ref sig, None) => { + ast::AssocItemKind::Const(..) => self.visit_static(&StaticParts::from_trait_item(ti)), + ast::AssocItemKind::Fn(ref sig, None) => { let indent = self.block_indent; let rewrite = self.rewrite_required_fn(indent, ti.ident, sig, &ti.generics, ti.span); self.push_rewrite(ti.span, rewrite); } - ast::TraitItemKind::Method(ref sig, Some(ref body)) => { + ast::AssocItemKind::Fn(ref sig, Some(ref body)) => { let inner_attrs = inner_attributes(&ti.attrs); + let vis = rustc_span::source_map::dummy_spanned(ast::VisibilityKind::Inherited); + let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Trait); self.visit_fn( - visit::FnKind::Method(ti.ident, sig, None, body), + visit::FnKind::Fn(fn_ctxt, ti.ident, sig, &vis, Some(body)), &ti.generics, &sig.decl, ti.span, @@ -576,7 +602,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { Some(&inner_attrs), ); } - ast::TraitItemKind::Type(ref generic_bounds, ref type_default) => { + ast::AssocItemKind::TyAlias(ref generic_bounds, ref type_default) => { let rewrite = rewrite_associated_type( ti.ident, type_default.as_ref(), @@ -587,25 +613,26 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ); self.push_rewrite(ti.span, rewrite); } - ast::TraitItemKind::Macro(ref mac) => { + ast::AssocItemKind::Macro(ref mac) => { self.visit_mac(mac, Some(ti.ident), MacroPosition::Item); } } } - pub(crate) fn visit_impl_item(&mut self, ii: &ast::ImplItem) { + pub(crate) fn visit_impl_item(&mut self, ii: &ast::AssocItem) { skip_out_of_file_lines_range_visitor!(self, ii.span); if self.visit_attrs(&ii.attrs, ast::AttrStyle::Outer) { - self.push_skipped_with_span(ii.attrs.as_slice(), ii.span(), ii.span()); + self.push_skipped_with_span(ii.attrs.as_slice(), ii.span, ii.span); return; } match ii.kind { - ast::ImplItemKind::Method(ref sig, ref body) => { + ast::AssocItemKind::Fn(ref sig, Some(ref body)) => { let inner_attrs = inner_attributes(&ii.attrs); + let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Impl); self.visit_fn( - visit::FnKind::Method(ii.ident, sig, Some(&ii.vis), body), + visit::FnKind::Fn(fn_ctxt, ii.ident, sig, &ii.vis, Some(body)), &ii.generics, &sig.decl, ii.span, @@ -613,41 +640,73 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { Some(&inner_attrs), ); } - ast::ImplItemKind::Const(..) => self.visit_static(&StaticParts::from_impl_item(ii)), - ast::ImplItemKind::TyAlias(ref ty) => { - let rewrite = rewrite_associated_impl_type( - ii.ident, - ii.defaultness, - Some(ty), - &ii.generics, - &self.get_context(), - self.block_indent, - ); + ast::AssocItemKind::Fn(ref sig, None) => { + let indent = self.block_indent; + let rewrite = + self.rewrite_required_fn(indent, ii.ident, sig, &ii.generics, ii.span); self.push_rewrite(ii.span, rewrite); } - ast::ImplItemKind::OpaqueTy(ref generic_bounds) => { - let rewrite = rewrite_opaque_impl_type( - &self.get_context(), - ii.ident, - &ii.generics, - generic_bounds, - self.block_indent, - ); + ast::AssocItemKind::Const(..) => self.visit_static(&StaticParts::from_impl_item(ii)), + ast::AssocItemKind::TyAlias(_, ref ty) => { + let rewrite_associated = || { + rewrite_associated_impl_type( + ii.ident, + ii.defaultness, + ty.as_ref(), + &ii.generics, + &self.get_context(), + self.block_indent, + ) + }; + let rewrite = match ty { + None => rewrite_associated(), + Some(ty) => match ty.kind.opaque_top_hack() { + Some(generic_bounds) => rewrite_opaque_impl_type( + &self.get_context(), + ii.ident, + &ii.generics, + generic_bounds, + self.block_indent, + ), + None => rewrite_associated(), + }, + }; self.push_rewrite(ii.span, rewrite); } - ast::ImplItemKind::Macro(ref mac) => { + ast::AssocItemKind::Macro(ref mac) => { self.visit_mac(mac, Some(ii.ident), MacroPosition::Item); } } } fn visit_mac(&mut self, mac: &ast::Mac, ident: Option, pos: MacroPosition) { - skip_out_of_file_lines_range_visitor!(self, mac.span); + skip_out_of_file_lines_range_visitor!(self, mac.span()); // 1 = ; let shape = self.shape().saturating_sub_width(1); let rewrite = self.with_context(|ctx| rewrite_macro(mac, ident, ctx, shape, pos)); - self.push_rewrite(mac.span, rewrite); + // As of v638 of the rustc-ap-* crates, the associated span no longer includes + // the trailing semicolon. This determines the correct span to ensure scenarios + // with whitespace between the delimiters and trailing semi (i.e. `foo!(abc) ;`) + // are formatted correctly. + let (span, rewrite) = match macro_style(mac, &self.get_context()) { + DelimToken::Bracket | DelimToken::Paren if MacroPosition::Item == pos => { + let search_span = mk_sp(mac.span().hi(), self.snippet_provider.end_pos()); + let hi = self.snippet_provider.span_before(search_span, ";"); + let target_span = mk_sp(mac.span().lo(), hi + BytePos(1)); + let rewrite = rewrite.map(|rw| { + if !rw.ends_with(";") { + format!("{};", rw) + } else { + rw + } + }); + (target_span, rewrite) + } + _ => (mac.span(), rewrite), + }; + + self.push_rewrite(span, rewrite); } pub(crate) fn push_str(&mut self, s: &str) { @@ -751,16 +810,23 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ErrorKind::DeprecatedAttr, )], ); - } else if self.is_unknown_rustfmt_attr(&attr.path.segments) { - let file_name = self.source_map.span_to_filename(attr.span).into(); - self.report.append( - file_name, - vec![FormattingError::from_span( - attr.span, - &self.source_map, - ErrorKind::BadAttr, - )], - ); + } else { + match &attr.kind { + ast::AttrKind::Normal(ref attribute_item) + if self.is_unknown_rustfmt_attr(&attribute_item.path.segments) => + { + let file_name = self.source_map.span_to_filename(attr.span).into(); + self.report.append( + file_name, + vec![FormattingError::from_span( + attr.span, + self.source_map, + ErrorKind::BadAttr, + )], + ); + } + _ => (), + } } } if contains_skip(attrs) { diff --git a/tests/source/issue-2916.rs b/tests/source/issue-2916.rs new file mode 100644 index 00000000000..ccb1f8486c5 --- /dev/null +++ b/tests/source/issue-2916.rs @@ -0,0 +1,2 @@ +a_macro!(name, +) ; diff --git a/tests/target/issue-2916.rs b/tests/target/issue-2916.rs index 5a6471ca863..fb07cc8065c 100644 --- a/tests/target/issue-2916.rs +++ b/tests/target/issue-2916.rs @@ -1,2 +1,2 @@ -a_macro!(name, +a_macro!(name, ); From e72f307f15138a8bb4fd1ae9ef3256fe1fa9dd94 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sat, 8 Feb 2020 22:47:48 -0600 Subject: [PATCH 2/3] fix: backport parse bug fix Backport the fix for the parser bug where the messages from fatal/non-recoverable parser errors were being silently eaten by rustfmt. --- src/formatting.rs | 251 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 215 insertions(+), 36 deletions(-) diff --git a/src/formatting.rs b/src/formatting.rs index 0c273400695..bed87748253 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -715,37 +715,43 @@ fn parse_crate( struct SilentOnIgnoredFilesEmitter { ignore_path_set: Rc, source_map: Rc, - emitter: EmitterWriter, + emitter: Box, has_non_ignorable_parser_errors: bool, can_reset: Rc>, } +impl SilentOnIgnoredFilesEmitter { + fn handle_non_ignoreable_error(&mut self, db: &Diagnostic) { + self.has_non_ignorable_parser_errors = true; + *self.can_reset.borrow_mut() = false; + self.emitter.emit_diagnostic(db); + } +} + impl Emitter for SilentOnIgnoredFilesEmitter { fn source_map(&self) -> Option<&Lrc> { None } + fn emit_diagnostic(&mut self, db: &Diagnostic) { + if db.level == DiagnosticLevel::Fatal { + return self.handle_non_ignoreable_error(db); + } if let Some(primary_span) = &db.span.primary_span() { let file_name = self.source_map.span_to_filename(*primary_span); - match file_name { - rustc_span::FileName::Real(ref path) => { - if self - .ignore_path_set - .is_match(&FileName::Real(path.to_path_buf())) - { - if !self.has_non_ignorable_parser_errors { - *self.can_reset.borrow_mut() = true; - } - return; + if let rustc_span::FileName::Real(ref path) = file_name { + if self + .ignore_path_set + .is_match(&FileName::Real(path.to_path_buf())) + { + if !self.has_non_ignorable_parser_errors { + *self.can_reset.borrow_mut() = true; } + return; } - _ => (), }; } - - self.has_non_ignorable_parser_errors = true; - *self.can_reset.borrow_mut() = false; - self.emitter.emit_diagnostic(db); + self.handle_non_ignoreable_error(db); } } @@ -759,7 +765,7 @@ impl Emitter for SilentEmitter { fn emit_diagnostic(&mut self, _db: &Diagnostic) {} } -fn silent_emitter() -> Box { +fn silent_emitter() -> Box { Box::new(SilentEmitter {}) } @@ -769,36 +775,38 @@ fn make_parse_sess( ignore_path_set: Rc, can_reset: Rc>, ) -> ParseSess { - let tty_handler = if config.hide_parse_errors() { - let silent_emitter = silent_emitter(); - Handler::with_emitter(true, None, silent_emitter) + let supports_color = term::stderr().map_or(false, |term| term.supports_color()); + let color_cfg = if supports_color { + ColorConfig::Auto } else { - let supports_color = term::stderr().map_or(false, |term| term.supports_color()); - let color_cfg = if supports_color { - ColorConfig::Auto - } else { - ColorConfig::Never - }; + ColorConfig::Never + }; - let emitter_writer = EmitterWriter::stderr( + let emitter = if config.hide_parse_errors() { + silent_emitter() + } else { + Box::new(EmitterWriter::stderr( color_cfg, Some(source_map.clone()), false, false, None, false, - ); - let emitter = Box::new(SilentOnIgnoredFilesEmitter { + )) + }; + let handler = Handler::with_emitter( + true, + None, + Box::new(SilentOnIgnoredFilesEmitter { has_non_ignorable_parser_errors: false, - ignore_path_set: ignore_path_set, - source_map: Rc::clone(&source_map), - emitter: emitter_writer, + source_map: source_map.clone(), + emitter, + ignore_path_set, can_reset, - }); - Handler::with_emitter(true, None, emitter) - }; + }), + ); - ParseSess::with_span_handler(tty_handler, source_map) + ParseSess::with_span_handler(handler, source_map) } fn should_emit_verbose(is_stdin: bool, config: &Config, f: F) @@ -809,3 +817,174 @@ where f(); } } + +#[cfg(test)] +mod tests { + use super::*; + + mod emitter { + use super::*; + use crate::config::IgnoreList; + use crate::is_nightly_channel; + use crate::utils::mk_sp; + use rustc_span::{BytePos, FileName as SourceMapFileName, MultiSpan, DUMMY_SP}; + use std::path::{Path, PathBuf}; + + struct TestEmitter { + num_emitted_errors: Rc>, + } + + impl Emitter for TestEmitter { + fn source_map(&self) -> Option<&Lrc> { + None + } + fn emit_diagnostic(&mut self, _db: &Diagnostic) { + *self.num_emitted_errors.borrow_mut() += 1; + } + } + + fn build_diagnostic(level: DiagnosticLevel, span: Option) -> Diagnostic { + Diagnostic { + level, + code: None, + message: vec![], + children: vec![], + suggestions: vec![], + span: span.unwrap_or_else(MultiSpan::new), + sort_span: DUMMY_SP, + } + } + + fn build_emitter( + num_emitted_errors: Rc>, + can_reset: Rc>, + source_map: Option>, + ignore_list: Option, + ) -> SilentOnIgnoredFilesEmitter { + let emitter_writer = TestEmitter { num_emitted_errors }; + let source_map = + source_map.unwrap_or_else(|| Rc::new(SourceMap::new(FilePathMapping::empty()))); + let ignore_path_set = + Rc::new(IgnorePathSet::from_ignore_list(&ignore_list.unwrap_or_default()).unwrap()); + SilentOnIgnoredFilesEmitter { + has_non_ignorable_parser_errors: false, + source_map, + emitter: Box::new(emitter_writer), + ignore_path_set, + can_reset, + } + } + + fn get_ignore_list(config: &str) -> IgnoreList { + Config::from_toml(config, Path::new("")).unwrap().ignore() + } + + #[test] + fn handles_fatal_parse_error_in_ignored_file() { + let num_emitted_errors = Rc::new(RefCell::new(0)); + let can_reset_errors = Rc::new(RefCell::new(false)); + let ignore_list = get_ignore_list(r#"ignore = ["foo.rs"]"#); + let source_map = Rc::new(SourceMap::new(FilePathMapping::empty())); + let source = + String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#); + source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source); + let mut emitter = build_emitter( + Rc::clone(&num_emitted_errors), + Rc::clone(&can_reset_errors), + Some(Rc::clone(&source_map)), + Some(ignore_list), + ); + let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); + let fatal_diagnostic = build_diagnostic(DiagnosticLevel::Fatal, Some(span)); + emitter.emit_diagnostic(&fatal_diagnostic); + assert_eq!(*num_emitted_errors.borrow(), 1); + assert_eq!(*can_reset_errors.borrow(), false); + } + + #[test] + fn handles_recoverable_parse_error_in_ignored_file() { + if !is_nightly_channel!() { + return; + } + let num_emitted_errors = Rc::new(RefCell::new(0)); + let can_reset_errors = Rc::new(RefCell::new(false)); + let ignore_list = get_ignore_list(r#"ignore = ["foo.rs"]"#); + let source_map = Rc::new(SourceMap::new(FilePathMapping::empty())); + let source = String::from(r#"pub fn bar() { 1x; }"#); + source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source); + let mut emitter = build_emitter( + Rc::clone(&num_emitted_errors), + Rc::clone(&can_reset_errors), + Some(Rc::clone(&source_map)), + Some(ignore_list), + ); + let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); + let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span)); + emitter.emit_diagnostic(&non_fatal_diagnostic); + assert_eq!(*num_emitted_errors.borrow(), 0); + assert_eq!(*can_reset_errors.borrow(), true); + } + + #[test] + fn handles_recoverable_parse_error_in_non_ignored_file() { + if !is_nightly_channel!() { + return; + } + let num_emitted_errors = Rc::new(RefCell::new(0)); + let can_reset_errors = Rc::new(RefCell::new(false)); + let source_map = Rc::new(SourceMap::new(FilePathMapping::empty())); + let source = String::from(r#"pub fn bar() { 1x; }"#); + source_map.new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), source); + let mut emitter = build_emitter( + Rc::clone(&num_emitted_errors), + Rc::clone(&can_reset_errors), + Some(Rc::clone(&source_map)), + None, + ); + let span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); + let non_fatal_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(span)); + emitter.emit_diagnostic(&non_fatal_diagnostic); + assert_eq!(*num_emitted_errors.borrow(), 1); + assert_eq!(*can_reset_errors.borrow(), false); + } + + #[test] + fn handles_mix_of_recoverable_parse_error() { + if !is_nightly_channel!() { + return; + } + let num_emitted_errors = Rc::new(RefCell::new(0)); + let can_reset_errors = Rc::new(RefCell::new(false)); + let source_map = Rc::new(SourceMap::new(FilePathMapping::empty())); + let ignore_list = get_ignore_list(r#"ignore = ["foo.rs"]"#); + let bar_source = String::from(r#"pub fn bar() { 1x; }"#); + let foo_source = String::from(r#"pub fn foo() { 1x; }"#); + let fatal_source = + String::from(r#"extern "system" fn jni_symbol!( funcName ) ( ... ) -> {} "#); + source_map + .new_source_file(SourceMapFileName::Real(PathBuf::from("bar.rs")), bar_source); + source_map + .new_source_file(SourceMapFileName::Real(PathBuf::from("foo.rs")), foo_source); + source_map.new_source_file( + SourceMapFileName::Real(PathBuf::from("fatal.rs")), + fatal_source, + ); + let mut emitter = build_emitter( + Rc::clone(&num_emitted_errors), + Rc::clone(&can_reset_errors), + Some(Rc::clone(&source_map)), + Some(ignore_list), + ); + let bar_span = MultiSpan::from_span(mk_sp(BytePos(0), BytePos(1))); + let foo_span = MultiSpan::from_span(mk_sp(BytePos(21), BytePos(22))); + let bar_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(bar_span)); + let foo_diagnostic = build_diagnostic(DiagnosticLevel::Warning, Some(foo_span)); + let fatal_diagnostic = build_diagnostic(DiagnosticLevel::Fatal, None); + emitter.emit_diagnostic(&bar_diagnostic); + emitter.emit_diagnostic(&foo_diagnostic); + emitter.emit_diagnostic(&fatal_diagnostic); + assert_eq!(*num_emitted_errors.borrow(), 2); + assert_eq!(*can_reset_errors.borrow(), false); + } + } +} From 760bb29feb90d30329de4394591ec2d02666735c Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sat, 8 Feb 2020 22:54:37 -0600 Subject: [PATCH 3/3] chore: fix compile warnings --- src/expr.rs | 4 ++-- src/items.rs | 2 +- src/modules.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index a694cc69ac6..84f01f2a1a9 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1148,10 +1148,10 @@ pub(crate) fn is_simple_block( attrs: Option<&[ast::Attribute]>, source_map: &SourceMap, ) -> bool { - (block.stmts.len() == 1 + block.stmts.len() == 1 && stmt_is_expr(&block.stmts[0]) && !block_contains_comment(block, source_map) - && attrs.map_or(true, |a| a.is_empty())) + && attrs.map_or(true, |a| a.is_empty()) } /// Checks whether a block contains at most one statement or expression, and no diff --git a/src/items.rs b/src/items.rs index ed7b46c8e4f..0316dc6f0c2 100644 --- a/src/items.rs +++ b/src/items.rs @@ -2585,7 +2585,7 @@ fn compute_budgets_for_params( ret_str_len: usize, fn_brace_style: FnBraceStyle, force_vertical_layout: bool, -) -> Option<((usize, usize, Indent))> { +) -> Option<(usize, usize, Indent)> { debug!( "compute_budgets_for_params {} {:?}, {}, {:?}", result.len(), diff --git a/src/modules.rs b/src/modules.rs index 92db42de13f..e7a2e21179d 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; -use rustc_errors::{Diagnostic, PResult}; +use rustc_errors::PResult; use rustc_parse::{new_sub_parser_from_file, parser, DirectoryOwnership}; use rustc_session::parse::ParseSess; use rustc_span::symbol::{sym, Symbol};