Skip to content

Commit

Permalink
Mute some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Jun 26, 2024
1 parent c0ebed2 commit 7709ae3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 60 deletions.
4 changes: 0 additions & 4 deletions protobuf-codegen/src/gen/field/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ impl<'a> SingularOrOneofField<'a> {
}
}

// Representation of map entry: key type and value type
#[derive(Clone, Debug)]
pub struct EntryKeyValue<'a>(FieldElem<'a>, FieldElem<'a>);

#[derive(Clone)]
pub(crate) struct FieldGen<'a> {
syntax: Syntax,
Expand Down
4 changes: 2 additions & 2 deletions protobuf-codegen/src/gen/field/type_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::gen::rust_types_values::RustType;

pub(crate) trait TypeExt {
fn read(&self, is: &str, primitive_type_variant: PrimitiveTypeVariant) -> String;
fn is_s_varint(&self) -> bool;
fn _is_s_varint(&self) -> bool;
fn is_copy(&self) -> bool;
fn protobuf_name(&self) -> &'static str;
fn rust_type(&self) -> RustType;
Expand All @@ -28,7 +28,7 @@ impl TypeExt for Type {
}

/// True if self is signed integer with zigzag encoding
fn is_s_varint(&self) -> bool {
fn _is_s_varint(&self) -> bool {
match *self {
Type::TYPE_SINT32 | Type::TYPE_SINT64 => true,
_ => false,
Expand Down
28 changes: 14 additions & 14 deletions protobuf-json-mapping/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ struct Parser<'a> {
}

trait FromJsonNumber: PartialEq + Sized {
fn from_f64(v: f64) -> Self;
fn to_f64(&self) -> f64;
fn _from_f64(v: f64) -> Self;
fn _to_f64(&self) -> f64;
fn from_string(v: &str) -> ParseResultWithoutLoc<Self>;
}

impl FromJsonNumber for u32 {
fn from_f64(v: f64) -> Self {
fn _from_f64(v: f64) -> Self {
v as u32
}

fn to_f64(&self) -> f64 {
fn _to_f64(&self) -> f64 {
*self as f64
}

Expand All @@ -151,11 +151,11 @@ impl FromJsonNumber for u32 {
}

impl FromJsonNumber for u64 {
fn from_f64(v: f64) -> Self {
fn _from_f64(v: f64) -> Self {
v as u64
}

fn to_f64(&self) -> f64 {
fn _to_f64(&self) -> f64 {
*self as f64
}

Expand All @@ -165,11 +165,11 @@ impl FromJsonNumber for u64 {
}

impl FromJsonNumber for i32 {
fn from_f64(v: f64) -> Self {
fn _from_f64(v: f64) -> Self {
v as i32
}

fn to_f64(&self) -> f64 {
fn _to_f64(&self) -> f64 {
*self as f64
}

Expand All @@ -179,11 +179,11 @@ impl FromJsonNumber for i32 {
}

impl FromJsonNumber for i64 {
fn from_f64(v: f64) -> Self {
fn _from_f64(v: f64) -> Self {
v as i64
}

fn to_f64(&self) -> f64 {
fn _to_f64(&self) -> f64 {
*self as f64
}

Expand All @@ -193,11 +193,11 @@ impl FromJsonNumber for i64 {
}

impl FromJsonNumber for f32 {
fn from_f64(v: f64) -> Self {
fn _from_f64(v: f64) -> Self {
v as f32
}

fn to_f64(&self) -> f64 {
fn _to_f64(&self) -> f64 {
*self as f64
}

Expand All @@ -215,11 +215,11 @@ impl FromJsonNumber for f32 {
}

impl FromJsonNumber for f64 {
fn from_f64(v: f64) -> Self {
fn _from_f64(v: f64) -> Self {
v
}

fn to_f64(&self) -> f64 {
fn _to_f64(&self) -> f64 {
*self
}

Expand Down
2 changes: 1 addition & 1 deletion protobuf-parse/src/pure/convert/option_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl LookupScopeUnion2 {
pub(crate) trait ProtobufOptions {
fn by_name(&self, name: &str) -> Option<&model::ProtobufConstant>;

fn by_name_bool(&self, name: &str) -> anyhow::Result<Option<bool>> {
fn _by_name_bool(&self, name: &str) -> anyhow::Result<Option<bool>> {
match self.by_name(name) {
Some(model::ProtobufConstant::Bool(b)) => Ok(Some(*b)),
Some(c) => Err(OptionResolverError::WrongOptionType("bool", c.to_string()).into()),
Expand Down
30 changes: 0 additions & 30 deletions protobuf-parse/src/pure/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ pub(crate) enum ParserError {
// TODO
#[error("incorrect input")]
IncorrectInput,
#[error("not UTF-8")]
NotUtf8,
#[error("expecting a constant")]
ExpectConstant,
#[error("unknown syntax")]
Expand Down Expand Up @@ -112,10 +110,6 @@ pub struct ParserErrorWithLocation {
pub col: u32,
}

trait ToU8 {
fn to_u8(&self) -> anyhow::Result<u8>;
}

trait ToI32 {
fn to_i32(&self) -> anyhow::Result<i32>;
}
Expand All @@ -124,10 +118,6 @@ trait ToI64 {
fn to_i64(&self) -> anyhow::Result<i64>;
}

trait ToChar {
fn to_char(&self) -> anyhow::Result<char>;
}

impl ToI32 for u64 {
fn to_i32(&self) -> anyhow::Result<i32> {
if *self <= i32::max_value() as u64 {
Expand Down Expand Up @@ -158,26 +148,6 @@ impl ToI64 for u64 {
}
}

impl ToChar for u8 {
fn to_char(&self) -> anyhow::Result<char> {
if *self <= 0x7f {
Ok(*self as char)
} else {
Err(ParserError::NotUtf8.into())
}
}
}

impl ToU8 for u32 {
fn to_u8(&self) -> anyhow::Result<u8> {
if *self as u8 as u32 == *self {
Ok(*self as u8)
} else {
Err(ParserError::IntegerOverflow.into())
}
}
}

#[derive(Clone)]
pub(crate) struct Parser<'a> {
pub tokenizer: Tokenizer<'a>,
Expand Down
18 changes: 9 additions & 9 deletions protobuf-parse/src/rel_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ pub(crate) struct RelPath {

/// Wrapper for `PathBuf` that asserts that the path is relative.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) struct RelPathBuf {
pub(crate) struct _RelPathBuf {
path: PathBuf,
}

impl RelPath {
pub(crate) fn new(path: &Path) -> &RelPath {
pub(crate) fn _new(path: &Path) -> &RelPath {
assert!(
!path.is_absolute(),
"path must be relative: {}",
Expand All @@ -24,21 +24,21 @@ impl RelPath {
unsafe { &*(path as *const Path as *const RelPath) }
}

pub(crate) fn _to_owned(&self) -> RelPathBuf {
RelPathBuf {
pub(crate) fn _to_owned(&self) -> _RelPathBuf {
_RelPathBuf {
path: self.path.to_owned(),
}
}
}

impl RelPathBuf {
pub(crate) fn _new(path: PathBuf) -> RelPathBuf {
impl _RelPathBuf {
pub(crate) fn _new(path: PathBuf) -> _RelPathBuf {
assert!(
!path.is_absolute(),
"path must be relative: {}",
path.display()
);
RelPathBuf { path }
_RelPathBuf { path }
}
}

Expand All @@ -50,10 +50,10 @@ impl Deref for RelPath {
}
}

impl Deref for RelPathBuf {
impl Deref for _RelPathBuf {
type Target = RelPath;

fn deref(&self) -> &Self::Target {
RelPath::new(&self.path)
RelPath::_new(&self.path)
}
}

0 comments on commit 7709ae3

Please sign in to comment.