File tree 1 file changed +33
-10
lines changed
1 file changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -101,21 +101,44 @@ fn cargo_files_are_tidy() {
101
101
let mut section = None ;
102
102
for ( line_no, text) in read_file ( & cargo) . unwrap ( ) . lines ( ) . enumerate ( ) {
103
103
let text = text. trim ( ) ;
104
- if text. starts_with ( "[" ) {
104
+ if text. starts_with ( '[' ) {
105
+ if !text. ends_with ( ']' ) {
106
+ panic ! (
107
+ "\n please don't add comments or trailing whitespace in section lines.\n \
108
+ {}:{}\n ",
109
+ cargo. display( ) ,
110
+ line_no + 1
111
+ )
112
+ }
105
113
section = Some ( text) ;
106
114
continue ;
107
115
}
108
- if !section. map ( |it| it. starts_with ( "[dependencies" ) ) . unwrap_or ( false ) {
116
+ let text: String = text. split_whitespace ( ) . collect ( ) ;
117
+ if !text. contains ( "path=" ) {
109
118
continue ;
110
119
}
111
- let text: String = text. split_whitespace ( ) . collect ( ) ;
112
- if text. contains ( "path=" ) && !text. contains ( "version" ) {
113
- panic ! (
114
- "\n cargo internal dependencies should have version.\n \
115
- {}:{}\n ",
116
- cargo. display( ) ,
117
- line_no + 1
118
- )
120
+ match section {
121
+ Some ( s) if s. contains ( "dev-dependencies" ) => {
122
+ if text. contains ( "version" ) {
123
+ panic ! (
124
+ "\n cargo internal dev-dependencies should not have a version.\n \
125
+ {}:{}\n ",
126
+ cargo. display( ) ,
127
+ line_no + 1
128
+ ) ;
129
+ }
130
+ }
131
+ Some ( s) if s. contains ( "dependencies" ) => {
132
+ if !text. contains ( "version" ) {
133
+ panic ! (
134
+ "\n cargo internal dependencies should have a version.\n \
135
+ {}:{}\n ",
136
+ cargo. display( ) ,
137
+ line_no + 1
138
+ ) ;
139
+ }
140
+ }
141
+ _ => { }
119
142
}
120
143
}
121
144
}
You can’t perform that action at this time.
0 commit comments