From 6b9d05d1937f298df4197cebf862c3f644dd6778 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 7 Feb 2020 18:17:08 +0100 Subject: Fix add_new assist (kind of) --- crates/ra_assists/src/handlers/add_new.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 12d63b54d..2701eddb8 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -1,5 +1,5 @@ use format_buf::format; -use hir::InFile; +use hir::{Adt, InFile}; use join_to_string::join; use ra_syntax::{ ast::{ @@ -135,17 +135,22 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option; impl S {}` + // (we currently use the wrong type parameter) + // also we wouldn't want to use e.g. `impl S` + let same_ty = match blk.target_ty(db).as_adt() { + Some(def) => def == Adt::Struct(struct_def), + None => false, + }; let not_trait_impl = blk.target_trait(db).is_none(); if !(same_ty && not_trait_impl) { -- cgit v1.2.3