diff --git a/examples/wip.rs b/examples/wip.rs index 4f5e391..4a89a4d 100644 --- a/examples/wip.rs +++ b/examples/wip.rs @@ -1,5 +1,10 @@ verus! { -struct ExManuallyDrop(); + fn test() { + let x = 1;/* inline multi-line comment stays inline */ + let y = 1; /* Long + dangling + comment doesn't */ + } } // verus! diff --git a/src/lib.rs b/src/lib.rs index 84da34c..cb22062 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1313,7 +1313,7 @@ const NONINLINE_COMMENT_DST: &str = "FORMATTER_NOT_INLINE_DST"; // let y = 5; fn find_inline_comment_lines(s: &str) -> HashSet { let mut comment_lines = HashSet::new(); - let re_inline_candidate = Regex::new(r"^.*\S.*(//|/\*)").unwrap(); + let re_inline_candidate = Regex::new(r"^.*\S.*(//|/\*.*\*/)").unwrap(); let re_spaced_comment = Regex::new(r"^\s*(///|//|/\*)").unwrap(); for (line_num, line) in s.lines().enumerate() { if re_inline_candidate.captures(line).is_some() @@ -1358,9 +1358,12 @@ fn fix_inline_comments(s: String) -> String { let mut prev_str: String = "".to_string(); let mut first_iteration = true; let mut comment_replacement = None; + //let mut line_num = 1; for line in s.lines() { fixed_str += &prev_str; + //println!("Processing line {}", line_num); + //line_num += 1; if re_was_inline.is_match(line) { if is_inline_comment(line) { // After we formatted the inline comment, it's still inline, diff --git a/tests/verus-consistency.rs b/tests/verus-consistency.rs index d0ba35d..270653a 100644 --- a/tests/verus-consistency.rs +++ b/tests/verus-consistency.rs @@ -1058,6 +1058,12 @@ pub fn test() { }// No space between the one character indicating non-inline and the comment } +fn test() { + let x = 1;/* inline multi-line comment stays inline */ + let y = 1; /* Long + dangling + comment doesn't */ +} } // verus! "#; @@ -1212,6 +1218,14 @@ pub fn test() { } + fn test() { + let x = 1; /* inline multi-line comment stays inline */ + let y = 1; + /* Long + dangling + comment doesn't */ + } + } // verus! "###); }