diff options
-rw-r--r-- | crates/ra_assists/src/assist_context.rs | 8 | ||||
-rw-r--r-- | crates/ra_assists/src/ast_transform.rs | 16 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_explicit_type.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_function.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_new.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/auto_import.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs | 10 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/fill_match_arms.rs | 8 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/fix_visibility.rs | 24 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/inline_local_variable.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/reorder_fields.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 16 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 2 |
14 files changed, 52 insertions, 54 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index ee614de72..3640bb4d2 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs | |||
@@ -55,7 +55,6 @@ use crate::{ | |||
55 | pub(crate) struct AssistContext<'a> { | 55 | pub(crate) struct AssistContext<'a> { |
56 | pub(crate) config: &'a AssistConfig, | 56 | pub(crate) config: &'a AssistConfig, |
57 | pub(crate) sema: Semantics<'a, RootDatabase>, | 57 | pub(crate) sema: Semantics<'a, RootDatabase>, |
58 | pub(crate) db: &'a RootDatabase, | ||
59 | pub(crate) frange: FileRange, | 58 | pub(crate) frange: FileRange, |
60 | source_file: SourceFile, | 59 | source_file: SourceFile, |
61 | } | 60 | } |
@@ -67,8 +66,11 @@ impl<'a> AssistContext<'a> { | |||
67 | frange: FileRange, | 66 | frange: FileRange, |
68 | ) -> AssistContext<'a> { | 67 | ) -> AssistContext<'a> { |
69 | let source_file = sema.parse(frange.file_id); | 68 | let source_file = sema.parse(frange.file_id); |
70 | let db = sema.db; | 69 | AssistContext { config, sema, frange, source_file } |
71 | AssistContext { config, sema, db, frange, source_file } | 70 | } |
71 | |||
72 | pub(crate) fn db(&self) -> &RootDatabase { | ||
73 | self.sema.db | ||
72 | } | 74 | } |
73 | 75 | ||
74 | // NB, this ignores active selection. | 76 | // NB, this ignores active selection. |
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 00fa95b6c..01adb834c 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs | |||
@@ -2,7 +2,6 @@ | |||
2 | use rustc_hash::FxHashMap; | 2 | use rustc_hash::FxHashMap; |
3 | 3 | ||
4 | use hir::{HirDisplay, PathResolution, SemanticsScope}; | 4 | use hir::{HirDisplay, PathResolution, SemanticsScope}; |
5 | use ra_ide_db::RootDatabase; | ||
6 | use ra_syntax::{ | 5 | use ra_syntax::{ |
7 | algo::SyntaxRewriter, | 6 | algo::SyntaxRewriter, |
8 | ast::{self, AstNode}, | 7 | ast::{self, AstNode}, |
@@ -32,14 +31,14 @@ impl<'a> AstTransform<'a> for NullTransformer { | |||
32 | } | 31 | } |
33 | 32 | ||
34 | pub struct SubstituteTypeParams<'a> { | 33 | pub struct SubstituteTypeParams<'a> { |
35 | source_scope: &'a SemanticsScope<'a, RootDatabase>, | 34 | source_scope: &'a SemanticsScope<'a>, |
36 | substs: FxHashMap<hir::TypeParam, ast::TypeRef>, | 35 | substs: FxHashMap<hir::TypeParam, ast::TypeRef>, |
37 | previous: Box<dyn AstTransform<'a> + 'a>, | 36 | previous: Box<dyn AstTransform<'a> + 'a>, |
38 | } | 37 | } |
39 | 38 | ||
40 | impl<'a> SubstituteTypeParams<'a> { | 39 | impl<'a> SubstituteTypeParams<'a> { |
41 | pub fn for_trait_impl( | 40 | pub fn for_trait_impl( |
42 | source_scope: &'a SemanticsScope<'a, RootDatabase>, | 41 | source_scope: &'a SemanticsScope<'a>, |
43 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... | 42 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... |
44 | trait_: hir::Trait, | 43 | trait_: hir::Trait, |
45 | impl_def: ast::ImplDef, | 44 | impl_def: ast::ImplDef, |
@@ -126,16 +125,13 @@ impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> { | |||
126 | } | 125 | } |
127 | 126 | ||
128 | pub struct QualifyPaths<'a> { | 127 | pub struct QualifyPaths<'a> { |
129 | target_scope: &'a SemanticsScope<'a, RootDatabase>, | 128 | target_scope: &'a SemanticsScope<'a>, |
130 | source_scope: &'a SemanticsScope<'a, RootDatabase>, | 129 | source_scope: &'a SemanticsScope<'a>, |
131 | previous: Box<dyn AstTransform<'a> + 'a>, | 130 | previous: Box<dyn AstTransform<'a> + 'a>, |
132 | } | 131 | } |
133 | 132 | ||
134 | impl<'a> QualifyPaths<'a> { | 133 | impl<'a> QualifyPaths<'a> { |
135 | pub fn new( | 134 | pub fn new(target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>) -> Self { |
136 | target_scope: &'a SemanticsScope<'a, RootDatabase>, | ||
137 | source_scope: &'a SemanticsScope<'a, RootDatabase>, | ||
138 | ) -> Self { | ||
139 | Self { target_scope, source_scope, previous: Box::new(NullTransformer) } | 135 | Self { target_scope, source_scope, previous: Box::new(NullTransformer) } |
140 | } | 136 | } |
141 | 137 | ||
@@ -156,7 +152,7 @@ impl<'a> QualifyPaths<'a> { | |||
156 | let resolution = self.source_scope.resolve_hir_path(&hir_path?)?; | 152 | let resolution = self.source_scope.resolve_hir_path(&hir_path?)?; |
157 | match resolution { | 153 | match resolution { |
158 | PathResolution::Def(def) => { | 154 | PathResolution::Def(def) => { |
159 | let found_path = from.find_use_path(self.source_scope.db, def)?; | 155 | let found_path = from.find_use_path(self.source_scope.db.upcast(), def)?; |
160 | let mut path = path_to_ast(found_path); | 156 | let mut path = path_to_ast(found_path); |
161 | 157 | ||
162 | let type_args = p | 158 | let type_args = p |
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 90b06a625..11df922a2 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -57,7 +57,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
57 | return None; | 57 | return None; |
58 | } | 58 | } |
59 | 59 | ||
60 | let inferred_type = ty.display_source_code(ctx.db, module.into()).ok()?; | 60 | let inferred_type = ty.display_source_code(ctx.db(), module.into()).ok()?; |
61 | acc.add( | 61 | acc.add( |
62 | AssistId("add_explicit_type"), | 62 | AssistId("add_explicit_type"), |
63 | format!("Insert explicit type `{}`", inferred_type), | 63 | format!("Insert explicit type `{}`", inferred_type), |
diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs index 1cfbd75aa..fc4e82309 100644 --- a/crates/ra_assists/src/handlers/add_function.rs +++ b/crates/ra_assists/src/handlers/add_function.rs | |||
@@ -117,7 +117,7 @@ impl FunctionBuilder { | |||
117 | let mut file = ctx.frange.file_id; | 117 | let mut file = ctx.frange.file_id; |
118 | let target = match &target_module { | 118 | let target = match &target_module { |
119 | Some(target_module) => { | 119 | Some(target_module) => { |
120 | let module_source = target_module.definition_source(ctx.db); | 120 | let module_source = target_module.definition_source(ctx.db()); |
121 | let (in_file, target) = next_space_for_fn_in_module(ctx.sema.db, &module_source)?; | 121 | let (in_file, target) = next_space_for_fn_in_module(ctx.sema.db, &module_source)?; |
122 | file = in_file; | 122 | file = in_file; |
123 | target | 123 | target |
@@ -269,7 +269,7 @@ fn fn_arg_type( | |||
269 | return None; | 269 | return None; |
270 | } | 270 | } |
271 | 271 | ||
272 | if let Ok(rendered) = ty.display_source_code(ctx.db, target_module.into()) { | 272 | if let Ok(rendered) = ty.display_source_code(ctx.db(), target_module.into()) { |
273 | Some(rendered) | 273 | Some(rendered) |
274 | } else { | 274 | } else { |
275 | None | 275 | None |
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index abacd4065..77e092f62 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -128,9 +128,9 @@ fn add_missing_impl_members_inner( | |||
128 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) | 128 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) |
129 | .iter() | 129 | .iter() |
130 | .map(|i| match i { | 130 | .map(|i| match i { |
131 | hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db).value), | 131 | hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), |
132 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db).value), | 132 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), |
133 | hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db).value), | 133 | hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), |
134 | }) | 134 | }) |
135 | .filter(|t| def_name(&t).is_some()) | 135 | .filter(|t| def_name(&t).is_some()) |
136 | .filter(|t| match t { | 136 | .filter(|t| match t { |
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 837aa8377..e41b2aa06 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -122,7 +122,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | |||
122 | // FIXME: change the new fn checking to a more semantic approach when that's more | 122 | // FIXME: change the new fn checking to a more semantic approach when that's more |
123 | // viable (e.g. we process proc macros, etc) | 123 | // viable (e.g. we process proc macros, etc) |
124 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { | 124 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { |
125 | let db = ctx.db; | 125 | let db = ctx.db(); |
126 | let module = strukt.syntax().ancestors().find(|node| { | 126 | let module = strukt.syntax().ancestors().find(|node| { |
127 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) | 127 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) |
128 | })?; | 128 | })?; |
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index d1cafa7d9..e8060a491 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs | |||
@@ -36,7 +36,7 @@ use crate::{utils::insert_use_statement, AssistContext, AssistId, Assists, Group | |||
36 | // ``` | 36 | // ``` |
37 | pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 37 | pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
38 | let auto_import_assets = AutoImportAssets::new(&ctx)?; | 38 | let auto_import_assets = AutoImportAssets::new(&ctx)?; |
39 | let proposed_imports = auto_import_assets.search_for_imports(ctx.db); | 39 | let proposed_imports = auto_import_assets.search_for_imports(ctx.db()); |
40 | if proposed_imports.is_empty() { | 40 | if proposed_imports.is_empty() { |
41 | return None; | 41 | return None; |
42 | } | 42 | } |
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index 43b4584b4..bdf9d7ae2 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -37,15 +37,15 @@ pub(crate) fn extract_struct_from_enum_variant( | |||
37 | }; | 37 | }; |
38 | let variant_name = variant.name()?.to_string(); | 38 | let variant_name = variant.name()?.to_string(); |
39 | let variant_hir = ctx.sema.to_def(&variant)?; | 39 | let variant_hir = ctx.sema.to_def(&variant)?; |
40 | if existing_struct_def(ctx.db, &variant_name, &variant_hir) { | 40 | if existing_struct_def(ctx.db(), &variant_name, &variant_hir) { |
41 | return None; | 41 | return None; |
42 | } | 42 | } |
43 | let enum_ast = variant.parent_enum(); | 43 | let enum_ast = variant.parent_enum(); |
44 | let visibility = enum_ast.visibility(); | 44 | let visibility = enum_ast.visibility(); |
45 | let enum_hir = ctx.sema.to_def(&enum_ast)?; | 45 | let enum_hir = ctx.sema.to_def(&enum_ast)?; |
46 | let variant_hir_name = variant_hir.name(ctx.db); | 46 | let variant_hir_name = variant_hir.name(ctx.db()); |
47 | let enum_module_def = ModuleDef::from(enum_hir); | 47 | let enum_module_def = ModuleDef::from(enum_hir); |
48 | let current_module = enum_hir.module(ctx.db); | 48 | let current_module = enum_hir.module(ctx.db()); |
49 | let target = variant.syntax().text_range(); | 49 | let target = variant.syntax().text_range(); |
50 | acc.add( | 50 | acc.add( |
51 | AssistId("extract_struct_from_enum_variant"), | 51 | AssistId("extract_struct_from_enum_variant"), |
@@ -53,7 +53,7 @@ pub(crate) fn extract_struct_from_enum_variant( | |||
53 | target, | 53 | target, |
54 | |builder| { | 54 | |builder| { |
55 | let definition = Definition::ModuleDef(ModuleDef::EnumVariant(variant_hir)); | 55 | let definition = Definition::ModuleDef(ModuleDef::EnumVariant(variant_hir)); |
56 | let res = definition.find_usages(&ctx.db, None); | 56 | let res = definition.find_usages(&ctx.db(), None); |
57 | let start_offset = variant.parent_enum().syntax().text_range().start(); | 57 | let start_offset = variant.parent_enum().syntax().text_range().start(); |
58 | let mut visited_modules_set = FxHashSet::default(); | 58 | let mut visited_modules_set = FxHashSet::default(); |
59 | visited_modules_set.insert(current_module); | 59 | visited_modules_set.insert(current_module); |
@@ -101,7 +101,7 @@ fn insert_import( | |||
101 | enum_module_def: &ModuleDef, | 101 | enum_module_def: &ModuleDef, |
102 | variant_hir_name: &Name, | 102 | variant_hir_name: &Name, |
103 | ) -> Option<()> { | 103 | ) -> Option<()> { |
104 | let db = ctx.db; | 104 | let db = ctx.db(); |
105 | let mod_path = module.find_use_path(db, enum_module_def.clone()); | 105 | let mod_path = module.find_use_path(db, enum_module_def.clone()); |
106 | if let Some(mut mod_path) = mod_path { | 106 | if let Some(mut mod_path) = mod_path { |
107 | mod_path.segments.pop(); | 107 | mod_path.segments.pop(); |
diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 64270c86f..5b1235682 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs | |||
@@ -51,11 +51,11 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
51 | let module = ctx.sema.scope(expr.syntax()).module()?; | 51 | let module = ctx.sema.scope(expr.syntax()).module()?; |
52 | 52 | ||
53 | let missing_arms: Vec<MatchArm> = if let Some(enum_def) = resolve_enum_def(&ctx.sema, &expr) { | 53 | let missing_arms: Vec<MatchArm> = if let Some(enum_def) = resolve_enum_def(&ctx.sema, &expr) { |
54 | let variants = enum_def.variants(ctx.db); | 54 | let variants = enum_def.variants(ctx.db()); |
55 | 55 | ||
56 | let mut variants = variants | 56 | let mut variants = variants |
57 | .into_iter() | 57 | .into_iter() |
58 | .filter_map(|variant| build_pat(ctx.db, module, variant)) | 58 | .filter_map(|variant| build_pat(ctx.db(), module, variant)) |
59 | .filter(|variant_pat| is_variant_missing(&mut arms, variant_pat)) | 59 | .filter(|variant_pat| is_variant_missing(&mut arms, variant_pat)) |
60 | .map(|pat| make::match_arm(iter::once(pat), make::expr_empty_block())) | 60 | .map(|pat| make::match_arm(iter::once(pat), make::expr_empty_block())) |
61 | .collect::<Vec<_>>(); | 61 | .collect::<Vec<_>>(); |
@@ -84,11 +84,11 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
84 | // where each tuple represents a proposed match arm. | 84 | // where each tuple represents a proposed match arm. |
85 | enum_defs | 85 | enum_defs |
86 | .into_iter() | 86 | .into_iter() |
87 | .map(|enum_def| enum_def.variants(ctx.db)) | 87 | .map(|enum_def| enum_def.variants(ctx.db())) |
88 | .multi_cartesian_product() | 88 | .multi_cartesian_product() |
89 | .map(|variants| { | 89 | .map(|variants| { |
90 | let patterns = | 90 | let patterns = |
91 | variants.into_iter().filter_map(|variant| build_pat(ctx.db, module, variant)); | 91 | variants.into_iter().filter_map(|variant| build_pat(ctx.db(), module, variant)); |
92 | ast::Pat::from(make::tuple_pat(patterns)) | 92 | ast::Pat::from(make::tuple_pat(patterns)) |
93 | }) | 93 | }) |
94 | .filter(|variant_pat| is_variant_missing(&mut arms, variant_pat)) | 94 | .filter(|variant_pat| is_variant_missing(&mut arms, variant_pat)) |
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 19d4dac5e..c0f57c329 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -41,14 +41,14 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | let current_module = ctx.sema.scope(&path.syntax()).module()?; | 43 | let current_module = ctx.sema.scope(&path.syntax()).module()?; |
44 | let target_module = def.module(ctx.db)?; | 44 | let target_module = def.module(ctx.db())?; |
45 | 45 | ||
46 | let vis = target_module.visibility_of(ctx.db, &def)?; | 46 | let vis = target_module.visibility_of(ctx.db(), &def)?; |
47 | if vis.is_visible_from(ctx.db, current_module.into()) { | 47 | if vis.is_visible_from(ctx.db(), current_module.into()) { |
48 | return None; | 48 | return None; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | let (offset, target, target_file, target_name) = target_data_for_def(ctx.db, def)?; | 51 | let (offset, target, target_file, target_name) = target_data_for_def(ctx.db(), def)?; |
52 | 52 | ||
53 | let missing_visibility = | 53 | let missing_visibility = |
54 | if current_module.krate() == target_module.krate() { "pub(crate)" } else { "pub" }; | 54 | if current_module.krate() == target_module.krate() { "pub(crate)" } else { "pub" }; |
@@ -72,16 +72,16 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> | |||
72 | let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; | 72 | let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; |
73 | 73 | ||
74 | let current_module = ctx.sema.scope(record_field.syntax()).module()?; | 74 | let current_module = ctx.sema.scope(record_field.syntax()).module()?; |
75 | let visibility = record_field_def.visibility(ctx.db); | 75 | let visibility = record_field_def.visibility(ctx.db()); |
76 | if visibility.is_visible_from(ctx.db, current_module.into()) { | 76 | if visibility.is_visible_from(ctx.db(), current_module.into()) { |
77 | return None; | 77 | return None; |
78 | } | 78 | } |
79 | 79 | ||
80 | let parent = record_field_def.parent_def(ctx.db); | 80 | let parent = record_field_def.parent_def(ctx.db()); |
81 | let parent_name = parent.name(ctx.db); | 81 | let parent_name = parent.name(ctx.db()); |
82 | let target_module = parent.module(ctx.db); | 82 | let target_module = parent.module(ctx.db()); |
83 | 83 | ||
84 | let in_file_source = record_field_def.source(ctx.db); | 84 | let in_file_source = record_field_def.source(ctx.db()); |
85 | let (offset, target) = match in_file_source.value { | 85 | let (offset, target) = match in_file_source.value { |
86 | hir::FieldSource::Named(it) => { | 86 | hir::FieldSource::Named(it) => { |
87 | let s = it.syntax(); | 87 | let s = it.syntax(); |
@@ -95,9 +95,9 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> | |||
95 | 95 | ||
96 | let missing_visibility = | 96 | let missing_visibility = |
97 | if current_module.krate() == target_module.krate() { "pub(crate)" } else { "pub" }; | 97 | if current_module.krate() == target_module.krate() { "pub(crate)" } else { "pub" }; |
98 | let target_file = in_file_source.file_id.original_file(ctx.db); | 98 | let target_file = in_file_source.file_id.original_file(ctx.db()); |
99 | 99 | ||
100 | let target_name = record_field_def.name(ctx.db); | 100 | let target_name = record_field_def.name(ctx.db()); |
101 | let assist_label = | 101 | let assist_label = |
102 | format!("Change visibility of {}.{} to {}", parent_name, target_name, missing_visibility); | 102 | format!("Change visibility of {}.{} to {}", parent_name, target_name, missing_visibility); |
103 | 103 | ||
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index d26e68847..f4fb0056b 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs | |||
@@ -44,7 +44,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O | |||
44 | 44 | ||
45 | let def = ctx.sema.to_def(&bind_pat)?; | 45 | let def = ctx.sema.to_def(&bind_pat)?; |
46 | let def = Definition::Local(def); | 46 | let def = Definition::Local(def); |
47 | let refs = def.find_usages(ctx.db, None); | 47 | let refs = def.find_usages(ctx.db(), None); |
48 | if refs.is_empty() { | 48 | if refs.is_empty() { |
49 | mark::hit!(test_not_applicable_if_variable_unused); | 49 | mark::hit!(test_not_applicable_if_variable_unused); |
50 | return None; | 50 | return None; |
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index bc58ce5fe..b8cf30e7f 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs | |||
@@ -90,10 +90,10 @@ fn struct_definition(path: &ast::Path, sema: &Semantics<RootDatabase>) -> Option | |||
90 | fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> { | 90 | fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> { |
91 | Some( | 91 | Some( |
92 | struct_definition(path, &ctx.sema)? | 92 | struct_definition(path, &ctx.sema)? |
93 | .fields(ctx.db) | 93 | .fields(ctx.db()) |
94 | .iter() | 94 | .iter() |
95 | .enumerate() | 95 | .enumerate() |
96 | .map(|(idx, field)| (field.name(ctx.db).to_string(), idx)) | 96 | .map(|(idx, field)| (field.name(ctx.db()).to_string(), idx)) |
97 | .collect(), | 97 | .collect(), |
98 | ) | 98 | ) |
99 | } | 99 | } |
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 6a49c424a..810c49d6f 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -297,19 +297,19 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
297 | self.with_ctx(|ctx| ctx.file_to_def(file)).map(Module::from) | 297 | self.with_ctx(|ctx| ctx.file_to_def(file)).map(Module::from) |
298 | } | 298 | } |
299 | 299 | ||
300 | pub fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db, DB> { | 300 | pub fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db> { |
301 | let node = self.find_file(node.clone()); | 301 | let node = self.find_file(node.clone()); |
302 | let resolver = self.analyze2(node.as_ref(), None).resolver; | 302 | let resolver = self.analyze2(node.as_ref(), None).resolver; |
303 | SemanticsScope { db: self.db, resolver } | 303 | SemanticsScope { db: self.db, resolver } |
304 | } | 304 | } |
305 | 305 | ||
306 | pub fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db, DB> { | 306 | pub fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db> { |
307 | let node = self.find_file(node.clone()); | 307 | let node = self.find_file(node.clone()); |
308 | let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver; | 308 | let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver; |
309 | SemanticsScope { db: self.db, resolver } | 309 | SemanticsScope { db: self.db, resolver } |
310 | } | 310 | } |
311 | 311 | ||
312 | pub fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db, DB> { | 312 | pub fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> { |
313 | let resolver = def.id.resolver(self.db); | 313 | let resolver = def.id.resolver(self.db); |
314 | SemanticsScope { db: self.db, resolver } | 314 | SemanticsScope { db: self.db, resolver } |
315 | } | 315 | } |
@@ -419,12 +419,12 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode { | |||
419 | node.ancestors().last().unwrap() | 419 | node.ancestors().last().unwrap() |
420 | } | 420 | } |
421 | 421 | ||
422 | pub struct SemanticsScope<'a, DB> { | 422 | pub struct SemanticsScope<'a> { |
423 | pub db: &'a DB, | 423 | pub db: &'a dyn HirDatabase, |
424 | resolver: Resolver, | 424 | resolver: Resolver, |
425 | } | 425 | } |
426 | 426 | ||
427 | impl<'a, DB: HirDatabase> SemanticsScope<'a, DB> { | 427 | impl<'a> SemanticsScope<'a> { |
428 | pub fn module(&self) -> Option<Module> { | 428 | pub fn module(&self) -> Option<Module> { |
429 | Some(Module { id: self.resolver.module()? }) | 429 | Some(Module { id: self.resolver.module()? }) |
430 | } | 430 | } |
@@ -433,13 +433,13 @@ impl<'a, DB: HirDatabase> SemanticsScope<'a, DB> { | |||
433 | // FIXME: rename to visible_traits to not repeat scope? | 433 | // FIXME: rename to visible_traits to not repeat scope? |
434 | pub fn traits_in_scope(&self) -> FxHashSet<TraitId> { | 434 | pub fn traits_in_scope(&self) -> FxHashSet<TraitId> { |
435 | let resolver = &self.resolver; | 435 | let resolver = &self.resolver; |
436 | resolver.traits_in_scope(self.db) | 436 | resolver.traits_in_scope(self.db.upcast()) |
437 | } | 437 | } |
438 | 438 | ||
439 | pub fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) { | 439 | pub fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) { |
440 | let resolver = &self.resolver; | 440 | let resolver = &self.resolver; |
441 | 441 | ||
442 | resolver.process_all_names(self.db, &mut |name, def| { | 442 | resolver.process_all_names(self.db.upcast(), &mut |name, def| { |
443 | let def = match def { | 443 | let def = match def { |
444 | resolver::ScopeDef::PerNs(it) => { | 444 | resolver::ScopeDef::PerNs(it) => { |
445 | let items = ScopeDef::all_items(it); | 445 | let items = ScopeDef::all_items(it); |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 560fb19e6..ef22ea54d 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -213,7 +213,7 @@ impl<'a> CompletionContext<'a> { | |||
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | pub(crate) fn scope(&self) -> SemanticsScope<'_, RootDatabase> { | 216 | pub(crate) fn scope(&self) -> SemanticsScope<'_> { |
217 | self.sema.scope_at_offset(&self.token.parent(), self.offset) | 217 | self.sema.scope_at_offset(&self.token.parent(), self.offset) |
218 | } | 218 | } |
219 | 219 | ||