@@ -76,7 +76,8 @@ fn create_test(lint: &LintData) -> io::Result<()> {
7676
7777 path. push ( "src" ) ;
7878 fs:: create_dir ( & path) ?;
79- write_file ( path. join ( "main.rs" ) , get_test_file_contents ( lint_name) ) ?;
79+ let header = format ! ( "// compile-flags: --crate-name={}" , lint_name) ;
80+ write_file ( path. join ( "main.rs" ) , get_test_file_contents ( lint_name, Some ( & header) ) ) ?;
8081
8182 Ok ( ( ) )
8283 }
@@ -90,7 +91,7 @@ fn create_test(lint: &LintData) -> io::Result<()> {
9091 create_project_layout ( lint. name , & test_dir, "pass" , "This file should not trigger the lint" )
9192 } else {
9293 let test_path = format ! ( "tests/ui/{}.rs" , lint. name) ;
93- let test_contents = get_test_file_contents ( lint. name ) ;
94+ let test_contents = get_test_file_contents ( lint. name , None ) ;
9495 write_file ( lint. project_root . join ( test_path) , test_contents)
9596 }
9697}
@@ -119,16 +120,22 @@ fn to_camel_case(name: &str) -> String {
119120 . collect ( )
120121}
121122
122- fn get_test_file_contents ( lint_name : & str ) -> String {
123- format ! (
123+ fn get_test_file_contents ( lint_name : & str , header_commands : Option < & str > ) -> String {
124+ let mut contents = format ! (
124125 "#![warn(clippy::{})]
125126
126127fn main() {{
127128 // test code goes here
128129}}
129130" ,
130131 lint_name
131- )
132+ ) ;
133+
134+ if let Some ( header) = header_commands {
135+ contents = format ! ( "{}\n {}" , header, contents) ;
136+ }
137+
138+ contents
132139}
133140
134141fn get_manifest_contents ( lint_name : & str , hint : & str ) -> String {
0 commit comments