mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Deny all warnings in our cargo test setup.
Some suppressions to make our current code warning-clean. A number of these are slightly odd, because in blazel upb/rust is a separate crate and so has sensible pub fns that we don't happen to use (which is no-warning), but in Cargo where we embed it as a module in our crate without re-exporting it, it becomes a warning if we don't use those fns/constants/etc (because an unused fn on a crate-visibility struct is considered an unused fn warning). Rust is set up so it won't show warnings from your cratesio deps, but as our gencode is embedded in the callers crate warnings will annoy them. Tightening this will help reduce (but not totally prevent) cases where warnings in our code will show up to users. PiperOrigin-RevId: 882686850
This commit is contained in:
parent
323f58a1fb
commit
665c1a3445
8 changed files with 16 additions and 7 deletions
|
|
@ -32,10 +32,10 @@ TMP_DIR=$(mktemp -d)
|
|||
trap 'rm -rf -- "$TMP_DIR"' EXIT
|
||||
|
||||
CARGO_HOME=$TMP_DIR/cargo_home
|
||||
mkdir $CARGO_HOME
|
||||
mkdir "$CARGO_HOME"
|
||||
|
||||
WORKSPACE_ROOT=$TMP_DIR/workspace
|
||||
mkdir $WORKSPACE_ROOT
|
||||
mkdir "$WORKSPACE_ROOT"
|
||||
|
||||
WORKSPACE_TAR=$(rlocation com_google_protobuf/rust/release_crates/workspace.tar)
|
||||
|
||||
|
|
@ -44,15 +44,15 @@ echo "Expanding Cargo workspace tar"
|
|||
# The tar binary on Windows does not know how to handle file paths that start
|
||||
# with C:\ or similar, so we go a little out of our way here to avoid passing
|
||||
# any paths as arguments to tar.
|
||||
pushd $WORKSPACE_ROOT
|
||||
tar -xv < $WORKSPACE_TAR
|
||||
pushd "$WORKSPACE_ROOT"
|
||||
tar -xv < "$WORKSPACE_TAR"
|
||||
popd
|
||||
|
||||
# Put the Bazel-built protoc at the beginning of $PATH
|
||||
PATH=$(dirname $(rlocation com_google_protobuf/protoc)):$PATH
|
||||
|
||||
export RUSTFLAGS="-Dmismatched-lifetime-syntaxes"
|
||||
export RUSTFLAGS="-Dwarnings"
|
||||
|
||||
cd $WORKSPACE_ROOT
|
||||
cd "$WORKSPACE_ROOT"
|
||||
CARGO_HOME=$CARGO_HOME cargo test
|
||||
CARGO_HOME=$CARGO_HOME cargo publish --dry-run --workspace
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ googletest = "0.14.2"
|
|||
cc = "1.1.6"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bzl)', 'cfg(cpp_kernel)', 'cfg(upb_kernel)'] }
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bzl)', 'cfg(cpp_kernel)', 'cfg(upb_kernel)', 'cfg(lite_runtime)'] }
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ impl<T: ?Sized + 'static> OwnedArenaBox<T> {
|
|||
OwnedArenaBox { arena, data }
|
||||
}
|
||||
|
||||
#[allow(unused)] // Not used today.
|
||||
pub fn data(&self) -> *const T {
|
||||
self.data.as_ptr()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ impl upb_MessageValue {
|
|||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
#[allow(unused)] // FFI type.
|
||||
pub union upb_MutableMessageValue {
|
||||
pub array: Option<RawArray>,
|
||||
pub map: Option<RawMap>,
|
||||
|
|
|
|||
|
|
@ -13,4 +13,6 @@ use core::ptr::NonNull;
|
|||
use sys::opaque_pointee::opaque_pointee;
|
||||
|
||||
opaque_pointee!(upb_ExtensionRegistry);
|
||||
|
||||
#[allow(unused)] // Not used yet but intended in the future.
|
||||
pub type RawExtensionRegistry = NonNull<upb_ExtensionRegistry>;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ pub type RawMiniTableField = NonNull<upb_MiniTableField>;
|
|||
// we are not currently using it.
|
||||
opaque_pointee!(upb_Status);
|
||||
|
||||
#[allow(unused)] // FFI
|
||||
unsafe extern "C" {
|
||||
/// Finds the field with the provided number, will return NULL if no such
|
||||
/// field is found.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use sys::mini_table::mini_table::RawMiniTable;
|
|||
// LINT.IfChange(encode_status)
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||
#[allow(unused)] // C struct values used in FFI.
|
||||
pub enum EncodeStatus {
|
||||
Ok = 0,
|
||||
OutOfMemory = 1,
|
||||
|
|
@ -29,6 +30,7 @@ pub enum EncodeStatus {
|
|||
// LINT.IfChange(decode_status)
|
||||
#[repr(C)]
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
||||
#[allow(unused)] // C struct values used in FFI.
|
||||
pub enum DecodeStatus {
|
||||
Ok = 0,
|
||||
OutOfMemory = 1,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use super::sys::wire::wire::{upb_Decode, upb_Encode, DecodeStatus, EncodeStatus}
|
|||
use super::{Arena, AssociatedMiniTable, MessagePtr};
|
||||
|
||||
/// Contains the decode options that can be passed to `decode_with_options`.
|
||||
#[allow(unused)] // FFI constants.
|
||||
pub mod decode_options {
|
||||
// LINT.IfChange(decode_option)
|
||||
pub const ALIAS_STRING: i32 = 1;
|
||||
|
|
@ -48,6 +49,7 @@ pub fn encode<T: AssociatedMiniTable>(msg: MessagePtr<T>) -> Result<Vec<u8>, Enc
|
|||
///
|
||||
/// # Safety
|
||||
/// - `msg` must be mutable.
|
||||
#[allow(unused)] // Not used yet.
|
||||
pub unsafe fn decode<T: AssociatedMiniTable>(
|
||||
buf: &[u8],
|
||||
msg: MessagePtr<T>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue