Skip to content

Commit 9c6b17e

Browse files
committed
Remove #![allow(unused)] and --crate-name from new_lint tests
1 parent 9f0cbfd commit 9c6b17e

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

clippy_dev/src/new_lint.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> {
9696

9797
path.push("src");
9898
fs::create_dir(&path)?;
99-
let header = format!("//@compile-flags: --crate-name={lint_name}");
100-
write_file(path.join("main.rs"), get_test_file_contents(lint_name, Some(&header)))?;
99+
write_file(path.join("main.rs"), get_test_file_contents(lint_name))?;
101100

102101
Ok(())
103102
}
@@ -113,7 +112,7 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> {
113112
println!("Generated test directories: `{relative_test_dir}/pass`, `{relative_test_dir}/fail`");
114113
} else {
115114
let test_path = format!("tests/ui/{}.rs", lint.name);
116-
let test_contents = get_test_file_contents(lint.name, None);
115+
let test_contents = get_test_file_contents(lint.name);
117116
write_file(lint.project_root.join(&test_path), test_contents)?;
118117

119118
println!("Generated test file: `{test_path}`");
@@ -195,23 +194,16 @@ pub(crate) fn get_stabilization_version() -> String {
195194
parse_manifest(&contents).expect("Unable to find package version in `Cargo.toml`")
196195
}
197196

198-
fn get_test_file_contents(lint_name: &str, header_commands: Option<&str>) -> String {
199-
let mut contents = formatdoc!(
197+
fn get_test_file_contents(lint_name: &str) -> String {
198+
formatdoc!(
200199
r#"
201-
#![allow(unused)]
202200
#![warn(clippy::{lint_name})]
203201
204202
fn main() {{
205203
// test code goes here
206204
}}
207205
"#
208-
);
209-
210-
if let Some(header) = header_commands {
211-
contents = format!("{header}\n{contents}");
212-
}
213-
214-
contents
206+
)
215207
}
216208

217209
fn get_manifest_contents(lint_name: &str, hint: &str) -> String {

0 commit comments

Comments
 (0)