diff --git a/cli/cache/check.rs b/cli/cache/check.rs index a886f9fe0f..201d770411 100644 --- a/cli/cache/check.rs +++ b/cli/cache/check.rs @@ -92,7 +92,7 @@ impl TypeCheckCache { .0 .query_row( "SELECT text FROM tsbuildinfo WHERE specifier=?1 LIMIT 1", - params![specifier.to_string()], + params![specifier.as_str()], |row| Ok(row.get::<_, String>(0)?), ) .ok()? @@ -116,7 +116,7 @@ impl TypeCheckCache { ) -> Result<(), AnyError> { self.0.execute( "INSERT OR REPLACE INTO tsbuildinfo (specifier, text) VALUES (?1, ?2)", - params![specifier.to_string(), text], + params![specifier.as_str(), text], )?; Ok(()) } diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs index 11c3ac47f8..fdf6ee9407 100644 --- a/cli/lsp/registries.rs +++ b/cli/lsp/registries.rs @@ -853,7 +853,7 @@ impl ModuleRegistry { { format!("{text}{suffix}") } else { - url.to_string() + url.into() }; let text_edit = Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { diff --git a/cli/tools/bundle/mod.rs b/cli/tools/bundle/mod.rs index cf42dfcb81..1526d13e37 100644 --- a/cli/tools/bundle/mod.rs +++ b/cli/tools/bundle/mod.rs @@ -423,7 +423,7 @@ fn format_message( location.file.as_str(), current_dir ) - .map(|url| deno_terminal::colors::cyan(url.to_string())) + .map(|url| deno_terminal::colors::cyan(url.into())) .unwrap_or(deno_terminal::colors::cyan(location.file.clone())), deno_terminal::colors::yellow(location.line), deno_terminal::colors::yellow(location.column) @@ -773,7 +773,7 @@ impl DenoPluginHandler { ); match result { - Ok(specifier) => Ok(Some(file_path_or_url(&specifier)?)), + Ok(specifier) => Ok(Some(file_path_or_url(specifier)?)), Err(e) => { log::debug!("{}: {:?}", deno_terminal::colors::red("error"), e); Err(BundleError::Resolver(e)) @@ -1000,16 +1000,16 @@ impl DenoPluginHandler { } fn file_path_or_url( - url: &Url, + url: Url, ) -> Result { if url.scheme() == "file" { Ok( - deno_path_util::url_to_file_path(url)? + deno_path_util::url_to_file_path(&url)? .to_string_lossy() .into(), ) } else { - Ok(url.to_string()) + Ok(url.into()) } } diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 88a6561a19..d5a1538e40 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -306,7 +306,7 @@ impl deno_doc::html::HrefResolver for DocResolver { if url.domain() == Some("deno.land") { url.set_query(Some(&format!("s={}", symbol.join(".")))); - return Some(url.to_string()); + return Some(url.into()); } None diff --git a/cli/tools/installer/mod.rs b/cli/tools/installer/mod.rs index 31885ef705..9ef61a9941 100644 --- a/cli/tools/installer/mod.rs +++ b/cli/tools/installer/mod.rs @@ -616,7 +616,7 @@ async fn resolve_shim_data( } } - executable_args.push(module_url.to_string()); + executable_args.push(module_url.into()); executable_args.extend_from_slice(&install_flags_global.args); Ok(ShimData { diff --git a/cli/tools/run/hmr.rs b/cli/tools/run/hmr.rs index 6c4cb41d1c..cc003d3cd8 100644 --- a/cli/tools/run/hmr.rs +++ b/cli/tools/run/hmr.rs @@ -132,7 +132,7 @@ impl HmrRunner { let file_path = file_url.to_file_path().unwrap(); if let Ok(canonicalized_file_path) = file_path.canonicalize() { let canonicalized_file_url = Url::from_file_path(canonicalized_file_path).unwrap(); - self.script_ids.insert(canonicalized_file_url.to_string(), params.script_id); + self.script_ids.insert(canonicalized_file_url.into(), params.script_id); } } } diff --git a/ext/net/quic.rs b/ext/net/quic.rs index 9142f6b3c7..e37d6948bc 100644 --- a/ext/net/quic.rs +++ b/ext/net/quic.rs @@ -1202,7 +1202,7 @@ pub(crate) mod webtransport { }; Ok(( - url.to_string(), + url.into(), connect_tx_rid, connect_rx_rid, settings_tx_rid, diff --git a/ext/node/ops/worker_threads.rs b/ext/node/ops/worker_threads.rs index 25460de5f2..4293c20cb0 100644 --- a/ext/node/ops/worker_threads.rs +++ b/ext/node/ops/worker_threads.rs @@ -110,5 +110,5 @@ pub fn op_worker_threads_filename< url_path.to_path_buf(), )); } - Ok(Some(url.to_string())) + Ok(Some(url.into())) } diff --git a/ext/web/blob.rs b/ext/web/blob.rs index 9b0258cf31..7c51247d7f 100644 --- a/ext/web/blob.rs +++ b/ext/web/blob.rs @@ -268,7 +268,7 @@ pub fn op_blob_create_object_url( let url = blob_store .insert_object_url(blob, maybe_location.map(|location| location.0.clone())); - Ok(url.to_string()) + Ok(url.into()) } #[op2(fast)] diff --git a/tests/util/server/src/servers/mod.rs b/tests/util/server/src/servers/mod.rs index d70a93d27f..325f26da34 100644 --- a/tests/util/server/src/servers/mod.rs +++ b/tests/util/server/src/servers/mod.rs @@ -226,13 +226,12 @@ async fn hyper_hello(port: u16) { .await; } -fn redirect_resp(url: String) -> Response> { +fn redirect_resp(url: &str) -> Response> { let mut redirect_resp = Response::new(UnsyncBoxBody::new(Empty::new())); *redirect_resp.status_mut() = StatusCode::MOVED_PERMANENTLY; - redirect_resp.headers_mut().insert( - http::header::LOCATION, - HeaderValue::from_str(&url[..]).unwrap(), - ); + redirect_resp + .headers_mut() + .insert(http::header::LOCATION, HeaderValue::from_str(url).unwrap()); redirect_resp } @@ -244,7 +243,7 @@ async fn redirect( assert_eq!(&p[0..1], "/"); let url = format!("http://localhost:{PORT}{p}"); - Ok(redirect_resp(url)) + Ok(redirect_resp(&url)) } async fn double_redirects( @@ -254,7 +253,7 @@ async fn double_redirects( assert_eq!(&p[0..1], "/"); let url = format!("http://localhost:{REDIRECT_PORT}{p}"); - Ok(redirect_resp(url)) + Ok(redirect_resp(&url)) } async fn inf_redirects( @@ -264,7 +263,7 @@ async fn inf_redirects( assert_eq!(&p[0..1], "/"); let url = format!("http://localhost:{INF_REDIRECTS_PORT}{p}"); - Ok(redirect_resp(url)) + Ok(redirect_resp(&url)) } async fn another_redirect( @@ -274,7 +273,7 @@ async fn another_redirect( assert_eq!(&p[0..1], "/"); let url = format!("http://localhost:{PORT}/subdir{p}"); - Ok(redirect_resp(url)) + Ok(redirect_resp(&url)) } async fn auth_redirect( @@ -289,7 +288,7 @@ async fn auth_redirect( let p = req.uri().path(); assert_eq!(&p[0..1], "/"); let url = format!("http://localhost:{PORT}{p}"); - return Ok(redirect_resp(url)); + return Ok(redirect_resp(&url)); } } @@ -312,7 +311,7 @@ async fn basic_auth_redirect( let p = req.uri().path(); assert_eq!(&p[0..1], "/"); let url = format!("http://localhost:{PORT}{p}"); - return Ok(redirect_resp(url)); + return Ok(redirect_resp(&url)); } } @@ -421,21 +420,21 @@ async fn absolute_redirect( .collect(); if let Some(url) = query_params.get("redirect_to") { - let redirect = redirect_resp(url.to_owned()); + let redirect = redirect_resp(url); return Ok(redirect); } } if path.starts_with("/REDIRECT") { let url = &req.uri().path()[9..]; - let redirect = redirect_resp(url.to_string()); + let redirect = redirect_resp(url); return Ok(redirect); } if path.starts_with("/a/b/c") { if let Some(x_loc) = req.headers().get("x-location") { let loc = x_loc.to_str().unwrap(); - return Ok(redirect_resp(loc.to_string())); + return Ok(redirect_resp(loc)); } }