From b4233d2a34f7b851ed96931b4204a66d0627fc79 Mon Sep 17 00:00:00 2001 From: WhizSid Date: Sun, 27 Sep 2020 17:36:21 +0530 Subject: [PATCH 1/6] Fixed comment formatting issue between assignment --- src/formatting/expr.rs | 44 ++++++++++++++++++++------------------ src/formatting/items.rs | 28 ++++++++++++++++++++++-- tests/source/issue-4427.rs | 7 ++++++ tests/target/issue-4427.rs | 5 +++++ 4 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 tests/source/issue-4427.rs create mode 100644 tests/target/issue-4427.rs diff --git a/src/formatting/expr.rs b/src/formatting/expr.rs index 30b9acb5d51..17b00e55f58 100644 --- a/src/formatting/expr.rs +++ b/src/formatting/expr.rs @@ -892,22 +892,12 @@ impl<'a> ControlFlow<'a> { .block_indent(context.config) .to_string_with_newline(context.config); let shape = pat_shape.block_indent(context.config.tab_spaces()); - let comment = format!( - "{}{}", + format!( + "{}{}{}", newline, rewrite_missing_comment(comments_span, shape, context)?, - ); - let lhs = format!("{}{}{}{}", matcher, pat_string, self.connector, comment); - let orig_rhs = Some(format!("{}{}", newline, expr.rewrite(context, shape)?)); - let rhs = choose_rhs( - context, - expr, - cond_shape, - orig_rhs, - RhsTactics::Default, - true, - )?; - return Some(format!("{}{}", lhs, rhs)); + newline + ) } }; let result = format!( @@ -1951,17 +1941,20 @@ pub(crate) fn rewrite_assign_rhs_expr( } else { 0 }); + // 1 = space between operator and rhs. let orig_shape = shape.offset_left(last_line_width + 1).unwrap_or(Shape { width: 0, offset: shape.offset + last_line_width + 1, ..shape }); - let has_rhs_comment = if let Some(offset) = lhs.find_last_uncommented("=") { - lhs.trim_end().len() > offset + 1 - } else { - false - }; + let (has_rhs_comment, lhs_ends_with_line_comment) = + if let Some(offset) = lhs.find_last_uncommented("=") { + let lhs_end = &lhs[offset..lhs.len()]; + (lhs.trim_end().len() > offset + 1, lhs_end.contains("//")) + } else { + (false, false) + }; choose_rhs( context, @@ -1970,6 +1963,7 @@ pub(crate) fn rewrite_assign_rhs_expr( ex.rewrite(context, orig_shape), rhs_tactics, has_rhs_comment, + lhs_ends_with_line_comment, ) } @@ -1992,12 +1986,15 @@ fn choose_rhs( orig_rhs: Option, rhs_tactics: RhsTactics, has_rhs_comment: bool, + lhs_ends_with_line_comment: bool, ) -> Option { match orig_rhs { Some(ref new_str) if !new_str.contains('\n') && unicode_str_width(new_str) <= shape.width => { - Some(format!(" {}", new_str)) + let before_space_str = if lhs_ends_with_line_comment { "" } else { " " }; + + Some(format!("{}{}", before_space_str, new_str)) } _ => { // Expression did not fit on the same line as the identifier. @@ -2008,7 +2005,12 @@ fn choose_rhs( .indent .block_indent(context.config) .to_string_with_newline(context.config); - let before_space_str = if has_rhs_comment { "" } else { " " }; + + let before_space_str = if has_rhs_comment || lhs_ends_with_line_comment { + "" + } else { + " " + }; match (orig_rhs, new_rhs) { (Some(ref orig_rhs), Some(ref new_rhs)) diff --git a/src/formatting/items.rs b/src/formatting/items.rs index dc6a0649ed2..02c78516357 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -13,7 +13,7 @@ use crate::config::{BraceStyle, Config, IndentStyle}; use crate::formatting::{ attr::filter_inline_attrs, comment::{ - combine_strs_with_missing_comments, contains_comment, is_last_comment_block, + combine_strs_with_missing_comments, comment_style, contains_comment, is_last_comment_block, recover_comment_removed, recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented, }, @@ -1878,7 +1878,31 @@ fn rewrite_static( }; if let Some(expr) = static_parts.expr_opt { - let lhs = format!("{}{} =", prefix, ty_str); + let comments_lo = context.snippet_provider.span_after(static_parts.span, "="); + let expr_lo = expr.span.lo(); + let comments_span = mk_sp(comments_lo, expr_lo); + + let missing_comments = match rewrite_missing_comment(comments_span, ty_shape, context) { + None => "".to_owned(), + Some(comment) if comment.is_empty() => "".to_owned(), + Some(comment) if comment_style(&comment, false).is_line_comment() => { + let newline = &ty_shape + .indent + .block_indent(context.config) + .to_string_with_newline(context.config); + let shape = ty_shape.block_indent(context.config.tab_spaces()); + format!( + "{}{}{}", + newline, + rewrite_missing_comment(comments_span, shape, context)?, + newline + ) + } + Some(comment) => format!(" {}", comment), + }; + + let lhs = format!("{}{} ={}", prefix, ty_str, missing_comments); + // 1 = ; let remaining_width = context.budget(offset.block_indent + 1); rewrite_assign_rhs( diff --git a/tests/source/issue-4427.rs b/tests/source/issue-4427.rs new file mode 100644 index 00000000000..a81718a0c7d --- /dev/null +++ b/tests/source/issue-4427.rs @@ -0,0 +1,7 @@ +const A: usize = + // Some constant + 2; + +const B: usize = +/* Some constant */ +3; diff --git a/tests/target/issue-4427.rs b/tests/target/issue-4427.rs new file mode 100644 index 00000000000..fa75de33d79 --- /dev/null +++ b/tests/target/issue-4427.rs @@ -0,0 +1,5 @@ +const A: usize = + // Some constant + 2; + +const B: usize = /* Some constant */ 3; From aec621841b4a2c44b68380a8f7fc8b13958d916a Mon Sep 17 00:00:00 2001 From: WhizSid Date: Tue, 29 Sep 2020 02:01:58 +0530 Subject: [PATCH 2/6] rewrite_rhs_with_comments method --- src/formatting/expr.rs | 96 ++++++++++++++++---------------------- src/formatting/items.rs | 29 +++--------- tests/source/issue-4427.rs | 2 +- tests/target/issue-4427.rs | 4 +- 4 files changed, 50 insertions(+), 81 deletions(-) diff --git a/src/formatting/expr.rs b/src/formatting/expr.rs index 17b00e55f58..9c58570a4e2 100644 --- a/src/formatting/expr.rs +++ b/src/formatting/expr.rs @@ -11,9 +11,8 @@ use crate::formatting::{ chains::rewrite_chain, closures, comment::{ - combine_strs_with_missing_comments, comment_style, contains_comment, - recover_comment_removed, rewrite_comment, rewrite_missing_comment, CharClasses, - FindUncommented, + combine_strs_with_missing_comments, contains_comment, recover_comment_removed, + rewrite_comment, rewrite_missing_comment, CharClasses, FindUncommented, }, lists::{ definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape, @@ -868,43 +867,16 @@ impl<'a> ControlFlow<'a> { .span_after(self.span, self.connector.trim()); let comments_span = mk_sp(comments_lo, expr.span.lo()); - let missing_comments = match rewrite_missing_comment(comments_span, cond_shape, context) - { - None => "".to_owned(), - Some(comment) if self.connector.is_empty() || comment.is_empty() => comment, - // Handle same-line block comments: - // if let Some(foo) = /*bar*/ baz { ... } - // if let Some(ref /*def*/ mut /*abc*/ state)... - Some(comment) - if !comment_style(&comment, false).is_line_comment() - && !comment.contains('\n') => - { - format!(" {}", comment) - } - // Handle sequence of multiple inline comments: - // if let Some(n) = - // // this is a test comment - // // with another - // foo { .... } - Some(_) => { - let newline = &cond_shape - .indent - .block_indent(context.config) - .to_string_with_newline(context.config); - let shape = pat_shape.block_indent(context.config.tab_spaces()); - format!( - "{}{}{}", - newline, - rewrite_missing_comment(comments_span, shape, context)?, - newline - ) - } - }; - let result = format!( - "{}{}{}{}", - matcher, pat_string, self.connector, missing_comments + let result = format!("{}{}{}", matcher, pat_string, self.connector); + + return rewrite_assign_rhs_with_comments( + context, + result, + expr, + cond_shape, + RhsTactics::Default, + comments_span, ); - return rewrite_assign_rhs(context, result, expr, cond_shape); } let expr_rw = expr.rewrite(context, cond_shape); @@ -1948,13 +1920,11 @@ pub(crate) fn rewrite_assign_rhs_expr( offset: shape.offset + last_line_width + 1, ..shape }); - let (has_rhs_comment, lhs_ends_with_line_comment) = - if let Some(offset) = lhs.find_last_uncommented("=") { - let lhs_end = &lhs[offset..lhs.len()]; - (lhs.trim_end().len() > offset + 1, lhs_end.contains("//")) - } else { - (false, false) - }; + let has_rhs_comment = if let Some(offset) = lhs.find_last_uncommented("=") { + lhs.trim_end().len() > offset + 1 + } else { + false + }; choose_rhs( context, @@ -1963,7 +1933,6 @@ pub(crate) fn rewrite_assign_rhs_expr( ex.rewrite(context, orig_shape), rhs_tactics, has_rhs_comment, - lhs_ends_with_line_comment, ) } @@ -1979,6 +1948,28 @@ pub(crate) fn rewrite_assign_rhs_with, R: Rewrite>( Some(lhs + &rhs) } +pub(crate) fn rewrite_assign_rhs_with_comments, R: Rewrite>( + context: &RewriteContext<'_>, + lhs: S, + ex: &R, + shape: Shape, + rhs_tactics: RhsTactics, + between: Span, +) -> Option { + let lhs = lhs.into(); + let rhs = rewrite_assign_rhs_expr(context, &lhs, ex, shape, rhs_tactics)?; + let comment_shape = shape.block_left(context.config.tab_spaces())?; + + let comment = context.snippet_provider.span_to_snippet(between)?; + if comment.trim().starts_with("/") { + let rhs = rhs.trim_start(); + + combine_strs_with_missing_comments(context, &lhs, &rhs, between, comment_shape, false) + } else { + Some(lhs + &rhs) + } +} + fn choose_rhs( context: &RewriteContext<'_>, expr: &R, @@ -1986,15 +1977,12 @@ fn choose_rhs( orig_rhs: Option, rhs_tactics: RhsTactics, has_rhs_comment: bool, - lhs_ends_with_line_comment: bool, ) -> Option { match orig_rhs { Some(ref new_str) if !new_str.contains('\n') && unicode_str_width(new_str) <= shape.width => { - let before_space_str = if lhs_ends_with_line_comment { "" } else { " " }; - - Some(format!("{}{}", before_space_str, new_str)) + Some(format!(" {}", new_str)) } _ => { // Expression did not fit on the same line as the identifier. @@ -2006,11 +1994,7 @@ fn choose_rhs( .block_indent(context.config) .to_string_with_newline(context.config); - let before_space_str = if has_rhs_comment || lhs_ends_with_line_comment { - "" - } else { - " " - }; + let before_space_str = if has_rhs_comment { "" } else { " " }; match (orig_rhs, new_rhs) { (Some(ref orig_rhs), Some(ref new_rhs)) diff --git a/src/formatting/items.rs b/src/formatting/items.rs index 02c78516357..299e468556e 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -13,13 +13,13 @@ use crate::config::{BraceStyle, Config, IndentStyle}; use crate::formatting::{ attr::filter_inline_attrs, comment::{ - combine_strs_with_missing_comments, comment_style, contains_comment, is_last_comment_block, + combine_strs_with_missing_comments, contains_comment, is_last_comment_block, recover_comment_removed, recover_missing_comment_in_span, rewrite_missing_comment, FindUncommented, }, expr::{ is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, rewrite_assign_rhs_expr, - rewrite_assign_rhs_with, RhsTactics, + rewrite_assign_rhs_with, rewrite_assign_rhs_with_comments, RhsTactics, }, lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator}, macros::{rewrite_macro, MacroPosition}, @@ -1882,34 +1882,17 @@ fn rewrite_static( let expr_lo = expr.span.lo(); let comments_span = mk_sp(comments_lo, expr_lo); - let missing_comments = match rewrite_missing_comment(comments_span, ty_shape, context) { - None => "".to_owned(), - Some(comment) if comment.is_empty() => "".to_owned(), - Some(comment) if comment_style(&comment, false).is_line_comment() => { - let newline = &ty_shape - .indent - .block_indent(context.config) - .to_string_with_newline(context.config); - let shape = ty_shape.block_indent(context.config.tab_spaces()); - format!( - "{}{}{}", - newline, - rewrite_missing_comment(comments_span, shape, context)?, - newline - ) - } - Some(comment) => format!(" {}", comment), - }; - - let lhs = format!("{}{} ={}", prefix, ty_str, missing_comments); + let lhs = format!("{}{} =", prefix, ty_str); // 1 = ; let remaining_width = context.budget(offset.block_indent + 1); - rewrite_assign_rhs( + rewrite_assign_rhs_with_comments( context, &lhs, &**expr, Shape::legacy(remaining_width, offset.block_only()), + RhsTactics::Default, + comments_span, ) .and_then(|res| recover_comment_removed(res, static_parts.span, context)) .or_else(|| { diff --git a/tests/source/issue-4427.rs b/tests/source/issue-4427.rs index a81718a0c7d..c5a53d35423 100644 --- a/tests/source/issue-4427.rs +++ b/tests/source/issue-4427.rs @@ -3,5 +3,5 @@ const A: usize = 2; const B: usize = -/* Some constant */ +/* constant */ 3; diff --git a/tests/target/issue-4427.rs b/tests/target/issue-4427.rs index fa75de33d79..ccc60a7c3f4 100644 --- a/tests/target/issue-4427.rs +++ b/tests/target/issue-4427.rs @@ -2,4 +2,6 @@ const A: usize = // Some constant 2; -const B: usize = /* Some constant */ 3; +const B: usize = + /* constant */ + 3; From e3f2383c9413548c0223e8361ec0a39ad4b1d6ee Mon Sep 17 00:00:00 2001 From: WhizSid Date: Tue, 29 Sep 2020 02:13:50 +0530 Subject: [PATCH 3/6] Add more tests --- tests/source/issue-4427.rs | 3 +++ tests/target/issue-4427.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/source/issue-4427.rs b/tests/source/issue-4427.rs index c5a53d35423..6cd5f3aae02 100644 --- a/tests/source/issue-4427.rs +++ b/tests/source/issue-4427.rs @@ -5,3 +5,6 @@ const A: usize = const B: usize = /* constant */ 3; + +const C : usize + = /* foo */5; diff --git a/tests/target/issue-4427.rs b/tests/target/issue-4427.rs index ccc60a7c3f4..7a7dbdba079 100644 --- a/tests/target/issue-4427.rs +++ b/tests/target/issue-4427.rs @@ -5,3 +5,5 @@ const A: usize = const B: usize = /* constant */ 3; + +const C: usize = /* foo */ 5; From 944ffa99892a8f74026bbc91c5e821a478403fe8 Mon Sep 17 00:00:00 2001 From: WhizSid Date: Wed, 30 Sep 2020 04:13:09 +0530 Subject: [PATCH 4/6] Added more test cases and optimized --- src/formatting/expr.rs | 76 +++++++++++++++++++++++++++++--------- src/formatting/items.rs | 1 + tests/source/issue-4427.rs | 21 +++++++++++ tests/target/issue-4427.rs | 21 +++++++++++ tmp/test.rs | 30 +++++++++++++++ 5 files changed, 132 insertions(+), 17 deletions(-) create mode 100644 tmp/test.rs diff --git a/src/formatting/expr.rs b/src/formatting/expr.rs index 9c58570a4e2..fbc74d3338a 100644 --- a/src/formatting/expr.rs +++ b/src/formatting/expr.rs @@ -11,8 +11,9 @@ use crate::formatting::{ chains::rewrite_chain, closures, comment::{ - combine_strs_with_missing_comments, contains_comment, recover_comment_removed, - rewrite_comment, rewrite_missing_comment, CharClasses, FindUncommented, + combine_strs_with_missing_comments, comment_style, contains_comment, + recover_comment_removed, rewrite_comment, rewrite_missing_comment, CharClasses, + FindUncommented, }, lists::{ definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape, @@ -867,16 +868,54 @@ impl<'a> ControlFlow<'a> { .span_after(self.span, self.connector.trim()); let comments_span = mk_sp(comments_lo, expr.span.lo()); - let result = format!("{}{}{}", matcher, pat_string, self.connector); - return rewrite_assign_rhs_with_comments( - context, - result, - expr, - cond_shape, - RhsTactics::Default, - comments_span, + let missing_comments = match rewrite_missing_comment(comments_span, cond_shape, context) + { + None => "".to_owned(), + Some(comment) if self.connector.is_empty() || comment.is_empty() => comment, + // Handle same-line block comments: + // if let Some(foo) = /*bar*/ baz { ... } + // if let Some(ref /*def*/ mut /*abc*/ state)... + Some(comment) + if !comment_style(&comment, false).is_line_comment() + && !comment.contains('\n') => + { + format!(" {}", comment) + } + // Handle sequence of multiple inline comments: + // if let Some(n) = + // // this is a test comment + // // with another + // foo { .... } + Some(_) => { + let newline = &cond_shape + .indent + .block_indent(context.config) + .to_string_with_newline(context.config); + let shape = pat_shape.block_indent(context.config.tab_spaces()); + let comment = format!( + "{}{}", + newline, + rewrite_missing_comment(comments_span, shape, context)?, + ); + let lhs = format!("{}{}{}{}", matcher, pat_string, self.connector, comment); + let orig_rhs = Some(format!("{}{}", newline, expr.rewrite(context, shape)?)); + let rhs = choose_rhs( + context, + expr, + cond_shape, + orig_rhs, + RhsTactics::Default, + true, + )?; + return Some(format!("{}{}", lhs, rhs)); + } + }; + let result = format!( + "{}{}{}{}", + matcher, pat_string, self.connector, missing_comments ); + return rewrite_assign_rhs(context, result, expr, cond_shape); } let expr_rw = expr.rewrite(context, cond_shape); @@ -1913,7 +1952,6 @@ pub(crate) fn rewrite_assign_rhs_expr( } else { 0 }); - // 1 = space between operator and rhs. let orig_shape = shape.offset_left(last_line_width + 1).unwrap_or(Shape { width: 0, @@ -1954,17 +1992,21 @@ pub(crate) fn rewrite_assign_rhs_with_comments, R: Rewrite>( ex: &R, shape: Shape, rhs_tactics: RhsTactics, - between: Span, + between_span: Span, + allow_extend: bool, ) -> Option { let lhs = lhs.into(); + let contains_comment = contains_comment(context.snippet(between_span)); + let shape = if contains_comment { + shape.block_left(context.config.tab_spaces())? + } else { + shape + }; let rhs = rewrite_assign_rhs_expr(context, &lhs, ex, shape, rhs_tactics)?; - let comment_shape = shape.block_left(context.config.tab_spaces())?; - let comment = context.snippet_provider.span_to_snippet(between)?; - if comment.trim().starts_with("/") { + if contains_comment { let rhs = rhs.trim_start(); - - combine_strs_with_missing_comments(context, &lhs, &rhs, between, comment_shape, false) + combine_strs_with_missing_comments(context, &lhs, &rhs, between_span, shape, allow_extend) } else { Some(lhs + &rhs) } diff --git a/src/formatting/items.rs b/src/formatting/items.rs index 299e468556e..615526f92ff 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -1893,6 +1893,7 @@ fn rewrite_static( Shape::legacy(remaining_width, offset.block_only()), RhsTactics::Default, comments_span, + true, ) .and_then(|res| recover_comment_removed(res, static_parts.span, context)) .or_else(|| { diff --git a/tests/source/issue-4427.rs b/tests/source/issue-4427.rs index 6cd5f3aae02..e14e039b98f 100644 --- a/tests/source/issue-4427.rs +++ b/tests/source/issue-4427.rs @@ -8,3 +8,24 @@ const B: usize = const C : usize = /* foo */5; + +const D: usize = // baz +/* Some constant */ + /* ba */ + { 3 + // foo + }; +const E: usize= /* foo */5; +const F: usize = +{ + 7 + }; +const G: usize = /* foooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000xx00 */ 5; + const H: usize = /* asdfasdf */ match G > 1 { + true => 1, + false => 3, + }; + + pub static FOO_BAR: Vec = //f + { + vec![]}; diff --git a/tests/target/issue-4427.rs b/tests/target/issue-4427.rs index 7a7dbdba079..c8a37ead8cb 100644 --- a/tests/target/issue-4427.rs +++ b/tests/target/issue-4427.rs @@ -7,3 +7,24 @@ const B: usize = 3; const C: usize = /* foo */ 5; + +const D: usize = // baz + /* Some constant */ + /* ba */ + { + 3 + // foo + }; +const E: usize = /* foo */ 5; +const F: usize = { 7 }; +const G: usize = + /* foooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000xx00 */ + 5; +const H: usize = /* asdfasdf */ + match G > 1 { + true => 1, + false => 3, + }; + +pub static FOO_BAR: Vec = //f + { vec![] }; diff --git a/tmp/test.rs b/tmp/test.rs new file mode 100644 index 00000000000..c8a37ead8cb --- /dev/null +++ b/tmp/test.rs @@ -0,0 +1,30 @@ +const A: usize = + // Some constant + 2; + +const B: usize = + /* constant */ + 3; + +const C: usize = /* foo */ 5; + +const D: usize = // baz + /* Some constant */ + /* ba */ + { + 3 + // foo + }; +const E: usize = /* foo */ 5; +const F: usize = { 7 }; +const G: usize = + /* foooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000xx00 */ + 5; +const H: usize = /* asdfasdf */ + match G > 1 { + true => 1, + false => 3, + }; + +pub static FOO_BAR: Vec = //f + { vec![] }; From ab168abc878db5e3b29e154f2ac56dddd16b233e Mon Sep 17 00:00:00 2001 From: WhizSid Date: Wed, 30 Sep 2020 04:17:25 +0530 Subject: [PATCH 5/6] Removed extra new lines --- src/formatting/expr.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/formatting/expr.rs b/src/formatting/expr.rs index fbc74d3338a..b53496affa8 100644 --- a/src/formatting/expr.rs +++ b/src/formatting/expr.rs @@ -868,7 +868,6 @@ impl<'a> ControlFlow<'a> { .span_after(self.span, self.connector.trim()); let comments_span = mk_sp(comments_lo, expr.span.lo()); - let missing_comments = match rewrite_missing_comment(comments_span, cond_shape, context) { None => "".to_owned(), @@ -2035,7 +2034,6 @@ fn choose_rhs( .indent .block_indent(context.config) .to_string_with_newline(context.config); - let before_space_str = if has_rhs_comment { "" } else { " " }; match (orig_rhs, new_rhs) { From f138f3fc617b6bb1a1d248758844b5e390d9b0de Mon Sep 17 00:00:00 2001 From: WhizSid Date: Wed, 30 Sep 2020 04:20:26 +0530 Subject: [PATCH 6/6] Removed accidentally pushed tmp file --- tmp/test.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 tmp/test.rs diff --git a/tmp/test.rs b/tmp/test.rs deleted file mode 100644 index c8a37ead8cb..00000000000 --- a/tmp/test.rs +++ /dev/null @@ -1,30 +0,0 @@ -const A: usize = - // Some constant - 2; - -const B: usize = - /* constant */ - 3; - -const C: usize = /* foo */ 5; - -const D: usize = // baz - /* Some constant */ - /* ba */ - { - 3 - // foo - }; -const E: usize = /* foo */ 5; -const F: usize = { 7 }; -const G: usize = - /* foooooooooooooooooooooooooooooooooooooooooooooooooooooooo0000000000000000xx00 */ - 5; -const H: usize = /* asdfasdf */ - match G > 1 { - true => 1, - false => 3, - }; - -pub static FOO_BAR: Vec = //f - { vec![] };