From 515c3bc59bfc227cbbb82f80b53c5c125be4fc30 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 23 Dec 2018 12:15:46 +0100 Subject: Cleanup --- crates/ra_hir/src/ty/tests.rs | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 98eedaa3f..0880b51bc 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -1,31 +1,38 @@ use std::fmt::Write; -use std::sync::Arc; -use std::path::{Path, PathBuf}; +use std::path::{PathBuf}; -use salsa::Database; -use ra_db::{FilesDatabase, CrateGraph, SyntaxDatabase}; -use ra_syntax::{SmolStr, algo::visit::{visitor, Visitor}, ast::{self, AstNode}}; +use ra_db::{SyntaxDatabase}; +use ra_syntax::ast::{self, AstNode}; use test_utils::{project_dir, dir_tests}; -use relative_path::RelativePath; - -use crate::{source_binder, mock::WORKSPACE, module::ModuleSourceNode}; use crate::{ - self as hir, - db::HirDatabase, + source_binder, mock::MockDatabase, }; fn infer_file(content: &str) -> String { - let (db, source_root, file_id) = MockDatabase::with_single_file(content); + let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.source_file(file_id); let mut acc = String::new(); - for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) { - let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap().unwrap(); + for fn_def in source_file + .syntax() + .descendants() + .filter_map(ast::FnDef::cast) + { + let func = source_binder::function_from_source(&db, file_id, fn_def) + .unwrap() + .unwrap(); let inference_result = func.infer(&db); for (syntax_ptr, ty) in &inference_result.type_for { let node = syntax_ptr.resolve(&source_file); - write!(acc, "{} '{}': {}\n", syntax_ptr.range(), ellipsize(node.text().to_string().replace("\n", " "), 15), ty); + write!( + acc, + "{} '{}': {}\n", + syntax_ptr.range(), + ellipsize(node.text().to_string().replace("\n", " "), 15), + ty + ) + .unwrap(); } } acc @@ -51,9 +58,7 @@ fn ellipsize(mut text: String, max_len: usize) -> String { #[test] pub fn infer_tests() { - dir_tests(&test_data_dir(), &["."], |text, _path| { - infer_file(text) - }); + dir_tests(&test_data_dir(), &["."], |text, _path| infer_file(text)); } fn test_data_dir() -> PathBuf { -- cgit v1.2.3