diff options
| author | bors <bors@rust-lang.org> | 2023-09-21 01:02:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-21 01:02:00 +0000 |
| commit | cbce15c6173cd0fcd4abe25c108067d32f1135b4 (patch) | |
| tree | 2f3b907d724e65d9a293265c17ee725302382361 /src | |
| parent | 3223b0b5e8dadda3f76c3fd1a8d6c5addc09599e (diff) | |
| parent | 156d2e274649491ec385b51264582d9384ca9271 (diff) | |
| download | rust-cbce15c6173cd0fcd4abe25c108067d32f1135b4.tar.gz rust-cbce15c6173cd0fcd4abe25c108067d32f1135b4.zip | |
Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator)) - #115990 (Allow anyone to set llvm-fixed-upstream) - #116008 (Rename BoxMeUp to PanicPayload.) - #116011 (Update browser-ui-test version to 0.16.10) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version | 2 | ||||
| -rw-r--r-- | src/doc/style-guide/src/expressions.md | 28 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index 0d67319168d..50b6386a009 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.16.9 \ No newline at end of file +0.16.10 \ No newline at end of file diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index e9ef509e6a2..12037b5992e 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -328,6 +328,26 @@ foo_bar Prefer line-breaking at an assignment operator (either `=` or `+=`, etc.) rather than at other binary operators. +### Casts (`as`) + +Format `as` casts like a binary operator. In particular, always include spaces +around `as`, and if line-breaking, break before the `as` (never after) and +block-indent the subsequent line. Format the type on the right-hand side using +the rules for types. + +However, unlike with other binary operators, if chaining a series of `as` casts +that require line-breaking, and line-breaking before the first `as` suffices to +make the remainder fit on the next line, don't break before any subsequent +`as`; instead, leave the series of types all on the same line: + +```rust +let cstr = very_long_expression() + as *const str as *const [u8] as *const std::os::raw::c_char; +``` + +If the subsequent line still requires line-breaking, break and block-indent +before each `as` as with other binary operators. + ## Control flow Do not include extraneous parentheses for `if` and `while` expressions. @@ -426,14 +446,6 @@ assert_eq!( ); ``` -## Casts (`as`) - -Put spaces before and after `as`: - -```rust -let cstr = "Hi\0" as *const str as *const [u8] as *const std::os::raw::c_char; -``` - ## Chains of fields and method calls A chain is a sequence of field accesses, method calls, and/or uses of the try |
