mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Clippy lints
This commit is contained in:
parent
70a7cb34ec
commit
f32dc71351
5 changed files with 14 additions and 17 deletions
|
@ -94,7 +94,7 @@ impl RawRequest {
|
||||||
R::Params: Serialize,
|
R::Params: Serialize,
|
||||||
{
|
{
|
||||||
RawRequest {
|
RawRequest {
|
||||||
id: id,
|
id,
|
||||||
method: R::METHOD.to_string(),
|
method: R::METHOD.to_string(),
|
||||||
params: to_value(params).unwrap(),
|
params: to_value(params).unwrap(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,7 @@ impl ConvWith for TextUnit {
|
||||||
|
|
||||||
fn conv_with(self, line_index: &LineIndex) -> Position {
|
fn conv_with(self, line_index: &LineIndex) -> Position {
|
||||||
let line_col = line_index.line_col(self);
|
let line_col = line_index.line_col(self);
|
||||||
Position::new(
|
Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16))
|
||||||
u64::from(line_col.line),
|
|
||||||
u64::from(u32::from(line_col.col_utf16)),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,10 +201,8 @@ impl TryConvWith for SourceChange {
|
||||||
.map(|it| it.edits.as_slice())
|
.map(|it| it.edits.as_slice())
|
||||||
.unwrap_or(&[]);
|
.unwrap_or(&[]);
|
||||||
let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits);
|
let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits);
|
||||||
let position = Position::new(
|
let position =
|
||||||
u64::from(line_col.line),
|
Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16));
|
||||||
u64::from(u32::from(line_col.col_utf16)),
|
|
||||||
);
|
|
||||||
Some(TextDocumentPositionParams {
|
Some(TextDocumentPositionParams {
|
||||||
text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?),
|
text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?),
|
||||||
position,
|
position,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate flexi_logger;
|
extern crate flexi_logger;
|
||||||
|
|
|
@ -384,7 +384,7 @@ pub fn handle_completion(
|
||||||
let completion_triggered_after_single_colon = {
|
let completion_triggered_after_single_colon = {
|
||||||
let mut res = false;
|
let mut res = false;
|
||||||
if let Some(ctx) = params.context {
|
if let Some(ctx) = params.context {
|
||||||
if ctx.trigger_character.unwrap_or(String::new()) == ":" {
|
if ctx.trigger_character.unwrap_or_default() == ":" {
|
||||||
let source_file = world.analysis().file_syntax(position.file_id);
|
let source_file = world.analysis().file_syntax(position.file_id);
|
||||||
let syntax = source_file.syntax();
|
let syntax = source_file.syntax();
|
||||||
let text = syntax.text();
|
let text = syntax.text();
|
||||||
|
@ -567,10 +567,13 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option<
|
||||||
let mut changes = HashMap::new();
|
let mut changes = HashMap::new();
|
||||||
for r in refs {
|
for r in refs {
|
||||||
if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) {
|
if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) {
|
||||||
changes.entry(loc.uri).or_insert(Vec::new()).push(TextEdit {
|
changes
|
||||||
range: loc.range,
|
.entry(loc.uri)
|
||||||
new_text: params.new_name.clone(),
|
.or_insert_with(Vec::new)
|
||||||
});
|
.push(TextEdit {
|
||||||
|
range: loc.range,
|
||||||
|
new_text: params.new_name.clone(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl PathMap {
|
||||||
let file_id = self
|
let file_id = self
|
||||||
.path2id
|
.path2id
|
||||||
.get(path.as_path())
|
.get(path.as_path())
|
||||||
.map(|&id| id)
|
.cloned()
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
inserted = true;
|
inserted = true;
|
||||||
let id = self.new_file_id();
|
let id = self.new_file_id();
|
||||||
|
@ -43,7 +43,7 @@ impl PathMap {
|
||||||
(inserted, file_id)
|
(inserted, file_id)
|
||||||
}
|
}
|
||||||
pub fn get_id(&self, path: &Path) -> Option<FileId> {
|
pub fn get_id(&self, path: &Path) -> Option<FileId> {
|
||||||
self.path2id.get(path).map(|&id| id)
|
self.path2id.get(path).cloned()
|
||||||
}
|
}
|
||||||
pub fn get_path(&self, file_id: FileId) -> &Path {
|
pub fn get_path(&self, file_id: FileId) -> &Path {
|
||||||
self.id2path.get(&file_id).unwrap().as_path()
|
self.id2path.get(&file_id).unwrap().as_path()
|
||||||
|
|
Loading…
Reference in a new issue