Skip to content

Commit bdf1052

Browse files
committed
fix Const generics are handled incorrectly
1 parent 531b2d9 commit bdf1052

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/comment.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,12 @@ pub(crate) fn recover_missing_comment_in_span(
880880
Some(String::new())
881881
} else {
882882
let missing_snippet = context.snippet(span);
883+
let trimmed_missing_snippet = missing_snippet.trim();
884+
if !trimmed_missing_snippet.starts_with("//") && !trimmed_missing_snippet.starts_with("/*")
885+
{
886+
return None;
887+
};
888+
883889
let pos = missing_snippet.find('/').unwrap_or(0);
884890
// 1 = ` `
885891
let total_width = missing_comment.len() + used_width + 1;

tests/target/issue-3554.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![feature(const_generics)]
2+
3+
pub struct S<const N: usize>;
4+
impl S<{ 0 }> {}

0 commit comments

Comments
 (0)