From 95c7325ac2aa89043e2ab39b86a3dc1615bee5ce Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 15 Nov 2017 15:46:00 +0900 Subject: [PATCH] Do not get tricked by a nested comment --- src/lists.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lists.rs b/src/lists.rs index a5d2334dcdab..dc55a8261fa9 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -572,10 +572,12 @@ where let comment_end = match self.inner.peek() { Some(..) => { let mut block_open_index = post_snippet.find("/*"); - // check if it really is a block comment (and not //*) + // check if it really is a block comment (and not `//*` or a nested comment) if let Some(i) = block_open_index { - if i > 0 && &post_snippet[i - 1..i] == "/" { - block_open_index = None; + match post_snippet.find("/") { + Some(j) if j < i => block_open_index = None, + _ if i > 0 && &post_snippet[i - 1..i] == "/" => block_open_index = None, + _ => (), } } let newline_index = post_snippet.find('\n');