Skip to content

Commit

Permalink
chore: Fix remaining workspace lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbz00 committed Apr 2, 2024
1 parent 8637b6b commit 6f45aad
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion conformance/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tests::{roundtrip, RoundtripResult};

fn main() -> io::Result<()> {
env_logger::init();
let mut bytes = Vec::new();
let mut bytes = vec![0; 4];

loop {
bytes.resize(4, 0);
Expand Down
15 changes: 5 additions & 10 deletions prost-build/src/code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ impl<'a> CodeGenerator<'a> {
.as_ref()
.and_then(|type_name| map_types.get(type_name))
{
Some(&(ref key, ref value)) => {
self.append_map_field(&fq_message_name, field, key, value)
}
Some((key, value)) => self.append_map_field(&fq_message_name, field, key, value),
None => self.append_field(&fq_message_name, field),
}
self.path.pop();
Expand Down Expand Up @@ -268,7 +266,7 @@ impl<'a> CodeGenerator<'a> {
self.buf.push_str(&format!(
"impl {}::Name for {} {{\n",
self.config.prost_path.as_deref().unwrap_or("::prost"),
to_upper_camel(&message_name)
to_upper_camel(message_name)
));
self.depth += 1;

Expand Down Expand Up @@ -377,7 +375,7 @@ impl<'a> CodeGenerator<'a> {
|| (self
.config
.boxed
.get_first_field(&fq_message_name, field.name())
.get_first_field(fq_message_name, field.name())
.is_some());

debug!(
Expand Down Expand Up @@ -559,10 +557,7 @@ impl<'a> CodeGenerator<'a> {
self.buf.push_str(&format!(
"#[prost(oneof=\"{}\", tags=\"{}\")]\n",
name,
fields
.iter()
.map(|&(ref field, _)| field.number())
.join(", ")
fields.iter().map(|(field, _)| field.number()).join(", ")
));
self.append_field_attributes(fq_message_name, oneof.name());
self.push_indent();
Expand Down Expand Up @@ -596,7 +591,7 @@ impl<'a> CodeGenerator<'a> {
"#[derive(Clone, PartialEq, {}::Oneof)]\n",
self.config.prost_path.as_deref().unwrap_or("::prost")
));
self.append_skip_debug(&fq_message_name);
self.append_skip_debug(fq_message_name);
self.push_indent();
self.buf.push_str("pub enum ");
self.buf.push_str(&to_upper_camel(oneof.name()));
Expand Down
3 changes: 0 additions & 3 deletions prost-build/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ pub fn to_upper_camel(s: &str) -> String {

#[cfg(test)]
mod tests {

#![allow(clippy::cognitive_complexity)]

use super::*;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn main() {

prost_build::Config::new()
.enable_type_names()
.type_name_domain(&[".type_names.Foo"], "tests")
.type_name_domain([".type_names.Foo"], "tests")
.compile_protos(&[src.join("type_names.proto")], includes)
.unwrap();

Expand Down
4 changes: 3 additions & 1 deletion tests/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
//! The tests check against expected output. This may be a bit fragile, but it is likely OK for
//! actual use.

use prost::alloc::{format, string::String};
use prost::alloc::format;
#[cfg(not(feature = "std"))]
use prost::alloc::string::String;

// Borrow some types from other places.
#[cfg(feature = "std")]
Expand Down
1 change: 1 addition & 0 deletions tests/src/deprecated_field.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::string::ToString;

mod deprecated_field {
Expand Down
14 changes: 7 additions & 7 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub mod default_string_escape {
include!(concat!(env!("OUT_DIR"), "/default_string_escape.rs"));
}

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use anyhow::anyhow;
Expand Down Expand Up @@ -278,11 +279,10 @@ where
#[cfg(test)]
mod tests {

use alloc::borrow::ToOwned;
use alloc::boxed::Box;
use alloc::collections::{BTreeMap, BTreeSet};
use alloc::string::ToString;
use alloc::vec;
#[cfg(not(feature = "std"))]
use alloc::{borrow::ToOwned, boxed::Box, string::ToString};

use super::*;

Expand Down Expand Up @@ -409,10 +409,10 @@ mod tests {
fn test_nesting() {
use crate::nesting::{A, B};
let _ = A {
a: Some(Box::new(A::default())),
a: Some(Box::default()),
repeated_a: Vec::<A>::new(),
map_a: BTreeMap::<i32, A>::new(),
b: Some(Box::new(B::default())),
b: Some(Box::default()),
repeated_b: Vec::<B>::new(),
map_b: BTreeMap::<i32, B>::new(),
};
Expand All @@ -423,9 +423,9 @@ mod tests {
fn build_and_roundtrip(depth: usize) -> Result<(), prost::DecodeError> {
use crate::nesting::A;

let mut a = Box::new(A::default());
let mut a = Box::<A>::default();
for _ in 0..depth {
let mut next = Box::new(A::default());
let mut next = Box::<A>::default();
next.a = Some(a);
a = next;
}
Expand Down
5 changes: 4 additions & 1 deletion tests/src/message_encoding.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use prost::alloc::{borrow::ToOwned, string::String, vec, vec::Vec};
use prost::alloc::vec;
#[cfg(not(feature = "std"))]
use prost::alloc::{borrow::ToOwned, string::String, vec::Vec};

use prost::bytes::Bytes;
use prost::{Enumeration, Message, Oneof};

Expand Down
8 changes: 6 additions & 2 deletions tests/src/skip_debug.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//! Tests for skipping the default Debug implementation.

use std::fmt;

use prost::alloc::format;
#[cfg(not(feature = "std"))]
use prost::alloc::string::String;

use crate::custom_debug::{msg, AnEnum, Msg};
use crate::message_encoding::BasicEnumeration;
use prost::alloc::{format, string::String};
use std::fmt;

/// A special case with a tuple struct
#[test]
Expand Down

0 comments on commit 6f45aad

Please sign in to comment.