Don't use matches! on MessageVal tests.

This is a warning today, as in a future release of Rust this won't be legal to match on floating point values.

As these are C-style unions, there's no signal about what type they are and the matches! is behaving the same as just checking value directly (wouldn't fail to match if a mismatched type was written anyway).

PiperOrigin-RevId: 695488356
pull/19224/head
Protobuf Team Bot 4 months ago committed by Copybara-Service
parent 9e42c11864
commit 0a7691e98f
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 4
      rust/upb/array.rs
  3. 2
      rust/upb/map.rs

@ -1,17 +0,0 @@
#region Copyright notice and license
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#endregion
namespace Google.Protobuf.Reflection;
internal sealed partial class FeatureSetDescriptor
{
// Canonical serialized form of the edition defaults, generated by embed_edition_defaults.
private const string DefaultsBase64 =
"ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH";
}

@ -57,11 +57,11 @@ mod tests {
assert!(upb_Array_Append(array, upb_MessageValue { float_val: 7.0 }, raw_arena));
assert!(upb_Array_Append(array, upb_MessageValue { float_val: 42.0 }, raw_arena));
assert_eq!(upb_Array_Size(array), 2);
assert!(matches!(upb_Array_Get(array, 1), upb_MessageValue { float_val: 42.0 }));
assert_eq!(upb_Array_Get(array, 1).float_val, 42.0);
assert!(upb_Array_Resize(array, 3, raw_arena));
assert_eq!(upb_Array_Size(array), 3);
assert!(matches!(upb_Array_Get(array, 2), upb_MessageValue { float_val: 0.0 }));
assert_eq!(upb_Array_Get(array, 2).float_val, 0.0);
}
}
}

@ -106,7 +106,7 @@ mod tests {
let mut out = upb_MessageValue::zeroed();
assert!(upb_Map_Get(map, upb_MessageValue { bool_val: true }, &mut out));
assert!(matches!(out, upb_MessageValue { double_val: 4.0 }));
assert_eq!(out.double_val, 4.0);
}
}
}

Loading…
Cancel
Save