Skip to content

Commit 8050fdb

Browse files
committed
Auto merge of #13642 - bvanjoi:fix-13292, r=Veykril
fix(assists): remove `item_const` which had default value when implement missing members Fixed #13292
2 parents ac60077 + a4f071a commit 8050fdb

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

crates/ide-assists/src/handlers/add_missing_impl_members.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ trait Foo {
196196
type Output;
197197
198198
const CONST: usize = 42;
199+
const CONST_2: i32;
199200
200201
fn foo(&self);
201202
fn bar(&self);
@@ -213,6 +214,7 @@ trait Foo {
213214
type Output;
214215
215216
const CONST: usize = 42;
217+
const CONST_2: i32;
216218
217219
fn foo(&self);
218220
fn bar(&self);
@@ -226,7 +228,7 @@ impl Foo for S {
226228
227229
$0type Output;
228230
229-
const CONST: usize = 42;
231+
const CONST_2: i32;
230232
231233
fn foo(&self) {
232234
todo!()
@@ -658,6 +660,7 @@ trait Foo {
658660
type Output;
659661
660662
const CONST: usize = 42;
663+
const CONST_2: i32;
661664
662665
fn valid(some: u32) -> bool { false }
663666
fn foo(some: u32) -> bool;
@@ -669,13 +672,16 @@ trait Foo {
669672
type Output;
670673
671674
const CONST: usize = 42;
675+
const CONST_2: i32;
672676
673677
fn valid(some: u32) -> bool { false }
674678
fn foo(some: u32) -> bool;
675679
}
676680
struct S;
677681
impl Foo for S {
678-
$0fn valid(some: u32) -> bool { false }
682+
$0const CONST: usize = 42;
683+
684+
fn valid(some: u32) -> bool { false }
679685
}"#,
680686
)
681687
}

crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,6 @@ struct Foo {
10191019
impl foo::Bar for Foo {
10201020
$0type Qux;
10211021
1022-
const Baz: usize = 42;
1023-
10241022
const Fez: usize;
10251023
10261024
fn foo() {

crates/ide-assists/src/utils.rs

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ pub fn filter_assoc_items(
119119
(default_methods, def.body()),
120120
(DefaultMethods::Only, Some(_)) | (DefaultMethods::No, None)
121121
),
122+
ast::AssocItem::Const(def) => matches!(
123+
(default_methods, def.body()),
124+
(DefaultMethods::Only, Some(_)) | (DefaultMethods::No, None)
125+
),
122126
_ => default_methods == DefaultMethods::No,
123127
})
124128
.collect::<Vec<_>>()

0 commit comments

Comments
 (0)