on master help sign in
Avoid using the format ident Rust feature (#1881)
commitf2dd3d446914ec0953cd7e056d430fc3b959e75d authorMarcin Puc <tranzystorek.io@protonmail.com> dateWed 30 Mar 2022, 02:08 (5 years ago) parentc8082a1
3 files changed+16−11
helix-loader/src/grammar.rs+9−5 helix-term/src/commands/typed.rs+2−2 helix-term/src/health.rs+5−4
helix-loader/src/grammar.rs+9−5
@@ -63,12 +63,12 @@ pub fn get_language(name: &str) -> Result<Language> {
6363 library_path.set_extension(DYLIB_EXTENSION);
6464
6565 let library = unsafe { Library::new(&library_path) }
66− .with_context(|| format!("Error opening dynamic library {library_path:?}"))?;
66+ .with_context(|| format!("Error opening dynamic library {:?}", library_path))?;
6767 let language_fn_name = format!("tree_sitter_{}", name.replace('-', "_"));
6868 let language = unsafe {
6969 let language_fn: Symbol<unsafe extern "C" fn() -> Language> = library
7070 .get(language_fn_name.as_bytes())
71− .with_context(|| format!("Failed to load symbol {language_fn_name}"))?;
71+ .with_context(|| format!("Failed to load symbol {}", language_fn_name))?;
7272 language_fn()
7373 };
7474 std::mem::forget(library);
@@ -133,7 +133,7 @@ where
133133 // TODO: print all failures instead of the first one found.
134134 rx.iter()
135135 .find(|result| result.is_err())
136− .map(|err| err.with_context(|| format!("Failed to {action} some grammar(s)")))
136+ .map(|err| err.with_context(|| format!("Failed to {} some grammar(s)", action)))
137137 .unwrap_or(Ok(()))
138138}
139139
@@ -238,12 +238,16 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> {
238238 };
239239
240240 let grammar_dir_entries = grammar_dir.read_dir().with_context(|| {
241− format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --grammar fetch'?")
241+ format!(
242+ "Failed to read directory {:?}. Did you use 'hx --grammar fetch'?",
243+ grammar_dir
244+ )
242245 })?;
243246
244247 if grammar_dir_entries.count() == 0 {
245248 return Err(anyhow!(
246− "Directory {grammar_dir:?} is empty. Did you use 'hx --grammar fetch'?"
249+ "Directory {:?} is empty. Did you use 'hx --grammar fetch'?",
250+ grammar_dir
247251 ));
248252 };
249253
helix-term/src/commands/typed.rs+2−2
@@ -891,8 +891,8 @@ fn setting(
891891 }
892892 let (key, arg) = (&args[0].to_lowercase(), &args[1]);
893893
894− let key_error = || anyhow::anyhow!("Unknown key `{key}`");
895− let field_error = |_| anyhow::anyhow!("Could not parse field `{arg}`");
894+ let key_error = || anyhow::anyhow!("Unknown key `{}`", key);
895+ let field_error = |_| anyhow::anyhow!("Could not parse field `{}`", arg);
896896
897897 let mut config = serde_json::to_value(&cx.editor.config().clone()).unwrap();
898898 let pointer = format!("/{}", key.replace('.', "/"));
helix-term/src/health.rs+5−4
@@ -89,10 +89,11 @@ pub fn languages_all() {
8989
9090 let column = |item: &str, color: Color| {
9191 let data = format!(
92− "{:column_width$}",
92+ "{:width$}",
9393 item.get(..column_width - 2)
94− .map(|s| format!("{s}…"))
95− .unwrap_or_else(|| item.to_string())
94+ .map(|s| format!("{}…", s))
95+ .unwrap_or_else(|| item.to_string()),
96+ width = column_width,
9697 )
9798 .stylize()
9899 .with(color);
@@ -158,7 +159,7 @@ pub fn language(lang_str: String) {
158159 {
159160 Some(l) => l,
160161 None => {
161− let msg = format!("Language '{lang_str}' not found");
162+ let msg = format!("Language '{}' not found", lang_str);
162163 println!("{}", msg.red());
163164 let suggestions: Vec<&str> = syn_loader_conf
164165 .language