diff options
| author | Philipp Krones <hello@philkrones.com> | 2023-07-31 23:53:53 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2023-07-31 23:53:53 +0200 |
| commit | b0e64a9c09773e5ac908d89bff3db95d35491308 (patch) | |
| tree | 81571ddba0b66bcc5c6d658fc3adcc7032b1810b /clippy_dev | |
| parent | f54263af58f5ae062d382c40c28ed8d9fa9c6935 (diff) | |
| download | rust-b0e64a9c09773e5ac908d89bff3db95d35491308.tar.gz rust-b0e64a9c09773e5ac908d89bff3db95d35491308.zip | |
Merge commit '5436dba826191964ac1d0dab534b7eb6d4c878f6' into clippyup
Diffstat (limited to 'clippy_dev')
| -rw-r--r-- | clippy_dev/src/lib.rs | 2 | ||||
| -rw-r--r-- | clippy_dev/src/new_lint.rs | 18 |
2 files changed, 6 insertions, 14 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 4624451cff4..c4ae4f0e2bd 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -51,7 +51,7 @@ pub fn clippy_project_root() -> PathBuf { for path in current_dir.ancestors() { let result = std::fs::read_to_string(path.join("Cargo.toml")); if let Err(err) = &result { - if err.kind() == std::io::ErrorKind::NotFound { + if err.kind() == io::ErrorKind::NotFound { continue; } } diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index f39bc06e6d7..e64cf2c8749 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -96,8 +96,7 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> { path.push("src"); 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, Some(&header)))?; + write_file(path.join("main.rs"), get_test_file_contents(lint_name))?; Ok(()) } @@ -113,7 +112,7 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> { println!("Generated test directories: `{relative_test_dir}/pass`, `{relative_test_dir}/fail`"); } else { 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)?; println!("Generated test file: `{test_path}`"); @@ -195,23 +194,16 @@ pub(crate) fn get_stabilization_version() -> String { 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 { - let mut contents = formatdoc!( +fn get_test_file_contents(lint_name: &str) -> String { + formatdoc!( r#" - #![allow(unused)] #![warn(clippy::{lint_name})] fn main() {{ // 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 { |
