From cbd83b80836a500ec3b6c5033d5742d504d04542 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sun, 14 Mar 2021 13:15:48 -0500 Subject: [PATCH] chore: add span creation util function --- Cargo.lock | 426 +++++++++++------------------------------------- Cargo.toml | 2 +- src/patterns.rs | 4 +- src/utils.rs | 4 + 4 files changed, 99 insertions(+), 337 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bf7db5aa59..6689d6cfe01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -878,15 +878,6 @@ dependencies = [ "crossbeam-utils 0.6.5", ] -[[package]] -name = "rustc-ap-rustc_arena" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705baf7965088195f2e85d0bc548036d7e6a94973c309819f2ae4540e221ba15" -dependencies = [ - "smallvec", -] - [[package]] name = "rustc-ap-rustc_arena" version = "708.0.0" @@ -896,23 +887,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "rustc-ap-rustc_ast" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5579379dd7e34bb522cbab946df43921f3d6fa587fc9101358db0a26b177b24" -dependencies = [ - "bitflags", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_index 706.0.0", - "rustc-ap-rustc_lexer 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-ap-rustc_span 706.0.0", - "smallvec", - "tracing", -] - [[package]] name = "rustc-ap-rustc_ast" version = "708.0.0" @@ -920,12 +894,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5415b0026ca0198717b04d9a579c941ca34089bc921d3f02cff1b6cf63fa95c9" dependencies = [ "bitflags", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_index 708.0.0", - "rustc-ap-rustc_lexer 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_index", + "rustc-ap-rustc_lexer", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_span", "smallvec", "tracing", ] @@ -937,26 +911,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1737c6420474739cb89f557ed8d1231f0b6068620fb3c0fd0a09f0dd79aebbb9" dependencies = [ "itertools 0.9.0", - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_ast_pretty 708.0.0", - "rustc-ap-rustc_attr 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_errors 708.0.0", - "rustc-ap-rustc_feature 708.0.0", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_ast_pretty", + "rustc-ap-rustc_attr", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_errors", + "rustc-ap-rustc_feature", "rustc-ap-rustc_parse", - "rustc-ap-rustc_session 708.0.0", - "rustc-ap-rustc_span 708.0.0", - "tracing", -] - -[[package]] -name = "rustc-ap-rustc_ast_pretty" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11fe1dbcfbb58ea768a9a05a9df27093b4a8fe03b715d3d96df84ae1093b3859" -dependencies = [ - "rustc-ap-rustc_ast 706.0.0", - "rustc-ap-rustc_span 706.0.0", + "rustc-ap-rustc_session", + "rustc-ap-rustc_span", "tracing", ] @@ -966,76 +929,27 @@ version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e86b6a279fd02e57590834a489eb4a4fe31d03c176f755072505977a4d5f202" dependencies = [ - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_span", "tracing", ] -[[package]] -name = "rustc-ap-rustc_attr" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9429e42aaf0b12e133b93411bb8205388fba4fe3dd819199ae52672ad21b81a0" -dependencies = [ - "rustc-ap-rustc_ast 706.0.0", - "rustc-ap-rustc_ast_pretty 706.0.0", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_errors 706.0.0", - "rustc-ap-rustc_feature 706.0.0", - "rustc-ap-rustc_lexer 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-ap-rustc_session 706.0.0", - "rustc-ap-rustc_span 706.0.0", -] - [[package]] name = "rustc-ap-rustc_attr" version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f31de4bc77d5fc437a50451ac12d3e2459f6794d8e7f50bd6c0f48ec6744b96f" dependencies = [ - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_ast_pretty 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_errors 708.0.0", - "rustc-ap-rustc_feature 708.0.0", - "rustc-ap-rustc_lexer 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_session 708.0.0", - "rustc-ap-rustc_span 708.0.0", -] - -[[package]] -name = "rustc-ap-rustc_data_structures" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70bc6c6857800146381494c5247d5b86502e4a25a71fea67d2db58f14f22d6ce" -dependencies = [ - "arrayvec 0.5.1", - "bitflags", - "cfg-if 0.1.10", - "crossbeam-utils 0.7.0", - "ena", - "indexmap", - "jobserver", - "libc", - "measureme", - "parking_lot", - "rustc-ap-rustc_graphviz 706.0.0", - "rustc-ap-rustc_index 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-hash", - "rustc-rayon", - "rustc-rayon-core", - "smallvec", - "stable_deref_trait", - "stacker", - "tempfile", - "tracing", - "winapi", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_ast_pretty", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_errors", + "rustc-ap-rustc_feature", + "rustc-ap-rustc_lexer", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_session", + "rustc-ap-rustc_span", ] [[package]] @@ -1054,10 +968,10 @@ dependencies = [ "libc", "measureme", "parking_lot", - "rustc-ap-rustc_graphviz 708.0.0", - "rustc-ap-rustc_index 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", + "rustc-ap-rustc_graphviz", + "rustc-ap-rustc_index", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", "rustc-hash", "rustc-rayon", "rustc-rayon-core", @@ -1069,26 +983,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rustc-ap-rustc_errors" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "988c7a3ecba53728d383c6bd8268c7a4c957244944c05a3f0e448795747d9db9" -dependencies = [ - "annotate-snippets 0.8.0", - "atty", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_lint_defs 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-ap-rustc_span 706.0.0", - "termcolor", - "termize", - "tracing", - "unicode-width", - "winapi", -] - [[package]] name = "rustc-ap-rustc_errors" version = "708.0.0" @@ -1097,11 +991,11 @@ checksum = "5973e5ebae02c6a22f19176946e7a5b520270f8e9caff7e97e2e1de95c06eb79" dependencies = [ "annotate-snippets 0.8.0", "atty", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_lint_defs 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_lint_defs", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_span", "termcolor", "termize", "tracing", @@ -1115,79 +1009,46 @@ version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d112553937beffff6c801441bed60ba07cce72ce40687de722fc54e2880cd63d" dependencies = [ - "rustc-ap-rustc_ast 708.0.0", + "rustc-ap-rustc_ast", "rustc-ap-rustc_ast_passes", - "rustc-ap-rustc_ast_pretty 708.0.0", - "rustc-ap-rustc_attr 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_errors 708.0.0", - "rustc-ap-rustc_feature 708.0.0", - "rustc-ap-rustc_lexer 708.0.0", - "rustc-ap-rustc_lint_defs 708.0.0", - "rustc-ap-rustc_macros 708.0.0", + "rustc-ap-rustc_ast_pretty", + "rustc-ap-rustc_attr", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_errors", + "rustc-ap-rustc_feature", + "rustc-ap-rustc_lexer", + "rustc-ap-rustc_lint_defs", + "rustc-ap-rustc_macros", "rustc-ap-rustc_parse", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_session 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_session", + "rustc-ap-rustc_span", "smallvec", "tracing", ] -[[package]] -name = "rustc-ap-rustc_feature" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10224171d523b2fb814e549b256ab53734abdb4d285f113cd0af887bc73150f3" -dependencies = [ - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_span 706.0.0", -] - [[package]] name = "rustc-ap-rustc_feature" version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0caa284fd8f72aaf8e04aad950ced072ba46aa88fcfa454f195e5fc02811b6b4" dependencies = [ - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_span", ] -[[package]] -name = "rustc-ap-rustc_fs_util" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05d63d5678f4e01bbf61189d86112783357d405a1fb63d52a70be03a8713395" - [[package]] name = "rustc-ap-rustc_fs_util" version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aecdc1324ccbb7f67a015ee6fd6d267cc189045ff3779fb63880e4f51f58711" -[[package]] -name = "rustc-ap-rustc_graphviz" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f13a83a674d50c3a2400138e4aaecd4d712921f3b8925c22691c85ae2bde235" - [[package]] name = "rustc-ap-rustc_graphviz" version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a21bff3ba32d853fbc930bebbc3c2c3bf66788873c2183a57160e2c9c7b9063d" -[[package]] -name = "rustc-ap-rustc_index" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469c83791194b83a480b18441da1f04dbd2671d062a9f2a1c6bc5369b2185360" -dependencies = [ - "arrayvec 0.5.1", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", -] - [[package]] name = "rustc-ap-rustc_index" version = "708.0.0" @@ -1195,17 +1056,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26daf768bf9ad1a492a6a93404d17c34aee58b692fd7515b6b654897e71704c5" dependencies = [ "arrayvec 0.5.1", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", -] - -[[package]] -name = "rustc-ap-rustc_lexer" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f76b414e6f4a136e04c5b2d79785fbf689b6c975f7f40c9fbe314dd9e4345a5" -dependencies = [ - "unicode-xid", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", ] [[package]] @@ -1217,48 +1069,21 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "rustc-ap-rustc_lint_defs" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10363995e377811d2bd42a4700c7ffe1b8fec88c7f207036fc4b797b01941ea4" -dependencies = [ - "rustc-ap-rustc_ast 706.0.0", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-ap-rustc_span 706.0.0", - "rustc-ap-rustc_target 706.0.0", - "tracing", -] - [[package]] name = "rustc-ap-rustc_lint_defs" version = "708.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "493863f3a69509b0cd53f337215ed13a459dd3687c3782fc79f7f02ad021b8d2" dependencies = [ - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_span 708.0.0", - "rustc-ap-rustc_target 708.0.0", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_span", + "rustc-ap-rustc_target", "tracing", ] -[[package]] -name = "rustc-ap-rustc_macros" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e106ab6d8fcd906b8e0efd48d14bca07cc7a591a938a0a8844badb8d253897" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - [[package]] name = "rustc-ap-rustc_macros" version = "708.0.0" @@ -1278,29 +1103,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d76291d0a578f974e4ef4d31db587b35db6613b057cb18e5717ed8d0781a678" dependencies = [ "bitflags", - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_ast_pretty 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_errors 708.0.0", - "rustc-ap-rustc_feature 708.0.0", - "rustc-ap-rustc_lexer 708.0.0", - "rustc-ap-rustc_session 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_ast_pretty", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_errors", + "rustc-ap-rustc_feature", + "rustc-ap-rustc_lexer", + "rustc-ap-rustc_session", + "rustc-ap-rustc_span", "smallvec", "tracing", "unicode-normalization", ] -[[package]] -name = "rustc-ap-rustc_serialize" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5791d0d7b4b8f5ab89c80e0558aaae6cc3784b9cd1db5f239f7fa51e618e73" -dependencies = [ - "indexmap", - "smallvec", -] - [[package]] name = "rustc-ap-rustc_serialize" version = "708.0.0" @@ -1311,28 +1126,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "rustc-ap-rustc_session" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0662079826bfb6543f4c261049d497feb5686f71aabdba13befa2f6f41a628" -dependencies = [ - "bitflags", - "getopts", - "num_cpus", - "rustc-ap-rustc_ast 706.0.0", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_errors 706.0.0", - "rustc-ap-rustc_feature 706.0.0", - "rustc-ap-rustc_fs_util 706.0.0", - "rustc-ap-rustc_lint_defs 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-ap-rustc_span 706.0.0", - "rustc-ap-rustc_target 706.0.0", - "tracing", -] - [[package]] name = "rustc-ap-rustc_session" version = "708.0.0" @@ -1342,39 +1135,19 @@ dependencies = [ "bitflags", "getopts", "num_cpus", - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_errors 708.0.0", - "rustc-ap-rustc_feature 708.0.0", - "rustc-ap-rustc_fs_util 708.0.0", - "rustc-ap-rustc_lint_defs 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_span 708.0.0", - "rustc-ap-rustc_target 708.0.0", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_errors", + "rustc-ap-rustc_feature", + "rustc-ap-rustc_fs_util", + "rustc-ap-rustc_lint_defs", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_span", + "rustc-ap-rustc_target", "tracing", ] -[[package]] -name = "rustc-ap-rustc_span" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12314b0cb62961245fb6f103095f0584877e54439a62cf66278a4c83d6133e1d" -dependencies = [ - "cfg-if 0.1.10", - "md-5", - "rustc-ap-rustc_arena 706.0.0", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_index 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "scoped-tls", - "sha-1", - "sha2", - "tracing", - "unicode-width", -] - [[package]] name = "rustc-ap-rustc_span" version = "708.0.0" @@ -1383,11 +1156,11 @@ checksum = "5c9af35a8e82b7445d5ce593bd93437aa3a93c97a34845c17395c85744531e82" dependencies = [ "cfg-if 0.1.10", "md-5", - "rustc-ap-rustc_arena 708.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_index 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", + "rustc-ap-rustc_arena", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_index", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", "scoped-tls", "sha-1", "sha2", @@ -1395,21 +1168,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "rustc-ap-rustc_target" -version = "706.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b33190c2f2cb83aea78d78c90ee5b29404ecc46abb2d9ce7c270a7c0f132e1" -dependencies = [ - "bitflags", - "rustc-ap-rustc_data_structures 706.0.0", - "rustc-ap-rustc_index 706.0.0", - "rustc-ap-rustc_macros 706.0.0", - "rustc-ap-rustc_serialize 706.0.0", - "rustc-ap-rustc_span 706.0.0", - "tracing", -] - [[package]] name = "rustc-ap-rustc_target" version = "708.0.0" @@ -1417,11 +1175,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d7984c64589b94ba3b192fc97b288ed8c5d549176f264ffe11774c27cecf3fd" dependencies = [ "bitflags", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_index 708.0.0", - "rustc-ap-rustc_macros 708.0.0", - "rustc-ap-rustc_serialize 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_index", + "rustc-ap-rustc_macros", + "rustc-ap-rustc_serialize", + "rustc-ap-rustc_span", "tracing", ] @@ -1503,15 +1261,15 @@ dependencies = [ "lazy_static", "log", "regex", - "rustc-ap-rustc_ast 708.0.0", - "rustc-ap-rustc_ast_pretty 708.0.0", - "rustc-ap-rustc_attr 706.0.0", - "rustc-ap-rustc_data_structures 708.0.0", - "rustc-ap-rustc_errors 708.0.0", + "rustc-ap-rustc_ast", + "rustc-ap-rustc_ast_pretty", + "rustc-ap-rustc_attr", + "rustc-ap-rustc_data_structures", + "rustc-ap-rustc_errors", "rustc-ap-rustc_expand", "rustc-ap-rustc_parse", - "rustc-ap-rustc_session 708.0.0", - "rustc-ap-rustc_span 708.0.0", + "rustc-ap-rustc_session", + "rustc-ap-rustc_span", "rustc-workspace-hack", "rustfmt-config_proc_macro", "serde", diff --git a/Cargo.toml b/Cargo.toml index 554fc70e8ec..84e0f0b5806 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,7 +74,7 @@ version = "708.0.0" [dependencies.rustc_attr] package = "rustc-ap-rustc_attr" -version = "706.0.0" +version = "708.0.0" [dependencies.rustc_data_structures] package = "rustc-ap-rustc_data_structures" diff --git a/src/patterns.rs b/src/patterns.rs index 5847bd08d80..f9a9388e4ab 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -17,7 +17,7 @@ use crate::shape::Shape; use crate::source_map::SpanUtils; use crate::spanned::Spanned; use crate::types::{rewrite_path, PathContext}; -use crate::utils::{format_mutability, mk_sp, rewrite_ident}; +use crate::utils::{format_mutability, mk_sp, mk_sp_lo_plus_one, rewrite_ident}; /// Returns `true` if the given pattern is "short". /// A short pattern is defined by the following grammar: @@ -460,7 +460,7 @@ fn rewrite_tuple_pat( let sp = pat_vec[new_item_count - 1].span(); let snippet = context.snippet(sp); let lo = sp.lo() + BytePos(snippet.find_uncommented("_").unwrap() as u32); - pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp(lo, lo + BytePos(1))); + pat_vec[new_item_count - 1] = TuplePatField::Dotdot(mk_sp_lo_plus_one(lo)); ( &pat_vec[..new_item_count], mk_sp(span.lo(), lo + BytePos(1)), diff --git a/src/utils.rs b/src/utils.rs index a3d0ed050e3..d3c349fb701 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -360,6 +360,10 @@ pub(crate) fn mk_sp(lo: BytePos, hi: BytePos) -> Span { Span::new(lo, hi, SyntaxContext::root()) } +pub(crate) fn mk_sp_lo_plus_one(lo: BytePos) -> Span { + Span::new(lo, lo + BytePos(1), SyntaxContext::root()) +} + // Returns `true` if the given span does not intersect with file lines. macro_rules! out_of_file_lines_range { ($self:ident, $span:expr) => {