From 13735d91a78ba51fb202cb7dde1dfe25420afe9a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 2 Nov 2019 23:42:38 +0300 Subject: Move diagnostics to hir_expand --- crates/ra_hir/src/ty/infer.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 6694467a3..2370e8d4f 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -25,7 +25,7 @@ use hir_def::{ path::known, type_ref::{Mutability, TypeRef}, }; -use hir_expand::name; +use hir_expand::{diagnostics::DiagnosticSink, name}; use ra_arena::map::ArenaMap; use ra_prof::profile; use test_utils::tested_by; @@ -40,7 +40,6 @@ use crate::{ adt::VariantDef, code_model::TypeAlias, db::HirDatabase, - diagnostics::DiagnosticSink, expr::{BindingAnnotation, Body, ExprId, PatId}, resolve::{Resolver, TypeNs}, ty::infer::diagnostics::InferenceDiagnostic, @@ -719,12 +718,9 @@ impl Expectation { } mod diagnostics { - use crate::{ - db::HirDatabase, - diagnostics::{DiagnosticSink, NoSuchField}, - expr::ExprId, - Function, HasSource, - }; + use hir_expand::diagnostics::DiagnosticSink; + + use crate::{db::HirDatabase, diagnostics::NoSuchField, expr::ExprId, Function, HasSource}; #[derive(Debug, PartialEq, Eq, Clone)] pub(super) enum InferenceDiagnostic { -- cgit v1.2.3 From ba2efca2bbe5f4434f9a2522b2b94df873f3563b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 31 Oct 2019 18:45:10 +0300 Subject: Move CrateDefMap to hir_def --- crates/ra_hir/src/ty/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 bfef48b16..f27155737 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -3403,7 +3403,7 @@ fn test() { S.foo()<|>; } #[test] fn infer_macro_with_dollar_crate_is_correct_in_expr() { - covers!(macro_dollar_crate_other); + // covers!(macro_dollar_crate_other); let (mut db, pos) = MockDatabase::with_position( r#" //- /main.rs -- cgit v1.2.3 From f0eb9cc6e66a65d2df42c662499ebd77ea980de5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 3 Nov 2019 23:49:44 +0300 Subject: Remove last traces of nameres from hir --- crates/ra_hir/src/ty/infer/expr.rs | 3 +-- crates/ra_hir/src/ty/lower.rs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs index fed52df39..a09ef5c5d 100644 --- a/crates/ra_hir/src/ty/infer/expr.rs +++ b/crates/ra_hir/src/ty/infer/expr.rs @@ -11,12 +11,11 @@ use crate::{ db::HirDatabase, expr::{self, Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, generics::{GenericParams, HasGenericParams}, - nameres::Namespace, ty::{ autoderef, method_resolution, op, primitive, CallableDef, InferTy, Mutability, Obligation, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk, }, - Adt, Name, + Adt, Name, Namespace, }; impl<'a, D: HirDatabase> InferenceContext<'a, D> { diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 8e2834307..e29ab8492 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs @@ -23,15 +23,14 @@ use crate::{ db::HirDatabase, generics::HasGenericParams, generics::{GenericDef, WherePredicate}, - nameres::Namespace, resolve::{Resolver, TypeNs}, ty::{ primitive::{FloatTy, IntTy}, Adt, }, util::make_mut_slice, - Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField, Trait, - TypeAlias, Union, + Const, Enum, EnumVariant, Function, ModuleDef, Namespace, Path, Static, Struct, StructField, + Trait, TypeAlias, Union, }; impl Ty { -- cgit v1.2.3 From dfdb6321acbe30704ef07ba7a2257f860a7a1398 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 Nov 2019 13:25:42 +0300 Subject: Use new text DSL instead of crate_graph! macro --- crates/ra_hir/src/ty/tests.rs | 84 +++++++++++++------------------------------ 1 file changed, 25 insertions(+), 59 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 f27155737..4b7e34878 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -2,8 +2,7 @@ use std::fmt::Write; use std::sync::Arc; use insta::assert_snapshot; - -use ra_db::{salsa::Database, FilePosition, SourceDatabase}; +use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase}; use ra_syntax::{ algo, ast::{self, AstNode}, @@ -25,9 +24,9 @@ mod coercion; #[test] fn cfg_impl_block() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:foo cfg:test use foo::S as T; struct S; @@ -46,7 +45,7 @@ fn test() { t<|>; } -//- /foo.rs +//- /foo.rs crate:foo struct S; #[cfg(not(test))] @@ -60,18 +59,14 @@ impl S { } "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["foo"], cfg = { "test" }), - "foo": ("/foo.rs", []), - }); assert_eq!("(i32, {unknown}, i32, {unknown})", type_at_pos(&db, pos)); } #[test] fn infer_await() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:std struct IntFuture; @@ -85,7 +80,7 @@ fn test() { v<|>; } -//- /std.rs +//- /std.rs crate:std #[prelude_import] use future::*; mod future { trait Future { @@ -95,18 +90,14 @@ mod future { "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["std"]), - "std": ("/std.rs", []), - }); assert_eq!("u64", type_at_pos(&db, pos)); } #[test] fn infer_box() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:std fn test() { let x = box 1; @@ -114,7 +105,7 @@ fn test() { t<|>; } -//- /std.rs +//- /std.rs crate:std #[prelude_import] use prelude::*; mod prelude {} @@ -126,10 +117,6 @@ mod boxed { "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["std"]), - "std": ("/std.rs", []), - }); assert_eq!("(Box, Box>, Box<&i32>, Box<[i32;_]>)", type_at_pos(&db, pos)); } @@ -154,9 +141,9 @@ fn test() { #[test] fn infer_try() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:std fn test() { let r: Result = Result::Ok(1); @@ -164,7 +151,7 @@ fn test() { v<|>; } -//- /std.rs +//- /std.rs crate:std #[prelude_import] use ops::*; mod ops { @@ -189,18 +176,14 @@ mod result { "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["std"]), - "std": ("/std.rs", []), - }); assert_eq!("i32", type_at_pos(&db, pos)); } #[test] fn infer_for_loop() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:std use std::collections::Vec; @@ -212,7 +195,7 @@ fn test() { } } -//- /std.rs +//- /std.rs crate:std #[prelude_import] use iter::*; mod iter { @@ -234,10 +217,6 @@ mod collections { } "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["std"]), - "std": ("/std.rs", []), - }); assert_eq!("&str", type_at_pos(&db, pos)); } @@ -2505,15 +2484,15 @@ pub fn main_loop() { #[test] fn cross_crate_associated_method_call() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:other_crate fn test() { let x = other_crate::foo::S::thing(); x<|>; } -//- /lib.rs +//- /lib.rs crate:other_crate mod foo { struct S; impl S { @@ -2522,10 +2501,6 @@ mod foo { } "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["other_crate"]), - "other_crate": ("/lib.rs", []), - }); assert_eq!("i128", type_at_pos(&db, pos)); } @@ -3403,16 +3378,15 @@ fn test() { S.foo()<|>; } #[test] fn infer_macro_with_dollar_crate_is_correct_in_expr() { - // covers!(macro_dollar_crate_other); - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:foo fn test() { let x = (foo::foo!(1), foo::foo!(2)); x<|>; } -//- /lib.rs +//- /lib.rs crate:foo #[macro_export] macro_rules! foo { (1) => { $crate::bar!() }; @@ -3427,10 +3401,6 @@ macro_rules! bar { pub fn baz() -> usize { 31usize } "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["foo"]), - "foo": ("/lib.rs", []), - }); assert_eq!("(i32, usize)", type_at_pos(&db, pos)); } @@ -3512,9 +3482,9 @@ fn test() { (&S).foo()<|>; } #[test] fn method_resolution_trait_from_prelude() { - let (mut db, pos) = MockDatabase::with_position( + let (db, pos) = MockDatabase::with_position( r#" -//- /main.rs +//- /main.rs crate:main deps:other_crate struct S; impl Clone for S {} @@ -3522,7 +3492,7 @@ fn test() { S.clone()<|>; } -//- /lib.rs +//- /lib.rs crate:other_crate #[prelude_import] use foo::*; mod foo { @@ -3532,10 +3502,6 @@ mod foo { } "#, ); - db.set_crate_graph_from_fixture(crate_graph! { - "main": ("/main.rs", ["other_crate"]), - "other_crate": ("/lib.rs", []), - }); assert_eq!("S", type_at_pos(&db, pos)); } -- cgit v1.2.3