Skip to content

Commit ca2cda8

Browse files
authored
Remove unneeded 'static lifetimes on &strs in constants (#8698)
This PR removes unneeded `'static` lifetimes on `&str`s stored in `const` declarations. This addresses some Clippy lints about [`redundant_static_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#/redundant_static_lifetimes). In item-level `const` declarations we can rely on lifetime elision and use the default `'static` lifetime. Note that associated constants still require an explicit `'static` lifetime, as explained in rust-lang/rust#115010. Release Notes: - N/A
1 parent 5c2bd81 commit ca2cda8

File tree

32 files changed

+50
-53
lines changed

32 files changed

+50
-53
lines changed

crates/ai/src/providers/open_ai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ pub use completion::*;
66
pub use embedding::*;
77
pub use model::OpenAiLanguageModel;
88

9-
pub const OPEN_AI_API_URL: &'static str = "https://api.openai.com/v1";
9+
pub const OPEN_AI_API_URL: &str = "https://api.openai.com/v1";

crates/collab/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl Database {
375375
}
376376

377377
fn is_serialization_error(error: &Error) -> bool {
378-
const SERIALIZATION_FAILURE_CODE: &'static str = "40001";
378+
const SERIALIZATION_FAILURE_CODE: &str = "40001";
379379
match error {
380380
Error::Database(
381381
DbErr::Exec(sea_orm::RuntimeErr::SqlxError(error))

crates/collab/src/db/tests/feature_flag_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ async fn test_get_user_flags(db: &Arc<Database>) {
3737
.unwrap()
3838
.user_id;
3939

40-
const CHANNELS_ALPHA: &'static str = "channels-alpha";
41-
const NEW_SEARCH: &'static str = "new-search";
40+
const CHANNELS_ALPHA: &str = "channels-alpha";
41+
const NEW_SEARCH: &str = "new-search";
4242

4343
let channels_flag = db.create_user_flag(CHANNELS_ALPHA).await.unwrap();
4444
let search_flag = db.create_user_flag(NEW_SEARCH).await.unwrap();

crates/collab/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use tracing_log::LogTracer;
2020
use tracing_subscriber::{filter::EnvFilter, fmt::format::JsonFields, Layer};
2121
use util::ResultExt;
2222

23-
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
23+
const VERSION: &str = env!("CARGO_PKG_VERSION");
2424
const REVISION: Option<&'static str> = option_env!("GITHUB_SHA");
2525

2626
#[tokio::main]

crates/collab/src/tests/integration_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,8 +2821,8 @@ async fn test_git_status_sync(
28212821
)
28222822
.await;
28232823

2824-
const A_TXT: &'static str = "a.txt";
2825-
const B_TXT: &'static str = "b.txt";
2824+
const A_TXT: &str = "a.txt";
2825+
const B_TXT: &str = "b.txt";
28262826

28272827
client_a.fs().set_status_for_repo_via_git_operation(
28282828
Path::new("/dir/.git"),

crates/collab_ui/src/chat_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use workspace::{
3434
mod message_editor;
3535

3636
const MESSAGE_LOADING_THRESHOLD: usize = 50;
37-
const CHAT_PANEL_KEY: &'static str = "ChatPanel";
37+
const CHAT_PANEL_KEY: &str = "ChatPanel";
3838

3939
pub fn init(cx: &mut AppContext) {
4040
cx.observe_new_views(|workspace: &mut Workspace, _| {

crates/collab_ui/src/collab_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct ChannelMoveClipboard {
6262
channel_id: ChannelId,
6363
}
6464

65-
const COLLABORATION_PANEL_KEY: &'static str = "CollaborationPanel";
65+
const COLLABORATION_PANEL_KEY: &str = "CollaborationPanel";
6666

6767
pub fn init(cx: &mut AppContext) {
6868
cx.observe_new_views(|workspace: &mut Workspace, _| {

crates/collab_ui/src/notification_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use workspace::{
2929
const LOADING_THRESHOLD: usize = 30;
3030
const MARK_AS_READ_DELAY: Duration = Duration::from_secs(1);
3131
const TOAST_DURATION: Duration = Duration::from_secs(5);
32-
const NOTIFICATION_PANEL_KEY: &'static str = "NotificationPanel";
32+
const NOTIFICATION_PANEL_KEY: &str = "NotificationPanel";
3333

3434
pub struct NotificationPanel {
3535
client: Arc<Client>,

crates/copilot/src/copilot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ async fn clear_copilot_dir() {
971971
}
972972

973973
async fn get_copilot_lsp(http: Arc<dyn HttpClient>) -> anyhow::Result<PathBuf> {
974-
const SERVER_PATH: &'static str = "dist/agent.js";
974+
const SERVER_PATH: &str = "dist/agent.js";
975975

976976
///Check for the latest copilot language server and download it if we haven't already
977977
async fn fetch_latest(http: Arc<dyn HttpClient>) -> anyhow::Result<PathBuf> {

crates/copilot_ui/src/sign_in.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gpui::{
77
use ui::{prelude::*, Button, IconName, Label};
88
use workspace::ModalView;
99

10-
const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot";
10+
const COPILOT_SIGN_UP_URL: &str = "https://github.com/features/copilot";
1111

1212
pub struct CopilotCodeVerification {
1313
status: Status,

crates/db/src/db.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ use std::path::{Path, PathBuf};
2222
use std::sync::atomic::{AtomicBool, Ordering};
2323
use util::{async_maybe, ResultExt};
2424

25-
const CONNECTION_INITIALIZE_QUERY: &'static str = sql!(
25+
const CONNECTION_INITIALIZE_QUERY: &str = sql!(
2626
PRAGMA foreign_keys=TRUE;
2727
);
2828

29-
const DB_INITIALIZE_QUERY: &'static str = sql!(
29+
const DB_INITIALIZE_QUERY: &str = sql!(
3030
PRAGMA journal_mode=WAL;
3131
PRAGMA busy_timeout=1;
3232
PRAGMA case_sensitive_like=TRUE;
3333
PRAGMA synchronous=NORMAL;
3434
);
3535

36-
const FALLBACK_DB_NAME: &'static str = "FALLBACK_MEMORY_DB";
36+
const FALLBACK_DB_NAME: &str = "FALLBACK_MEMORY_DB";
3737

38-
const DB_FILE_NAME: &'static str = "db.sqlite";
38+
const DB_FILE_NAME: &str = "db.sqlite";
3939

4040
lazy_static::lazy_static! {
4141
pub static ref ZED_STATELESS: bool = std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty());

crates/editor/src/editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8644,7 +8644,7 @@ impl Editor {
86448644
let mut cwd = worktree.read(cx).abs_path().to_path_buf();
86458645
cwd.push(".git");
86468646

8647-
const REMOTE_NAME: &'static str = "origin";
8647+
const REMOTE_NAME: &str = "origin";
86488648
let repo = project
86498649
.fs()
86508650
.open_repo(&cwd)

crates/gpui/src/platform/mac/metal_renderer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ pub(crate) type PointF = crate::Point<f32>;
2626
#[cfg(not(feature = "runtime_shaders"))]
2727
const SHADERS_METALLIB: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/shaders.metallib"));
2828
#[cfg(feature = "runtime_shaders")]
29-
const SHADERS_SOURCE_FILE: &'static str =
30-
include_str!(concat!(env!("OUT_DIR"), "/stitched_shaders.metal"));
29+
const SHADERS_SOURCE_FILE: &str = include_str!(concat!(env!("OUT_DIR"), "/stitched_shaders.metal"));
3130
const INSTANCE_BUFFER_SIZE: usize = 2 * 1024 * 1024; // This is an arbitrary decision. There's probably a more optimal value (maybe even we could adjust dynamically...)
3231

3332
pub type Context = Arc<Mutex<Vec<metal::Buffer>>>;

crates/languages/src/astro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{
1414
};
1515
use util::ResultExt;
1616

17-
const SERVER_PATH: &'static str = "node_modules/@astrojs/language-server/bin/nodeServer.js";
17+
const SERVER_PATH: &str = "node_modules/@astrojs/language-server/bin/nodeServer.js";
1818

1919
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2020
vec![server_path.into(), "--stdio".into()]

crates/languages/src/css.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{
1414
};
1515
use util::{async_maybe, ResultExt};
1616

17-
const SERVER_PATH: &'static str =
17+
const SERVER_PATH: &str =
1818
"node_modules/vscode-langservers-extracted/bin/vscode-css-language-server";
1919

2020
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {

crates/languages/src/dockerfile.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use std::{
1313
};
1414
use util::{async_maybe, ResultExt};
1515

16-
const SERVER_PATH: &'static str =
17-
"node_modules/dockerfile-language-server-nodejs/bin/docker-langserver";
16+
const SERVER_PATH: &str = "node_modules/dockerfile-language-server-nodejs/bin/docker-langserver";
1817

1918
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2019
vec![server_path.into(), "--stdio".into()]

crates/languages/src/elm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use std::{
1717
};
1818
use util::ResultExt;
1919

20-
const SERVER_NAME: &'static str = "elm-language-server";
21-
const SERVER_PATH: &'static str = "node_modules/@elm-tooling/elm-language-server/out/node/index.js";
20+
const SERVER_NAME: &str = "elm-language-server";
21+
const SERVER_PATH: &str = "node_modules/@elm-tooling/elm-language-server/out/node/index.js";
2222

2323
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2424
vec![server_path.into(), "--stdio".into()]

crates/languages/src/html.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{
1414
};
1515
use util::{async_maybe, ResultExt};
1616

17-
const SERVER_PATH: &'static str =
17+
const SERVER_PATH: &str =
1818
"node_modules/vscode-langservers-extracted/bin/vscode-html-language-server";
1919

2020
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {

crates/languages/src/json.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use std::{
1818
};
1919
use util::{async_maybe, paths, ResultExt};
2020

21-
const SERVER_PATH: &'static str =
22-
"node_modules/vscode-json-languageserver/bin/vscode-json-languageserver";
21+
const SERVER_PATH: &str = "node_modules/vscode-json-languageserver/bin/vscode-json-languageserver";
2322

2423
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2524
vec![server_path.into(), "--stdio".into()]

crates/languages/src/prisma.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
};
1414
use util::{async_maybe, ResultExt};
1515

16-
const SERVER_PATH: &'static str = "node_modules/.bin/prisma-language-server";
16+
const SERVER_PATH: &str = "node_modules/.bin/prisma-language-server";
1717

1818
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
1919
vec![server_path.into(), "--stdio".into()]

crates/languages/src/purescript.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{
1515
};
1616
use util::{async_maybe, ResultExt};
1717

18-
const SERVER_PATH: &'static str = "node_modules/.bin/purescript-language-server";
18+
const SERVER_PATH: &str = "node_modules/.bin/purescript-language-server";
1919

2020
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2121
vec![server_path.into(), "--stdio".into()]

crates/languages/src/python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212
};
1313
use util::ResultExt;
1414

15-
const SERVER_PATH: &'static str = "node_modules/pyright/langserver.index.js";
15+
const SERVER_PATH: &str = "node_modules/pyright/langserver.index.js";
1616

1717
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
1818
vec![server_path.into(), "--stdio".into()]

crates/languages/src/svelte.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{
1414
};
1515
use util::{async_maybe, ResultExt};
1616

17-
const SERVER_PATH: &'static str = "node_modules/svelte-language-server/bin/server.js";
17+
const SERVER_PATH: &str = "node_modules/svelte-language-server/bin/server.js";
1818

1919
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2020
vec![server_path.into(), "--stdio".into()]

crates/languages/src/tailwind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{
1616
};
1717
use util::{async_maybe, ResultExt};
1818

19-
const SERVER_PATH: &'static str = "node_modules/.bin/tailwindcss-language-server";
19+
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server";
2020

2121
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2222
vec![server_path.into(), "--stdio".into()]

crates/languages/src/yaml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{
1717
};
1818
use util::{async_maybe, ResultExt};
1919

20-
const SERVER_PATH: &'static str = "node_modules/yaml-language-server/bin/yaml-language-server";
20+
const SERVER_PATH: &str = "node_modules/yaml-language-server/bin/yaml-language-server";
2121

2222
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
2323
vec![server_path.into(), "--stdio".into()]

crates/project_core/src/worktree_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ async fn test_git_repository_for_path(cx: &mut TestAppContext) {
21022102
async fn test_git_status(cx: &mut TestAppContext) {
21032103
init_test(cx);
21042104
cx.executor().allow_parking();
2105-
const IGNORE_RULE: &'static str = "**/target";
2105+
const IGNORE_RULE: &str = "**/target";
21062106

21072107
let root = temp_tree(json!({
21082108
"project": {
@@ -2122,12 +2122,12 @@ async fn test_git_status(cx: &mut TestAppContext) {
21222122

21232123
}));
21242124

2125-
const A_TXT: &'static str = "a.txt";
2126-
const B_TXT: &'static str = "b.txt";
2127-
const E_TXT: &'static str = "c/d/e.txt";
2128-
const F_TXT: &'static str = "f.txt";
2129-
const DOTGITIGNORE: &'static str = ".gitignore";
2130-
const BUILD_FILE: &'static str = "target/build_file";
2125+
const A_TXT: &str = "a.txt";
2126+
const B_TXT: &str = "b.txt";
2127+
const E_TXT: &str = "c/d/e.txt";
2128+
const F_TXT: &str = "f.txt";
2129+
const DOTGITIGNORE: &str = ".gitignore";
2130+
const BUILD_FILE: &str = "target/build_file";
21312131
let project_path = Path::new("project");
21322132

21332133
// Set up git repository before creating the worktree.
@@ -2243,7 +2243,7 @@ async fn test_git_status(cx: &mut TestAppContext) {
22432243
cx.executor().run_until_parked();
22442244

22452245
let mut renamed_dir_name = "first_directory/second_directory";
2246-
const RENAMED_FILE: &'static str = "rf.txt";
2246+
const RENAMED_FILE: &str = "rf.txt";
22472247

22482248
std::fs::create_dir_all(work_dir.join(renamed_dir_name)).unwrap();
22492249
std::fs::write(

crates/project_panel/src/file_associations.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ pub struct FileAssociations {
2020

2121
impl Global for FileAssociations {}
2222

23-
const COLLAPSED_DIRECTORY_TYPE: &'static str = "collapsed_folder";
24-
const EXPANDED_DIRECTORY_TYPE: &'static str = "expanded_folder";
25-
const COLLAPSED_CHEVRON_TYPE: &'static str = "collapsed_chevron";
26-
const EXPANDED_CHEVRON_TYPE: &'static str = "expanded_chevron";
27-
pub const FILE_TYPES_ASSET: &'static str = "icons/file_icons/file_types.json";
23+
const COLLAPSED_DIRECTORY_TYPE: &str = "collapsed_folder";
24+
const EXPANDED_DIRECTORY_TYPE: &str = "expanded_folder";
25+
const COLLAPSED_CHEVRON_TYPE: &str = "collapsed_chevron";
26+
const EXPANDED_CHEVRON_TYPE: &str = "expanded_chevron";
27+
pub const FILE_TYPES_ASSET: &str = "icons/file_icons/file_types.json";
2828

2929
pub fn init(assets: impl AssetSource, cx: &mut AppContext) {
3030
cx.set_global(FileAssociations::new(assets))

crates/project_panel/src/project_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use workspace::{
3434
Workspace,
3535
};
3636

37-
const PROJECT_PANEL_KEY: &'static str = "ProjectPanel";
37+
const PROJECT_PANEL_KEY: &str = "ProjectPanel";
3838
const NEW_ENTRY_ID: ProjectEntryId = ProjectEntryId::MAX;
3939

4040
pub struct ProjectPanel {

crates/rpc/src/notification.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize};
33
use serde_json::{map, Value};
44
use strum::{EnumVariantNames, VariantNames as _};
55

6-
const KIND: &'static str = "kind";
7-
const ENTITY_ID: &'static str = "entity_id";
6+
const KIND: &str = "kind";
7+
const ENTITY_ID: &str = "entity_id";
88

99
/// A notification that can be stored, associated with a given recipient.
1010
///

crates/terminal_view/src/terminal_panel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use workspace::{
3131

3232
use anyhow::Result;
3333

34-
const TERMINAL_PANEL_KEY: &'static str = "TerminalPanel";
34+
const TERMINAL_PANEL_KEY: &str = "TerminalPanel";
3535

3636
actions!(terminal_panel, [ToggleFocus]);
3737

crates/ui/src/components/stories/list_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use story::Story;
44
use crate::{prelude::*, Avatar};
55
use crate::{IconName, ListItem};
66

7-
const OVERFLOWING_TEXT: &'static str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mauris ligula, luctus vel dignissim eu, vestibulum sed libero. Sed at convallis velit.";
7+
const OVERFLOWING_TEXT: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mauris ligula, luctus vel dignissim eu, vestibulum sed libero. Sed at convallis velit.";
88

99
pub struct ListItemStory;
1010

crates/vim/src/object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ mod test {
835835
test::{ExemptionFeatures, NeovimBackedTestContext, VimTestContext},
836836
};
837837

838-
const WORD_LOCATIONS: &'static str = indoc! {"
838+
const WORD_LOCATIONS: &str = indoc! {"
839839
The quick ˇbrowˇnˇ•••
840840
fox ˇjuˇmpsˇ over
841841
the lazy dogˇ••

0 commit comments

Comments
 (0)