]> git.lizzy.rs Git - rust.git/commitdiff
Merge pull request #1639 from topecongiro/rfc-update
authorNick Cameron <nrc@ncameron.org>
Tue, 6 Jun 2017 20:08:59 +0000 (08:08 +1200)
committerGitHub <noreply@github.com>
Tue, 6 Jun 2017 20:08:59 +0000 (08:08 +1200)
Add 'fn_args_paren_newline = false' to rfc-rustfmt.toml

27 files changed:
Cargo.lock
Cargo.toml
src/chains.rs
src/expr.rs
src/imports.rs
src/items.rs
src/lib.rs
src/lists.rs
src/macros.rs
src/missed_spans.rs
src/patterns.rs
src/types.rs
src/utils.rs
src/visitor.rs
tests/source/attrib.rs
tests/source/catch.rs [new file with mode: 0644]
tests/source/enum.rs
tests/source/pub-restricted.rs
tests/source/struct-field-attributes.rs
tests/target/attrib.rs
tests/target/catch.rs [new file with mode: 0644]
tests/target/enum.rs
tests/target/match.rs
tests/target/nestedmod/mod.rs
tests/target/nestedmod/mod2b.rs
tests/target/pub-restricted.rs
tests/target/struct-field-attributes.rs

index 2d34a8f7cea6052d2b7cb71650c72d868b0f0f3d..161a26ad916db1984a1cbbe3f600fe0681e08763 100644 (file)
@@ -3,18 +3,18 @@ name = "rustfmt"
 version = "0.8.4"
 dependencies = [
  "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "strings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntex_errors 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntex_syntax 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "toml 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -31,7 +31,7 @@ dependencies = [
 
 [[package]]
 name = "bitflags"
-version = "0.8.2"
+version = "0.9.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -46,13 +46,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "env_logger"
-version = "0.4.2"
+version = "0.4.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
+[[package]]
+name = "extprim"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "getopts"
 version = "0.2.14"
@@ -79,7 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "log"
-version = "0.3.7"
+version = "0.3.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -100,6 +110,14 @@ name = "quote"
 version = "0.3.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "rand"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
 [[package]]
 name = "regex"
 version = "0.2.2"
@@ -118,28 +136,44 @@ version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "rustc-serialize"
-version = "0.3.24"
+name = "rustc_version"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "semver"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "semver-parser"
+version = "0.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "serde"
-version = "1.0.7"
+version = "1.0.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "serde_derive"
-version = "1.0.7"
+version = "1.0.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "serde_derive_internals"
-version = "0.15.0"
+version = "0.15.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -154,7 +188,7 @@ dependencies = [
  "dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -162,7 +196,7 @@ name = "strings"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -185,35 +219,40 @@ dependencies = [
 
 [[package]]
 name = "syntex_errors"
-version = "0.58.1"
+version = "0.59.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntex_pos 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "syntex_pos"
-version = "0.58.1"
+version = "0.59.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "syntex_syntax"
-version = "0.58.1"
+version = "0.59.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "extprim 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntex_errors 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntex_pos 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -248,7 +287,7 @@ name = "toml"
 version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -261,6 +300,11 @@ name = "unicode-xid"
 version = "0.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "unicode-xid"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
 [[package]]
 name = "unreachable"
 version = "0.1.1"
@@ -291,37 +335,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [metadata]
 "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
-"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
+"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
 "checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472"
 "checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
-"checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83"
+"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"
+"checksum extprim 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d9f92dbf3843b6b56a224bce6aacd734feea193013d6ee1e18f03dcb36a93911"
 "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
 "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c"
 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
 "checksum libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)" = "e7eb6b826bfc1fdea7935d46556250d1799b7fe2d9f7951071f4291710665e3e"
-"checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad"
+"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b"
 "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
 "checksum num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e1cbfa3781f3fe73dc05321bed52a06d2d491eaa764c52335cf4399f046ece99"
 "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
+"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
 "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
 "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
-"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
-"checksum serde 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c0c3d79316a6051231925504f6ef893d45088e8823c77a8331a3dcf427ee9087"
-"checksum serde_derive 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0019cd5b9f0529a1a0e145a912e9a2d60c325c58f7f260fc36c71976e9d76aee"
-"checksum serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1"
+"checksum rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9743a7670d88d5d52950408ecdb7c71d8986251ab604d4689dd2ca25c9bca69"
+"checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537"
+"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
+"checksum serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f530d36fb84ec48fb7146936881f026cdbf4892028835fd9398475f82c1bb4"
+"checksum serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "10552fad5500771f3902d0c5ba187c5881942b811b7ba0d8fbbfbf84d80806d3"
+"checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a"
 "checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b"
 "checksum strings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "da75d8bf2c4d210d63dd09581a041b036001f9f6e03d9b151dbff810fb7ba26a"
 "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
 "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
-"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c"
-"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047"
-"checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791"
+"checksum syntex_errors 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f769b93e132914e999edb13018e192bd5f0296c2886fb6d5473ee6e055acb1c"
+"checksum syntex_pos 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56c108cb745a38857097c1662a9d513594486acaf1d508831201fd122f83ba44"
+"checksum syntex_syntax 0.59.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c815f257bdfb6f8b8876bb2937438a5365f2884f268c312f864cd002abace6"
 "checksum term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d168af3930b369cfe245132550579d47dfd873d69470755a19c2c6568dbbd989"
 "checksum thread-id 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8df7875b676fddfadffd96deea3b1124e5ede707d4884248931077518cf1f773"
 "checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7"
 "checksum toml 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4cc5dbfb20a481e64b99eb7ae280859ec76730c7191570ba5edaa962394edb0a"
 "checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946"
 "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
+"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
 "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
 "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
 "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
index 4f5eaa7f0181f2a37dd369fe1623143433e1b317..083dfd787fa2023abcfecd4cad01a3219a3643a2 100644 (file)
@@ -28,8 +28,8 @@ regex = "0.2"
 term = "0.4"
 strings = "0.1"
 diff = "0.1"
-syntex_syntax = "0.58"
-syntex_errors = "0.58"
+syntex_syntax = "0.59"
+syntex_errors = "0.59"
 log = "0.3"
 env_logger = "0.4"
 getopts = "0.2"
index 204f0b804232c3ec436b62e578ff55f886b601a1..b84a7e469f2a8949558937961b30dcd1b1f5a7f1 100644 (file)
@@ -78,7 +78,7 @@
 
 use Shape;
 use rewrite::{Rewrite, RewriteContext};
-use utils::{wrap_str, first_line_width, last_line_width};
+use utils::{wrap_str, first_line_width, last_line_width, mk_sp};
 use expr::rewrite_call;
 use config::IndentStyle;
 use macros::convert_try_mac;
@@ -86,7 +86,7 @@
 use std::cmp::min;
 use std::iter;
 use syntax::{ast, ptr};
-use syntax::codemap::{mk_sp, Span};
+use syntax::codemap::Span;
 
 pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {
     debug!("rewrite_chain {:?}", shape);
index 72c10619ea292a270c7e3eeedbb461f155c3a6e4..aa5913e5f0fa9bb613558f67400b2de9f49eb99c 100644 (file)
@@ -22,7 +22,7 @@
 use string::{StringFormat, rewrite_string};
 use utils::{extra_offset, last_line_width, wrap_str, binary_search, first_line_width,
             semicolon_for_stmt, trimmed_last_line_width, left_most_sub_expr, stmt_expr,
-            colon_spaces, contains_skip};
+            colon_spaces, contains_skip, mk_sp};
 use visitor::FmtVisitor;
 use config::{Config, IndentStyle, MultilineStyle, ControlBraceStyle, Style};
 use comment::{FindUncommented, rewrite_comment, contains_comment, recover_comment_removed};
@@ -32,7 +32,7 @@
 use macros::{rewrite_macro, MacroPosition};
 
 use syntax::{ast, ptr};
-use syntax::codemap::{CodeMap, Span, BytePos, mk_sp};
+use syntax::codemap::{CodeMap, Span, BytePos};
 use syntax::parse::classify;
 
 impl Rewrite for ast::Expr {
@@ -253,6 +253,16 @@ fn format_expr(expr: &ast::Expr,
                      context.config.max_width(),
                      shape)
         }
+        ast::ExprKind::Catch(ref block) => {
+            if let rewrite @ Some(_) = try_one_line_block(context, shape, "do catch ", block) {
+                return rewrite;
+            }
+            // 9 = `do catch `
+            let budget = shape.width.checked_sub(9).unwrap_or(0);
+            Some(format!("{}{}",
+                         "do catch ",
+                         try_opt!(block.rewrite(&context, Shape::legacy(budget, shape.indent)))))
+        }
     };
     match (attr_rw, expr_rw) {
         (Some(attr_str), Some(expr_str)) => {
@@ -266,6 +276,22 @@ fn format_expr(expr: &ast::Expr,
     }
 }
 
+fn try_one_line_block(context: &RewriteContext,
+                      shape: Shape,
+                      prefix: &str,
+                      block: &ast::Block)
+                      -> Option<String> {
+    if is_simple_block(block, context.codemap) {
+        let expr_shape = Shape::legacy(shape.width - prefix.len(), shape.indent);
+        let expr_str = try_opt!(block.stmts[0].rewrite(context, expr_shape));
+        let result = format!("{}{{ {} }}", prefix, expr_str);
+        if result.len() <= shape.width && !result.contains('\n') {
+            return Some(result);
+        }
+    }
+    None
+}
+
 pub fn rewrite_pair<LHS, RHS>(lhs: &LHS,
                               rhs: &RHS,
                               prefix: &str,
@@ -620,9 +646,7 @@ fn rewrite_closure_block(block: &ast::Block,
         // means we must re-format.
         let block_shape = shape.block().with_max_width(context.config);
         let block_str = try_opt!(block.rewrite(&context, block_shape));
-        Some(format!("{} {}",
-                     prefix,
-                     try_opt!(block_str.rewrite(context, block_shape))))
+        Some(format!("{} {}", prefix, block_str))
     }
 }
 
@@ -687,24 +711,13 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                 } else {
                     "unsafe ".to_owned()
                 };
-
-                if is_simple_block(self, context.codemap) && prefix.len() < shape.width {
-                    let expr_str =
-                        self.stmts[0].rewrite(context,
-                                              Shape::legacy(shape.width - prefix.len(),
-                                                            shape.indent));
-                    let expr_str = try_opt!(expr_str);
-                    let result = format!("{}{{ {} }}", prefix, expr_str);
-                    if result.len() <= shape.width && !result.contains('\n') {
-                        return Some(result);
-                    }
+                if let result @ Some(_) = try_one_line_block(context, shape, &prefix, self) {
+                    return result;
                 }
-
                 prefix
             }
             ast::BlockCheckMode::Default => {
                 visitor.last_pos = self.span.lo;
-
                 String::new()
             }
         };
index 46ce14f47b73942904d943fb0c34d37f980815c0..83e7661aad97567dbd3421e0067262587a4ddb6a 100644 (file)
@@ -10,7 +10,7 @@
 
 use Shape;
 use utils;
-use syntax::codemap::{self, BytePos, Span};
+use syntax::codemap::{BytePos, Span};
 use codemap::SpanUtils;
 use lists::{write_list, itemize_list, ListItem, ListFormatting, SeparatorTactic, definitive_tactic};
 use types::{rewrite_path, PathContext};
@@ -202,7 +202,7 @@ pub fn format_imports(&mut self, use_items: &[ptr::P<ast::Item>]) {
         // Order the imports by view-path & other import path properties
         ordered_use_items.sort_by(|a, b| compare_use_items(a.0, b.0).unwrap());
         // First, output the span before the first import
-        let prev_span_str = self.snippet(codemap::mk_sp(self.last_pos, pos_before_first_use_item));
+        let prev_span_str = self.snippet(utils::mk_sp(self.last_pos, pos_before_first_use_item));
         // Look for purely trailing space at the start of the prefix snippet before a linefeed, or
         // a prefix that's entirely horizontal whitespace.
         let prefix_span_start = match prev_span_str.find('\n') {
@@ -241,7 +241,7 @@ pub fn format_import(&mut self, vis: &ast::Visibility, vp: &ast::ViewPath, span:
                          Shape::legacy(self.config.max_width() - offset.width() - 1, offset)) {
             Some(ref s) if s.is_empty() => {
                 // Format up to last newline
-                let prev_span = codemap::mk_sp(self.last_pos, source!(self, span).lo);
+                let prev_span = utils::mk_sp(self.last_pos, source!(self, span).lo);
                 let span_end = match self.snippet(prev_span).rfind('\n') {
                     Some(offset) => self.last_pos + BytePos(offset as u32),
                     None => source!(self, span).lo,
index c9d9f7a12fc7113fd2ee03b45fc5e1653987bbc5..bbbe75ddf780ce1ccfac3c30dcffaf926c7118da 100644 (file)
@@ -14,7 +14,7 @@
 use codemap::SpanUtils;
 use utils::{format_mutability, format_visibility, contains_skip, end_typaram, wrap_str,
             last_line_width, format_unsafety, trim_newlines, stmt_expr, semicolon_for_expr,
-            trimmed_last_line_width, colon_spaces};
+            trimmed_last_line_width, colon_spaces, mk_sp};
 use lists::{write_list, itemize_list, ListItem, ListFormatting, SeparatorTactic, list_helper,
             DefinitiveListTactic, ListTactic, definitive_tactic, format_item_list};
 use expr::{is_empty_block, is_simple_block_stmt, rewrite_assign_rhs};
@@ -23,8 +23,8 @@
 use rewrite::{Rewrite, RewriteContext};
 use config::{Config, IndentStyle, Density, ReturnIndent, BraceStyle, Style, TypeDensity};
 
-use syntax::{ast, abi, codemap, ptr, symbol};
-use syntax::codemap::{Span, BytePos, mk_sp};
+use syntax::{ast, abi, ptr, symbol};
+use syntax::codemap::{Span, BytePos};
 use syntax::ast::ImplItem;
 
 fn type_annotation_separator(config: &Config) -> &str {
@@ -246,7 +246,7 @@ pub fn rewrite_fn(&mut self,
         let mut newline_brace = newline_for_brace(self.config, &generics.where_clause);
         let context = self.get_context();
 
-        let block_snippet = self.snippet(codemap::mk_sp(block.span.lo, block.span.hi));
+        let block_snippet = self.snippet(mk_sp(block.span.lo, block.span.hi));
         let has_body = !block_snippet[1..block_snippet.len() - 1].trim().is_empty() ||
                        !context.config.fn_empty_single_line();
 
@@ -527,7 +527,7 @@ pub fn format_impl(context: &RewriteContext,
                    offset: Indent,
                    where_span_end: Option<BytePos>)
                    -> Option<String> {
-    if let ast::ItemKind::Impl(_, _, ref generics, ref trait_ref, _, ref items) = item.node {
+    if let ast::ItemKind::Impl(_, _, _, ref generics, ref trait_ref, _, ref items) = item.node {
         let mut result = String::new();
         // First try to format the ref and type without a split at the 'for'.
         let mut ref_and_type = try_opt!(format_impl_ref_and_type(context, item, offset, false));
@@ -647,8 +647,13 @@ fn format_impl_ref_and_type(context: &RewriteContext,
                             offset: Indent,
                             split_at_for: bool)
                             -> Option<String> {
-    if let ast::ItemKind::Impl(unsafety, polarity, ref generics, ref trait_ref, ref self_ty, _) =
-        item.node {
+    if let ast::ItemKind::Impl(unsafety,
+                               polarity,
+                               _,
+                               ref generics,
+                               ref trait_ref,
+                               ref self_ty,
+                               _) = item.node {
         let mut result = String::new();
 
         result.push_str(&format_visibility(&item.vis));
index 1635553eccd9ad590d3eb956e26e9dca607a94b1..b7edc1836183021e40253cb0a5da72b256b34733 100644 (file)
@@ -33,7 +33,7 @@
 use errors::{Handler, DiagnosticBuilder};
 use errors::emitter::{ColorConfig, EmitterWriter};
 use syntax::ast;
-use syntax::codemap::{mk_sp, CodeMap, Span};
+use syntax::codemap::{CodeMap, Span, FilePathMapping};
 use syntax::parse::{self, ParseSess};
 
 use strings::string_buffer::StringBuffer;
@@ -107,7 +107,7 @@ fn span(&self) -> Span {
 impl Spanned for ast::Arg {
     fn span(&self) -> Span {
         if items::is_named_arg(self) {
-            mk_sp(self.pat.span.lo, self.ty.span.hi)
+            utils::mk_sp(self.pat.span.lo, self.ty.span.hi)
         } else {
             self.ty.span
         }
@@ -578,7 +578,7 @@ pub fn format_input<T: Write>(input: Input,
     if config.disable_all_formatting() {
         return Ok((summary, FileMap::new(), FormatReport::new()));
     }
-    let codemap = Rc::new(CodeMap::new());
+    let codemap = Rc::new(CodeMap::new(FilePathMapping::empty()));
 
     let tty_handler =
         Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(codemap.clone()));
index 3448f8a446a2390c0ed80918163bb723d7406401..978d9dbaceb3212fb57ba8466e29ae2eef57ba77 100644 (file)
 use std::cmp;
 use std::iter::Peekable;
 
-use syntax::codemap::{self, CodeMap, BytePos};
+use syntax::codemap::{CodeMap, BytePos};
 
 use {Indent, Shape};
 use comment::{FindUncommented, rewrite_comment, find_comment_end};
 use config::{Config, IndentStyle};
 use rewrite::RewriteContext;
+use utils::mk_sp;
 
 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
 /// Formatting tactic for lists. This will be cast down to a
@@ -344,7 +345,7 @@ fn next(&mut self) -> Option<Self::Item> {
             let mut new_lines = false;
             // Pre-comment
             let pre_snippet = self.codemap
-                .span_to_snippet(codemap::mk_sp(self.prev_span_end, (self.get_lo)(&item)))
+                .span_to_snippet(mk_sp(self.prev_span_end, (self.get_lo)(&item)))
                 .unwrap();
             let trimmed_pre_snippet = pre_snippet.trim();
             let has_pre_comment = trimmed_pre_snippet.contains("//") ||
@@ -361,7 +362,7 @@ fn next(&mut self) -> Option<Self::Item> {
                 None => self.next_span_start,
             };
             let post_snippet = self.codemap
-                .span_to_snippet(codemap::mk_sp((self.get_hi)(&item), next_start))
+                .span_to_snippet(mk_sp((self.get_hi)(&item), next_start))
                 .unwrap();
 
             let comment_end = match self.inner.peek() {
index f99e236ac88e4c1a70e867310032ffbcb3f01956..eca89a4b609b56dfe897e962eebd218c5ceae40c 100644 (file)
 // and those with brackets will be formatted as array literals.
 
 use syntax::ast;
-use syntax::codemap::{mk_sp, BytePos};
+use syntax::codemap::BytePos;
 use syntax::parse::token::Token;
-use syntax::parse::tts_to_parser;
+use syntax::parse::new_parser_from_tts;
+use syntax::tokenstream::TokenStream;
 use syntax::symbol;
 use syntax::util::ThinVec;
 
@@ -31,6 +32,7 @@
 use rewrite::{Rewrite, RewriteContext};
 use expr::{rewrite_call, rewrite_array, rewrite_pair};
 use comment::{FindUncommented, contains_comment};
+use utils::mk_sp;
 
 const FORCED_BRACKET_MACROS: &'static [&'static str] = &["vec!"];
 
@@ -92,7 +94,8 @@ pub fn rewrite_macro(mac: &ast::Mac,
         original_style
     };
 
-    if mac.node.tts.is_empty() && !contains_comment(&context.snippet(mac.span)) {
+    let ts: TokenStream = mac.node.tts.clone().into();
+    if ts.is_empty() && !contains_comment(&context.snippet(mac.span)) {
         return match style {
             MacroStyle::Parens if position == MacroPosition::Item => {
                 Some(format!("{}();", macro_name))
@@ -103,7 +106,7 @@ pub fn rewrite_macro(mac: &ast::Mac,
         };
     }
 
-    let mut parser = tts_to_parser(context.parse_session, mac.node.tts.clone());
+    let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
     let mut expr_vec = Vec::new();
     let mut vec_with_semi = false;
 
@@ -222,7 +225,8 @@ pub fn rewrite_macro(mac: &ast::Mac,
 /// failed).
 pub fn convert_try_mac(mac: &ast::Mac, context: &RewriteContext) -> Option<ast::Expr> {
     if &format!("{}", mac.node.path)[..] == "try" {
-        let mut parser = tts_to_parser(context.parse_session, mac.node.tts.clone());
+        let ts: TokenStream = mac.node.tts.clone().into();
+        let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
 
         Some(ast::Expr {
                  id: ast::NodeId::new(0), // dummy value
index 57ebc332ac485a4ece626cd08502d37dc5828a67..90a1327786540ebbeb084b73ea925d9672d5aa7b 100644 (file)
 
 use config::WriteMode;
 use visitor::FmtVisitor;
-use syntax::codemap::{self, BytePos, Span, Pos};
+use syntax::codemap::{BytePos, Span, Pos};
 use comment::{CodeCharKind, CommentCodeSlices, rewrite_comment};
 use Shape;
+use utils::mk_sp;
 
 impl<'a> FmtVisitor<'a> {
     fn output_at_start(&self) -> bool {
@@ -65,7 +66,7 @@ fn format_missing_inner<F: Fn(&mut FmtVisitor, &str, &str)>(&mut self,
                 self.codemap.lookup_char_pos(end));
 
         self.last_pos = end;
-        let span = codemap::mk_sp(start, end);
+        let span = mk_sp(start, end);
 
         self.write_snippet(span, &process_last_snippet);
     }
index 312f2b0ace932b8520636e069aed2326431bb0c1..eb100abd664c872ec3145eb94aa22bb56e5fc6de 100644 (file)
@@ -12,7 +12,7 @@
 use codemap::SpanUtils;
 use config::{IndentStyle, MultilineStyle};
 use rewrite::{Rewrite, RewriteContext};
-use utils::{wrap_str, format_mutability};
+use utils::{wrap_str, format_mutability, mk_sp};
 use lists::{DefinitiveListTactic, SeparatorTactic, format_item_list, itemize_list, ListItem,
             struct_lit_shape, struct_lit_tactic, shape_for_tactic, struct_lit_formatting,
             write_list};
@@ -261,14 +261,14 @@ fn rewrite_tuple_pat(pats: &[ptr::P<ast::Pat>],
         } else {
             pats[pos + 1].span().lo
         };
-        let dot_span = codemap::mk_sp(prev, next);
+        let dot_span = mk_sp(prev, next);
         let snippet = context.snippet(dot_span);
         let lo = dot_span.lo + BytePos(snippet.find_uncommented("..").unwrap() as u32);
         let span = Span {
             lo: lo,
             // 2 == "..".len()
             hi: lo + BytePos(2),
-            expn_id: codemap::NO_EXPANSION,
+            ctxt: codemap::NO_EXPANSION,
         };
         let dotdot = TuplePatField::Dotdot(span);
         pat_vec.insert(pos, dotdot);
index 17e9a467d1bb0355f960c07eb7475a203f17d4b7..7dfc4337178999076a416d58c659aca24824efb8 100644 (file)
@@ -21,7 +21,7 @@
 use codemap::SpanUtils;
 use lists::{format_item_list, itemize_list, format_fn_args};
 use rewrite::{Rewrite, RewriteContext};
-use utils::{extra_offset, format_mutability, colon_spaces, wrap_str};
+use utils::{extra_offset, format_mutability, colon_spaces, wrap_str, mk_sp};
 use expr::{rewrite_unary_prefix, rewrite_pair, rewrite_tuple_type};
 use config::TypeDensity;
 
@@ -206,9 +206,7 @@ fn rewrite_segment(path_context: PathContext,
                     .collect::<Vec<_>>();
 
                 let next_span_lo = param_list.last().unwrap().get_span().hi + BytePos(1);
-                let list_lo = context
-                    .codemap
-                    .span_after(codemap::mk_sp(*span_lo, span_hi), "<");
+                let list_lo = context.codemap.span_after(mk_sp(*span_lo, span_hi), "<");
                 let separator = if path_context == PathContext::Expr {
                     "::"
                 } else {
@@ -686,6 +684,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                 it.rewrite(context, shape)
                     .map(|it_str| format!("impl {}", it_str))
             }
+            ast::TyKind::Err |
             ast::TyKind::Typeof(..) => unreachable!(),
         }
     }
index e80c558e51eadd1449bc1eb7adbd3140998d8dfb..b4095978b8a8e675906780170ad9315722810bbf 100644 (file)
@@ -13,7 +13,7 @@
 
 use syntax::ast::{self, Visibility, Attribute, MetaItem, MetaItemKind, NestedMetaItem,
                   NestedMetaItemKind, Path};
-use syntax::codemap::BytePos;
+use syntax::codemap::{BytePos, Span, NO_EXPANSION};
 use syntax::abi;
 
 use Shape;
@@ -48,8 +48,11 @@ pub fn format_visibility(vis: &Visibility) -> Cow<'static, str> {
                     .next()
                     .expect("Non-global path in pub(restricted)?");
             }
+            let is_keyword = |s: &str| s == "self" || s == "super";
+            let path = segments_iter.collect::<Vec<_>>().join("::");
+            let in_str = if is_keyword(&path) { "" } else { "in " };
 
-            Cow::from(format!("pub({}) ", segments_iter.collect::<Vec<_>>().join("::")))
+            Cow::from(format!("pub({}{}) ", in_str, path))
         }
     }
 }
@@ -125,7 +128,9 @@ fn is_skip_nested(meta_item: &NestedMetaItem) -> bool {
 
 #[inline]
 pub fn contains_skip(attrs: &[Attribute]) -> bool {
-    attrs.iter().any(|a| is_skip(&a.value))
+    attrs
+        .iter()
+        .any(|a| a.meta().map_or(false, |a| is_skip(&a)))
 }
 
 // Find the end of a TyParam
@@ -287,7 +292,15 @@ macro_rules! msg {
 // Required as generated code spans aren't guaranteed to follow on from the last span.
 macro_rules! source {
     ($this:ident, $sp: expr) => {
-        $this.codemap.source_callsite($sp)
+        $sp.source_callsite()
+    }
+}
+
+pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
+    Span {
+        lo,
+        hi,
+        ctxt: NO_EXPANSION,
     }
 }
 
index 51ae96158360e2b916b179545a85f336e4ce4fbd..d01e8e02eadf57b356df2d98dd90ac0dcd060a18 100644 (file)
 use std::cmp;
 
 use syntax::{ast, ptr, visit};
-use syntax::codemap::{self, CodeMap, Span, BytePos};
+use syntax::codemap::{CodeMap, Span, BytePos};
 use syntax::parse::ParseSess;
 
 use strings::string_buffer::StringBuffer;
 
 use {Indent, Shape};
-use utils;
+use utils::{self, mk_sp};
 use codemap::{LineRangeUtils, SpanUtils};
 use comment::FindUncommented;
 use config::Config;
@@ -26,6 +26,7 @@
 use macros::{rewrite_macro, MacroPosition};
 use items::{rewrite_static, rewrite_associated_type, rewrite_associated_impl_type,
             rewrite_type_alias, format_impl, format_trait};
+use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorTactic};
 
 fn is_use_item(item: &ast::Item) -> bool {
     match item.node {
@@ -42,7 +43,7 @@ fn item_bound(item: &ast::Item) -> Span {
             Span {
                 lo: cmp::min(bound.lo, span.lo),
                 hi: cmp::max(bound.hi, span.hi),
-                expn_id: span.expn_id,
+                ctxt: span.ctxt,
             }
         })
 }
@@ -121,8 +122,7 @@ pub fn visit_block(&mut self, b: &ast::Block) {
         let mut unindent_comment = self.is_if_else_block && !b.stmts.is_empty();
         if unindent_comment {
             let end_pos = source!(self, b.span).hi - brace_compensation;
-            let snippet = self.get_context()
-                .snippet(codemap::mk_sp(self.last_pos, end_pos));
+            let snippet = self.get_context().snippet(mk_sp(self.last_pos, end_pos));
             unindent_comment = snippet.contains("//") || snippet.contains("/*");
         }
         // FIXME: we should compress any newlines here to just one
@@ -177,7 +177,7 @@ fn visit_fn(&mut self,
                                 defaultness,
                                 abi,
                                 vis,
-                                codemap::mk_sp(s.lo, b.span.lo),
+                                mk_sp(s.lo, b.span.lo),
                                 &b)
             }
             visit::FnKind::Method(ident, sig, vis, b) => {
@@ -191,7 +191,7 @@ fn visit_fn(&mut self,
                                 defaultness,
                                 sig.abi,
                                 vis.unwrap_or(&ast::Visibility::Inherited),
-                                codemap::mk_sp(s.lo, b.span.lo),
+                                mk_sp(s.lo, b.span.lo),
                                 &b)
             }
             visit::FnKind::Closure(_) => unreachable!(),
@@ -383,6 +383,15 @@ pub fn visit_item(&mut self, item: &ast::Item) {
             ast::ItemKind::Union(..) => {
                 // FIXME(#1157): format union definitions.
             }
+            ast::ItemKind::GlobalAsm(..) => {
+                let snippet = Some(self.snippet(item.span));
+                self.push_rewrite(item.span, snippet);
+            }
+            ast::ItemKind::MacroDef(..) => {
+                // FIXME(#1539): macros 2.0
+                let snippet = Some(self.snippet(item.span));
+                self.push_rewrite(item.span, snippet);
+            }
         }
     }
 
@@ -598,8 +607,7 @@ fn format_mod(&mut self, m: &ast::Mod, vis: &ast::Visibility, s: Span, ident: as
             self.buffer.push_str(" {");
             // Hackery to account for the closing }.
             let mod_lo = self.codemap.span_after(source!(self, s), "{");
-            let body_snippet =
-                self.snippet(codemap::mk_sp(mod_lo, source!(self, m.inner).hi - BytePos(1)));
+            let body_snippet = self.snippet(mk_sp(mod_lo, source!(self, m.inner).hi - BytePos(1)));
             let body_snippet = body_snippet.trim();
             if body_snippet.is_empty() {
                 self.buffer.push_str("}");
@@ -638,6 +646,81 @@ pub fn get_context(&self) -> RewriteContext {
     }
 }
 
+impl Rewrite for ast::NestedMetaItem {
+    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+        match self.node {
+            ast::NestedMetaItemKind::MetaItem(ref meta_item) => meta_item.rewrite(context, shape),
+            ast::NestedMetaItemKind::Literal(..) => Some(context.snippet(self.span)),
+        }
+    }
+}
+
+impl Rewrite for ast::MetaItem {
+    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+        Some(match self.node {
+                 ast::MetaItemKind::Word => String::from(&*self.name.as_str()),
+                 ast::MetaItemKind::List(ref list) => {
+                     let name = self.name.as_str();
+                     // 3 = `#[` and `(`, 2 = `]` and `)`
+                     let item_shape = try_opt!(shape
+                                                   .shrink_left(name.len() + 3)
+                                                   .and_then(|s| s.sub_width(2)));
+                     let items = itemize_list(context.codemap,
+                                              list.iter(),
+                                              ")",
+                                              |nested_meta_item| nested_meta_item.span.lo,
+                                              |nested_meta_item| nested_meta_item.span.hi,
+                                              |nested_meta_item| {
+                                                  nested_meta_item.rewrite(context, item_shape)
+                                              },
+                                              self.span.lo,
+                                              self.span.hi);
+                     let item_vec = items.collect::<Vec<_>>();
+                     let fmt = ListFormatting {
+                         tactic: DefinitiveListTactic::Mixed,
+                         separator: ",",
+                         trailing_separator: SeparatorTactic::Never,
+                         shape: item_shape,
+                         ends_with_newline: false,
+                         config: context.config,
+                     };
+                     format!("{}({})", name, try_opt!(write_list(&item_vec, &fmt)))
+                 }
+                 ast::MetaItemKind::NameValue(ref literal) => {
+                     let name = self.name.as_str();
+                     let value = context.snippet(literal.span);
+                     if &*name == "doc" && value.starts_with("///") {
+                         let doc_shape = Shape {
+                             width: cmp::min(shape.width, context.config.comment_width())
+                                 .checked_sub(shape.indent.width())
+                                 .unwrap_or(0),
+                             ..shape
+                         };
+                         format!("{}",
+                                 try_opt!(rewrite_comment(&value,
+                                                          false,
+                                                          doc_shape,
+                                                          context.config)))
+                     } else {
+                         format!("{} = {}", name, value)
+                     }
+                 }
+             })
+    }
+}
+
+impl Rewrite for ast::Attribute {
+    fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
+        try_opt!(self.meta())
+            .rewrite(context, shape)
+            .map(|rw| if rw.starts_with("///") {
+                     rw
+                 } else {
+                     format!("#[{}]", rw)
+                 })
+    }
+}
+
 impl<'a> Rewrite for [ast::Attribute] {
     fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
         let mut result = String::new();
@@ -647,11 +730,11 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
         let indent = shape.indent.to_string(context.config);
 
         for (i, a) in self.iter().enumerate() {
-            let mut a_str = context.snippet(a.span);
+            let a_str = try_opt!(a.rewrite(context, shape));
 
             // Write comments and blank lines between attributes.
             if i > 0 {
-                let comment = context.snippet(codemap::mk_sp(self[i - 1].span.hi, a.span.lo));
+                let comment = context.snippet(mk_sp(self[i - 1].span.hi, a.span.lo));
                 // This particular horror show is to preserve line breaks in between doc
                 // comments. An alternative would be to force such line breaks to start
                 // with the usual doc comment token.
@@ -674,15 +757,6 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
                 result.push_str(&indent);
             }
 
-            if a_str.starts_with("//") {
-                a_str = try_opt!(rewrite_comment(&a_str,
-                                                 false,
-                                                 Shape::legacy(context.config.comment_width() -
-                                                               shape.indent.width(),
-                                                               shape.indent),
-                                                 context.config));
-            }
-
             // Write the attribute itself.
             result.push_str(&a_str);
 
index a47c2507156174f23ce8a34cd204ea60aba96e04..593fb0ff57ef434aa99835e3c783284e9c5f611f 100644 (file)
@@ -41,4 +41,14 @@ fn f3(self) -> Dog {
     /// Blah blah bing.
     fn f4(self) -> Cat {
     }
+
+    // We want spaces around `=`
+    #[cfg(feature="nightly")]
+    fn f5(self) -> Monkey {}
+}
+
+// #984
+struct Foo {
+    # [ derive ( Clone , PartialEq , Debug , Deserialize , Serialize ) ]
+    foo: usize,
 }
diff --git a/tests/source/catch.rs b/tests/source/catch.rs
new file mode 100644 (file)
index 0000000..64cc9e7
--- /dev/null
@@ -0,0 +1,27 @@
+#![feature(catch_expr)]
+
+fn main() {
+    let x = do catch {
+        foo()?
+    };
+
+    let x = do catch /* Invisible comment */ { foo()? };
+
+    let x = do catch {
+        unsafe { foo()? }
+    };
+
+    let y = match (do catch {
+        foo()?
+    }) {
+        _ => (),
+    };
+
+    do catch {
+        foo()?;
+    };
+
+    do catch {
+        // Regular do catch block
+    };
+}
index 0e2e2c066c3b05a76b85087bebe2cb43c1e5e5a7..6992ca53c1b4c7479c92df65f8baf2c360dad864 100644 (file)
@@ -109,3 +109,14 @@ pub enum Bencoding<'i> {
     // TODO make Dict "structlike" AKA name the two values.
     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
 }
+
+// #1261
+pub enum CoreResourceMsg {
+    SetCookieForUrl(
+        ServoUrl,
+        #[serde(deserialize_with = "::hyper_serde::deserialize",
+                serialize_with = "::hyper_serde::serialize")]
+        Cookie,
+        CookieSource
+    ),
+}
index 77b19b8e746ae93b50894a779a13fb41fb1e86ba..5683acbf3aa936dd622a536906c06a6faf9a9d39 100644 (file)
@@ -24,7 +24,7 @@ pub(  crate  ) enum WriteState<D> {
     WriteData(Writer<D>),
 }
 
-pub(  ::global::  path :: to::some_mod  ) enum WriteState<D> {
+pub(in  ::global::  path :: to::some_mod  ) enum WriteState<D> {
     WriteId {
         id: U64Writer,
         size: U64Writer,
@@ -37,7 +37,7 @@ pub(  ::global::  path :: to::some_mod  ) enum WriteState<D> {
     WriteData(Writer<D>),
 }
 
-pub(  local::  path :: to::some_mod  ) enum WriteState<D> {
+pub(   in  local::  path :: to::some_mod  ) enum WriteState<D> {
     WriteId {
         id: U64Writer,
         size: U64Writer,
index 2e5381a7e414be42fe8323f51ee91d74b74b1550..6fc69c2dfe47979c968ec951edd41498417df637 100644 (file)
@@ -20,3 +20,18 @@ fn do_something() -> Foo {
 fn main() {
     do_something();
 }
+
+// #1462
+struct Foo {
+    foo: usize,
+    #[cfg(feature="include-bar")]
+    bar: usize,
+}
+
+fn new_foo() -> Foo {
+    Foo {
+        foo: 0,
+        #[cfg(feature="include-bar")]
+        bar: 0,
+    }
+}
index b861b971d9b77b2bbaf88711fbb5ef237b24b1fb..fb70585bd21cc20433586f0462811984718dcef6 100644 (file)
@@ -37,4 +37,14 @@ fn f3(self) -> Dog {}
     // tooooooooooooooooooooooooooooooo loooooooooooong.
     /// Blah blah bing.
     fn f4(self) -> Cat {}
+
+    // We want spaces around `=`
+    #[cfg(feature = "nightly")]
+    fn f5(self) -> Monkey {}
+}
+
+// #984
+struct Foo {
+    #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
+    foo: usize,
 }
diff --git a/tests/target/catch.rs b/tests/target/catch.rs
new file mode 100644 (file)
index 0000000..640f9ba
--- /dev/null
@@ -0,0 +1,21 @@
+#![feature(catch_expr)]
+
+fn main() {
+    let x = do catch { foo()? };
+
+    let x = do catch /* Invisible comment */ { foo()? };
+
+    let x = do catch { unsafe { foo()? } };
+
+    let y = match (do catch { foo()? }) {
+        _ => (),
+    };
+
+    do catch {
+        foo()?;
+    };
+
+    do catch {
+        // Regular do catch block
+    };
+}
index 3e0e46d3fae97950b9014ebfaae60d493b617040..0bb18e2df674f1a7f56c048431711f4e6ec09968 100644 (file)
@@ -139,3 +139,12 @@ pub enum Bencoding<'i> {
     // TODO make Dict "structlike" AKA name the two values.
     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
 }
+
+// #1261
+pub enum CoreResourceMsg {
+    SetCookieForUrl(ServoUrl,
+                    #[serde(deserialize_with = "::hyper_serde::deserialize",
+                            serialize_with = "::hyper_serde::serialize")]
+                    Cookie,
+                    CookieSource),
+}
index 09df7ebd55fdf7e997e5008bca1cc464ed4db5b5..6acab043e67565d00b6d9301e9652c4b47b2c669 100644 (file)
@@ -326,11 +326,10 @@ fn issue1371() {
              sfEvtGainedFocus => GainedFocus,
              sfEvtTextEntered => {
                  TextEntered {
-                     unicode:
-                         unsafe {
-                             ::std::char::from_u32((*event.text.as_ref()).unicode)
-                                 .expect("Invalid unicode encountered on TextEntered event")
-                         },
+                     unicode: unsafe {
+                         ::std::char::from_u32((*event.text.as_ref()).unicode)
+                             .expect("Invalid unicode encountered on TextEntered event")
+                     },
                  }
              }
              sfEvtKeyPressed => {
index b3456bf0d0fb9b0de19effc44b365fe3ee973cd8..ff0d55b0175c4ddd3dca6dce910e1097abd3cbf0 100644 (file)
@@ -7,7 +7,7 @@ mod mymod1 {
     mod mod3a;
 }
 
-#[path="mod2c.rs"]
+#[path = "mod2c.rs"]
 mod mymod2;
 
 mod submod2;
index f128e2da6dbfb64eb890ec0325395e9219719a60..f06766f304fdf64f84714023453d30fd19236b57 100644 (file)
@@ -1,3 +1,3 @@
 
-#[path="mod2a.rs"]
+#[path = "mod2a.rs"]
 mod c;
index 88053173704602be89f8ed0464ab01215871d317..0e178ef10136e3965f7185ef1998b329b5982da5 100644 (file)
@@ -24,7 +24,7 @@ pub(crate) enum WriteState<D> {
     WriteData(Writer<D>),
 }
 
-pub(global::path::to::some_mod) enum WriteState<D> {
+pub(in global::path::to::some_mod) enum WriteState<D> {
     WriteId {
         id: U64Writer,
         size: U64Writer,
@@ -37,7 +37,7 @@ pub(global::path::to::some_mod) enum WriteState<D> {
     WriteData(Writer<D>),
 }
 
-pub(local::path::to::some_mod) enum WriteState<D> {
+pub(in local::path::to::some_mod) enum WriteState<D> {
     WriteId {
         id: U64Writer,
         size: U64Writer,
index 2e5381a7e414be42fe8323f51ee91d74b74b1550..8ae40ac9bdfbdad97bf50c7b32e22665cb3544fc 100644 (file)
@@ -20,3 +20,18 @@ fn do_something() -> Foo {
 fn main() {
     do_something();
 }
+
+// #1462
+struct Foo {
+    foo: usize,
+    #[cfg(feature = "include-bar")]
+    bar: usize,
+}
+
+fn new_foo() -> Foo {
+    Foo {
+        foo: 0,
+        #[cfg(feature = "include-bar")]
+        bar: 0,
+    }
+}