mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 10:58:02 +00:00
cargo clippy --fix
This commit is contained in:
parent
423c7dd23a
commit
8ce30264c8
186 changed files with 3056 additions and 3314 deletions
|
|
@ -555,12 +555,11 @@ fn concat_expand(
|
|||
// FIXME: hack on top of a hack: `$e:expr` captures get surrounded in parentheses
|
||||
// to ensure the right parsing order, so skip the parentheses here. Ideally we'd
|
||||
// implement rustc's model. cc https://github.com/rust-lang/rust-analyzer/pull/10623
|
||||
if let TtElement::Subtree(subtree, subtree_iter) = &t {
|
||||
if let [tt::TokenTree::Leaf(tt)] = subtree_iter.remaining().flat_tokens() {
|
||||
if subtree.delimiter.kind == tt::DelimiterKind::Parenthesis {
|
||||
t = TtElement::Leaf(tt);
|
||||
}
|
||||
}
|
||||
if let TtElement::Subtree(subtree, subtree_iter) = &t
|
||||
&& let [tt::TokenTree::Leaf(tt)] = subtree_iter.remaining().flat_tokens()
|
||||
&& subtree.delimiter.kind == tt::DelimiterKind::Parenthesis
|
||||
{
|
||||
t = TtElement::Leaf(tt);
|
||||
}
|
||||
match t {
|
||||
TtElement::Leaf(tt::Leaf::Literal(it)) if i % 2 == 0 => {
|
||||
|
|
|
|||
|
|
@ -334,10 +334,10 @@ where
|
|||
_ => Some(CfgExpr::Atom(CfgAtom::Flag(name))),
|
||||
},
|
||||
};
|
||||
if let Some(NodeOrToken::Token(element)) = iter.peek() {
|
||||
if element.kind() == syntax::T![,] {
|
||||
iter.next();
|
||||
}
|
||||
if let Some(NodeOrToken::Token(element)) = iter.peek()
|
||||
&& element.kind() == syntax::T![,]
|
||||
{
|
||||
iter.next();
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,8 +280,8 @@ pub(crate) fn fixup_syntax(
|
|||
}
|
||||
},
|
||||
ast::RecordExprField(it) => {
|
||||
if let Some(colon) = it.colon_token() {
|
||||
if it.name_ref().is_some() && it.expr().is_none() {
|
||||
if let Some(colon) = it.colon_token()
|
||||
&& it.name_ref().is_some() && it.expr().is_none() {
|
||||
append.insert(colon.into(), vec![
|
||||
Leaf::Ident(Ident {
|
||||
sym: sym::__ra_fixup,
|
||||
|
|
@ -290,11 +290,10 @@ pub(crate) fn fixup_syntax(
|
|||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
ast::Path(it) => {
|
||||
if let Some(colon) = it.coloncolon_token() {
|
||||
if it.segment().is_none() {
|
||||
if let Some(colon) = it.coloncolon_token()
|
||||
&& it.segment().is_none() {
|
||||
append.insert(colon.into(), vec![
|
||||
Leaf::Ident(Ident {
|
||||
sym: sym::__ra_fixup,
|
||||
|
|
@ -303,7 +302,6 @@ pub(crate) fn fixup_syntax(
|
|||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
ast::ClosureExpr(it) => {
|
||||
if it.body().is_none() {
|
||||
|
|
|
|||
|
|
@ -365,12 +365,11 @@ impl HirFileId {
|
|||
HirFileId::FileId(id) => break id,
|
||||
HirFileId::MacroFile(file) => {
|
||||
let loc = db.lookup_intern_macro_call(file);
|
||||
if loc.def.is_include() {
|
||||
if let MacroCallKind::FnLike { eager: Some(eager), .. } = &loc.kind {
|
||||
if let Ok(it) = include_input_to_file_id(db, file, &eager.arg) {
|
||||
break it;
|
||||
}
|
||||
}
|
||||
if loc.def.is_include()
|
||||
&& let MacroCallKind::FnLike { eager: Some(eager), .. } = &loc.kind
|
||||
&& let Ok(it) = include_input_to_file_id(db, file, &eager.arg)
|
||||
{
|
||||
break it;
|
||||
}
|
||||
self = loc.kind.file_id();
|
||||
}
|
||||
|
|
@ -648,12 +647,11 @@ impl MacroCallLoc {
|
|||
db: &dyn ExpandDatabase,
|
||||
macro_call_id: MacroCallId,
|
||||
) -> Option<EditionedFileId> {
|
||||
if self.def.is_include() {
|
||||
if let MacroCallKind::FnLike { eager: Some(eager), .. } = &self.kind {
|
||||
if let Ok(it) = include_input_to_file_id(db, macro_call_id, &eager.arg) {
|
||||
return Some(it);
|
||||
}
|
||||
}
|
||||
if self.def.is_include()
|
||||
&& let MacroCallKind::FnLike { eager: Some(eager), .. } = &self.kind
|
||||
&& let Ok(it) = include_input_to_file_id(db, macro_call_id, &eager.arg)
|
||||
{
|
||||
return Some(it);
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
|||
|
|
@ -273,16 +273,17 @@ fn convert_path(
|
|||
// Basically, even in rustc it is quite hacky:
|
||||
// https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456
|
||||
// We follow what it did anyway :)
|
||||
if mod_path.segments.len() == 1 && mod_path.kind == PathKind::Plain {
|
||||
if let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) {
|
||||
let syn_ctx = span_for_range(segment.syntax().text_range());
|
||||
if let Some(macro_call_id) = syn_ctx.outer_expn(db) {
|
||||
if db.lookup_intern_macro_call(macro_call_id.into()).def.local_inner {
|
||||
mod_path.kind = match resolve_crate_root(db, syn_ctx) {
|
||||
Some(crate_root) => PathKind::DollarCrate(crate_root),
|
||||
None => PathKind::Crate,
|
||||
}
|
||||
}
|
||||
if mod_path.segments.len() == 1
|
||||
&& mod_path.kind == PathKind::Plain
|
||||
&& let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast)
|
||||
{
|
||||
let syn_ctx = span_for_range(segment.syntax().text_range());
|
||||
if let Some(macro_call_id) = syn_ctx.outer_expn(db)
|
||||
&& db.lookup_intern_macro_call(macro_call_id.into()).def.local_inner
|
||||
{
|
||||
mod_path.kind = match resolve_crate_root(db, syn_ctx) {
|
||||
Some(crate_root) => PathKind::DollarCrate(crate_root),
|
||||
None => PathKind::Crate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue