Skip to content

Commit 293040a

Browse files
committed
Fix clippy lints
1 parent e2bab51 commit 293040a

6 files changed

Lines changed: 26 additions & 32 deletions

File tree

crates/dm-langserver/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl Engine {
441441
kind: if var
442442
.declaration
443443
.as_ref()
444-
.map_or(false, |d| d.var_type.flags.is_const())
444+
.is_some_and(|d| d.var_type.flags.is_const())
445445
{
446446
lsp_types::SymbolKind::CONSTANT
447447
} else {

crates/dreamchecker/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,7 @@ impl<'o, 's> AnalyzeProc<'o, 's> {
28842884
.path
28852885
.split('/')
28862886
.filter(|elem| !elem.is_empty())
2887-
.map(|segment| Ident::from_nonstatic(segment))
2887+
.map(Ident::from_nonstatic)
28882888
.collect();
28892889
// Only tricky bit is adding on the type if required
28902890
if let Some(declaration) = decl.get_declaration() {

crates/dreammaker/src/ast.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ impl Ident {
757757
self.inner.into_owned()
758758
}
759759

760+
#[allow(clippy::inherent_to_string_shadow_display)]
760761
pub fn to_string(&self) -> String {
761762
self.as_str().to_owned()
762763
}
@@ -792,7 +793,7 @@ impl PartialEq<Ident> for str {
792793
}
793794
}
794795

795-
impl<'a> PartialEq<Ident> for &'a str {
796+
impl PartialEq<Ident> for &str {
796797
fn eq(&self, other: &Ident) -> bool {
797798
&*other.inner == *self
798799
}
@@ -882,7 +883,7 @@ pub type TreePath = Box<[Ident]>;
882883
pub fn treepath_from_str(str: &str) -> TreePath {
883884
str.split('/')
884885
.filter(|elem| !elem.is_empty())
885-
.map(|segment| Ident::from_nonstatic(segment))
886+
.map(Ident::from_nonstatic)
886887
.collect::<TreePath>()
887888
}
888889

crates/dreammaker/src/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<'a> ConstantFolder<'a> {
665665
rhs,
666666
} => {
667667
let key = match Term::from(*lhs) {
668-
Term::Ident(ident) => Constant::String(ident.into()),
668+
Term::Ident(ident) => Constant::String(ident),
669669
other => self.term(other, None)?,
670670
};
671671
(key, Some(self.expr(*rhs, None)?))
@@ -1094,7 +1094,7 @@ impl<'a> ConstantFolder<'a> {
10941094
.path
10951095
.split('/')
10961096
.filter(|elem| !elem.is_empty())
1097-
.map(|segment| Ident::from_nonstatic(segment))
1097+
.map(Ident::from_nonstatic)
10981098
.collect();
10991099
// Only tricky bit is adding on the type if required
11001100
if let Some(declaration) = proc_ref.get_declaration() {

crates/dreammaker/src/objtree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ impl<'o> NavigatePathResult<'o> {
543543
.path
544544
.split('/')
545545
.skip(1)
546-
.map(|p| Ident::from_nonstatic(p))
546+
.map(Ident::from_nonstatic)
547547
.collect();
548548
match self {
549549
NavigatePathResult::Type(_) => {},
@@ -1125,7 +1125,7 @@ impl ObjectTreeBuilder {
11251125
Ok((current, last))
11261126
}
11271127

1128-
fn register_var<'a, I>(
1128+
fn register_var<I>(
11291129
&mut self,
11301130
location: Location,
11311131
parent: NodeIndex,
@@ -1161,7 +1161,7 @@ impl ObjectTreeBuilder {
11611161

11621162
let mut type_path = Vec::new();
11631163
for each in rest {
1164-
type_path.push(prev.to_owned().into());
1164+
type_path.push(prev.clone());
11651165
prev = each;
11661166
}
11671167
let mut var_type = VarTypeBuilder {

crates/dreammaker/src/parser.rs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,9 +1633,9 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
16331633
// Returns a for(k,v)
16341634
spanned(Statement::ForKeyValue(Box::new(ForKeyValueStatement {
16351635
var_type: Some(var_type.expect("/")),
1636-
key: key.into(),
1636+
key,
16371637
key_input_type,
1638-
value: value.into(),
1638+
value,
16391639
in_list: Some(*rhs), // We'll assume the rhs of [v in x] is a list. Any other case, DM will catch anyway.
16401640
block: require!(self.block(&LoopContext::ForLoop)),
16411641
})))
@@ -1707,7 +1707,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
17071707
require!(self.exact(Token::Punct(Punctuation::RParen)));
17081708
return spanned(Statement::ForList(Box::new(ForListStatement {
17091709
var_type: None,
1710-
name: name.into(),
1710+
name,
17111711
input_type: None,
17121712
in_list: Some(rhs),
17131713
block: require!(self.block(&LoopContext::ForList)),
@@ -1743,7 +1743,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
17431743
require!(self.exact(Token::Punct(Punctuation::RParen)));
17441744
spanned(Statement::ForList(Box::new(ForListStatement {
17451745
var_type,
1746-
name: name.into(),
1746+
name,
17471747
input_type,
17481748
in_list,
17491749
block: require!(self.block(&LoopContext::ForList)),
@@ -1834,11 +1834,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
18341834
};
18351835
let value = require!(self.expression());
18361836
require!(self.statement_terminator());
1837-
spanned(Statement::Setting {
1838-
name: name.into(),
1839-
mode,
1840-
value,
1841-
})
1837+
spanned(Statement::Setting { name, mode, value })
18421838
} else if let Some(()) = self.exact_ident("break")? {
18431839
let label = self.ident()?;
18441840
require!(self.statement_terminator());
@@ -2037,7 +2033,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
20372033
// {...}
20382034
success(Statement::ForRange(Box::new(ForRangeStatement {
20392035
var_type,
2040-
name: name.into(),
2036+
name,
20412037
start,
20422038
end,
20432039
step,
@@ -2139,7 +2135,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
21392135
let key = require!(this.ident());
21402136
require!(this.exact(Token::Punct(Punctuation::Assign)));
21412137
let value = require!(this.expression());
2142-
vars.push((key.into(), value));
2138+
vars.push((key, value));
21432139
SUCCESS
21442140
},
21452141
)?;
@@ -2406,7 +2402,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
24062402
}
24072403
Term::NewMiniExpr {
24082404
expr: Box::new(MiniExpr {
2409-
ident: ident.into(),
2405+
ident,
24102406
fields: fields.into_boxed_slice(),
24112407
}),
24122408
args: self.arguments(&[], &ident!("New"))?,
@@ -2549,7 +2545,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
25492545
match self.arguments(&[], &i)? {
25502546
Some(args) => {
25512547
self.annotate_precise(start..first_token, || Annotation::UnscopedCall(i.clone()));
2552-
Term::Call(i.into(), args)
2548+
Term::Call(i, args)
25532549
},
25542550
None => {
25552551
belongs_to.push(i.clone());
@@ -2588,9 +2584,9 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
25882584
Token::Punct(Punctuation::Scope) => {
25892585
if let Some(ident) = self.ident()? {
25902586
if let Some(args) = self.arguments(&[], &ident!("::"))? {
2591-
Term::GlobalCall(Ident::from(ident), args)
2587+
Term::GlobalCall(ident, args)
25922588
} else {
2593-
Term::GlobalIdent(Ident::from(ident))
2589+
Term::GlobalIdent(ident)
25942590
}
25952591
} else {
25962592
// Go away
@@ -2711,8 +2707,8 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
27112707
});
27122708
}
27132709
match kind {
2714-
PropertyAccessKind::Scope => Follow::ProcReference(ident.into()),
2715-
_ => Follow::Call(kind, ident.into(), args),
2710+
PropertyAccessKind::Scope => Follow::ProcReference(ident),
2711+
_ => Follow::Call(kind, ident, args),
27162712
}
27172713
},
27182714
None => {
@@ -2723,8 +2719,8 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
27232719
belongs_to.push(ident.clone());
27242720
}
27252721
match kind {
2726-
PropertyAccessKind::Scope => Follow::StaticField(ident.into()),
2727-
_ => Follow::Field(kind, ident.into()),
2722+
PropertyAccessKind::Scope => Follow::StaticField(ident),
2723+
_ => Follow::Field(kind, ident),
27282724
}
27292725
},
27302726
};
@@ -2766,10 +2762,7 @@ impl<'ctx, 'an, 'inp> Parser<'ctx, 'an, 'inp> {
27662762
});
27672763
belongs_to.push(ident.clone());
27682764
}
2769-
success(Field {
2770-
kind,
2771-
ident: ident.into(),
2772-
})
2765+
success(Field { kind, ident })
27732766
}
27742767

27752768
/// a parenthesized, comma-separated list of expressions

0 commit comments

Comments
 (0)