Detailed changes
@@ -52,7 +52,7 @@ fn compile_metal_shaders() {
println!("cargo:rerun-if-changed={}", shader_path);
let output = Command::new("xcrun")
- .args(&[
+ .args([
"-sdk",
"macosx",
"metal",
@@ -76,7 +76,7 @@ fn compile_metal_shaders() {
}
let output = Command::new("xcrun")
- .args(&["-sdk", "macosx", "metallib"])
+ .args(["-sdk", "macosx", "metallib"])
.arg(air_output_path)
.arg("-o")
.arg(metallib_output_path)
@@ -647,7 +647,7 @@ impl platform::Platform for MacPlatform {
attrs.set(kSecReturnAttributes as *const _, cf_true);
attrs.set(kSecReturnData as *const _, cf_true);
- let mut result = CFTypeRef::from(ptr::null_mut());
+ let mut result = CFTypeRef::from(ptr::null());
let status = SecItemCopyMatching(attrs.as_concrete_TypeRef(), &mut result);
match status {
security::errSecSuccess => {}
@@ -162,11 +162,9 @@ pub fn test(args: TokenStream, function: TokenStream) -> TokenStream {
if let FnArg::Typed(arg) = arg {
if let Type::Path(ty) = &*arg.ty {
let last_segment = ty.path.segments.last();
- match last_segment.map(|s| s.ident.to_string()).as_deref() {
- Some("StdRng") => {
- inner_fn_args.extend(quote!(rand::SeedableRng::seed_from_u64(seed),));
- }
- _ => {}
+
+ if let Some("StdRng") = last_segment.map(|s| s.ident.to_string()).as_deref() {
+ inner_fn_args.extend(quote!(rand::SeedableRng::seed_from_u64(seed),));
}
} else {
inner_fn_args.extend(quote!(cx,));
@@ -5,7 +5,7 @@ use std::{
process::Command,
};
-const SWIFT_PACKAGE_NAME: &'static str = "LiveKitBridge";
+const SWIFT_PACKAGE_NAME: &str = "LiveKitBridge";
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -61,8 +61,8 @@ fn build_bridge(swift_target: &SwiftTarget) {
let swift_package_root = swift_package_root();
if !Command::new("swift")
.arg("build")
- .args(&["--configuration", &env::var("PROFILE").unwrap()])
- .args(&["--triple", &swift_target.target.triple])
+ .args(["--configuration", &env::var("PROFILE").unwrap()])
+ .args(["--triple", &swift_target.target.triple])
.current_dir(&swift_package_root)
.status()
.unwrap()
@@ -116,7 +116,7 @@ fn get_swift_target() -> SwiftTarget {
let target = format!("{}-apple-macosx{}", arch, MACOS_TARGET_VERSION);
let swift_target_info_str = Command::new("swift")
- .args(&["-target", &target, "-print-target-info"])
+ .args(["-target", &target, "-print-target-info"])
.output()
.unwrap()
.stdout;
@@ -143,7 +143,7 @@ fn copy_dir(source: &Path, destination: &Path) {
assert!(
Command::new("cp")
.arg("-R")
- .args(&[source, destination])
+ .args([source, destination])
.status()
.unwrap()
.success(),
@@ -3,7 +3,7 @@ use std::{env, path::PathBuf, process::Command};
fn main() {
let sdk_path = String::from_utf8(
Command::new("xcrun")
- .args(&["--sdk", "macosx", "--show-sdk-path"])
+ .args(["--sdk", "macosx", "--show-sdk-path"])
.output()
.unwrap()
.stdout,
@@ -113,9 +113,9 @@ pub mod core_video {
let mut this = ptr::null();
let result = CVMetalTextureCacheCreate(
kCFAllocatorDefault,
- ptr::null_mut(),
+ ptr::null(),
metal_device,
- ptr::null_mut(),
+ ptr::null(),
&mut this,
);
if result == kCVReturnSuccess {
@@ -192,7 +192,7 @@ pub mod core_video {
pub fn as_texture_ref(&self) -> &metal::TextureRef {
unsafe {
let texture = CVMetalTextureGetTexture(self.as_concrete_TypeRef());
- &metal::TextureRef::from_ptr(texture as *mut _)
+ metal::TextureRef::from_ptr(texture as *mut _)
}
}
}
@@ -23,7 +23,7 @@ pub fn random_token() -> String {
for byte in token_bytes.iter_mut() {
*byte = rng.gen();
}
- base64::encode_config(&token_bytes, base64::URL_SAFE)
+ base64::encode_config(token_bytes, base64::URL_SAFE)
}
impl PublicKey {
@@ -62,7 +62,7 @@ fn parse_snippet<'a>(
}
}
Some(_) => {
- let chunk_end = source.find(&['}', '$', '\\']).unwrap_or(source.len());
+ let chunk_end = source.find(['}', '$', '\\']).unwrap_or(source.len());
let (chunk, rest) = source.split_at(chunk_end);
text.push_str(chunk);
source = rest;
@@ -20,7 +20,7 @@ unsafe impl Send for Connection {}
impl Connection {
pub(crate) fn open(uri: &str, persistent: bool) -> Result<Self> {
let mut connection = Self {
- sqlite3: 0 as *mut _,
+ sqlite3: ptr::null_mut(),
persistent,
write: RefCell::new(true),
_sqlite: PhantomData,
@@ -32,7 +32,7 @@ impl Connection {
CString::new(uri)?.as_ptr(),
&mut connection.sqlite3,
flags,
- 0 as *const _,
+ ptr::null(),
);
// Turn on extended error codes
@@ -97,7 +97,7 @@ impl Connection {
let remaining_sql_str = remaining_sql.to_str().unwrap().trim();
remaining_sql_str != ";" && !remaining_sql_str.is_empty()
} {
- let mut raw_statement = 0 as *mut sqlite3_stmt;
+ let mut raw_statement = ptr::null_mut::<sqlite3_stmt>();
let mut remaining_sql_ptr = ptr::null();
sqlite3_prepare_v2(
self.sqlite3,
@@ -48,7 +48,7 @@ impl<'a> Statement<'a> {
.trim();
remaining_sql_str != ";" && !remaining_sql_str.is_empty()
} {
- let mut raw_statement = 0 as *mut sqlite3_stmt;
+ let mut raw_statement = ptr::null_mut::<sqlite3_stmt>();
let mut remaining_sql_ptr = ptr::null();
sqlite3_prepare_v2(
connection.sqlite3,
@@ -101,7 +101,7 @@ impl<'a> Statement<'a> {
}
}
- fn bind_index_with(&self, index: i32, bind: impl Fn(&*mut sqlite3_stmt) -> ()) -> Result<()> {
+ fn bind_index_with(&self, index: i32, bind: impl Fn(&*mut sqlite3_stmt)) -> Result<()> {
let mut any_succeed = false;
unsafe {
for raw_statement in self.raw_statements.iter() {
@@ -133,7 +133,7 @@ impl<'a> Statement<'a> {
})
}
- pub fn column_blob<'b>(&'b mut self, index: i32) -> Result<&'b [u8]> {
+ pub fn column_blob(&mut self, index: i32) -> Result<&[u8]> {
let index = index as c_int;
let pointer = unsafe { sqlite3_column_blob(self.current_statement(), index) };
@@ -217,7 +217,7 @@ impl<'a> Statement<'a> {
})
}
- pub fn column_text<'b>(&'b mut self, index: i32) -> Result<&'b str> {
+ pub fn column_text(&mut self, index: i32) -> Result<&str> {
let index = index as c_int;
let pointer = unsafe { sqlite3_column_text(self.current_statement(), index) };
@@ -114,12 +114,12 @@ impl<M: Migrator> ThreadSafeConnection<M> {
let mut queues = QUEUES.write();
if !queues.contains_key(&self.uri) {
let mut write_queue_constructor =
- write_queue_constructor.unwrap_or(background_thread_queue());
+ write_queue_constructor.unwrap_or_else(background_thread_queue);
queues.insert(self.uri.clone(), write_queue_constructor());
return true;
}
}
- return false;
+ false
}
pub fn builder(uri: &str, persistent: bool) -> ThreadSafeConnectionBuilder<M> {
@@ -187,10 +187,9 @@ impl<M: Migrator> ThreadSafeConnection<M> {
*connection.write.get_mut() = false;
if let Some(initialize_query) = connection_initialize_query {
- connection.exec(initialize_query).expect(&format!(
- "Initialize query failed to execute: {}",
- initialize_query
- ))()
+ connection.exec(initialize_query).unwrap_or_else(|_| {
+ panic!("Initialize query failed to execute: {}", initialize_query)
+ })()
.unwrap()
}
@@ -225,7 +224,7 @@ impl<M: Migrator> Clone for ThreadSafeConnection<M> {
Self {
uri: self.uri.clone(),
persistent: self.persistent,
- connection_initialize_query: self.connection_initialize_query.clone(),
+ connection_initialize_query: self.connection_initialize_query,
connections: self.connections.clone(),
_migrator: PhantomData,
}
@@ -8,7 +8,7 @@ use crate::{
impl Connection {
pub fn exec<'a>(&'a self, query: &str) -> Result<impl 'a + FnMut() -> Result<()>> {
- let mut statement = Statement::prepare(&self, query)?;
+ let mut statement = Statement::prepare(self, query)?;
Ok(move || statement.exec())
}
@@ -16,7 +16,7 @@ impl Connection {
&'a self,
query: &str,
) -> Result<impl 'a + FnMut(B) -> Result<()>> {
- let mut statement = Statement::prepare(&self, query)?;
+ let mut statement = Statement::prepare(self, query)?;
Ok(move |bindings| statement.with_bindings(bindings)?.exec())
}
@@ -24,7 +24,7 @@ impl Connection {
&'a self,
query: &str,
) -> Result<impl 'a + FnMut() -> Result<Vec<C>>> {
- let mut statement = Statement::prepare(&self, query)?;
+ let mut statement = Statement::prepare(self, query)?;
Ok(move || statement.rows::<C>())
}
@@ -32,7 +32,7 @@ impl Connection {
&'a self,
query: &str,
) -> Result<impl 'a + FnMut(B) -> Result<Vec<C>>> {
- let mut statement = Statement::prepare(&self, query)?;
+ let mut statement = Statement::prepare(self, query)?;
Ok(move |bindings| statement.with_bindings(bindings)?.rows::<C>())
}
@@ -40,7 +40,7 @@ impl Connection {
&'a self,
query: &str,
) -> Result<impl 'a + FnMut() -> Result<Option<C>>> {
- let mut statement = Statement::prepare(&self, query)?;
+ let mut statement = Statement::prepare(self, query)?;
Ok(move || statement.maybe_row::<C>())
}
@@ -48,7 +48,7 @@ impl Connection {
&'a self,
query: &str,
) -> Result<impl 'a + FnMut(B) -> Result<Option<C>>> {
- let mut statement = Statement::prepare(&self, query)?;
+ let mut statement = Statement::prepare(self, query)?;
Ok(move |bindings| {
statement
.with_bindings(bindings)
@@ -33,14 +33,14 @@ fn create_error(
.skip_while(|(offset, _)| offset <= &error_offset)
.map(|(_, span)| span)
.next()
- .unwrap_or(Span::call_site());
+ .unwrap_or_else(Span::call_site);
let error_text = format!("Sql Error: {}\nFor Query: {}", error, formatted_sql);
TokenStream::from(Error::new(error_span.into(), error_text).into_compile_error())
}
fn make_sql(tokens: TokenStream) -> (Vec<(usize, Span)>, String) {
let mut sql_tokens = vec![];
- flatten_stream(tokens.clone(), &mut sql_tokens);
+ flatten_stream(tokens, &mut sql_tokens);
// Lookup of spans by offset at the end of the token
let mut spans: Vec<(usize, Span)> = Vec::new();
let mut sql = String::new();
@@ -67,7 +67,7 @@ fn flatten_stream(tokens: TokenStream, result: &mut Vec<(String, Span)>) {
result.push((close_delimiter(group.delimiter()), group.span()));
}
TokenTree::Ident(ident) => {
- result.push((format!("{} ", ident.to_string()), ident.span()));
+ result.push((format!("{} ", ident), ident.span()));
}
leaf_tree => result.push((leaf_tree.to_string(), leaf_tree.span())),
}
@@ -58,7 +58,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
self.0.insert_or_replace(MapEntry { key, value }, &());
}
- pub fn remove<'a>(&mut self, key: &'a K) -> Option<V> {
+ pub fn remove(&mut self, key: &K) -> Option<V> {
let mut removed = None;
let mut cursor = self.0.cursor::<MapKeyRef<'_, K>>();
let key = MapKeyRef(Some(key));
@@ -4,7 +4,7 @@ use lazy_static::lazy_static;
lazy_static! {
pub static ref RELEASE_CHANNEL_NAME: String = env::var("ZED_RELEASE_CHANNEL")
- .unwrap_or(include_str!("../../zed/RELEASE_CHANNEL").to_string());
+ .unwrap_or_else(|_| include_str!("../../zed/RELEASE_CHANNEL").to_string());
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() {
"dev" => ReleaseChannel::Dev,
"preview" => ReleaseChannel::Preview,
@@ -36,7 +36,7 @@ pub fn truncate_and_trailoff(s: &str, max_chars: usize) -> String {
debug_assert!(max_chars >= 5);
if s.len() > max_chars {
- format!("{}…", truncate(&s, max_chars.saturating_sub(3)))
+ format!("{}…", truncate(s, max_chars.saturating_sub(3)))
} else {
s.to_string()
}
@@ -50,14 +50,14 @@ impl LspAdapter for RubyLanguageServer {
grammar.highlight_id_for_name("type")?
}
lsp::CompletionItemKind::KEYWORD => {
- if label.starts_with(":") {
+ if label.starts_with(':') {
grammar.highlight_id_for_name("string.special.symbol")?
} else {
grammar.highlight_id_for_name("keyword")?
}
}
lsp::CompletionItemKind::VARIABLE => {
- if label.starts_with("@") {
+ if label.starts_with('@') {
grammar.highlight_id_for_name("property")?
} else {
return None;
@@ -101,7 +101,7 @@ fn main() {
//Setup settings global before binding actions
cx.set_global(SettingsFile::new(
- &*paths::SETTINGS,
+ &paths::SETTINGS,
settings_file_content.clone(),
fs.clone(),
));
@@ -586,7 +586,7 @@ async fn handle_cli_connection(
responses
.send(CliResponse::Exit {
- status: if errored { 1 } else { 0 },
+ status: i32::from(errored),
})
.log_err();
}
@@ -338,11 +338,11 @@ pub fn initialize_workspace(
},
"schemas": [
{
- "fileMatch": [schema_file_match(&*paths::SETTINGS)],
+ "fileMatch": [schema_file_match(&paths::SETTINGS)],
"schema": settings_file_json_schema(theme_names, language_names),
},
{
- "fileMatch": [schema_file_match(&*paths::KEYMAP)],
+ "fileMatch": [schema_file_match(&paths::KEYMAP)],
"schema": keymap_file_json_schema(&action_names),
}
]
@@ -646,7 +646,7 @@ fn open_bundled_config_file(
cx: &mut ViewContext<Workspace>,
) {
workspace
- .with_local_workspace(&app_state.clone(), cx, |workspace, cx| {
+ .with_local_workspace(&app_state, cx, |workspace, cx| {
let project = workspace.project().clone();
let buffer = project.update(cx, |project, cx| {
let text = Assets::get(asset_path).unwrap().data;