chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but hey, it's a start. Release Notes: - N/A
This commit is contained in:
parent
93249fc82b
commit
e6c1c51b37
361 changed files with 3530 additions and 3587 deletions
|
@ -77,7 +77,7 @@ impl ExtensionBuilder {
|
|||
extension_manifest: &mut ExtensionManifest,
|
||||
options: CompileExtensionOptions,
|
||||
) -> Result<()> {
|
||||
populate_defaults(extension_manifest, &extension_dir)?;
|
||||
populate_defaults(extension_manifest, extension_dir)?;
|
||||
|
||||
if extension_dir.is_relative() {
|
||||
bail!(
|
||||
|
@ -123,7 +123,7 @@ impl ExtensionBuilder {
|
|||
self.install_rust_wasm_target_if_needed()?;
|
||||
let adapter_bytes = self.install_wasi_preview1_adapter_if_needed().await?;
|
||||
|
||||
let cargo_toml_content = fs::read_to_string(&extension_dir.join("Cargo.toml"))?;
|
||||
let cargo_toml_content = fs::read_to_string(extension_dir.join("Cargo.toml"))?;
|
||||
let cargo_toml: CargoToml = toml::from_str(&cargo_toml_content)?;
|
||||
|
||||
log::info!(
|
||||
|
@ -135,7 +135,7 @@ impl ExtensionBuilder {
|
|||
.args(options.release.then_some("--release"))
|
||||
.arg("--target-dir")
|
||||
.arg(extension_dir.join("target"))
|
||||
.current_dir(&extension_dir)
|
||||
.current_dir(extension_dir)
|
||||
.output()
|
||||
.context("failed to run `cargo`")?;
|
||||
if !output.status.success() {
|
||||
|
@ -281,12 +281,12 @@ impl ExtensionBuilder {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
fs::create_dir_all(&directory).with_context(|| {
|
||||
fs::create_dir_all(directory).with_context(|| {
|
||||
format!("failed to create grammar directory {}", directory.display(),)
|
||||
})?;
|
||||
let init_output = Command::new("git")
|
||||
.arg("init")
|
||||
.current_dir(&directory)
|
||||
.current_dir(directory)
|
||||
.output()?;
|
||||
if !init_output.status.success() {
|
||||
bail!(
|
||||
|
@ -312,15 +312,15 @@ impl ExtensionBuilder {
|
|||
let fetch_output = Command::new("git")
|
||||
.arg("--git-dir")
|
||||
.arg(&git_dir)
|
||||
.args(["fetch", "--depth", "1", "origin", &rev])
|
||||
.args(["fetch", "--depth", "1", "origin", rev])
|
||||
.output()
|
||||
.context("failed to execute `git fetch`")?;
|
||||
|
||||
let checkout_output = Command::new("git")
|
||||
.arg("--git-dir")
|
||||
.arg(&git_dir)
|
||||
.args(["checkout", &rev])
|
||||
.current_dir(&directory)
|
||||
.args(["checkout", rev])
|
||||
.current_dir(directory)
|
||||
.output()
|
||||
.context("failed to execute `git checkout`")?;
|
||||
if !checkout_output.status.success() {
|
||||
|
@ -488,14 +488,10 @@ impl ExtensionBuilder {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
match &payload {
|
||||
CustomSection(c) => {
|
||||
if strip_custom_section(c.name()) {
|
||||
continue;
|
||||
}
|
||||
if let CustomSection(c) = &payload {
|
||||
if strip_custom_section(c.name()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if let Some((id, range)) = payload.as_section() {
|
||||
|
|
|
@ -243,7 +243,7 @@ impl LspAdapter for ExtensionLspAdapter {
|
|||
language: &Arc<Language>,
|
||||
) -> Result<Vec<Option<CodeLabel>>> {
|
||||
let completions = completions
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|completion| wit::Completion::from(completion.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
@ -276,7 +276,7 @@ impl LspAdapter for ExtensionLspAdapter {
|
|||
language: &Arc<Language>,
|
||||
) -> Result<Vec<Option<CodeLabel>>> {
|
||||
let symbols = symbols
|
||||
.into_iter()
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|(name, kind)| wit::Symbol {
|
||||
name,
|
||||
|
@ -317,7 +317,7 @@ fn labels_from_wit(
|
|||
} else {
|
||||
language.highlight_text(&label.code.as_str().into(), 0..label.code.len())
|
||||
};
|
||||
build_code_label(&label, &runs, &language)
|
||||
build_code_label(&label, &runs, language)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ fn build_code_label(
|
|||
.grammar()
|
||||
.zip(span.highlight_name.as_ref())
|
||||
.and_then(|(grammar, highlight_name)| {
|
||||
grammar.highlight_id_for_name(&highlight_name)
|
||||
grammar.highlight_id_for_name(highlight_name)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let ix = text.len();
|
||||
|
|
|
@ -290,7 +290,7 @@ impl ExtensionStore {
|
|||
// it must be asynchronously rebuilt.
|
||||
let mut extension_index = ExtensionIndex::default();
|
||||
let mut extension_index_needs_rebuild = true;
|
||||
if let Some(index_content) = index_content.ok() {
|
||||
if let Ok(index_content) = index_content {
|
||||
if let Some(index) = serde_json::from_str(&index_content).log_err() {
|
||||
extension_index = index;
|
||||
if let (Ok(Some(index_metadata)), Ok(Some(extensions_metadata))) =
|
||||
|
@ -582,11 +582,11 @@ impl ExtensionStore {
|
|||
query: &[(&str, &str)],
|
||||
cx: &mut ModelContext<'_, ExtensionStore>,
|
||||
) -> Task<Result<Vec<ExtensionMetadata>>> {
|
||||
let url = self.http_client.build_zed_api_url(path, &query);
|
||||
let url = self.http_client.build_zed_api_url(path, query);
|
||||
let http_client = self.http_client.clone();
|
||||
cx.spawn(move |_, _| async move {
|
||||
let mut response = http_client
|
||||
.get(&url?.as_ref(), AsyncBody::empty(), true)
|
||||
.get(url?.as_ref(), AsyncBody::empty(), true)
|
||||
.await?;
|
||||
|
||||
let mut body = Vec::new();
|
||||
|
@ -651,7 +651,7 @@ impl ExtensionStore {
|
|||
});
|
||||
|
||||
let mut response = http_client
|
||||
.get(&url.as_ref(), Default::default(), true)
|
||||
.get(url.as_ref(), Default::default(), true)
|
||||
.await
|
||||
.map_err(|err| anyhow!("error downloading extension: {}", err))?;
|
||||
|
||||
|
@ -687,14 +687,11 @@ impl ExtensionStore {
|
|||
})?
|
||||
.await;
|
||||
|
||||
match operation {
|
||||
ExtensionOperation::Install => {
|
||||
this.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::ExtensionInstalled(extension_id));
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
_ => {}
|
||||
if let ExtensionOperation::Install = operation {
|
||||
this.update(&mut cx, |_, cx| {
|
||||
cx.emit(Event::ExtensionInstalled(extension_id));
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
anyhow::Ok(())
|
||||
|
@ -873,10 +870,10 @@ impl ExtensionStore {
|
|||
.await?;
|
||||
|
||||
let output_path = &extensions_dir.join(extension_id.as_ref());
|
||||
if let Some(metadata) = fs.metadata(&output_path).await? {
|
||||
if let Some(metadata) = fs.metadata(output_path).await? {
|
||||
if metadata.is_symlink {
|
||||
fs.remove_file(
|
||||
&output_path,
|
||||
output_path,
|
||||
RemoveOptions {
|
||||
recursive: false,
|
||||
ignore_if_not_exists: true,
|
||||
|
@ -967,7 +964,7 @@ impl ExtensionStore {
|
|||
(Some(_), None) => {
|
||||
extensions_to_unload.push(old_keys.next().unwrap().0.clone());
|
||||
}
|
||||
(Some((old_key, _)), Some((new_key, _))) => match old_key.cmp(&new_key) {
|
||||
(Some((old_key, _)), Some((new_key, _))) => match old_key.cmp(new_key) {
|
||||
Ordering::Equal => {
|
||||
let (old_key, old_value) = old_keys.next().unwrap();
|
||||
let (new_key, new_value) = new_keys.next().unwrap();
|
||||
|
@ -1140,7 +1137,7 @@ impl ExtensionStore {
|
|||
async move {
|
||||
for theme_path in &themes_to_add {
|
||||
theme_registry
|
||||
.load_user_theme(&theme_path, fs.clone())
|
||||
.load_user_theme(theme_path, fs.clone())
|
||||
.await
|
||||
.log_err();
|
||||
}
|
||||
|
|
|
@ -587,11 +587,8 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) {
|
|||
let executor = cx.executor();
|
||||
let _task = cx.executor().spawn(async move {
|
||||
while let Some(event) = events.next().await {
|
||||
match event {
|
||||
crate::Event::StartedReloading => {
|
||||
executor.advance_clock(RELOAD_DEBOUNCE_DURATION);
|
||||
}
|
||||
_ => (),
|
||||
if let crate::Event::StartedReloading = event {
|
||||
executor.advance_clock(RELOAD_DEBOUNCE_DURATION);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -173,11 +173,11 @@ impl WasmHost {
|
|||
.preopened_dir(&extension_work_dir, ".", dir_perms, file_perms)?
|
||||
.preopened_dir(
|
||||
&extension_work_dir,
|
||||
&extension_work_dir.to_string_lossy(),
|
||||
extension_work_dir.to_string_lossy(),
|
||||
dir_perms,
|
||||
file_perms,
|
||||
)?
|
||||
.env("PWD", &extension_work_dir.to_string_lossy())
|
||||
.env("PWD", extension_work_dir.to_string_lossy())
|
||||
.env("RUST_BACKTRACE", "full")
|
||||
.build())
|
||||
}
|
||||
|
|
|
@ -74,14 +74,14 @@ impl Extension {
|
|||
|
||||
if version >= latest::MIN_VERSION {
|
||||
let (extension, instance) =
|
||||
latest::Extension::instantiate_async(store, &component, latest::linker())
|
||||
latest::Extension::instantiate_async(store, component, latest::linker())
|
||||
.await
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok((Self::V010(extension), instance))
|
||||
} else if version >= since_v0_0_6::MIN_VERSION {
|
||||
let (extension, instance) = since_v0_0_6::Extension::instantiate_async(
|
||||
store,
|
||||
&component,
|
||||
component,
|
||||
since_v0_0_6::linker(),
|
||||
)
|
||||
.await
|
||||
|
@ -90,7 +90,7 @@ impl Extension {
|
|||
} else if version >= since_v0_0_4::MIN_VERSION {
|
||||
let (extension, instance) = since_v0_0_4::Extension::instantiate_async(
|
||||
store,
|
||||
&component,
|
||||
component,
|
||||
since_v0_0_4::linker(),
|
||||
)
|
||||
.await
|
||||
|
@ -99,7 +99,7 @@ impl Extension {
|
|||
} else {
|
||||
let (extension, instance) = since_v0_0_1::Extension::instantiate_async(
|
||||
store,
|
||||
&component,
|
||||
component,
|
||||
since_v0_0_1::linker(),
|
||||
)
|
||||
.await
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue