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),
169 d => println!("a", b),
172 h => println!("a", b), // h comment
173 i => vec![1, 2], // i comment
174 j => vec![3; 4], // j comment
176 k => println!("a", b),
181 // Rewrite splits macro
182 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => {
185 // Rewrite splits macro
186 oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => {
189 // Macro support fails to recognise this macro as splittable
190 // We push the whole expr to a new line, TODO split this macro as well
191 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => {
194 // q, r and s: Rewrite splits match arm
195 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq => {
198 rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr => {
201 ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss => {
204 // Funky bracketing styles
205 t => println! {"a", b},
208 w => println!["a", b],
211 // Brackets with comments
212 tc => println! {"a", b}, // comment
213 uc => vec![1, 2], // comment
214 vc => vec![3; 4], // comment
215 wc => println!["a", b], // comment
216 xc => vec![1, 2], // comment
217 yc => vec![3; 4], // comment
218 yd => looooooooooooooooooooooooooooooooooooooooooooooooooooooooong_func(
219 aaaaaaaaaa, bbbbbbbbbb, cccccccccc, dddddddddd,
227 CompressionMode::DiscardNewline | CompressionMode::CompressWhitespaceNewline => {
230 ast::ItemConst(ref typ, ref expr) => {
231 self.process_static_or_const_item(item, &typ, &expr)
238 match resolution.last_private {
239 LastImport { .. } => false,
246 1 => unsafe { std::intrinsics::abort() },
253 Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
254 HTMLElementTypeId::HTMLCanvasElement,
256 Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
257 HTMLElementTypeId::HTMLObjectElement,
258 ))) => s.has_object_data(),
259 Some(NodeTypeId::Element(_)) => false,
268 def::DefConst(def_id) | def::DefAssociatedConst(def_id) => {
269 match const_eval::lookup_const_by_id(cx.tcx, def_id, Some(self.pat.id)) {
270 Some(const_expr) => x,
282 hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) => {
283 result.push(StmtRef::Mirror(Box::new(Stmt {
285 kind: StmtKind::Expr {
286 scope: cx.tcx.region_maps.node_extent(id),
297 BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true,
298 BiAnd | BiOr | BiAdd | BiSub | BiMul | BiDiv | BiRem | BiBitXor | BiBitAnd | BiBitOr
299 | BiShl | BiShr => false,
305 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
306 if foooooooooooooo && barrrrrrrrrrrr => {}
307 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
308 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
309 if foooooooooooooo && barrrrrrrrrrrr => {}
310 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
311 if fooooooooooooooooooooo
312 && (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
313 || cccccccccccccccccccccccccccccccccccccccc) => {}
319 sfEvtClosed => Closed,
321 let e = unsafe { *event.size.as_ref() };
328 sfEvtLostFocus => LostFocus,
329 sfEvtGainedFocus => GainedFocus,
330 sfEvtTextEntered => TextEntered {
332 ::std::char::from_u32((*event.text.as_ref()).unicode)
333 .expect("Invalid unicode encountered on TextEntered event")
337 let e = unsafe { event.key.as_ref() };
340 code: unsafe { ::std::mem::transmute(e.code) },
341 alt: e.alt.to_bool(),
342 ctrl: e.control.to_bool(),
343 shift: e.shift.to_bool(),
344 system: e.system.to_bool(),
347 sfEvtKeyReleased => {
348 let e = unsafe { event.key.as_ref() };
351 code: unsafe { ::std::mem::transmute(e.code) },
352 alt: e.alt.to_bool(),
353 ctrl: e.control.to_bool(),
354 shift: e.shift.to_bool(),
355 system: e.system.to_bool(),
362 let bar = Some(true);
363 let foo = Some(true);
365 bar.and_then(|_| match foo {
376 artists: match reader.evaluate(".//mb:recording/mb:artist-credit/mb:name-credit")? {
377 Nodeset(nodeset) => {
378 let res: Result<Vec<ArtistRef>, ReadError> = nodeset
381 XPathNodeReader::new(node, &context).and_then(|r| ArtistRef::from_xml(&r))
393 REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT => {
394 "internal_spec_insert_internal_spec_insert_internal_spec_insert"
396 _ => "reorder_something",
405 TaskState::Started => "started",
406 TaskState::Success => "success",
407 TaskState::Failed => "failed",
413 fn match_with_near_max_width() {
414 let (this_line_uses_99_characters_and_is_formatted_properly, x012345) = match some_expression {
415 _ => unimplemented!(),
418 let (should_be_formatted_like_the_line_above_using_100_characters, x0) = match some_expression {
419 _ => unimplemented!(),
422 let (should_put_the_brace_on_the_next_line_using_101_characters, x0000) = match some_expression
424 _ => unimplemented!(),
432 | Variant::Tag6 => {}
436 fn match_with_trailing_spaces() {
438 #![allow(simple_match)]
452 impl<'tcx> Const<'tcx> {
453 pub fn from_constval<'a>() -> Const<'tcx> {
454 let val = match *cv {
455 ConstVal::Variant(_) | ConstVal::Aggregate(..) | ConstVal::Unevaluated(..) => bug!(
456 "MIR must not use `{:?}` (aggregates are expanded to MIR rvalues)",
474 "aaaaaaaaaaaaa" | "bbbbbbbbbbbbb" | "cccccccccccccccccccccccccccccccccccccccccccc"
476 "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => {
483 // Preserve block around expressions with condition.
506 // Strip leading `|` in match arm patterns
510 Foo::A => println!("No vert single condition"),
511 Foo::B | Foo::C => println!("Center vert two conditions"),
512 Foo::D => println!("Preceding vert single condition"),
513 Foo::E | Foo::F => println!("Preceding vert over two lines"),
514 Foo::G | Foo::H => println!("Trailing vert over two lines"),
515 // Comment on its own line
516 Foo::I => println!("With comment"), // Comment after line
534 Tok::TypeOf if prec <= 16 => {}
542 DevtoolScriptControlMsg::WantsLiveNotifications(id, to_send) => {
543 match documents.find_window(id) {
545 devtools::handle_wants_live_notifications(window.upcast(), to_send)
547 None => return warn!("Message sent to closed pipeline {}.", id),
556 match input.trim().parse::<f64>() {
559 // A valid number is the same as what rust considers to be valid,
560 // except for +1., NaN, and Infinity.
561 val.is_infinite() || val.is_nan() || input.ends_with(".") || input.starts_with("+")
570 } if num_context.is_ok(context.parsing_mode, value) => {
571 return NoCalcLength::parse_dimension(context, value, unit)
572 .map(LengthOrPercentage::Length)
573 .map_err(|()| location.new_unexpected_token_error(token.clone()));