1 // rustfmt-normalize_comments: true
17 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
19 Pattern1
| Pattern2
| Pattern3
=> false,
20 Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
21 | Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
=> blah
,
22 Patternnnnnnnnnnnnnnnnnnn
23 | Patternnnnnnnnnnnnnnnnnnn
24 | Patternnnnnnnnnnnnnnnnnnn
25 | Patternnnnnnnnnnnnnnnnnnn
=> meh
,
27 Patternnnnnnnnnnnnnnnnnnn
| Patternnnnnnnnnnnnnnnnnnn
if looooooooooooooooooong_guard
=> {
31 Patternnnnnnnnnnnnnnnnnnnnnnnnn
| Patternnnnnnnnnnnnnnnnnnnnnnnnn
32 if looooooooooooooooooooooooooooooooooooooooong_guard
=>
37 // Test that earlier patterns can take the guard space
38 (aaaa
, bbbbb
, ccccccc
, aaaaa
, bbbbbbbb
, cccccc
, aaaa
, bbbbbbbb
, cccccc
, dddddd
)
39 | Patternnnnnnnnnnnnnnnnnnnnnnnnn
40 if loooooooooooooooooooooooooooooooooooooooooong_guard
=> {}
43 ast
::PathParameters
::AngleBracketedParameters(ref data
)
44 if data
.lifetimes
.len() > 0 || data
.types
.len() > 0 || data
.bindings
.len() > 0 => {}
47 let whatever
= match something
{
50 // Comment on an attribute.
52 // Comment after an attribute.
59 // Test that a match on an overflow line is laid out properly.
62 match xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{
63 Some(sub_span
) => Some(sub_span
),
68 // Test that one-line bodies align.
71 Variableeeeeeeeeeeeeeeeee
=> (
73 vec
!["id", "name", "qualname", "value", "type", "scopeid"],
77 Enummmmmmmmmmmmmmmmmmmmm
=> (
79 vec
!["id", "qualname", "scopeid", "value"],
83 Variantttttttttttttttttttttttt
=> (
85 vec
!["id", "name", "qualname", "type", "value", "scopeid"],
92 y
=> { /*Block with comment. Preserve me.*/ }
111 let _
= match Some(1) {
124 // collapsing here is safe
125 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
=> {}
126 // collapsing here exceeds line length
127 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffg
=> {
129 h
=> { // comment above block
131 i
=> {}
// comment below block
133 // comment inside block
136 // comments inside...
138 // TODO uncomment when vertical whitespace is handled better
141 // // comment with WS above
144 // // comment with ws below
150 p
=> { // Don't collapse me
158 v
=> {}
/* funky block
166 a
=> println
!("a", b
),
178 h
=> println
!("a", b
), // h comment
179 i
=> vec
![1, 2], // i comment
180 j
=> vec
![3; 4], // j comment
182 k
=> println
!("a", b
),
187 // Rewrite splits macro
188 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
=> {
191 // Rewrite splits macro
192 oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
=> {
195 // Macro support fails to recognise this macro as splittable
196 // We push the whole expr to a new line, TODO split this macro as well
197 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
=> {
200 // q, r and s: Rewrite splits match arm
201 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
=> {
204 rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
=> {
207 ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
=> {
210 // Funky bracketing styles
211 t
=> println
! {"a", b}
,
214 w
=> println
!["a", b
],
217 // Brackets with comments
218 tc
=> println
! {"a", b}
, // comment
219 uc
=> vec
![1, 2], // comment
220 vc
=> vec
![3; 4], // comment
221 wc
=> println
!["a", b
], // comment
222 xc
=> vec
![1, 2], // comment
223 yc
=> vec
![3; 4], // comment
224 yd
=> looooooooooooooooooooooooooooooooooooooooooooooooooooooooong_func(
225 aaaaaaaaaa
, bbbbbbbbbb
, cccccccccc
, dddddddddd
,
233 CompressionMode
::DiscardNewline
| CompressionMode
::CompressWhitespaceNewline
=> {
236 ast
::ItemConst(ref typ
, ref expr
) => {
237 self.process_static_or_const_item(item
, &typ
, &expr
)
244 match resolution
.last_private
{
245 LastImport { .. }
=> false,
252 1 => unsafe { std::intrinsics::abort() }
,
259 Some(NodeTypeId
::Element(ElementTypeId
::HTMLElement(
260 HTMLElementTypeId
::HTMLCanvasElement
,
262 Some(NodeTypeId
::Element(ElementTypeId
::HTMLElement(
263 HTMLElementTypeId
::HTMLObjectElement
,
264 ))) => s
.has_object_data(),
265 Some(NodeTypeId
::Element(_
)) => false,
274 def
::DefConst(def_id
) | def
::DefAssociatedConst(def_id
) => {
275 match const_eval
::lookup_const_by_id(cx
.tcx
, def_id
, Some(self.pat
.id
)) {
276 Some(const_expr
) => x
,
288 hir
::StmtExpr(ref expr
, id
) | hir
::StmtSemi(ref expr
, id
) => {
289 result
.push(StmtRef
::Mirror(Box
::new(Stmt
{
291 kind
: StmtKind
::Expr
{
292 scope
: cx
.tcx
.region_maps
.node_extent(id
),
303 BiEq
| BiLt
| BiLe
| BiNe
| BiGt
| BiGe
=> true,
304 BiAnd
| BiOr
| BiAdd
| BiSub
| BiMul
| BiDiv
| BiRem
| BiBitXor
| BiBitAnd
| BiBitOr
305 | BiShl
| BiShr
=> false,
311 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
312 if foooooooooooooo
&& barrrrrrrrrrrr
=> {}
313 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
314 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
315 if foooooooooooooo
&& barrrrrrrrrrrr
=> {}
316 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
317 if fooooooooooooooooooooo
318 && (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
319 || cccccccccccccccccccccccccccccccccccccccc
) => {}
325 sfEvtClosed
=> Closed
,
327 let e
= unsafe { *event.size.as_ref() }
;
334 sfEvtLostFocus
=> LostFocus
,
335 sfEvtGainedFocus
=> GainedFocus
,
336 sfEvtTextEntered
=> TextEntered
{
338 ::std
::char::from_u32((*event
.text
.as_ref()).unicode
)
339 .expect("Invalid unicode encountered on TextEntered event")
343 let e
= unsafe { event.key.as_ref() }
;
346 code
: unsafe { ::std::mem::transmute(e.code) }
,
347 alt
: e
.alt
.to_bool(),
348 ctrl
: e
.control
.to_bool(),
349 shift
: e
.shift
.to_bool(),
350 system
: e
.system
.to_bool(),
353 sfEvtKeyReleased
=> {
354 let e
= unsafe { event.key.as_ref() }
;
357 code
: unsafe { ::std::mem::transmute(e.code) }
,
358 alt
: e
.alt
.to_bool(),
359 ctrl
: e
.control
.to_bool(),
360 shift
: e
.shift
.to_bool(),
361 system
: e
.system
.to_bool(),
368 let bar
= Some(true);
369 let foo
= Some(true);
371 bar
.and_then(|_
| match foo
{
382 artists
: match reader
.evaluate(".//mb:recording/mb:artist-credit/mb:name-credit")?
{
383 Nodeset(nodeset
) => {
384 let res
: Result
<Vec
<ArtistRef
>, ReadError
> = nodeset
387 XPathNodeReader
::new(node
, &context
).and_then(|r
| ArtistRef
::from_xml(&r
))
399 REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT
=> {
400 "internal_spec_insert_internal_spec_insert_internal_spec_insert"
402 _
=> "reorder_something",
411 TaskState
::Started
=> "started",
412 TaskState
::Success
=> "success",
413 TaskState
::Failed
=> "failed",
419 fn match_with_near_max_width() {
420 let (this_line_uses_99_characters_and_is_formatted_properly
, x012345
) = match some_expression
{
421 _
=> unimplemented
!(),
424 let (should_be_formatted_like_the_line_above_using_100_characters
, x0
) = match some_expression
{
425 _
=> unimplemented
!(),
428 let (should_put_the_brace_on_the_next_line_using_101_characters
, x0000
) = match some_expression
430 _
=> unimplemented
!(),
438 | Variant
::Tag6
=> {}
442 fn match_with_trailing_spaces() {
444 #![allow(simple_match)]
458 impl<'tcx
> Const
<'tcx
> {
459 pub fn from_constval
<'a
>() -> Const
<'tcx
> {
460 let val
= match *cv
{
461 ConstVal
::Variant(_
) | ConstVal
::Aggregate(..) | ConstVal
::Unevaluated(..) => bug
!(
462 "MIR must not use `{:?}` (aggregates are expanded to MIR rvalues)",
480 "aaaaaaaaaaaaa" | "bbbbbbbbbbbbb" | "cccccccccccccccccccccccccccccccccccccccccccc"
482 "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android
&& (aarch64
|| x86_64
) => {
489 // Preserve block around expressions with condition.
512 // Strip leading `|` in match arm patterns
516 Foo
::A
=> println
!("No vert single condition"),
517 Foo
::B
| Foo
::C
=> println
!("Center vert two conditions"),
518 Foo
::D
=> println
!("Preceding vert single condition"),
519 Foo
::E
| Foo
::F
=> println
!("Preceding vert over two lines"),
520 Foo
::G
| Foo
::H
=> println
!("Trailing vert over two lines"),
521 // Comment on its own line
522 Foo
::I
=> println
!("With comment"), // Comment after line
540 Tok
::TypeOf
if prec
<= 16 => {}
548 DevtoolScriptControlMsg
::WantsLiveNotifications(id
, to_send
) => {
549 match documents
.find_window(id
) {
551 devtools
::handle_wants_live_notifications(window
.upcast(), to_send
)
553 None
=> return warn
!("Message sent to closed pipeline {}.", id
),
562 match input
.trim().parse
::<f64>() {
565 // A valid number is the same as what rust considers to be valid,
566 // except for +1., NaN, and Infinity.
567 val
.is_infinite() || val
.is_nan() || input
.ends_with(".") || input
.starts_with("+")
576 } if num_context
.is_ok(context
.parsing_mode
, value
) => {
577 return NoCalcLength
::parse_dimension(context
, value
, unit
)
578 .map(LengthOrPercentage
::Length
)
579 .map_err(|()| location
.new_unexpected_token_error(token
.clone()));
590 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => unreachab(),
591 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => unreacha
!(),
592 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => {
595 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => {
598 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => {
601 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => {
604 Lam(_
, _
, _
) | Pi(_
, _
, _
) | Let(_
, _
, _
, _
) | Embed(_
) | Var(_
) => {