Skip to content

Commit

Permalink
Do not count /*/ as both start and end comment (rust-lang#3185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Du authored and topecongiro committed Nov 8, 2018
1 parent f10b225 commit 3986e69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,23 @@ fn identify_comment(
let closer = style.closer().trim_left();
let mut closing_symbol_offset = 0;
let mut hbl = false;
let mut first = true;
for line in orig.lines() {
closing_symbol_offset += compute_len(&orig[closing_symbol_offset..], line);
let trimmed_line = line.trim_left();
let mut trimmed_line = line.trim_left();
if !trimmed_line.starts_with('*')
&& !trimmed_line.starts_with("//")
&& !trimmed_line.starts_with("/*")
{
hbl = true;
}

// Remove opener from consideration when searching for closer
if first {
let opener = style.opener().trim_right();
trimmed_line = &trimmed_line[opener.len()..];
first = false;
}
if trimmed_line.ends_with(closer) {
break;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/target/issue-3184.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*/
struct Error{
message: String,
}
*/

0 comments on commit 3986e69

Please sign in to comment.