Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig committed Dec 19, 2024
1 parent 6bb6a31 commit 7cc5bd6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/hir-analysis/src/name_resolution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn resolve_path_early<'db>(
path: PathId<'db>,
scope: ScopeId<'db>,
) -> Option<EarlyResolvedPath<'db, &'db NameResBucket<'db>>> {
ResolveEarly::new().resolve_path(db, path, scope).ok()
ResolveEarly::default().resolve_path(db, path, scope).ok()
}

// xxx use or remove
Expand Down
14 changes: 7 additions & 7 deletions crates/hir-analysis/src/name_resolution/name_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ impl<'db> NameRes<'db> {
inner = parent;
}

return Self {
Self {
derivation: inner.as_ref().clone(),
..self.clone()
}
.is_visible(db, from);
.is_visible(db, from)
}
}
}
Expand Down Expand Up @@ -422,20 +422,20 @@ pub enum NameDerivation<'db> {
Prim,
}

impl<'db> NameDerivation<'db> {
impl NameDerivation<'_> {
fn lexed(&mut self) {
let inner = mem::replace(self, NameDerivation::Def);
*self = NameDerivation::Lex(Box::new(inner));
}
}

impl<'db> PartialOrd for NameDerivation<'db> {
impl PartialOrd for NameDerivation<'_> {
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
Some(self.cmp(other))
}
}

impl<'db> Ord for NameDerivation<'db> {
impl Ord for NameDerivation<'_> {
fn cmp(&self, other: &Self) -> cmp::Ordering {
match (self, other) {
(NameDerivation::Def, NameDerivation::Def) => cmp::Ordering::Equal,
Expand Down Expand Up @@ -727,7 +727,7 @@ pub enum NameResolutionError<'db> {

pub type NameResolutionResult<'db, T> = Result<T, NameResolutionError<'db>>;

impl<'db> fmt::Display for NameResolutionError<'db> {
impl fmt::Display for NameResolutionError<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NameResolutionError::NotFound => write!(f, "name not found"),
Expand All @@ -743,7 +743,7 @@ impl<'db> fmt::Display for NameResolutionError<'db> {
}
}

impl<'db> std::error::Error for NameResolutionError<'db> {}
impl std::error::Error for NameResolutionError<'_> {}

bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
Expand Down
9 changes: 5 additions & 4 deletions crates/hir-analysis/src/name_resolution/path_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ impl<T> ResolveEarly<T> {
self.observer
}
}
impl ResolveEarly<()> {
pub fn new() -> Self {

impl Default for ResolveEarly<()> {
fn default() -> Self {
Self { observer: () }
}
}
Expand Down Expand Up @@ -135,7 +136,7 @@ impl<'db> Observer<'db> for Trajectory<'db> {
}
}

impl<'db> Observer<'db> for () {
impl Observer<'_> for () {
fn did_resolve(&mut self, _path: PathId, _scope: ScopeId, _res: &NameRes) {}
}

Expand Down Expand Up @@ -206,7 +207,7 @@ impl<'db> Resolver<'db> for ResolveToTypeDomain {
path: PathId<'db>,
scope: ScopeId<'db>,
) -> Self::Output {
match ResolveEarly::new().resolve_path(db, path, scope).ok()? {
match ResolveEarly::default().resolve_path(db, path, scope).ok()? {
EarlyResolvedPath::Full(bucket) => {
let res = bucket.pick(NameDomain::TYPE).clone().ok()?;
Some(EarlyResolvedPath::Full(res))
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-analysis/tests/test_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl HirAnalysisTestDb {
for diag in diags {
let cs_db = DbWithJar::<driver::Jar>::as_jar_db(self);
let cs_diag = &diag.to_cs(self);
term::emit(&mut buffer, &config, &CsDbWrapper(cs_db), &cs_diag).unwrap();
term::emit(&mut buffer, &config, &CsDbWrapper(cs_db), cs_diag).unwrap();
}
eprintln!("{}", std::str::from_utf8(buffer.as_slice()).unwrap());

Expand Down
2 changes: 1 addition & 1 deletion crates/language-server/src/functionality/goto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn find_path_surrounding_cursor<'db>(
}
}
}
return None;
None
}

pub fn find_enclosing_item<'db>(
Expand Down
12 changes: 6 additions & 6 deletions crates/parser2/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,16 @@ fn is_method_call<S: TokenStream>(parser: &mut Parser<S>) -> bool {
return false;
}

if parser.current_kind() == Some(SyntaxKind::Lt) {
if is_lt_eq(parser)
if parser.current_kind() == Some(SyntaxKind::Lt)
&& (is_lt_eq(parser)
|| is_lshift(parser)
|| !parser
.parse_ok(GenericArgListScope::default())
.is_ok_and(identity)
{
return false;
}
.is_ok_and(identity))
{
return false;
}

if parser.current_kind() != Some(SyntaxKind::LParen) {
false
} else {
Expand Down

0 comments on commit 7cc5bd6

Please sign in to comment.