Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/sourcegen/src/lib.rs')
-rw-r--r--crates/sourcegen/src/lib.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/sourcegen/src/lib.rs b/crates/sourcegen/src/lib.rs
index 4e0ee63f32..72d26635c3 100644
--- a/crates/sourcegen/src/lib.rs
+++ b/crates/sourcegen/src/lib.rs
@@ -57,7 +57,7 @@ impl CommentBlock {
pub fn extract(tag: &str, text: &str) -> Vec<CommentBlock> {
assert!(tag.starts_with(char::is_uppercase));
- let tag = format!("{}:", tag);
+ let tag = format!("{tag}:");
// Would be nice if we had `.retain_mut` here!
CommentBlock::extract_untagged(text)
.into_iter()
@@ -65,10 +65,7 @@ impl CommentBlock {
let first = block.contents.remove(0);
first.strip_prefix(&tag).map(|id| {
if block.is_doc {
- panic!(
- "Use plain (non-doc) comments with tags like {}:\n {}",
- tag, first
- );
+ panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
}
block.id = id.trim().to_string();
@@ -122,7 +119,7 @@ pub struct Location {
impl fmt::Display for Location {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- let path = self.file.strip_prefix(&project_root()).unwrap().display().to_string();
+ let path = self.file.strip_prefix(project_root()).unwrap().display().to_string();
let path = path.replace('\\', "/");
let name = self.file.file_name().unwrap();
write!(
@@ -163,7 +160,7 @@ pub fn reformat(text: String) -> String {
}
pub fn add_preamble(generator: &'static str, mut text: String) -> String {
- let preamble = format!("//! Generated by `{}`, do not edit by hand.\n\n", generator);
+ let preamble = format!("//! Generated by `{generator}`, do not edit by hand.\n\n");
text.insert_str(0, &preamble);
text
}
@@ -178,7 +175,7 @@ pub fn ensure_file_contents(file: &Path, contents: &str) {
}
}
- let display_path = file.strip_prefix(&project_root()).unwrap_or(file);
+ let display_path = file.strip_prefix(project_root()).unwrap_or(file);
eprintln!(
"\n\x1b[31;1merror\x1b[0m: {} was not up-to-date, updating\n",
display_path.display()