Skip to content

Commit

Permalink
Run cargo clippy --fix (#1605)
Browse files Browse the repository at this point in the history
New lints with rust 1.83
  • Loading branch information
fredr authored Nov 28, 2024
1 parent 16f0a6c commit 2e1de90
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions runtimes/core/src/api/jsonschema/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ macro_rules! recurse0 {
}};
}

impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
impl<'de> Visitor<'de> for DecodeValue<'_> {
type Value = PValue;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down Expand Up @@ -492,7 +492,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
serde::de::Error::custom(format_args!("invalid datetime: {}", e,))
}),
Basic::Bool if self.cfg.coerce_strings => {
return if value == "true" {
if value == "true" {
Ok(PValue::Bool(true))
} else if value == "false" {
Ok(PValue::Bool(false))
Expand All @@ -504,7 +504,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
}
}
Basic::Number if self.cfg.coerce_strings => {
return if let Ok(num) = value.parse::<i64>() {
if let Ok(num) = value.parse::<i64>() {
Ok(PValue::Number(num.into()))
} else if let Ok(num) = value.parse::<f64>() {
Ok(JSONNumber::from_f64(num).map_or(PValue::Null, PValue::Number))
Expand All @@ -516,7 +516,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
}
}
Basic::Null if self.cfg.coerce_strings => {
return if value == "null" {
if value == "null" {
Ok(PValue::Null)
} else {
Err(serde::de::Error::custom(format_args!(
Expand All @@ -539,7 +539,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
Value::Literal(lit) => match lit {
Literal::Str(val) if val.as_str() == value => Ok(PValue::String(value)),
Literal::Bool(_) if self.cfg.coerce_strings => {
return if let Ok(got) = value.parse::<bool>() {
if let Ok(got) = value.parse::<bool>() {
self.visit_bool(got)
} else {
Err(serde::de::Error::custom(format_args!(
Expand All @@ -550,7 +550,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
}
}
Literal::Int(_) if self.cfg.coerce_strings => {
return if let Ok(got) = value.parse::<i64>() {
if let Ok(got) = value.parse::<i64>() {
self.visit_i64(got)
} else {
Err(serde::de::Error::custom(format_args!(
Expand All @@ -561,7 +561,7 @@ impl<'de, 'a> Visitor<'de> for DecodeValue<'a> {
}
}
Literal::Float(_) if self.cfg.coerce_strings => {
return if let Ok(got) = value.parse::<f64>() {
if let Ok(got) = value.parse::<f64>() {
self.visit_f64(got)
} else {
Err(serde::de::Error::custom(format_args!(
Expand Down Expand Up @@ -886,7 +886,7 @@ struct FieldList<'a> {
names: &'a [&'a str],
}

impl<'a> DecodeValue<'a> {
impl DecodeValue<'_> {
#[cfg_attr(
feature = "rttrace",
tracing::instrument(skip(self), ret, level = "trace")
Expand Down
2 changes: 1 addition & 1 deletion runtimes/core/src/api/jsonschema/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'a> Builder<'a> {
}
}

impl<'a, 'b> BuilderCtx<'a, 'b> {
impl BuilderCtx<'_, '_> {
/// Computes the JSONSchema value for the given type.
#[inline]
fn typ<T: ToType>(&mut self, typ: T) -> Result<Value> {
Expand Down
2 changes: 1 addition & 1 deletion runtimes/core/src/api/jsonschema/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct SchemaSerializeWrapper<'a> {
payload: &'a JSONPayload,
}

impl<'a> Serialize for SchemaSerializeWrapper<'a> {
impl Serialize for SchemaSerializeWrapper<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion runtimes/core/src/sqldb/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct ManagerConfig<'a> {
pub runtime: tokio::runtime::Handle,
}

impl<'a> ManagerConfig<'a> {
impl ManagerConfig<'_> {
pub fn build(self) -> anyhow::Result<Manager> {
// Start listening so we can tell which port it is when we generate configuration.
let listener =
Expand Down
2 changes: 1 addition & 1 deletion runtimes/core/src/trace/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct LogMessageData<'a, I> {
pub fields: Option<I>,
}

impl<'a, I> LogMessageData<'a, I> {
impl<I> LogMessageData<'_, I> {
fn level_byte(&self) -> u8 {
match self.level {
log::Level::Error => 4,
Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/legacymeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct MetaBuilder<'a> {
data: v1::Data,
}

impl<'a> MetaBuilder<'a> {
impl MetaBuilder<'_> {
pub fn build(mut self) -> Result<v1::Data> {
// self.data.app_revision = parse_app_revision(&self.app_root)?;
self.data.app_revision = std::env::var("ENCORE_APP_REVISION").unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/legacymeta/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a> SchemaBuilder<'a> {
}
}

impl<'a, 'b> BuilderCtx<'a, 'b> {
impl BuilderCtx<'_, '_> {
#[tracing::instrument(skip(self), ret, level = "trace")]
fn typ(&mut self, typ: &Type) -> Result<schema::Type> {
Ok(match typ {
Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a> Parser<'a> {

// Skip non-".ts" files.
let ext = entry.path().extension().and_then(OsStr::to_str);
if !ext.is_some_and(|ext| ext == "ts") {
if ext.is_none_or(|ext| ext != "ts") {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/parser/resourceparser/resource_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct ResourceParserRegistry<'a> {
interested_for_paths: HashMap<PkgPath<'a>, Vec<&'a ResourceParser>>,
}

impl<'a> Default for ResourceParserRegistry<'a> {
impl Default for ResourceParserRegistry<'_> {
fn default() -> Self {
Self::new(DEFAULT_RESOURCE_PARSERS)
}
Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/parser/resources/parseutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl<'a, R> IterReferenceVisitor<'a, R> {
}
}

impl<'a, R: ReferenceParser> swc_ecma_visit::VisitAstPath for IterReferenceVisitor<'a, R> {
impl<R: ReferenceParser> swc_ecma_visit::VisitAstPath for IterReferenceVisitor<'_, R> {
fn visit_ident<'ast: 'r, 'r>(
&mut self,
n: &'ast ast::Ident,
Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/parser/service_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ServiceDiscoverer<'a> {
strong_root: HashSet<PathBuf>,
}

impl<'a> ServiceDiscoverer<'a> {
impl ServiceDiscoverer<'_> {
fn discover(mut self) -> Result<Vec<DiscoveredService>> {
for b in self.binds {
match &b.resource {
Expand Down
2 changes: 1 addition & 1 deletion tsparser/src/parser/types/resolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
}
}

impl<'a, 'b, B: ?Sized, C: ?Sized> PartialEq<Resolved<'b, C>> for Resolved<'a, B>
impl<'b, B: ?Sized, C: ?Sized> PartialEq<Resolved<'b, C>> for Resolved<'_, B>
where
B: PartialEq<C> + ToOwned,
C: ToOwned,
Expand Down
6 changes: 3 additions & 3 deletions tsparser/src/parser/types/type_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a> Ctx<'a> {
}
}

impl<'a> Ctx<'a> {
impl Ctx<'_> {
pub fn typ(&self, typ: &ast::TsType) -> Type {
match typ {
ast::TsType::TsKeywordType(tt) => self.keyword(tt),
Expand Down Expand Up @@ -1244,7 +1244,7 @@ impl<'a> Ctx<'a> {
}
}

impl<'a> Ctx<'a> {
impl Ctx<'_> {
pub fn obj_type(&self, obj: &Object) -> Type {
if matches!(&obj.kind, ObjectKind::Module(_)) {
// Modules don't have a type.
Expand Down Expand Up @@ -1417,7 +1417,7 @@ impl<'a> Ctx<'a> {
}
}

impl<'a> Ctx<'a> {
impl Ctx<'_> {
#[tracing::instrument(skip(self), ret, level = "trace")]
pub fn concrete<'b>(&'b self, typ: &'b Type) -> Resolved<'b, Type> {
match typ {
Expand Down
4 changes: 2 additions & 2 deletions tsparser/src/parser/usageparser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<'a> UsageVisitor<'a> {
let parent = path.get(idx - 1);
let grandparent = path.get(idx - 2);

return match parent {
match parent {
Some(AstParentNodeRef::MemberExpr(sel, MemberExprField::Obj)) => {
// We have a member expression, where the object ("foo" in foo.bar) is the bind.
// Ensure "bar" is a static identifier and not a private field or a computed property.
Expand Down Expand Up @@ -439,7 +439,7 @@ impl<'a> UsageVisitor<'a> {
}
}
}
};
}
}
}

Expand Down

0 comments on commit 2e1de90

Please sign in to comment.