File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Check that we do not have `profile.*` sections in our `Cargo.toml` files,
2
+ // as this causes warnings when run from the compiler repository which includes
3
+ // Clippy in a workspace.
4
+ //
5
+ // Those sections can be put into `.cargo/config.toml` which will be read
6
+ // when commands are issued from the top-level Clippy directory, outside of
7
+ // a workspace.
8
+
9
+ use std:: fs:: File ;
10
+ use std:: io:: { self , BufRead as _} ;
11
+ use walkdir:: WalkDir ;
12
+
13
+ #[ test]
14
+ fn no_profile_in_cargo_toml ( ) {
15
+ // This check could parse `Cargo.toml` using a TOML deserializer, but in practice
16
+ // profile sections would be added at the beginning of a line as `[profile.*]`, so
17
+ // keep it fast and simple.
18
+ for entry in WalkDir :: new ( "." )
19
+ . into_iter ( )
20
+ . filter_map ( Result :: ok)
21
+ . filter ( |e| e. file_name ( ) . to_str ( ) == Some ( "Cargo.toml" ) )
22
+ {
23
+ for line in io:: BufReader :: new ( File :: open ( entry. path ( ) ) . unwrap ( ) )
24
+ . lines ( )
25
+ . map ( Result :: unwrap)
26
+ {
27
+ if line. starts_with ( "[profile." ) {
28
+ eprintln ! ( "Profile section `{line}` found in file `{}`." , entry. path( ) . display( ) ) ;
29
+ eprintln ! ( "Use `.cargo/config.toml` for profiles specific to the standalone Clippy repository." ) ;
30
+ panic ! ( "Profile section found in `Cargo.toml`" ) ;
31
+ }
32
+ }
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments