diff --git a/.clippy.toml b/.clippy.toml index 2cf2f297..37d2b1ac 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,4 +1,4 @@ -msrv = "1.70.0" # MSRV +msrv = "1.76.0" # MSRV warn-on-all-wildcard-imports = true allow-expect-in-tests = true allow-unwrap-in-tests = true diff --git a/Cargo.lock b/Cargo.lock index 5bf351c2..83e36014 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -181,9 +181,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitpacking" @@ -488,7 +488,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossterm_winapi", "libc", "mio", @@ -970,7 +970,7 @@ version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bstr", "gix-path", "libc", @@ -1095,7 +1095,7 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "682bdc43cb3c00dbedfcc366de2a849b582efd8d886215dbad2ea662ec156bb5" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bstr", "gix-features", "gix-path", @@ -1141,7 +1141,7 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "549621f13d9ccf325a7de45506a3266af0d08f915181c5687abb5e8669bfd2e6" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bstr", "filetime", "fnv", @@ -1190,7 +1190,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54ba98f8c8c06870dfc167d192ca38a38261867b836cb89ac80bc9176dba975e" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gix-commitgraph", "gix-date", "gix-hash", @@ -1303,7 +1303,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a96ed0e71ce9084a471fddfa74e842576a7cbf02fe8bd50388017ac461aed97" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "bstr", "gix-attributes", "gix-config-value", @@ -1427,7 +1427,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gix-path", "libc", "windows-sys 0.52.0", @@ -1626,9 +1626,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e57fa0ae458eb99874f54c09f4f9174f8b45fb87e854536a4e608696247f0c23" dependencies = [ "ahash", "allocator-api2", @@ -2012,7 +2012,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -2579,7 +2579,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcb12f8fbf6c62614b0d56eb352af54f6a22410c3b079eb53ee93c7b97dd31d8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cassowary", "compact_str", "crossterm", @@ -2779,7 +2779,7 @@ version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -3813,9 +3813,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", "serde", diff --git a/Cargo.toml b/Cargo.toml index 978d1266..4cc7668b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,4 +114,4 @@ too_many_arguments = "allow" type_complexity = "allow" wrong_self_convention = "allow" rc_buffer = "warn" -# str_to_string = "warn" +str_to_string = "warn" diff --git a/crates/weaver_forge/src/config.rs b/crates/weaver_forge/src/config.rs index 0411bc5a..f71a2cf0 100644 --- a/crates/weaver_forge/src/config.rs +++ b/crates/weaver_forge/src/config.rs @@ -227,32 +227,32 @@ pub struct TemplateSyntax { /// Default block start delimiter. fn default_block_start() -> String { - "{%".to_string() + "{%".to_owned() } /// Default block end delimiter. fn default_block_end() -> String { - "%}".to_string() + "%}".to_owned() } /// Default variable start delimiter. fn default_variable_start() -> String { - "{{".to_string() + "{{".to_owned() } /// Default variable end delimiter. fn default_variable_end() -> String { - "}}".to_string() + "}}".to_owned() } /// Default comment start delimiter. fn default_comment_start() -> String { - "{#".to_string() + "{#".to_owned() } /// Default comment end delimiter. fn default_comment_end() -> String { - "#}".to_string() + "#}".to_owned() } impl From for minijinja::Syntax { diff --git a/crates/weaver_forge/src/filter.rs b/crates/weaver_forge/src/filter.rs index 776182a7..d89897ad 100644 --- a/crates/weaver_forge/src/filter.rs +++ b/crates/weaver_forge/src/filter.rs @@ -30,7 +30,7 @@ impl Filter { return Err(Error::CompoundError( errs.into_iter() .map(|e| Error::FilterError { - filter: filter_expr.to_string(), + filter: filter_expr.to_owned(), error: e.to_string(), }) .collect(), @@ -38,12 +38,12 @@ impl Filter { } let parsed_expr = parsed_expr.ok_or_else(|| Error::FilterError { - filter: filter_expr.to_string(), - error: "No parsed expression".to_string(), + filter: filter_expr.to_owned(), + error: "No parsed expression".to_owned(), })?; Ok(Self { - filter_expr: filter_expr.to_string(), + filter_expr: filter_expr.to_owned(), filter: ctx.compile(parsed_expr), }) } diff --git a/crates/weaver_forge/src/lib.rs b/crates/weaver_forge/src/lib.rs index 80a26783..63e86304 100644 --- a/crates/weaver_forge/src/lib.rs +++ b/crates/weaver_forge/src/lib.rs @@ -85,7 +85,7 @@ impl Object for TemplateObject { ) -> Result { if name == "set_file_name" { let (file_name,): (&str,) = from_args(args)?; - *self.file_name.lock().expect("Lock poisoned") = file_name.to_string(); + file_name.clone_into(&mut self.file_name.lock().expect("Lock poisoned")); Ok(Value::from("")) } else { Err(minijinja::Error::new( @@ -146,7 +146,7 @@ impl TemplateEngine { if !target_path.exists() { return Err(TargetNotSupported { root_path: config.root_dir.to_string_lossy().to_string(), - target: target.to_string(), + target: target.to_owned(), }); } @@ -292,13 +292,13 @@ impl TemplateEngine { ) -> Result<(), Error> { let template_object = TemplateObject { file_name: Arc::new(Mutex::new( - template_path.to_str().unwrap_or_default().to_string(), + template_path.to_str().unwrap_or_default().to_owned(), )), }; let mut engine = self.template_engine()?; let template_file = template_path.to_str().ok_or(InvalidTemplateFile { template: template_path.to_path_buf(), - error: "".to_string(), + error: "".to_owned(), })?; engine.add_global("template", Value::from_object(template_object.clone())); diff --git a/crates/weaver_resolved_schema/src/catalog.rs b/crates/weaver_resolved_schema/src/catalog.rs index 29d568a3..311e26c9 100644 --- a/crates/weaver_resolved_schema/src/catalog.rs +++ b/crates/weaver_resolved_schema/src/catalog.rs @@ -86,7 +86,7 @@ impl Catalog { RequirementLevel::Recommended { .. } => "recommended", RequirementLevel::ConditionallyRequired { .. } => "conditionally_required", }; - (requirement_level.to_string(), 1) + (requirement_level.to_owned(), 1) }) .fold(BTreeMap::new(), |mut acc, (k, v)| { *acc.entry(k).or_insert(0) += v; diff --git a/crates/weaver_resolver/src/attribute.rs b/crates/weaver_resolver/src/attribute.rs index 610aa668..8d18dd29 100644 --- a/crates/weaver_resolver/src/attribute.rs +++ b/crates/weaver_resolver/src/attribute.rs @@ -222,7 +222,7 @@ impl AttributeCatalog { root_attr_id, AttributeWithGroupId { attribute: attr.clone(), - group_id: group_id.to_string(), + group_id: group_id.to_owned(), }, ); Some(self.attribute_ref(attr)) @@ -407,7 +407,7 @@ pub fn resolve_attribute( .attribute(r#ref) .ok_or(Error::FailToResolveAttributes { ids: vec![r#ref.clone()], - error: "Attribute ref not found in the resolved registry".to_string(), + error: "Attribute ref not found in the resolved registry".to_owned(), })?; resolve_attribute(registry, sem_conv_attr) } diff --git a/crates/weaver_resolver/src/lib.rs b/crates/weaver_resolver/src/lib.rs index 7e341939..34d31936 100644 --- a/crates/weaver_resolver/src/lib.rs +++ b/crates/weaver_resolver/src/lib.rs @@ -469,8 +469,8 @@ impl SchemaResolver { _ = registries.insert(registry.id().into(), resolved_registry); let resolved_schema = ResolvedTelemetrySchema { - file_format: "1.0.0".to_string(), - schema_url: "".to_string(), + file_format: "1.0.0".to_owned(), + schema_url: "".to_owned(), registries, catalog, resource: None, @@ -661,7 +661,7 @@ impl SchemaResolver { // of the semantic convention file. let prefix = git_repo .to_str() - .map(|s| s.to_string()) + .map(|s| s.to_owned()) .unwrap_or_default(); let path = format!( "{}/{}", diff --git a/crates/weaver_resolver/src/metrics.rs b/crates/weaver_resolver/src/metrics.rs index e101eddd..8577e987 100644 --- a/crates/weaver_resolver/src/metrics.rs +++ b/crates/weaver_resolver/src/metrics.rs @@ -119,7 +119,7 @@ pub fn resolve_metrics( metric_group_ref: metrics.name.clone(), metric_ref: referenced_metric.name.clone(), error: "Some required attributes are missing in this metric" - .to_string(), + .to_owned(), }); } diff --git a/crates/weaver_resolver/src/registry.rs b/crates/weaver_resolver/src/registry.rs index 4f71a25c..90ac4961 100644 --- a/crates/weaver_resolver/src/registry.rs +++ b/crates/weaver_resolver/src/registry.rs @@ -179,7 +179,7 @@ pub fn check_any_of_constraints( None => errors.push(Error::UnresolvedAttributeRef { group_id: group.id.clone(), attribute_ref: attr_ref.0.to_string(), - provenance: group.provenance().to_string(), + provenance: group.provenance().to_owned(), }), Some(attr_name) => { _ = group_attr_names.insert(attr_name.clone()); @@ -237,7 +237,7 @@ fn check_group_any_of_constraints( let errors = unsatisfied_any_of_constraints .into_values() .map(|v| Error::UnsatisfiedAnyOfConstraint { - group_id: group_id.to_string(), + group_id: group_id.to_owned(), any_of: v.any_of, missing_attributes: v.missing_attributes, }) @@ -275,7 +275,7 @@ fn unresolved_registry_from_specs( UnresolvedRegistry { registry: Registry { - registry_url: registry_url.to_string(), + registry_url: registry_url.to_owned(), groups: vec![], }, groups, @@ -577,6 +577,15 @@ fn resolve_inheritance_attrs( .collect() } +/// Returns a clone of the first argument that is Some(T). +fn clone_first_some(arg_1: &Option, arg_2: &Option) -> Option { + if arg_1.is_some() { + arg_1.clone() + } else { + arg_2.clone() + } +} + fn resolve_inheritance_attr(attr: &AttributeSpec, parent_attr: &AttributeSpec) -> AttributeSpec { match attr { AttributeSpec::Ref { @@ -605,46 +614,20 @@ fn resolve_inheritance_attr(attr: &AttributeSpec, parent_attr: &AttributeSpec) - // attr and attr_parent are both references. AttributeSpec::Ref { r#ref: r#ref.clone(), - brief: if brief.is_some() { - brief.clone() - } else { - parent_brief.clone() - }, - examples: if examples.is_some() { - examples.clone() - } else { - parent_examples.clone() - }, - tag: if tag.is_some() { - tag.clone() - } else { - parent_tag.clone() - }, - requirement_level: if requirement_level.is_some() { - requirement_level.clone() - } else { - parent_requirement_level.clone() - }, - sampling_relevant: if sampling_relevant.is_some() { - *sampling_relevant - } else { - *parent_sampling_relevant - }, - note: if note.is_some() { - note.clone() - } else { - parent_note.clone() - }, - stability: if stability.is_some() { - stability.clone() - } else { - parent_stability.clone() - }, - deprecated: if deprecated.is_some() { - deprecated.clone() - } else { - parent_deprecated.clone() - }, + brief: clone_first_some(brief, parent_brief), + examples: clone_first_some(examples, parent_examples), + tag: clone_first_some(tag, parent_tag), + requirement_level: clone_first_some( + requirement_level, + parent_requirement_level, + ), + sampling_relevant: clone_first_some( + sampling_relevant, + parent_sampling_relevant, + ), + note: clone_first_some(note, parent_note), + stability: clone_first_some(stability, parent_stability), + deprecated: clone_first_some(deprecated, parent_deprecated), } } AttributeSpec::Id { @@ -664,21 +647,9 @@ fn resolve_inheritance_attr(attr: &AttributeSpec, parent_attr: &AttributeSpec) - AttributeSpec::Id { id: r#ref.clone(), r#type: parent_type.clone(), - brief: if brief.is_some() { - brief.clone() - } else { - parent_brief.clone() - }, - examples: if examples.is_some() { - examples.clone() - } else { - parent_examples.clone() - }, - tag: if tag.is_some() { - tag.clone() - } else { - parent_tag.clone() - }, + brief: clone_first_some(brief, parent_brief), + examples: clone_first_some(examples, parent_examples), + tag: clone_first_some(tag, parent_tag), requirement_level: if requirement_level.is_some() { requirement_level .clone() @@ -686,26 +657,17 @@ fn resolve_inheritance_attr(attr: &AttributeSpec, parent_attr: &AttributeSpec) - } else { parent_requirement_level.clone() }, - sampling_relevant: if sampling_relevant.is_some() { - *sampling_relevant - } else { - *parent_sampling_relevant - }, + sampling_relevant: clone_first_some( + sampling_relevant, + parent_sampling_relevant, + ), note: if note.is_some() { note.clone().expect("is_some so this can't happen") } else { parent_note.clone() }, - stability: if stability.is_some() { - stability.clone() - } else { - parent_stability.clone() - }, - deprecated: if deprecated.is_some() { - deprecated.clone() - } else { - parent_deprecated.clone() - }, + stability: clone_first_some(stability, parent_stability), + deprecated: clone_first_some(deprecated, parent_deprecated), } } } @@ -825,27 +787,23 @@ mod tests { check_group_any_of_constraints("group", group_attr_names, &constraints)?; // Attributes and no constraint. - let group_attr_names = vec!["attr1".to_string(), "attr2".to_string()] + let group_attr_names = vec!["attr1".to_owned(), "attr2".to_owned()] .into_iter() .collect(); let constraints = vec![]; check_group_any_of_constraints("group", group_attr_names, &constraints)?; // Attributes and multiple constraints (all satisfiable). - let group_attr_names = vec![ - "attr1".to_string(), - "attr2".to_string(), - "attr3".to_string(), - ] - .into_iter() - .collect(); + let group_attr_names = vec!["attr1".to_owned(), "attr2".to_owned(), "attr3".to_owned()] + .into_iter() + .collect(); let constraints = vec![ Constraint { - any_of: vec!["attr1".to_string(), "attr2".to_string()], + any_of: vec!["attr1".to_owned(), "attr2".to_owned()], include: None, }, Constraint { - any_of: vec!["attr3".to_string()], + any_of: vec!["attr3".to_owned()], include: None, }, Constraint { @@ -856,16 +814,12 @@ mod tests { check_group_any_of_constraints("group", group_attr_names, &constraints)?; // Attributes and multiple constraints (one unsatisfiable). - let group_attr_names = vec![ - "attr1".to_string(), - "attr2".to_string(), - "attr3".to_string(), - ] - .into_iter() - .collect(); + let group_attr_names = vec!["attr1".to_owned(), "attr2".to_owned(), "attr3".to_owned()] + .into_iter() + .collect(); let constraints = vec![ Constraint { - any_of: vec!["attr4".to_string()], + any_of: vec!["attr4".to_owned()], include: None, }, Constraint { diff --git a/crates/weaver_schema/src/lib.rs b/crates/weaver_schema/src/lib.rs index 26312de1..2f2995ac 100644 --- a/crates/weaver_schema/src/lib.rs +++ b/crates/weaver_schema/src/lib.rs @@ -134,7 +134,7 @@ impl TelemetrySchema { pub fn load(schema: &str) -> Result { if schema.starts_with("http://") || schema.starts_with("https://") { let schema_url = Url::parse(schema).map_err(|e| Error::SchemaNotFound { - path_or_url: schema.to_string(), + path_or_url: schema.to_owned(), error: e.to_string(), })?; Self::load_from_url(&schema_url) diff --git a/crates/weaver_semconv/src/lib.rs b/crates/weaver_semconv/src/lib.rs index 2691e4bd..953dd5e1 100644 --- a/crates/weaver_semconv/src/lib.rs +++ b/crates/weaver_semconv/src/lib.rs @@ -331,11 +331,11 @@ impl SemConvRegistry { pub fn try_from_path(registry_id: &str, path_pattern: &str) -> Result { let mut registry = SemConvRegistry::new(registry_id); for sc_entry in glob(path_pattern).map_err(|e| Error::InvalidRegistryPathPattern { - path_pattern: path_pattern.to_string(), + path_pattern: path_pattern.to_owned(), error: e.to_string(), })? { let path_buf = sc_entry.map_err(|e| Error::InvalidRegistryAsset { - path_pattern: path_pattern.to_string(), + path_pattern: path_pattern.to_owned(), error: e.to_string(), })?; registry.load_from_file(path_buf.as_path())?; @@ -388,13 +388,13 @@ impl SemConvRegistry { let spec = SemConvSpec::load_from_url(sem_conv_url)?; if let Err(e) = spec.validate() { return Err(Error::InvalidCatalog { - path_or_url: sem_conv_url.to_string(), + path_or_url: sem_conv_url.to_owned(), line: None, column: None, error: e.to_string(), }); } - Ok((sem_conv_url.to_string(), spec)) + Ok((sem_conv_url.to_owned(), spec)) } /// Returns the number of semantic convention assets added in the semantic convention registry. @@ -488,7 +488,7 @@ impl SemConvRegistry { return Err(Error::InvalidMetric { path_or_url: provenance.clone(), group_id: group.id.clone(), - error: "Metric without name".to_string(), + error: "Metric without name".to_owned(), }); }; let instrument = if let Some(instrument) = group.instrument.as_ref() { @@ -497,7 +497,7 @@ impl SemConvRegistry { return Err(Error::InvalidMetric { path_or_url: provenance.clone(), group_id: group.id.clone(), - error: "Metric without instrument definition".to_string(), + error: "Metric without instrument definition".to_owned(), }); }; @@ -667,7 +667,7 @@ impl SemConvRegistry { } } else { return Err(Error::AttributeNotFound { - r#ref: r#ref.to_string(), + r#ref: r#ref.to_owned(), }); } Ok(attributes) @@ -840,7 +840,7 @@ impl SemConvSpec { let reader = ureq::get(semconv_url) .call() .map_err(|e| Error::CatalogNotFound { - path_or_url: semconv_url.to_string(), + path_or_url: semconv_url.to_owned(), error: e.to_string(), })? .into_reader(); @@ -848,7 +848,7 @@ impl SemConvSpec { // Deserialize the telemetry schema from the content reader let catalog: SemConvSpec = serde_yaml::from_reader(reader).map_err(|e| Error::InvalidCatalog { - path_or_url: semconv_url.to_string(), + path_or_url: semconv_url.to_owned(), line: e.location().map(|loc| loc.line()), column: e.location().map(|loc| loc.column()), error: e.to_string(), diff --git a/crates/weaver_template/src/config.rs b/crates/weaver_template/src/config.rs index 4552f90e..09dcf5af 100644 --- a/crates/weaver_template/src/config.rs +++ b/crates/weaver_template/src/config.rs @@ -115,7 +115,7 @@ impl DynamicGlobalConfig { .file_name .get_or(|| RefCell::new(None)) .borrow_mut() - .replace(file_name.to_string()); + .replace(file_name.to_owned()); } /// Get the file name for the current generated code. diff --git a/crates/weaver_template/src/filters.rs b/crates/weaver_template/src/filters.rs index b56fd198..3d66fee7 100644 --- a/crates/weaver_template/src/filters.rs +++ b/crates/weaver_template/src/filters.rs @@ -36,7 +36,7 @@ pub fn instrument(value: &Value, _: &HashMap) -> Result { if let Value::String(metric_type) = value { match metric_type.as_str() { "counter" | "gauge" | "histogram" => Ok(Value::String(metric_type.clone())), - "updowncounter" => Ok(Value::String("up_down_counter".to_string())), + "updowncounter" => Ok(Value::String("up_down_counter".to_owned())), _ => Err(tera::Error::msg(format!( "Filter instrument: unknown metric instrument {}", metric_type @@ -290,7 +290,7 @@ impl Filter for TypeMapping { let enum_name = match ctx.get("enum") { Some(Value::String(v)) => v.clone(), Some(_) => return Err(tera::Error::msg(format!("Filter type_mapping: expected a string for the enum parameter, got {:?}", ctx.get("enum")))), - _ => return Err(tera::Error::msg("Filter type_mapping: expected an enum parameter".to_string())) + _ => return Err(tera::Error::msg("Filter type_mapping: expected an enum parameter".to_owned())) }; Ok(Value::String(enum_name)) } @@ -312,7 +312,7 @@ pub fn comment(value: &Value, ctx: &HashMap) -> Result { let prefix = match ctx.get("prefix") { Some(Value::String(prefix)) => prefix.clone(), - _ => "".to_string(), + _ => "".to_owned(), }; let mut lines = vec![]; diff --git a/crates/weaver_template/src/sdkgen.rs b/crates/weaver_template/src/sdkgen.rs index cf7f475b..80158bbf 100644 --- a/crates/weaver_template/src/sdkgen.rs +++ b/crates/weaver_template/src/sdkgen.rs @@ -74,7 +74,7 @@ impl ClientSdkGenerator { let lang_path = config.template_dir.join(language); if !lang_path.exists() { - return Err(LanguageNotSupported(language.to_string())); + return Err(LanguageNotSupported(language.to_owned())); } let lang_dir_tree = match lang_path.to_str() { @@ -171,7 +171,7 @@ impl ClientSdkGenerator { })?; // Process recursively all files in the template directory - let mut lang_path = self.lang_path.to_str().unwrap_or_default().to_string(); + let mut lang_path = self.lang_path.to_str().unwrap_or_default().to_owned(); let paths = if lang_path.is_empty() { glob("**/*.tera").map_err(|e| InternalError(e.to_string()))? } else { diff --git a/crates/weaver_version/src/lib.rs b/crates/weaver_version/src/lib.rs index 47afbbb9..bdc1d684 100644 --- a/crates/weaver_version/src/lib.rs +++ b/crates/weaver_version/src/lib.rs @@ -578,7 +578,7 @@ impl VersionChanges { if let Some(new_name) = self.resource_old_to_new_attributes.get(name) { new_name.clone() } else { - name.to_string() + name.to_owned() } } @@ -589,7 +589,7 @@ impl VersionChanges { if let Some(new_name) = self.metric_old_to_new_attributes.get(name) { new_name.clone() } else { - name.to_string() + name.to_owned() } } @@ -600,7 +600,7 @@ impl VersionChanges { if let Some(new_name) = self.metric_old_to_new_names.get(name) { new_name.clone() } else { - name.to_string() + name.to_owned() } } @@ -611,7 +611,7 @@ impl VersionChanges { if let Some(new_name) = self.log_old_to_new_attributes.get(name) { new_name.clone() } else { - name.to_string() + name.to_owned() } } @@ -622,7 +622,7 @@ impl VersionChanges { if let Some(new_name) = self.span_old_to_new_attributes.get(name) { new_name.clone() } else { - name.to_string() + name.to_owned() } } } @@ -718,7 +718,7 @@ mod tests { .rename_attributes .attribute_map .get("messaging.kafka.client_id"); - assert_eq!(observed_value, Some(&"messaging.client.id".to_string())); + assert_eq!(observed_value, Some(&"messaging.client.id".to_owned())); let v1_8 = app_versions .versions @@ -728,35 +728,35 @@ mod tests { .rename_attributes .attribute_map .get("db.cassandra.keyspace"); - assert_eq!(observed_value, Some(&"database.name".to_string())); + assert_eq!(observed_value, Some(&"database.name".to_owned())); let observed_value = v1_8.spans.as_ref().unwrap().changes[0] .rename_attributes .attribute_map .get("db.cassandra.keyspace"); - assert_eq!(observed_value, Some(&"database.name".to_string())); + assert_eq!(observed_value, Some(&"database.name".to_owned())); let observed_value = v1_8.spans.as_ref().unwrap().changes[0] .rename_attributes .attribute_map .get("db.hbase.namespace"); - assert_eq!(observed_value, Some(&"db.name".to_string())); + assert_eq!(observed_value, Some(&"db.name".to_owned())); let observed_value = v1_8.logs.as_ref().unwrap().changes[0] .rename_attributes .attribute_map .get("db.cassandra.keyspace"); - assert_eq!(observed_value, Some(&"database.name".to_string())); + assert_eq!(observed_value, Some(&"database.name".to_owned())); let observed_value = v1_8.logs.as_ref().unwrap().changes[0] .rename_attributes .attribute_map .get("db.hbase.namespace"); - assert_eq!(observed_value, Some(&"db.name".to_string())); + assert_eq!(observed_value, Some(&"db.name".to_owned())); let observed_value = v1_8.metrics.as_ref().unwrap().changes[0] .rename_metrics .get("m1"); - assert_eq!(observed_value, Some(&"metric_1".to_string())); + assert_eq!(observed_value, Some(&"metric_1".to_owned())); let observed_value = v1_8.metrics.as_ref().unwrap().changes[0] .rename_metrics .get("m2"); - assert_eq!(observed_value, Some(&"metric2".to_string())); + assert_eq!(observed_value, Some(&"metric2".to_owned())); let v1_7_1 = app_versions .versions @@ -766,7 +766,7 @@ mod tests { .rename_attributes .attribute_map .get("db.cassandra.table"); - assert_eq!(observed_value, Some(&"database.table".to_string())); + assert_eq!(observed_value, Some(&"database.table".to_owned())); // Transformations inherited from `parent_versions.yaml` and // initially not present in `app_versions.yaml` @@ -779,13 +779,13 @@ mod tests { .get("process.runtime.jvm.cpu.utilization"); assert_eq!( observed_value, - Some(&"process.runtime.jvm.cpu.recent_utilization".to_string()) + Some(&"process.runtime.jvm.cpu.recent_utilization".to_owned()) ); let observed_value = v1_21.spans.as_ref().unwrap().changes[0] .rename_attributes .attribute_map .get("messaging.kafka.client_id"); - assert_eq!(observed_value, Some(&"messaging.client_id".to_string())); + assert_eq!(observed_value, Some(&"messaging.client_id".to_owned())); let changes = app_versions.version_changes_for(app_versions.latest_version().as_ref().unwrap()); diff --git a/src/search/mod.rs b/src/search/mod.rs index 43a042d0..74623f70 100644 --- a/src/search/mod.rs +++ b/src/search/mod.rs @@ -290,9 +290,9 @@ fn search_registry_command( schema } else { TelemetrySchema { - file_format: "".to_string(), + file_format: "".to_owned(), parent_schema_url: None, - schema_url: "".to_string(), + schema_url: "".to_owned(), semantic_conventions: vec![], schema: None, versions: None, @@ -459,8 +459,8 @@ fn ui(app: &mut SearchApp<'_>, frame: &mut Frame<'_>) { let brief = values[1].value().as_text().unwrap_or_default(); app.results.items.push(ResultItem { - path: path.to_string(), - brief: brief.to_string(), + path: path.to_owned(), + brief: brief.to_owned(), }); } app.results.next(); diff --git a/src/search/schema/attribute.rs b/src/search/schema/attribute.rs index 503427ea..26829ccc 100644 --- a/src/search/schema/attribute.rs +++ b/src/search/schema/attribute.rs @@ -47,7 +47,7 @@ pub fn index_schema_attribute<'a>( .. } = attr { - let tags: String = tags.as_ref().map_or("".to_string(), |tags| { + let tags: String = tags.as_ref().map_or("".to_owned(), |tags| { tags.iter() .map(|(k, v)| format!("{}: {}", k, v)) .collect::>() diff --git a/src/search/schema/attributes.rs b/src/search/schema/attributes.rs index 6809359e..dfbcc4d3 100644 --- a/src/search/schema/attributes.rs +++ b/src/search/schema/attributes.rs @@ -29,7 +29,7 @@ pub fn append_lines(attributes: &[Attribute], text: &mut Vec>, theme: & if let RequirementLevel::Basic(BasicRequirementLevelSpec::Required) = requirement_level { - properties.push("required".to_string()); + properties.push("required".to_owned()); } if let Some(tags) = tags { if !tags.is_empty() { diff --git a/src/search/schema/event.rs b/src/search/schema/event.rs index 87a47048..72a50c17 100644 --- a/src/search/schema/event.rs +++ b/src/search/schema/event.rs @@ -14,7 +14,7 @@ use weaver_schema::TelemetrySchema; /// Build index for events. pub fn index(schema: &TelemetrySchema, fields: &DocFields, index_writer: &mut IndexWriter) { for event in schema.events() { - let tags: String = event.tags.clone().map_or("".to_string(), |tags| { + let tags: String = event.tags.clone().map_or("".to_owned(), |tags| { tags.iter() .map(|(k, v)| format!("{}: {}", k, v)) .collect::>() diff --git a/src/search/schema/metric.rs b/src/search/schema/metric.rs index c89d3bb1..e61feff6 100644 --- a/src/search/schema/metric.rs +++ b/src/search/schema/metric.rs @@ -40,7 +40,7 @@ pub fn index_schema_metrics( index_writer: &mut IndexWriter, ) { for metric in schema.metrics() { - let tags: String = metric.tags().map_or("".to_string(), |tags| { + let tags: String = metric.tags().map_or("".to_owned(), |tags| { tags.iter() .map(|(k, v)| format!("{}: {}", k, v)) .collect::>() diff --git a/src/search/schema/metric_group.rs b/src/search/schema/metric_group.rs index 4e6b3bec..dec7a528 100644 --- a/src/search/schema/metric_group.rs +++ b/src/search/schema/metric_group.rs @@ -17,7 +17,7 @@ use crate::search::DocFields; /// Build index for metrics. pub fn index(schema: &TelemetrySchema, fields: &DocFields, index_writer: &mut IndexWriter) { for metric_group in schema.metric_groups() { - let tags: String = metric_group.tags().map_or("".to_string(), |tags| { + let tags: String = metric_group.tags().map_or("".to_owned(), |tags| { tags.iter() .map(|(k, v)| format!("{}: {}", k, v)) .collect::>() diff --git a/src/search/schema/resource.rs b/src/search/schema/resource.rs index dd8752d6..1234ed9d 100644 --- a/src/search/schema/resource.rs +++ b/src/search/schema/resource.rs @@ -24,7 +24,7 @@ pub fn index(schema: &TelemetrySchema, fields: &DocFields, index_writer: &mut In fields.path => format!("schema/resource/attr/{}", the_id), fields.brief => the_brief.as_str(), fields.note => the_note.as_str(), - fields.tag => the_tag.as_ref().unwrap_or(&"".to_string()).as_str(), + fields.tag => the_tag.as_ref().unwrap_or(&"".to_owned()).as_str(), )) .expect("Failed to add document"); } diff --git a/src/search/schema/span.rs b/src/search/schema/span.rs index 92a4b3a8..a8c5974b 100644 --- a/src/search/schema/span.rs +++ b/src/search/schema/span.rs @@ -14,7 +14,7 @@ use weaver_schema::TelemetrySchema; /// Build index for spans. pub fn index(schema: &TelemetrySchema, fields: &DocFields, index_writer: &mut IndexWriter) { for span in schema.spans() { - let tags: String = span.tags.clone().map_or("".to_string(), |tags| { + let tags: String = span.tags.clone().map_or("".to_owned(), |tags| { tags.iter() .map(|(k, v)| format!("{}: {}", k, v)) .collect::>() @@ -36,7 +36,7 @@ pub fn index(schema: &TelemetrySchema, fields: &DocFields, index_writer: &mut In index_writer, ); for event in span.events.iter() { - let tags: String = event.tags.clone().map_or("".to_string(), |tags| { + let tags: String = event.tags.clone().map_or("".to_owned(), |tags| { tags.iter() .map(|(k, v)| format!("{}: {}", k, v)) .collect::>() diff --git a/src/search/semconv/attributes.rs b/src/search/semconv/attributes.rs index b33a5e35..26b60e88 100644 --- a/src/search/semconv/attributes.rs +++ b/src/search/semconv/attributes.rs @@ -26,7 +26,7 @@ pub fn append_lines(attributes: &[AttributeSpec], text: &mut Vec>, them if let RequirementLevel::Basic(BasicRequirementLevelSpec::Required) = requirement_level { - properties.push("required".to_string()); + properties.push("required".to_owned()); } let properties = if properties.is_empty() { String::new() diff --git a/tests/resolution_process.rs b/tests/resolution_process.rs index deb0a187..6c1ca545 100644 --- a/tests/resolution_process.rs +++ b/tests/resolution_process.rs @@ -33,8 +33,8 @@ fn test_semconv_registry_resolution() { // No parsing errors should be observed. let semconv_specs = SchemaResolver::load_semconv_registry( registry_id, - SEMCONV_REGISTRY_URL.to_string(), - Some(SEMCONV_REGISTRY_MODEL.to_string()), + SEMCONV_REGISTRY_URL.to_owned(), + Some(SEMCONV_REGISTRY_MODEL.to_owned()), &cache, log.clone(), )