Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use `const` over `static` for string literals (#18635)
Marshall Bowers167af4bc1d3a
diff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex 48bd646d8aa..d565d620c3c 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -1752,7 +1752,7 @@ impl CredentialsProvider for KeychainCredentialsProvider {}/// prefix for the zed:// url scheme-pub static ZED_URL_SCHEME: &str = "zed";+pub const ZED_URL_SCHEME: &str = "zed";/// Parses the given link into a Zed link.///diff --git a/crates/collab/src/api/events.rs b/crates/collab/src/api/events.rsindex 377741f434c..bbfa69c0b8f 100644--- a/crates/collab/src/api/events.rs+++ b/crates/collab/src/api/events.rs@@ -23,7 +23,7 @@ use telemetry_events::{};use uuid::Uuid;-static CRASH_REPORTS_BUCKET: &str = "zed-crash-reports";+const CRASH_REPORTS_BUCKET: &str = "zed-crash-reports";pub fn router() -> Router {Router::new()diff --git a/crates/editor/src/clangd_ext.rs b/crates/editor/src/clangd_ext.rsindex 2f0f7aaee47..501f81b1073 100644--- a/crates/editor/src/clangd_ext.rs+++ b/crates/editor/src/clangd_ext.rs@@ -9,7 +9,7 @@ use crate::lsp_ext::find_specific_language_server_in_selection;use crate::{element::register_action, Editor, SwitchSourceHeader};-static CLANGD_SERVER_NAME: &str = "clangd";+const CLANGD_SERVER_NAME: &str = "clangd";fn is_c_language(language: &Language) -> bool {return language.name() == "C++".into() || language.name() == "C".into();diff --git a/crates/editor/src/rust_analyzer_ext.rs b/crates/editor/src/rust_analyzer_ext.rsindex db17eaab282..fa39e5c9d49 100644--- a/crates/editor/src/rust_analyzer_ext.rs+++ b/crates/editor/src/rust_analyzer_ext.rs@@ -10,7 +10,7 @@ use crate::{ExpandMacroRecursively,};-static RUST_ANALYZER_NAME: &str = "rust-analyzer";+const RUST_ANALYZER_NAME: &str = "rust-analyzer";fn is_rust_language(language: &Language) -> bool {language.name() == "Rust".into()diff --git a/crates/gpui/src/taffy.rs b/crates/gpui/src/taffy.rsindex a6a61031c9c..a80c734b81b 100644--- a/crates/gpui/src/taffy.rs+++ b/crates/gpui/src/taffy.rs@@ -24,7 +24,7 @@ pub struct TaffyLayoutEngine {nodes_to_measure: FxHashMap<LayoutId, NodeMeasureFn>,}-static EXPECT_MESSAGE: &str = "we should avoid taffy layout errors by construction if possible";+const EXPECT_MESSAGE: &str = "we should avoid taffy layout errors by construction if possible";impl TaffyLayoutEngine {pub fn new() -> Self {diff --git a/crates/task/src/vscode_format.rs b/crates/task/src/vscode_format.rsindex 74be56b5b17..c150ee807fb 100644--- a/crates/task/src/vscode_format.rs+++ b/crates/task/src/vscode_format.rs@@ -200,7 +200,7 @@ mod tests {#[test]fn can_deserialize_ts_tasks() {- static TYPESCRIPT_TASKS: &str = include_str!("../test_data/typescript.json");+ const TYPESCRIPT_TASKS: &str = include_str!("../test_data/typescript.json");let vscode_definitions: VsCodeTaskFile =serde_json_lenient::from_str(TYPESCRIPT_TASKS).unwrap();@@ -290,7 +290,7 @@ mod tests {#[test]fn can_deserialize_rust_analyzer_tasks() {- static RUST_ANALYZER_TASKS: &str = include_str!("../test_data/rust-analyzer.json");+ const RUST_ANALYZER_TASKS: &str = include_str!("../test_data/rust-analyzer.json");let vscode_definitions: VsCodeTaskFile =serde_json_lenient::from_str(RUST_ANALYZER_TASKS).unwrap();let expected = vec![diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rsindex a3daf8ea2ea..40cd465d9ba 100644--- a/crates/worktree/src/worktree.rs+++ b/crates/worktree/src/worktree.rs@@ -351,7 +351,7 @@ pub enum Event {DeletedEntry(ProjectEntryId),}-static EMPTY_PATH: &str = "";+const EMPTY_PATH: &str = "";impl EventEmitter<Event> for Worktree {}diff --git a/crates/zed/src/reliability.rs b/crates/zed/src/reliability.rsindex 50e5a05b823..b40bbc78bdb 100644--- a/crates/zed/src/reliability.rs+++ b/crates/zed/src/reliability.rs@@ -441,7 +441,7 @@ async fn upload_previous_panics(Ok::<_, anyhow::Error>(most_recent_panic)}-static LAST_CRASH_UPLOADED: &str = "LAST_CRASH_UPLOADED";+const LAST_CRASH_UPLOADED: &str = "LAST_CRASH_UPLOADED";/// upload crashes from apple's diagnostic reports to our server./// (only if telemetry is enabled)