Auto merge of #11183 - Alexendoo:new-lint-template, r=xFrednet
Remove `#![allow(unused)]` and `--crate-name` from `cargo dev new_lint` generated tests changelog: none Also removes some unused flags from `ui-cargo` tests because the entrypoint is now the `Cargo.toml`, not the `.rs` files
This commit is contained in:
commit
0fa1fd396e
@ -96,8 +96,7 @@ fn create_project_layout<P: Into<PathBuf>>(lint_name: &str, location: P, case: &
|
|||||||
|
|
||||||
path.push("src");
|
path.push("src");
|
||||||
fs::create_dir(&path)?;
|
fs::create_dir(&path)?;
|
||||||
let header = format!("//@compile-flags: --crate-name={lint_name}");
|
write_file(path.join("main.rs"), get_test_file_contents(lint_name))?;
|
||||||
write_file(path.join("main.rs"), get_test_file_contents(lint_name, Some(&header)))?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -113,7 +112,7 @@ fn create_project_layout<P: Into<PathBuf>>(lint_name: &str, location: P, case: &
|
|||||||
println!("Generated test directories: `{relative_test_dir}/pass`, `{relative_test_dir}/fail`");
|
println!("Generated test directories: `{relative_test_dir}/pass`, `{relative_test_dir}/fail`");
|
||||||
} else {
|
} else {
|
||||||
let test_path = format!("tests/ui/{}.rs", lint.name);
|
let test_path = format!("tests/ui/{}.rs", lint.name);
|
||||||
let test_contents = get_test_file_contents(lint.name, None);
|
let test_contents = get_test_file_contents(lint.name);
|
||||||
write_file(lint.project_root.join(&test_path), test_contents)?;
|
write_file(lint.project_root.join(&test_path), test_contents)?;
|
||||||
|
|
||||||
println!("Generated test file: `{test_path}`");
|
println!("Generated test file: `{test_path}`");
|
||||||
@ -195,23 +194,16 @@ fn parse_manifest(contents: &str) -> Option<String> {
|
|||||||
parse_manifest(&contents).expect("Unable to find package version in `Cargo.toml`")
|
parse_manifest(&contents).expect("Unable to find package version in `Cargo.toml`")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_test_file_contents(lint_name: &str, header_commands: Option<&str>) -> String {
|
fn get_test_file_contents(lint_name: &str) -> String {
|
||||||
let mut contents = formatdoc!(
|
formatdoc!(
|
||||||
r#"
|
r#"
|
||||||
#![allow(unused)]
|
|
||||||
#![warn(clippy::{lint_name})]
|
#![warn(clippy::{lint_name})]
|
||||||
|
|
||||||
fn main() {{
|
fn main() {{
|
||||||
// test code goes here
|
// test code goes here
|
||||||
}}
|
}}
|
||||||
"#
|
"#
|
||||||
);
|
)
|
||||||
|
|
||||||
if let Some(header) = header_commands {
|
|
||||||
contents = format!("{header}\n{contents}");
|
|
||||||
}
|
|
||||||
|
|
||||||
contents
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_manifest_contents(lint_name: &str, hint: &str) -> String {
|
fn get_manifest_contents(lint_name: &str, hint: &str) -> String {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=cargo_common_metadata
|
|
||||||
#![warn(clippy::cargo_common_metadata)]
|
#![warn(clippy::cargo_common_metadata)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=cargo_common_metadata
|
|
||||||
#![warn(clippy::cargo_common_metadata)]
|
#![warn(clippy::cargo_common_metadata)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=cargo_common_metadata
|
|
||||||
#![warn(clippy::cargo_common_metadata)]
|
#![warn(clippy::cargo_common_metadata)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=cargo_common_metadata
|
|
||||||
#![warn(clippy::cargo_common_metadata)]
|
#![warn(clippy::cargo_common_metadata)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=cargo_common_metadata
|
|
||||||
#![warn(clippy::cargo_common_metadata)]
|
#![warn(clippy::cargo_common_metadata)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=cargo_common_metadata
|
|
||||||
#![warn(clippy::cargo_common_metadata)]
|
#![warn(clippy::cargo_common_metadata)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=feature_name
|
|
||||||
#![warn(clippy::redundant_feature_names)]
|
#![warn(clippy::redundant_feature_names)]
|
||||||
#![warn(clippy::negative_feature_names)]
|
#![warn(clippy::negative_feature_names)]
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=feature_name
|
|
||||||
#![warn(clippy::redundant_feature_names)]
|
#![warn(clippy::redundant_feature_names)]
|
||||||
#![warn(clippy::negative_feature_names)]
|
#![warn(clippy::negative_feature_names)]
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// FIXME: find a way to add rustflags to ui-cargo tests
|
||||||
//@compile-flags: --remap-path-prefix {{src-base}}=/remapped
|
//@compile-flags: --remap-path-prefix {{src-base}}=/remapped
|
||||||
|
|
||||||
#![warn(clippy::self_named_module_files)]
|
#![warn(clippy::self_named_module_files)]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=multiple_crate_versions
|
|
||||||
#![warn(clippy::multiple_crate_versions)]
|
#![warn(clippy::multiple_crate_versions)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=multiple_crate_versions
|
|
||||||
#![warn(clippy::multiple_crate_versions)]
|
#![warn(clippy::multiple_crate_versions)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=multiple_crate_versions
|
|
||||||
#![warn(clippy::multiple_crate_versions)]
|
#![warn(clippy::multiple_crate_versions)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=wildcard_dependencies
|
|
||||||
#![warn(clippy::wildcard_dependencies)]
|
#![warn(clippy::wildcard_dependencies)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
//@compile-flags: --crate-name=wildcard_dependencies
|
|
||||||
#![warn(clippy::wildcard_dependencies)]
|
#![warn(clippy::wildcard_dependencies)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user