mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Merge #138
138: Fix some clippy lints r=matklad a=alanhdu
I went ahead and fixed all the clippy lints (there were a couple I thought would be better unfixed and added `cfg` statements to allow them) and also re-enabled clippy and rustfmt in CI.
They were disabled with `no time to explain, disable clippy checks`, so hopefully this won't go against whatever the reason at the time was 😆.
One question about the CI though: right now, it's an allowed failure that runs against the latest nightly each time. Would it be better to pin it to a specific nightly (or use the `beta` versions) to lower the churn?
Co-authored-by: Alan Du <alanhdu@gmail.com>
This commit is contained in:
commit
27694abd94
26 changed files with 67 additions and 68 deletions
|
@ -63,7 +63,7 @@ fn extend_ws(root: SyntaxNodeRef, ws: SyntaxNodeRef, offset: TextUnit) -> TextRa
|
|||
let prefix = TextRange::from_to(ws.range().start(), offset) - ws.range().start();
|
||||
let ws_suffix = &ws_text.as_str()[suffix];
|
||||
let ws_prefix = &ws_text.as_str()[prefix];
|
||||
if ws_text.contains("\n") && !ws_suffix.contains("\n") {
|
||||
if ws_text.contains('\n') && !ws_suffix.contains('\n') {
|
||||
if let Some(node) = ws.next_sibling() {
|
||||
let start = match ws_prefix.rfind('\n') {
|
||||
Some(idx) => ws.range().start() + TextUnit::from((idx + 1) as u32),
|
||||
|
|
|
@ -38,12 +38,12 @@ pub fn folding_ranges(file: &File) -> Vec<Fold> {
|
|||
continue;
|
||||
}
|
||||
if node.kind() == COMMENT {
|
||||
contiguous_range_for_comment(node, &mut visited_comments).map(|range| {
|
||||
if let Some(range) = contiguous_range_for_comment(node, &mut visited_comments) {
|
||||
res.push(Fold {
|
||||
range,
|
||||
kind: FoldKind::Comment,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ impl LineIndex {
|
|||
let line = self.newlines.upper_bound(&offset) - 1;
|
||||
let line_start_offset = self.newlines[line];
|
||||
let col = offset - line_start_offset;
|
||||
return LineCol {
|
||||
LineCol {
|
||||
line: line as u32,
|
||||
col,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn offset(&self, line_col: LineCol) -> TextUnit {
|
||||
|
|
|
@ -22,14 +22,14 @@ impl ModuleScope {
|
|||
let mut entries = Vec::new();
|
||||
for item in items {
|
||||
let entry = match item {
|
||||
ast::ModuleItem::StructDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::EnumDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::FnDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::ConstDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::StaticDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::TraitDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::TypeDef(item) => Entry::new(item),
|
||||
ast::ModuleItem::Module(item) => Entry::new(item),
|
||||
ast::ModuleItem::StructDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::EnumDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::FnDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::ConstDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::StaticDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::TraitDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::TypeDef(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::Module(item) => Entry::new_item(item),
|
||||
ast::ModuleItem::UseItem(item) => {
|
||||
if let Some(tree) = item.use_tree() {
|
||||
collect_imports(tree, &mut entries);
|
||||
|
@ -50,7 +50,7 @@ impl ModuleScope {
|
|||
}
|
||||
|
||||
impl Entry {
|
||||
fn new<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> {
|
||||
fn new_item<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> {
|
||||
let name = item.name()?;
|
||||
Some(Entry {
|
||||
node: name.syntax().owned(),
|
||||
|
|
|
@ -54,15 +54,15 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> {
|
|||
let mut res = Vec::new();
|
||||
let mut stack = Vec::new();
|
||||
|
||||
|
||||
for event in file.syntax().preorder() {
|
||||
match event {
|
||||
WalkEvent::Enter(node) => match structure_node(node) {
|
||||
Some(mut symbol) => {
|
||||
WalkEvent::Enter(node) => {
|
||||
if let Some(mut symbol) = structure_node(node) {
|
||||
symbol.parent = stack.last().map(|&n| n);
|
||||
stack.push(res.len());
|
||||
res.push(symbol);
|
||||
}
|
||||
None => (),
|
||||
},
|
||||
WalkEvent::Leave(node) => {
|
||||
if structure_node(node).is_some() {
|
||||
|
|
|
@ -58,7 +58,7 @@ pub fn join_lines(file: &File, range: TextRange) -> LocalEdit {
|
|||
pub fn on_enter(file: &File, offset: TextUnit) -> Option<LocalEdit> {
|
||||
let comment = find_leaf_at_offset(file.syntax(), offset)
|
||||
.left_biased()
|
||||
.and_then(|it| ast::Comment::cast(it))?;
|
||||
.and_then(ast::Comment::cast)?;
|
||||
|
||||
if let ast::CommentFlavor::Multiline = comment.flavor() {
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue