1 // rustfmt-normalize_comments: true
10 c => { // Another comment.
16 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
17 Pattern1 | Pattern2 | Pattern3 => false,
18 Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn |
19 Paternnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => {
22 Patternnnnnnnnnnnnnnnnnnn |
23 Patternnnnnnnnnnnnnnnnnnn |
24 Patternnnnnnnnnnnnnnnnnnn |
25 Patternnnnnnnnnnnnnnnnnnn => meh,
27 Patternnnnnnnnnnnnnnnnnnn |
28 Patternnnnnnnnnnnnnnnnnnn if looooooooooooooooooong_guard => meh,
30 Patternnnnnnnnnnnnnnnnnnnnnnnnn |
31 Patternnnnnnnnnnnnnnnnnnnnnnnnn if looooooooooooooooooooooooooooooooooooooooong_guard =>
34 // Test that earlier patterns can take the guard space
35 (aaaa, bbbbb, ccccccc, aaaaa, bbbbbbbb, cccccc, aaaa, bbbbbbbb, cccccc, dddddd) |
36 Patternnnnnnnnnnnnnnnnnnnnnnnnn if loooooooooooooooooooooooooooooooooooooooooong_guard => {}
39 ast::PathParameters::AngleBracketedParameters(ref data) if data.lifetimes.len() > 0 ||
40 data.types.len() > 0 ||
41 data.bindings.len() > 0 => {}
44 let whatever = match something {
47 // Comment on an attribute.
49 // Comment after an attribute.
56 // Test that a match on an overflow line is laid out properly.
59 match xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {
60 Some(sub_span) => Some(sub_span),
65 // Test that one-line bodies align.
68 Variableeeeeeeeeeeeeeeeee => ( "variable",
69 vec!("id", "name", "qualname",
70 "value", "type", "scopeid"),
73 Enummmmmmmmmmmmmmmmmmmmm => ("enum",
74 vec!("id","qualname","scopeid","value"),
77 Variantttttttttttttttttttttttt => ("variant",
89 y=>{/*Block with comment. Preserve me.*/ }
105 let _ = match Some(1) {
123 // collapsing here is safe
124 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff => {
126 // collapsing here exceeds line length
127 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffg => {
129 h => { // comment above block
132 } // 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
153 p => { // Don't collapse me
171 a => println!("a", b),
183 h => println!("a", b), // h comment
184 i => vec!(1, 2), // i comment
185 j => vec!(3; 4), // j comment
187 k => println!("a", b),
192 // Rewrite splits macro
193 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => println!("a", b),
194 // Rewrite splits macro
195 oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => vec!(1, 2),
196 // Macro support fails to recognise this macro as splittable
197 // We push the whole expr to a new line, TODO split this macro as well
198 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => vec!(3; 4),
199 // q, r and s: Rewrite splits match arm
200 qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq => println!("a", b),
201 rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr => vec!(1, 2),
202 ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss => vec!(3; 4),
203 // Funky bracketing styles
204 t => println!{"a", b},
207 w => println!["a", b],
210 // Brackets with comments
211 tc => println!{"a", b}, // comment
212 uc => vec!{1, 2}, // comment
213 vc =>vec!{3; 4}, // comment
214 wc =>println!["a", b], // comment
215 xc => vec![1,2], // comment
216 yc => vec![3; 4], // comment
218 looooooooooooooooooooooooooooooooooooooooooooooooooooooooong_func(aaaaaaaaaa,
228 CompressionMode::DiscardNewline | CompressionMode::CompressWhitespaceNewline => ch ==
230 ast::ItemConst(ref typ, ref expr) => self.process_static_or_const_item(item,
238 match resolution.last_private {LastImport{..} => false, _ => true};
243 1 => unsafe { std::intrinsics::abort() },
250 Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
251 HTMLElementTypeId::HTMLCanvasElement))) => true,
252 Some(NodeTypeId::Element(ElementTypeId::HTMLElement(
253 HTMLElementTypeId::HTMLObjectElement))) => s.has_object_data(),
254 Some(NodeTypeId::Element(_)) => false,
260 def::DefConst(def_id) | def::DefAssociatedConst(def_id) =>
261 match const_eval::lookup_const_by_id(cx.tcx, def_id, Some(self.pat.id)) {
262 Some(const_expr) => { x }}}}}}}
267 hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) =>
270 Box::new(Stmt { span: stmt.span,
271 kind: StmtKind::Expr {
272 scope: cx.tcx.region_maps.node_extent(id),
273 expr: expr.to_ref() } }))),
280 BiEq | BiLt | BiLe | BiNe | BiGt | BiGe =>
282 BiAnd | BiOr | BiAdd | BiSub | BiMul | BiDiv | BiRem |
283 BiBitXor | BiBitAnd | BiBitOr | BiShl | BiShr =>
290 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if foooooooooooooo && barrrrrrrrrrrr => {}
291 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if foooooooooooooo && barrrrrrrrrrrr => {}
292 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
293 if fooooooooooooooooooooo &&
294 (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || cccccccccccccccccccccccccccccccccccccccc) => {}
300 sfEvtClosed => Closed,
302 let e = unsafe { *event.size.as_ref() };
309 sfEvtLostFocus => LostFocus,
310 sfEvtGainedFocus => GainedFocus,
311 sfEvtTextEntered => {
314 ::std::char::from_u32((*event.text.as_ref()).unicode)
315 .expect("Invalid unicode encountered on TextEntered event")
320 let e = unsafe { event.key.as_ref() };
323 code: unsafe { ::std::mem::transmute(e.code) },
324 alt: e.alt.to_bool(),
325 ctrl: e.control.to_bool(),
326 shift: e.shift.to_bool(),
327 system: e.system.to_bool(),
330 sfEvtKeyReleased => {
331 let e = unsafe { event.key.as_ref() };
334 code: unsafe { ::std::mem::transmute(e.code) },
335 alt: e.alt.to_bool(),
336 ctrl: e.control.to_bool(),
337 shift: e.shift.to_bool(),
338 system: e.system.to_bool(),
345 let bar = Some(true);
346 let foo = Some(true);
361 artists: match reader.evaluate(".//mb:recording/mb:artist-credit/mb:name-credit")? {
362 Nodeset(nodeset) => {
363 let res: Result<Vec<ArtistRef>, ReadError> = nodeset
366 XPathNodeReader::new(node, &context).and_then(|r| ArtistRef::from_xml(&r))
378 REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT => "internal_spec_insert_internal_spec_insert_internal_spec_insert",
379 _ => "reorder_something",
384 foobar(f, "{}", match *self {
385 TaskState::Started => "started",
386 TaskState::Success => "success",
387 TaskState::Failed => "failed",
392 fn match_with_near_max_width() {
393 let (this_line_uses_99_characters_and_is_formatted_properly, x012345) = match some_expression {
394 _ => unimplemented!(),
397 let (should_be_formatted_like_the_line_above_using_100_characters, x0) = match some_expression {
398 _ => unimplemented!(),
401 let (should_put_the_brace_on_the_next_line_using_101_characters, x0000) = match some_expression
403 _ => unimplemented!(),
406 Variant::Tag | Variant::Tag2 | Variant::Tag3 | Variant::Tag4 | Variant::Tag5 | Variant::Tag6 =>
411 fn match_with_trailing_spaces() {
413 #![allow(simple_match)]
430 impl<'tcx> Const<'tcx> {
431 pub fn from_constval<'a>() -> Const<'tcx> {
432 let val = match *cv {
433 ConstVal::Variant(_) | ConstVal::Aggregate(..) | ConstVal::Unevaluated(..) => bug!("MIR must not use `{:?}` (aggregates are expanded to MIR rvalues)", cv),
450 "aaaaaaaaaaaaa" | "bbbbbbbbbbbbb" | "cccccccccccccccccccccccccccccccccccccccccccc" if true => {}
451 "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => true,
456 // Preserve block around expressions with condition.
479 // Strip leading `|` in match arm patterns
483 Foo::A => println!("No vert single condition"),
484 Foo::B | Foo::C => println!("Center vert two conditions"),
485 | Foo::D => println!("Preceding vert single condition"),
487 | Foo::F => println!("Preceding vert over two lines"),
489 Foo::H => println!("Trailing vert over two lines"),
490 // Comment on its own line
491 | Foo::I => println!("With comment"), // Comment after line
504 | Tok::Delete if prec <= 16 => {
507 Tok::TypeOf if prec <= 16 => {}
515 DevtoolScriptControlMsg::WantsLiveNotifications(id, to_send) => {
516 match documents.find_window(id) {
517 Some(window) => devtools::handle_wants_live_notifications(window.upcast(), to_send),
518 None => return warn!("Message sent to closed pipeline {}.", id),
527 match input.trim().parse::<f64>() {
530 // A valid number is the same as what rust considers to be valid,
531 // except for +1., NaN, and Infinity.
532 val.is_infinite() || val
533 .is_nan() || input.ends_with(".") || input.starts_with("+")
544 } if num_context.is_ok(context.parsing_mode, value) =>
546 return NoCalcLength::parse_dimension(context, value, unit)
547 .map(LengthOrPercentage::Length)
548 .map_err(|()| location.new_unexpected_token_error(token.clone()))