Clippy lints

This commit is contained in:
Jeremy A. Kolb 2018-11-29 15:30:49 -05:00
parent 70a7cb34ec
commit f32dc71351
5 changed files with 14 additions and 17 deletions

View file

@ -94,7 +94,7 @@ impl RawRequest {
R::Params: Serialize,
{
RawRequest {
id: id,
id,
method: R::METHOD.to_string(),
params: to_value(params).unwrap(),
}

View file

@ -63,10 +63,7 @@ impl ConvWith for TextUnit {
fn conv_with(self, line_index: &LineIndex) -> Position {
let line_col = line_index.line_col(self);
Position::new(
u64::from(line_col.line),
u64::from(u32::from(line_col.col_utf16)),
)
Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16))
}
}
@ -204,10 +201,8 @@ impl TryConvWith for SourceChange {
.map(|it| it.edits.as_slice())
.unwrap_or(&[]);
let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits);
let position = Position::new(
u64::from(line_col.line),
u64::from(u32::from(line_col.col_utf16)),
);
let position =
Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16));
Some(TextDocumentPositionParams {
text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?),
position,

View file

@ -2,7 +2,6 @@
extern crate log;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate flexi_logger;

View file

@ -384,7 +384,7 @@ pub fn handle_completion(
let completion_triggered_after_single_colon = {
let mut res = false;
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 syntax = source_file.syntax();
let text = syntax.text();
@ -567,7 +567,10 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option<
let mut changes = HashMap::new();
for r in refs {
if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) {
changes.entry(loc.uri).or_insert(Vec::new()).push(TextEdit {
changes
.entry(loc.uri)
.or_insert_with(Vec::new)
.push(TextEdit {
range: loc.range,
new_text: params.new_name.clone(),
});

View file

@ -33,7 +33,7 @@ impl PathMap {
let file_id = self
.path2id
.get(path.as_path())
.map(|&id| id)
.cloned()
.unwrap_or_else(|| {
inserted = true;
let id = self.new_file_id();
@ -43,7 +43,7 @@ impl PathMap {
(inserted, file_id)
}
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 {
self.id2path.get(&file_id).unwrap().as_path()