on master help sign in
Avoid using the format ident Rust feature (#1881)
f2dd3d4Marcin Puc
helix-loader/src/grammar.rs+9−5
@@ -63,12 +63,12 @@ pub fn get_language(name: &str) -> Result<Language> {
63 library_path.set_extension(DYLIB_EXTENSION);
63 library_path.set_extension(DYLIB_EXTENSION);
64
64
65 let library = unsafe { Library::new(&library_path) }
65 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))?;
67 let language_fn_name = format!("tree_sitter_{}", name.replace('-', "_"));
67 let language_fn_name = format!("tree_sitter_{}", name.replace('-', "_"));
68 let language = unsafe {
68 let language = unsafe {
69 let language_fn: Symbol<unsafe extern "C" fn() -> Language> = library
69 let language_fn: Symbol<unsafe extern "C" fn() -> Language> = library
70 .get(language_fn_name.as_bytes())
70 .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))?;
72 language_fn()
72 language_fn()
73 };
73 };
74 std::mem::forget(library);
74 std::mem::forget(library);
@@ -133,7 +133,7 @@ where
133 // TODO: print all failures instead of the first one found.
133 // TODO: print all failures instead of the first one found.
134 rx.iter()
134 rx.iter()
135 .find(|result| result.is_err())
135 .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)))
137 .unwrap_or(Ok(()))
137 .unwrap_or(Ok(()))
138}
138}
139
139
@@ -238,12 +238,16 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> {
238 };
238 };
239
239
240 let grammar_dir_entries = grammar_dir.read_dir().with_context(|| {
240 let grammar_dir_entries = grammar_dir.read_dir().with_context(|| {
241+ format!(
241− format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --grammar fetch'?")
242+ "Failed to read directory {:?}. Did you use 'hx --grammar fetch'?",
243+ grammar_dir
244+ )
242 })?;
245 })?;
243
246
244 if grammar_dir_entries.count() == 0 {
247 if grammar_dir_entries.count() == 0 {
245 return Err(anyhow!(
248 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
247 ));
251 ));
248 };
252 };
249
253
helix-term/src/commands/typed.rs+2−2
@@ -891,8 +891,8 @@ fn setting(
891 }
891 }
892 let (key, arg) = (&args[0].to_lowercase(), &args[1]);
892 let (key, arg) = (&args[0].to_lowercase(), &args[1]);
893
893
894− let key_error = || anyhow::anyhow!("Unknown key `{key}`");
894+ let key_error = || anyhow::anyhow!("Unknown key `{}`", key);
895− let field_error = |_| anyhow::anyhow!("Could not parse field `{arg}`");
895+ let field_error = |_| anyhow::anyhow!("Could not parse field `{}`", arg);
896
896
897 let mut config = serde_json::to_value(&cx.editor.config().clone()).unwrap();
897 let mut config = serde_json::to_value(&cx.editor.config().clone()).unwrap();
898 let pointer = format!("/{}", key.replace('.', "/"));
898 let pointer = format!("/{}", key.replace('.', "/"));
helix-term/src/health.rs+5−4
@@ -89,10 +89,11 @@ pub fn languages_all() {
89
89
90 let column = |item: &str, color: Color| {
90 let column = |item: &str, color: Color| {
91 let data = format!(
91 let data = format!(
92− "{:column_width$}",
92+ "{:width$}",
93 item.get(..column_width - 2)
93 item.get(..column_width - 2)
94− .map(|s| format!("{s}…"))
94+ .map(|s| format!("{}…", s))
95− .unwrap_or_else(|| item.to_string())
95+ .unwrap_or_else(|| item.to_string()),
96+ width = column_width,
96 )
97 )
97 .stylize()
98 .stylize()
98 .with(color);
99 .with(color);
@@ -158,7 +159,7 @@ pub fn language(lang_str: String) {
158 {
159 {
159 Some(l) => l,
160 Some(l) => l,
160 None => {
161 None => {
161− let msg = format!("Language '{lang_str}' not found");
162+ let msg = format!("Language '{}' not found", lang_str);
162 println!("{}", msg.red());
163 println!("{}", msg.red());
163 let suggestions: Vec<&str> = syn_loader_conf
164 let suggestions: Vec<&str> = syn_loader_conf
164 .language
165 .language