Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/generate_function.rs')
| -rw-r--r-- | crates/ide-assists/src/handlers/generate_function.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/crates/ide-assists/src/handlers/generate_function.rs b/crates/ide-assists/src/handlers/generate_function.rs index a9cf2c1bae..bd66c02b41 100644 --- a/crates/ide-assists/src/handlers/generate_function.rs +++ b/crates/ide-assists/src/handlers/generate_function.rs @@ -71,7 +71,7 @@ fn gen_fn(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> { fn_target_info(ctx, path, &call, fn_name)?; if let Some(m) = target_module - && !is_editable_crate(m.krate(), ctx.db()) + && !is_editable_crate(m.krate(ctx.db()), ctx.db()) { return None; } @@ -143,7 +143,7 @@ fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> { let adt = receiver_ty.as_adt()?; let target_module = adt.module(ctx.sema.db); - if !is_editable_crate(target_module.krate(), ctx.db()) { + if !is_editable_crate(target_module.krate(ctx.db()), ctx.db()) { return None; } @@ -241,7 +241,7 @@ impl FunctionBuilder { ) -> Option<Self> { let target_module = target_module.or_else(|| ctx.sema.scope(target.syntax()).map(|it| it.module()))?; - let target_edition = target_module.krate().edition(ctx.db()); + let target_edition = target_module.krate(ctx.db()).edition(ctx.db()); let current_module = ctx.sema.scope(call.syntax())?.module(); let visibility = calculate_necessary_visibility(current_module, target_module, ctx); @@ -311,7 +311,7 @@ impl FunctionBuilder { target_module: Module, target: GeneratedFunctionTarget, ) -> Option<Self> { - let target_edition = target_module.krate().edition(ctx.db()); + let target_edition = target_module.krate(ctx.db()).edition(ctx.db()); let current_module = ctx.sema.scope(call.syntax())?.module(); let visibility = calculate_necessary_visibility(current_module, target_module, ctx); @@ -546,7 +546,7 @@ fn assoc_fn_target_info( let current_module = ctx.sema.scope(call.syntax())?.module(); let module = adt.module(ctx.sema.db); let target_module = if current_module == module { None } else { Some(module) }; - if current_module.krate() != module.krate() { + if current_module.krate(ctx.db()) != module.krate(ctx.db()) { return None; } let (impl_, file) = get_adt_source(ctx, &adt, fn_name)?; @@ -1149,7 +1149,10 @@ fn fn_arg_type( convert_reference_type(ty.strip_references(), ctx.db(), famous_defs) .map(|conversion| { conversion - .convert_type(ctx.db(), target_module.krate().to_display_target(ctx.db())) + .convert_type( + ctx.db(), + target_module.krate(ctx.db()).to_display_target(ctx.db()), + ) .to_string() }) .or_else(|| ty.display_source_code(ctx.db(), target_module.into(), true).ok()) @@ -1235,7 +1238,7 @@ fn calculate_necessary_visibility( let current_module = current_module.nearest_non_block_module(db); let target_module = target_module.nearest_non_block_module(db); - if target_module.krate() != current_module.krate() { + if target_module.krate(ctx.db()) != current_module.krate(ctx.db()) { Visibility::Pub } else if current_module.path_to_root(db).contains(&target_module) { Visibility::None |