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 => {
130 // comment above block
132 i => {} // comment below block
134 // comment inside block
137 // comments inside...
139 // TODO uncomment when vertical whitespace is handled better
142 // // comment with WS above
145 // // comment with ws below
160 v => {} /* funky block
168 a => println!("a", b),
171 d => println!("a", b),
174 h => println!("a", b), // h comment
175 i => vec![1, 2], // i comment
176 j => vec![3; 4], // j comment
178 k => println!("a", b),
183 // Rewrite splits macro
184 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => {
187 // Rewrite splits macro
188 oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => {
191 // Macro support fails to recognise this macro as splittable
192 // We push the whole expr to a new line, TODO split this macro as well
193 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => {
196 // q, r and s: Rewrite splits match arm
197 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq => {
200 rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr => {
203 ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss => {
206 // Funky bracketing styles
207 t => println!{"a", b},
210 w => println!["a", b],
213 // Brackets with comments
214 tc => println!{"a", b}, // comment
215 uc => vec![1, 2], // comment
216 vc => vec![3; 4], // comment
217 wc => println!["a", b], // comment
218 xc => vec![1, 2], // comment
219 yc => vec![3; 4], // comment
220 yd => looooooooooooooooooooooooooooooooooooooooooooooooooooooooong_func(
221 aaaaaaaaaa, bbbbbbbbbb, cccccccccc, dddddddddd,
229 CompressionMode::DiscardNewline | CompressionMode::CompressWhitespaceNewline => {
232 ast::ItemConst(ref typ, ref expr) => {
233 self.process_static_or_const_item(item, &typ, &expr)
240 match resolution.last_private {
241 LastImport { .. } => false,
248 1 => unsafe { std::intrinsics::abort() },
255 Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
256 HTMLElementTypeId::HTMLCanvasElement,
258 Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
259 HTMLElementTypeId::HTMLObjectElement,
260 ))) => s.has_object_data(),
261 Some(NodeTypeId::Element(_)) => false,
270 def::DefConst(def_id) | def::DefAssociatedConst(def_id) => {
271 match const_eval::lookup_const_by_id(cx.tcx, def_id, Some(self.pat.id)) {
272 Some(const_expr) => x,
284 hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) => {
285 result.push(StmtRef::Mirror(Box::new(Stmt {
287 kind: StmtKind::Expr {
288 scope: cx.tcx.region_maps.node_extent(id),
299 BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true,
300 BiAnd | BiOr | BiAdd | BiSub | BiMul | BiDiv | BiRem | BiBitXor | BiBitAnd | BiBitOr
301 | BiShl | BiShr => false,
307 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
308 if foooooooooooooo && barrrrrrrrrrrr => {}
309 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
310 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
311 if foooooooooooooo && barrrrrrrrrrrr => {}
312 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
313 if fooooooooooooooooooooo
314 && (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
315 || cccccccccccccccccccccccccccccccccccccccc) => {}
321 sfEvtClosed => Closed,
323 let e = unsafe { *event.size.as_ref() };
330 sfEvtLostFocus => LostFocus,
331 sfEvtGainedFocus => GainedFocus,
332 sfEvtTextEntered => TextEntered {
334 ::std::char::from_u32((*event.text.as_ref()).unicode)
335 .expect("Invalid unicode encountered on TextEntered event")
339 let e = unsafe { event.key.as_ref() };
342 code: unsafe { ::std::mem::transmute(e.code) },
343 alt: e.alt.to_bool(),
344 ctrl: e.control.to_bool(),
345 shift: e.shift.to_bool(),
346 system: e.system.to_bool(),
349 sfEvtKeyReleased => {
350 let e = unsafe { event.key.as_ref() };
353 code: unsafe { ::std::mem::transmute(e.code) },
354 alt: e.alt.to_bool(),
355 ctrl: e.control.to_bool(),
356 shift: e.shift.to_bool(),
357 system: e.system.to_bool(),
364 let bar = Some(true);
365 let foo = Some(true);
367 bar.and_then(|_| match foo {
378 artists: match reader.evaluate(".//mb:recording/mb:artist-credit/mb:name-credit")? {
379 Nodeset(nodeset) => {
380 let res: Result<Vec<ArtistRef>, ReadError> = nodeset
383 XPathNodeReader::new(node, &context).and_then(|r| ArtistRef::from_xml(&r))
395 REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT => {
396 "internal_spec_insert_internal_spec_insert_internal_spec_insert"
398 _ => "reorder_something",
407 TaskState::Started => "started",
408 TaskState::Success => "success",
409 TaskState::Failed => "failed",
415 fn match_with_near_max_width() {
416 let (this_line_uses_99_characters_and_is_formatted_properly, x012345) = match some_expression {
417 _ => unimplemented!(),
420 let (should_be_formatted_like_the_line_above_using_100_characters, x0) = match some_expression {
421 _ => unimplemented!(),
424 let (should_put_the_brace_on_the_next_line_using_101_characters, x0000) = match some_expression
426 _ => unimplemented!(),
434 | Variant::Tag6 => {}
438 fn match_with_trailing_spaces() {
440 #![allow(simple_match)]
454 impl<'tcx> Const<'tcx> {
455 pub fn from_constval<'a>() -> Const<'tcx> {
456 let val = match *cv {
457 ConstVal::Variant(_) | ConstVal::Aggregate(..) | ConstVal::Unevaluated(..) => bug!(
458 "MIR must not use `{:?}` (aggregates are expanded to MIR rvalues)",
476 "aaaaaaaaaaaaa" | "bbbbbbbbbbbbb" | "cccccccccccccccccccccccccccccccccccccccccccc"
478 "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => {
485 // Preserve block around expressions with condition.
508 // Strip leading `|` in match arm patterns
512 Foo::A => println!("No vert single condition"),
513 Foo::B | Foo::C => println!("Center vert two conditions"),
514 Foo::D => println!("Preceding vert single condition"),
515 Foo::E | Foo::F => println!("Preceding vert over two lines"),
516 Foo::G | Foo::H => println!("Trailing vert over two lines"),
517 // Comment on its own line
518 Foo::I => println!("With comment"), // Comment after line
536 Tok::TypeOf if prec <= 16 => {}
544 DevtoolScriptControlMsg::WantsLiveNotifications(id, to_send) => {
545 match documents.find_window(id) {
547 devtools::handle_wants_live_notifications(window.upcast(), to_send)
549 None => return warn!("Message sent to closed pipeline {}.", id),
558 match input.trim().parse::<f64>() {
561 // A valid number is the same as what rust considers to be valid,
562 // except for +1., NaN, and Infinity.
563 val.is_infinite() || val.is_nan() || input.ends_with(".") || input.starts_with("+")
572 } if num_context.is_ok(context.parsing_mode, value) => {
573 return NoCalcLength::parse_dimension(context, value, unit)
574 .map(LengthOrPercentage::Length)
575 .map_err(|()| location.new_unexpected_token_error(token.clone()))