@@ -91,14 +91,14 @@ const fn split_version(version: &str) -> (u32, u32, u32, u32) {
9191
9292// Indicates whether the given gencode and runtime versions are compatible with
9393// each other. Generally they are compatible if the gencode is no newer than the
94- // runtime, but the exception is that we consider gencode at 4.32 and older to
94+ // runtime, but the exception is that we consider gencode at 4.33 and older to
9595// be incompatible no matter what.
9696#[ cfg( not( bzl) ) ]
9797const fn are_versions_compatible ( gencode : & str , runtime : & str ) -> bool {
9898 let gencode = split_version ( gencode) ;
9999 let runtime = split_version ( runtime) ;
100100
101- if gencode. 0 < 4 || ( gencode. 0 == 4 && gencode. 1 <= 32 ) {
101+ if gencode. 0 < 4 || ( gencode. 0 == 4 && gencode. 1 <= 33 ) {
102102 return false ;
103103 }
104104
@@ -125,12 +125,12 @@ const fn are_versions_compatible(gencode: &str, runtime: &str) -> bool {
125125/// the current runtime version. We require that the generated code cannot be
126126/// newer than the runtime version.
127127///
128- /// 4.33 is the first stable release, so any gencode older than that is not
128+ /// 4.34 is the first stable release, so any gencode older than that is not
129129/// compatible going forward.
130130///
131131/// If you are seeing this fail, it means that your generated code was built
132132/// with a protoc version newer than the runtime crate version (or you have
133- /// pre-4.33 gencode).
133+ /// pre-4.34 gencode).
134134#[ cfg( not( bzl) ) ]
135135pub const fn assert_compatible_gencode_version ( gencode_version : & ' static str ) {
136136 let runtime_version = env ! ( "CARGO_PKG_VERSION" ) ;
@@ -161,26 +161,26 @@ mod tests {
161161
162162 #[ gtest]
163163 fn test_are_versions_compatible ( ) {
164- // Pre-4.33 gencode is never considered compatible.
165- expect_false ! ( are_versions_compatible( "4.32 .0" , "4.32 .1" ) ) ;
166- expect_false ! ( are_versions_compatible( "3.32 .0" , "3.32 .0" ) ) ;
164+ // Pre-4.34 gencode is never considered compatible.
165+ expect_false ! ( are_versions_compatible( "4.33 .0" , "4.33 .1" ) ) ;
166+ expect_false ! ( are_versions_compatible( "3.33 .0" , "3.33 .0" ) ) ;
167167
168168 // Otherwise, exact matches are always fine.
169- expect_true ! ( are_versions_compatible( "4.33 .0-rc.1" , "4.33 .0-rc.1" ) ) ;
170- expect_true ! ( are_versions_compatible( "4.33 .1" , "4.33 .1" ) ) ;
169+ expect_true ! ( are_versions_compatible( "4.34 .0-rc.1" , "4.34 .0-rc.1" ) ) ;
170+ expect_true ! ( are_versions_compatible( "4.34 .1" , "4.34 .1" ) ) ;
171171
172172 // Gencode older than the runtime is also fine.
173- expect_true ! ( are_versions_compatible( "4.33 .0" , "5.34 .0" ) ) ;
174- expect_true ! ( are_versions_compatible( "4.33 .0" , "4.34 .0" ) ) ;
175- expect_true ! ( are_versions_compatible( "4.33 .0" , "4.33 .1" ) ) ;
176- expect_true ! ( are_versions_compatible( "4.33 .0-rc.1" , "4.33 .0-rc.2" ) ) ;
177- expect_true ! ( are_versions_compatible( "4.33 .0-rc.2" , "4.33 .0" ) ) ;
173+ expect_true ! ( are_versions_compatible( "4.34 .0" , "5.35 .0" ) ) ;
174+ expect_true ! ( are_versions_compatible( "4.34 .0" , "4.35 .0" ) ) ;
175+ expect_true ! ( are_versions_compatible( "4.34 .0" , "4.34 .1" ) ) ;
176+ expect_true ! ( are_versions_compatible( "4.34 .0-rc.1" , "4.34 .0-rc.2" ) ) ;
177+ expect_true ! ( are_versions_compatible( "4.34 .0-rc.2" , "4.34 .0" ) ) ;
178178
179179 // Gencode newer than the runtime is not allowed.
180- expect_false ! ( are_versions_compatible( "5.34 .0" , "4.33 .0" ) ) ;
181- expect_false ! ( are_versions_compatible( "4.34 .0" , "4.33 .0" ) ) ;
182- expect_false ! ( are_versions_compatible( "4.33 .1" , "4.33 .0" ) ) ;
183- expect_false ! ( are_versions_compatible( "4.33 .0-rc.2" , "4.33 .0-rc.1" ) ) ;
184- expect_false ! ( are_versions_compatible( "4.33 .0" , "4.33 .0-rc.2" ) ) ;
180+ expect_false ! ( are_versions_compatible( "5.35 .0" , "4.34 .0" ) ) ;
181+ expect_false ! ( are_versions_compatible( "4.35 .0" , "4.34 .0" ) ) ;
182+ expect_false ! ( are_versions_compatible( "4.35 .1" , "4.34 .0" ) ) ;
183+ expect_false ! ( are_versions_compatible( "4.35 .0-rc.2" , "4.34 .0-rc.1" ) ) ;
184+ expect_false ! ( are_versions_compatible( "4.35 .0" , "4.34 .0-rc.2" ) ) ;
185185 }
186186}
0 commit comments