Auto merge of #11140 - Centri3:four_forward_slashes, r=blyxyas

New lint [`four_forward_slashes`]

Closes #9212

changelog: New lint [`four_forward_slashes`]
This commit is contained in:
bors 2023-07-18 12:56:18 +00:00
commit 9f0cbfd7df
10 changed files with 296 additions and 0 deletions

View file

@ -0,0 +1,48 @@
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro
#![feature(custom_inner_attributes)]
#![allow(unused)]
#![warn(clippy::four_forward_slashes)]
#![no_main]
#![rustfmt::skip]
#[macro_use]
extern crate proc_macros;
/// whoops
fn a() {}
/// whoops
#[allow(dead_code)]
fn b() {}
/// whoops
/// two borked comments!
#[track_caller]
fn c() {}
fn d() {}
#[test]
/// between attributes
#[allow(dead_code)]
fn g() {}
/// not very start of contents
fn h() {}
fn i() {
//// don't lint me bozo
todo!()
}
external! {
//// don't lint me bozo
fn e() {}
}
with_span! {
span
//// don't lint me bozo
fn f() {}
}

View file

@ -0,0 +1,48 @@
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro
#![feature(custom_inner_attributes)]
#![allow(unused)]
#![warn(clippy::four_forward_slashes)]
#![no_main]
#![rustfmt::skip]
#[macro_use]
extern crate proc_macros;
//// whoops
fn a() {}
//// whoops
#[allow(dead_code)]
fn b() {}
//// whoops
//// two borked comments!
#[track_caller]
fn c() {}
fn d() {}
#[test]
//// between attributes
#[allow(dead_code)]
fn g() {}
//// not very start of contents
fn h() {}
fn i() {
//// don't lint me bozo
todo!()
}
external! {
//// don't lint me bozo
fn e() {}
}
with_span! {
span
//// don't lint me bozo
fn f() {}
}

View file

@ -0,0 +1,68 @@
error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't
--> $DIR/four_forward_slashes.rs:12:1
|
LL | / //// whoops
LL | | fn a() {}
| |_
|
= note: `-D clippy::four-forward-slashes` implied by `-D warnings`
help: make this a doc comment by removing one `/`
|
LL + /// whoops
|
error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't
--> $DIR/four_forward_slashes.rs:15:1
|
LL | / //// whoops
LL | | #[allow(dead_code)]
LL | | fn b() {}
| |_
|
help: make this a doc comment by removing one `/`
|
LL + /// whoops
|
error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't
--> $DIR/four_forward_slashes.rs:19:1
|
LL | / //// whoops
LL | | //// two borked comments!
LL | | #[track_caller]
LL | | fn c() {}
| |_
|
help: turn these into doc comments by removing one `/`
|
LL + /// whoops
LL ~ /// two borked comments!
|
error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't
--> $DIR/four_forward_slashes.rs:27:1
|
LL | / //// between attributes
LL | | #[allow(dead_code)]
LL | | fn g() {}
| |_
|
help: make this a doc comment by removing one `/`
|
LL + /// between attributes
|
error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't
--> $DIR/four_forward_slashes.rs:31:1
|
LL | / //// not very start of contents
LL | | fn h() {}
| |_
|
help: make this a doc comment by removing one `/`
|
LL + /// not very start of contents
|
error: aborting due to 5 previous errors

View file

@ -0,0 +1,7 @@
/// borked doc comment on the first line. doesn't combust!
fn a() {}
//@run-rustfix
// This test's entire purpose is to make sure we don't panic if the comment with four slashes
// extends to the first line of the file. This is likely pretty rare in production, but an ICE is an
// ICE.

View file

@ -0,0 +1,7 @@
//// borked doc comment on the first line. doesn't combust!
fn a() {}
//@run-rustfix
// This test's entire purpose is to make sure we don't panic if the comment with four slashes
// extends to the first line of the file. This is likely pretty rare in production, but an ICE is an
// ICE.

View file

@ -0,0 +1,15 @@
error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't
--> $DIR/four_forward_slashes_first_line.rs:1:1
|
LL | / //// borked doc comment on the first line. doesn't combust!
LL | | fn a() {}
| |_
|
= note: `-D clippy::four-forward-slashes` implied by `-D warnings`
help: make this a doc comment by removing one `/`
|
LL + /// borked doc comment on the first line. doesn't combust!
|
error: aborting due to previous error