Skip to content

Commit c118af5

Browse files
committed
Lints for Rust 1.78
Signed-off-by: itowlson <[email protected]>
1 parent 8454856 commit c118af5

File tree

7 files changed

+41
-34
lines changed

7 files changed

+41
-34
lines changed

crates/http/src/wagi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ fn parse_host_header_uri(
184184
let mut parse_host = |hdr: String| {
185185
let mut parts = hdr.splitn(2, ':');
186186
match parts.next() {
187-
Some(h) if !h.is_empty() => host = h.to_owned(),
187+
Some(h) if !h.is_empty() => h.clone_into(&mut host),
188188
_ => {}
189189
}
190190
match parts.next() {
191191
Some(p) if !p.is_empty() => {
192192
tracing::debug!(port = p, "Overriding port");
193-
port = p.to_owned()
193+
p.clone_into(&mut port);
194194
}
195195
_ => {}
196196
}

crates/manifest/src/normalize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn normalize_trigger_ids(manifest: &mut AppManifest) {
8686
if let Some(ComponentSpec::Reference(component_id)) = &trigger.component {
8787
let candidate_id = format!("{component_id}-{trigger_type}-trigger");
8888
if !trigger_ids.contains(&candidate_id) {
89-
trigger.id = candidate_id.clone();
89+
trigger.id.clone_from(&candidate_id);
9090
trigger_ids.insert(candidate_id);
9191
continue;
9292
}

crates/oci/src/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl AuthConfig {
6060
/// Get the registry authentication for a given registry from the default location.
6161
pub async fn get_auth_from_default(server: impl AsRef<str>) -> Result<RegistryAuth> {
6262
let auths = Self::load_default().await?;
63-
let encoded = match auths.auths.get(&server.as_ref().to_string()) {
63+
let encoded = match auths.auths.get(server.as_ref()) {
6464
Some(e) => e,
6565
None => bail!(format!("no credentials stored for {}", server.as_ref())),
6666
};

crates/trigger-http/src/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ fn set_http_origin_from_request(
378378
.host_components_data()
379379
.get_or_insert(outbound_http_handle);
380380

381-
outbound_http_data.origin = origin.clone();
381+
outbound_http_data.origin.clone_from(&origin);
382382
store.as_mut().data_mut().as_mut().allowed_hosts =
383383
outbound_http_data.allowed_hosts.clone();
384384
}

crates/trigger-http/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,10 @@ impl OutboundWasiHttpHandler for HttpRuntimeData {
662662
.map(|s| s == &Scheme::HTTPS)
663663
.unwrap_or_default();
664664
// We know that `uri` has an authority because we set it above
665-
request.authority = uri.authority().unwrap().as_str().to_owned();
665+
uri.authority()
666+
.unwrap()
667+
.as_str()
668+
.clone_into(&mut request.authority);
666669
*request.request.uri_mut() = uri;
667670
}
668671

crates/trigger/src/runtime_config/llm.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use async_trait::async_trait;
2-
use spin_llm::LlmEngine;
31
use spin_llm_remote_http::RemoteHttpLlmEngine;
4-
use spin_world::v2::llm as wasi_llm;
52
use url::Url;
63

74
#[derive(Default)]
@@ -26,7 +23,7 @@ pub(crate) async fn build_component(
2623
#[cfg(not(feature = "llm"))]
2724
LlmComputeOpts::Spin => {
2825
let _ = use_gpu;
29-
spin_llm::LlmComponent::new(move || Box::new(NoopLlmEngine.clone()))
26+
spin_llm::LlmComponent::new(move || Box::new(noop::NoopLlmEngine.clone()))
3027
}
3128
LlmComputeOpts::RemoteHttp(config) => {
3229
tracing::log::info!("Using remote compute for LLMs");
@@ -50,29 +47,36 @@ pub struct RemoteHttpComputeOpts {
5047
auth_token: String,
5148
}
5249

53-
#[derive(Clone)]
54-
struct NoopLlmEngine;
50+
#[cfg(not(feature = "llm"))]
51+
mod noop {
52+
use async_trait::async_trait;
53+
use spin_llm::LlmEngine;
54+
use spin_world::v2::llm as wasi_llm;
5555

56-
#[async_trait]
57-
impl LlmEngine for NoopLlmEngine {
58-
async fn infer(
59-
&mut self,
60-
_model: wasi_llm::InferencingModel,
61-
_prompt: String,
62-
_params: wasi_llm::InferencingParams,
63-
) -> Result<wasi_llm::InferencingResult, wasi_llm::Error> {
64-
Err(wasi_llm::Error::RuntimeError(
65-
"Local LLM operations are not supported in this version of Spin.".into(),
66-
))
67-
}
56+
#[derive(Clone)]
57+
pub(super) struct NoopLlmEngine;
58+
59+
#[async_trait]
60+
impl LlmEngine for NoopLlmEngine {
61+
async fn infer(
62+
&mut self,
63+
_model: wasi_llm::InferencingModel,
64+
_prompt: String,
65+
_params: wasi_llm::InferencingParams,
66+
) -> Result<wasi_llm::InferencingResult, wasi_llm::Error> {
67+
Err(wasi_llm::Error::RuntimeError(
68+
"Local LLM operations are not supported in this version of Spin.".into(),
69+
))
70+
}
6871

69-
async fn generate_embeddings(
70-
&mut self,
71-
_model: wasi_llm::EmbeddingModel,
72-
_data: Vec<String>,
73-
) -> Result<wasi_llm::EmbeddingsResult, wasi_llm::Error> {
74-
Err(wasi_llm::Error::RuntimeError(
75-
"Local LLM operations are not supported in this version of Spin.".into(),
76-
))
72+
async fn generate_embeddings(
73+
&mut self,
74+
_model: wasi_llm::EmbeddingModel,
75+
_data: Vec<String>,
76+
) -> Result<wasi_llm::EmbeddingsResult, wasi_llm::Error> {
77+
Err(wasi_llm::Error::RuntimeError(
78+
"Local LLM operations are not supported in this version of Spin.".into(),
79+
))
80+
}
7781
}
7882
}

tests/testcases/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,11 @@ pub fn bootstrap_smoke_test(
345345
let mut custom_path = value.to_owned();
346346
if value.starts_with('.') {
347347
let current_dir = env.path();
348-
custom_path = current_dir
348+
current_dir
349349
.join(value)
350350
.to_str()
351351
.unwrap_or_default()
352-
.to_owned();
352+
.clone_into(&mut custom_path);
353353
}
354354
build.env(key, format!("{}:{}", custom_path, path));
355355
} else {

0 commit comments

Comments
 (0)