@@ -128,6 +128,12 @@ impl Blacksmith {
128
128
129
129
let latest_stable_version = & blacksmith. stable_version . clone ( ) . unwrap ( ) ;
130
130
131
+ // We need to use a map to deduplicate entries and sort them in the correct order.
132
+ // There are multiple entries for stable 1.8.0, 1.14.0, 1.15.1, 1.49.0 in MANIFESTS_URL.
133
+ // Keys contain (minor_version, patch_version) and values contain (full_version, platforms).
134
+ let mut previous_stable_version_map: BTreeMap < ( u32 , u32 ) , ( String , Vec < String > ) > =
135
+ BTreeMap :: new ( ) ;
136
+
131
137
// Go over stable versions in https://static.rust-lang.org/manifests.txt in reverse order.
132
138
let manifests_content = reqwest:: blocking:: get ( MANIFESTS_URL ) ?. text ( ) ?;
133
139
let stable_manifest_url_regex = regex:: Regex :: new (
@@ -140,14 +146,19 @@ impl Blacksmith {
140
146
141
147
// Check if it's a stable version.
142
148
if let Some ( captures) = stable_manifest_url_regex. captures ( & ( manifest_url) ) {
143
- minor = captures. get ( 1 ) . unwrap ( ) . as_str ( ) ;
144
- patch = captures. get ( 2 ) . unwrap ( ) . as_str ( ) ;
149
+ minor = captures. get ( 1 ) . unwrap ( ) . as_str ( ) . parse :: < u32 > ( ) . unwrap ( ) ;
150
+ patch = captures. get ( 2 ) . unwrap ( ) . as_str ( ) . parse :: < u32 > ( ) . unwrap ( ) ;
145
151
} else {
146
152
continue ;
147
153
}
148
154
149
155
let full_version = format ! ( "1.{}.{}" , minor, patch) ;
150
156
157
+ // Check if we already processed that version.
158
+ if previous_stable_version_map. contains_key ( & ( minor, patch) ) {
159
+ continue ;
160
+ }
161
+
151
162
// Skip latest stable version.
152
163
if & full_version == latest_stable_version {
153
164
continue ;
@@ -169,6 +180,9 @@ impl Blacksmith {
169
180
170
181
let version = rust. version . split ( ' ' ) . next ( ) . unwrap ( ) . to_string ( ) ;
171
182
183
+ // Sanity check.
184
+ assert_eq ! ( & full_version, & version) ;
185
+
172
186
let platforms = rust
173
187
. target
174
188
. into_iter ( )
@@ -181,9 +195,13 @@ impl Blacksmith {
181
195
} )
182
196
. collect :: < Vec < _ > > ( ) ;
183
197
198
+ previous_stable_version_map. insert ( ( minor, patch) , ( version, platforms) ) ;
199
+ }
200
+
201
+ for ( _, ( version, platforms) ) in previous_stable_version_map. into_iter ( ) . rev ( ) {
184
202
blacksmith
185
203
. previous_stable_versions
186
- . push ( ( version. clone ( ) , platforms) ) ;
204
+ . push ( ( version, platforms) ) ;
187
205
}
188
206
189
207
blacksmith. last_update = unix_time ( ) ;
0 commit comments