Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoraefu committed Jan 22, 2023
1 parent 38663e8 commit d7e9ab2
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 48 deletions.
10 changes: 5 additions & 5 deletions components/dada-execute/src/heap_graph/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ impl HeapGraph {
Ok(())
}

fn find_lessor_place<'w>(
fn find_lessor_place(
&self,
w: &'w GraphvizWriter<'_>,
w: &GraphvizWriter<'_>,
permission: PermissionNode,
) -> Vec<GraphvizPlace> {
if let Some(place) = w.permissions.get(&permission) {
Expand Down Expand Up @@ -289,8 +289,8 @@ impl HeapGraph {
edge: ValueEdgeTarget,
) -> eyre::Result<()> {
if !self.value_edge_target_did_change(w, edge) {
w.println(&format!("color = {UNCHANGED:?},"))?;
w.println(&format!("fontcolor = {UNCHANGED:?},"))?;
w.println(format!("color = {UNCHANGED:?},"))?;
w.println(format!("fontcolor = {UNCHANGED:?},"))?;
}

Ok(())
Expand All @@ -317,7 +317,7 @@ impl HeapGraph {
.map(|i| Some(i.name.to_string(db)))
.collect(),

ObjectType::RustThunk(_) => (0..num_fields).map(|i| Some(format!("{}", i))).collect(),
ObjectType::RustThunk(_) => (0..num_fields).map(|i| Some(format!("{i}"))).collect(),

ObjectType::Reservation => vec![Some("reserved".to_string())],
}
Expand Down
10 changes: 5 additions & 5 deletions components/dada-execute/src/machine/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ pub(crate) impl<T: ?Sized + MachineOp> DefaultStringify for T {
);
match &self[object] {
ObjectData::String(s) => s.to_string(),
ObjectData::Bool(v) => format!("{}", v),
ObjectData::SignedInt(v) => format!("{}_i", v),
ObjectData::Float(v) => format!("{}", v),
ObjectData::UnsignedInt(v) => format!("{}_u", v),
ObjectData::Int(v) => format!("{}", v),
ObjectData::Bool(v) => format!("{v}"),
ObjectData::SignedInt(v) => format!("{v}_i"),
ObjectData::Float(v) => format!("{v}"),
ObjectData::UnsignedInt(v) => format!("{v}_u"),
ObjectData::Int(v) => format!("{v}"),
ObjectData::Unit(_) => "()".to_string(),
ObjectData::Intrinsic(i) => i.as_str(db).to_string(),
ObjectData::Function(f) => f.name(db).as_str(db).to_string(),
Expand Down
5 changes: 2 additions & 3 deletions components/dada-execute/src/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,12 @@ impl<'me> Stepper<'me> {
let class_span = class.name_span(db).anchor_to(db, class);
error!(
span,
"the class `{}` has no field named `{}`",
class_name,
"the class `{class_name}` has no field named `{}`",
name.as_str(db)
)
.secondary_label(
class_span,
&format!("the class `{}` is declared here", class_name),
format!("the class `{class_name}` is declared here"),
)
.eyre(db)
}
Expand Down
12 changes: 6 additions & 6 deletions components/dada-ir/src/code/bir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ pub enum ExprData {
impl DebugWithDb<InIrDb<'_, Bir>> for ExprData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Bir>) -> std::fmt::Result {
match self {
ExprData::BooleanLiteral(b) => write!(f, "{}", b),
ExprData::IntegerLiteral(w) => write!(f, "{}", w),
ExprData::UnsignedIntegerLiteral(w) => write!(f, "{}", w),
ExprData::SignedIntegerLiteral(w) => write!(f, "{}", w),
ExprData::BooleanLiteral(b) => write!(f, "{b}"),
ExprData::IntegerLiteral(w) => write!(f, "{w}"),
ExprData::UnsignedIntegerLiteral(w) => write!(f, "{w}"),
ExprData::SignedIntegerLiteral(w) => write!(f, "{w}"),
ExprData::StringLiteral(w) => write!(f, "{:?}", w.as_str(db.db())),
ExprData::FloatLiteral(w) => write!(f, "{}", w),
ExprData::FloatLiteral(w) => write!(f, "{w}"),
ExprData::IntoShared(e) => write!(f, "{:?}.share", e.debug(db)),
ExprData::Share(p) => write!(f, "{:?}.share", p.debug(db)),
ExprData::Lease(p) => write!(f, "{:?}.lease", p.debug(db)),
Expand Down Expand Up @@ -531,7 +531,7 @@ impl DebugWithDb<InIrDb<'_, Bir>> for PlaceData {
PlaceData::LocalVariable(v) => write!(f, "{:?}", v.debug(db)),
PlaceData::Function(func) => write!(f, "{:?}", func.debug(db.db())),
PlaceData::Class(class) => write!(f, "{:?}", class.debug(db.db())),
PlaceData::Intrinsic(intrinsic) => write!(f, "{:?}", intrinsic),
PlaceData::Intrinsic(intrinsic) => write!(f, "{intrinsic:?}"),
PlaceData::Dot(p, id) => write!(f, "{:?}.{}", p.debug(db), id.as_str(db.db())),
}
}
Expand Down
14 changes: 7 additions & 7 deletions components/dada-ir/src/code/validated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ id!(pub struct Expr);

impl DebugWithDb<InIrDb<'_, Tree>> for Expr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Tree>) -> std::fmt::Result {
let name = format!("{:?}", self);
let name = format!("{self:?}");
f.debug_tuple(&name)
.field(&self.data(db.tables()).debug(db))
.field(&db.origins()[*self])
Expand Down Expand Up @@ -325,10 +325,10 @@ impl ExprData {
let id = id.map(u32::from);
match self {
ExprData::BooleanLiteral(v) => std::fmt::Debug::fmt(v, f),
ExprData::IntegerLiteral(v) => write!(f, "{}", v),
ExprData::UnsignedIntegerLiteral(v) => write!(f, "{}", v),
ExprData::SignedIntegerLiteral(v) => write!(f, "{}", v),
ExprData::FloatLiteral(v) => write!(f, "{}", v),
ExprData::IntegerLiteral(v) => write!(f, "{v}"),
ExprData::UnsignedIntegerLiteral(v) => write!(f, "{v}"),
ExprData::SignedIntegerLiteral(v) => write!(f, "{v}"),
ExprData::FloatLiteral(v) => write!(f, "{v}"),
ExprData::StringLiteral(v) => std::fmt::Debug::fmt(&v.as_str(db.db()), f),
ExprData::Await(expr) => f.debug_tuple("Await").field(&expr.debug(db)).finish(),
ExprData::Call(expr, args) => f
Expand Down Expand Up @@ -410,7 +410,7 @@ id!(pub struct Place);

impl DebugWithDb<InIrDb<'_, Tree>> for Place {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Tree>) -> std::fmt::Result {
let name = format!("{:?}", self);
let name = format!("{self:?}");
f.debug_tuple(&name)
.field(&self.data(db.tables()).debug(db))
.field(&db.origins()[*self])
Expand Down Expand Up @@ -447,7 +447,7 @@ id!(pub struct TargetPlace);

impl DebugWithDb<InIrDb<'_, Tree>> for TargetPlace {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Tree>) -> std::fmt::Result {
let name = format!("{:?}", self);
let name = format!("{self:?}");
f.debug_tuple(&name)
.field(&self.data(db.tables()).debug(db))
.field(&db.origins()[*self])
Expand Down
2 changes: 1 addition & 1 deletion components/dada-ir/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl DebugWithDb<dyn crate::Db + '_> for Permission {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &dyn crate::Db) -> std::fmt::Result {
match self {
Permission::Known(v) => v.fmt(f, db),
Permission::Parameter(v) => write!(f, "{:?}", v),
Permission::Parameter(v) => write!(f, "{v:?}"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/dada-lang/src/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl Options {
&expected_diagnostics.compile,
&mut errors,
)?;
self.bless_debug_file(format!("{:#?}", diagnostics), &path.join("lsp.debug"))?;
self.bless_debug_file(format!("{diagnostics:#?}"), &path.join("lsp.debug"))?;
errors.into_result()
}

Expand Down Expand Up @@ -884,7 +884,7 @@ fn expected_queries(path: &Path) -> eyre::Result<Vec<Query>> {
// The column comes from the position of the `^`.
let given_line_number: u32 = parse_line_number(line_number, &c["line"])?;
let given_column_number: u32 = str::parse(&c["column"])
.with_context(|| format!("in query on line {}", line_number))?;
.with_context(|| format!("in query on line {line_number}"))?;

let query_kind = match &c["kind"] {
"HeapGraph" => QueryKind::HeapGraph,
Expand Down Expand Up @@ -925,7 +925,7 @@ fn parse_line_number(current_line_number: u32, line: &str) -> eyre::Result<u32>
};

let parsed: u32 =
str::parse(number).with_context(|| format!("in query on line {}", current_line_number))?;
str::parse(number).with_context(|| format!("in query on line {current_line_number}"))?;
#[allow(clippy::comparison_chain)]
Ok(if sign == 0 {
parsed
Expand Down
2 changes: 1 addition & 1 deletion components/dada-lex/src/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn closing_delimiter(ch: char) -> char {
'(' => ')',
'[' => ']',
'{' => '}',
_ => panic!("not a delimiter: {:?}", ch),
_ => panic!("not a delimiter: {ch:?}"),
}
}

Expand Down
4 changes: 1 addition & 3 deletions components/dada-parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,7 @@ impl CodeParser<'_, '_> {
fn parse_required_sub_expr(&mut self, token_tree: TokenTree) -> Expr {
let db = self.db;
self.with_sub_parser(token_tree, |sub_parser| sub_parser.parse_only_expr())
.or_report_error_at(self, token_tree.span(db), || {
"expected expression here".to_string()
})
.or_report_error_at(self, token_tree.span(db), || "expected expression here")
.or_dummy_expr(self)
}

Expand Down
10 changes: 3 additions & 7 deletions components/dada-parse/src/parser/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ impl<'db> Parser<'db> {
.or_report_error(&mut signature_parser, || "expected a class name")?;
let parameters = signature_parser
.parse_parameter_list()
.or_report_error(&mut signature_parser, || {
"expected class parameters".to_string()
})?;
.or_report_error(&mut signature_parser, || "expected class parameters")?;
let signature = syntax::Signature::new(
name,
fn_decl,
Expand Down Expand Up @@ -137,9 +135,7 @@ impl<'db> Parser<'db> {
let fn_kw = signature_parser.parse_fn().unwrap(); // we peeked above, it should be there
let name = signature_parser
.parse_name()
.or_report_error(&mut signature_parser, || {
"expected function name".to_string()
})?;
.or_report_error(&mut signature_parser, || "expected function name")?;
let parameters = signature_parser
.parse_parameter_list()
.or_report_error(&mut signature_parser, || {
Expand All @@ -148,7 +144,7 @@ impl<'db> Parser<'db> {
let return_type = signature_parser.parse_return_type();
let (_, body_tokens) = self
.delimited('{')
.or_report_error(self, || "expected function body".to_string())?;
.or_report_error(self, || "expected function body")?;
let code = UnparsedCode::new(body_tokens);
let signature = syntax::Signature::new(
name,
Expand Down
4 changes: 2 additions & 2 deletions components/dada-parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ impl CodeParser<'_, '_> {
let Some(colon_span) = self.eat_op(Op::Colon) else { return None };
let opt_ty = self.parse_ty();
if opt_ty.is_none() {
self.error_at_current_token(&"expected type after `:`".to_string())
.secondary_label(colon_span, "`:` is here".to_string())
self.error_at_current_token("expected type after `:`")
.secondary_label(colon_span, "`:` is here")
.emit(self.db);
}
opt_ty
Expand Down
1 change: 1 addition & 0 deletions components/dada-parse/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl<'me> Tokens<'me> {

/// Span of the previously consumed token (or `Span::start` otherwise).
/// Does not include any skipped tokens.
#[allow(clippy::misnamed_getters)]
pub(crate) fn last_span(&self) -> Span {
self.last_not_skipped_span
}
Expand Down
2 changes: 1 addition & 1 deletion components/dada-validate/src/validate/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<'me> Validator<'me> {
},
_ => parse_error(
self,
format!("`{}` is not a valid integer suffxi", suffix_str),
format!("`{suffix_str}` is not a valid integer suffxi"),
),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Validator<'_> {
'"' => '\"',
'{' => '{',
'}' => '}',
_ => panic!("not a escape: {:?}", ch),
_ => panic!("not a escape: {ch:?}"),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/dada-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl DadaCompiler {
self.output = String::new();
for item in self.db.items(self.input_file) {
if let Some(tree) = self.db.debug_syntax_tree(item) {
let _ = write!(self.output, "{:#?}", tree);
let _ = write!(self.output, "{tree:#?}");
self.output.push('\n');
}
}
Expand All @@ -104,7 +104,7 @@ impl DadaCompiler {
self.output = String::new();
for item in self.db.items(self.input_file) {
if let Some(tree) = self.db.debug_validated_tree(item) {
let _ = write!(self.output, "{:#?}", tree);
let _ = write!(self.output, "{tree:#?}");
self.output.push('\n');
}
}
Expand All @@ -116,7 +116,7 @@ impl DadaCompiler {
self.output = String::new();
for item in self.db.items(self.input_file) {
if let Some(tree) = self.db.debug_bir(item) {
let _ = write!(self.output, "{:#?}", tree);
let _ = write!(self.output, "{tree:#?}");
self.output.push('\n');
}
}
Expand Down

0 comments on commit d7e9ab2

Please sign in to comment.