Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using the format ident Rust feature #1881

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions helix-loader/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub fn get_language(name: &str) -> Result<Language> {
library_path.set_extension(DYLIB_EXTENSION);

let library = unsafe { Library::new(&library_path) }
.with_context(|| format!("Error opening dynamic library {library_path:?}"))?;
.with_context(|| format!("Error opening dynamic library {:?}", library_path))?;
let language_fn_name = format!("tree_sitter_{}", name.replace('-', "_"));
let language = unsafe {
let language_fn: Symbol<unsafe extern "C" fn() -> Language> = library
.get(language_fn_name.as_bytes())
.with_context(|| format!("Failed to load symbol {language_fn_name}"))?;
.with_context(|| format!("Failed to load symbol {}", language_fn_name))?;
language_fn()
};
std::mem::forget(library);
Expand Down Expand Up @@ -133,7 +133,7 @@ where
// TODO: print all failures instead of the first one found.
rx.iter()
.find(|result| result.is_err())
.map(|err| err.with_context(|| format!("Failed to {action} some grammar(s)")))
.map(|err| err.with_context(|| format!("Failed to {} some grammar(s)", action)))
.unwrap_or(Ok(()))
}

Expand Down Expand Up @@ -238,12 +238,16 @@ fn build_grammar(grammar: GrammarConfiguration) -> Result<()> {
};

let grammar_dir_entries = grammar_dir.read_dir().with_context(|| {
format!("Failed to read directory {grammar_dir:?}. Did you use 'hx --grammar fetch'?")
format!(
"Failed to read directory {:?}. Did you use 'hx --grammar fetch'?",
grammar_dir
)
})?;

if grammar_dir_entries.count() == 0 {
return Err(anyhow!(
"Directory {grammar_dir:?} is empty. Did you use 'hx --grammar fetch'?"
"Directory {:?} is empty. Did you use 'hx --grammar fetch'?",
grammar_dir
));
};

Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,8 @@ fn setting(
}
let (key, arg) = (&args[0].to_lowercase(), &args[1]);

let key_error = || anyhow::anyhow!("Unknown key `{key}`");
let field_error = |_| anyhow::anyhow!("Could not parse field `{arg}`");
let key_error = || anyhow::anyhow!("Unknown key `{}`", key);
let field_error = |_| anyhow::anyhow!("Could not parse field `{}`", arg);

let mut config = serde_json::to_value(&cx.editor.config().clone()).unwrap();
let pointer = format!("/{}", key.replace('.', "/"));
Expand Down
9 changes: 5 additions & 4 deletions helix-term/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ pub fn languages_all() {

let column = |item: &str, color: Color| {
let data = format!(
"{:column_width$}",
"{:width$}",
item.get(..column_width - 2)
.map(|s| format!("{s}…"))
.unwrap_or_else(|| item.to_string())
.map(|s| format!("{}…", s))
.unwrap_or_else(|| item.to_string()),
width = column_width,
)
.stylize()
.with(color);
Expand Down Expand Up @@ -158,7 +159,7 @@ pub fn language(lang_str: String) {
{
Some(l) => l,
None => {
let msg = format!("Language '{lang_str}' not found");
let msg = format!("Language '{}' not found", lang_str);
println!("{}", msg.red());
let suggestions: Vec<&str> = syn_loader_conf
.language
Expand Down