Skip to content

Commit

Permalink
Auto merge of rust-lang#13642 - bvanjoi:fix-13292, r=Veykril
Browse files Browse the repository at this point in the history
fix(assists): remove `item_const` which had default value when implement missing members

Fixed rust-lang/rust-analyzer#13292
  • Loading branch information
bors committed Nov 19, 2022
2 parents ac60077 + a4f071a commit 8050fdb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions crates/ide-assists/src/handlers/add_missing_impl_members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ trait Foo {
type Output;
const CONST: usize = 42;
const CONST_2: i32;
fn foo(&self);
fn bar(&self);
Expand All @@ -213,6 +214,7 @@ trait Foo {
type Output;
const CONST: usize = 42;
const CONST_2: i32;
fn foo(&self);
fn bar(&self);
Expand All @@ -226,7 +228,7 @@ impl Foo for S {
$0type Output;
const CONST: usize = 42;
const CONST_2: i32;
fn foo(&self) {
todo!()
Expand Down Expand Up @@ -658,6 +660,7 @@ trait Foo {
type Output;
const CONST: usize = 42;
const CONST_2: i32;
fn valid(some: u32) -> bool { false }
fn foo(some: u32) -> bool;
Expand All @@ -669,13 +672,16 @@ trait Foo {
type Output;
const CONST: usize = 42;
const CONST_2: i32;
fn valid(some: u32) -> bool { false }
fn foo(some: u32) -> bool;
}
struct S;
impl Foo for S {
$0fn valid(some: u32) -> bool { false }
$0const CONST: usize = 42;
fn valid(some: u32) -> bool { false }
}"#,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,6 @@ struct Foo {
impl foo::Bar for Foo {
$0type Qux;
const Baz: usize = 42;
const Fez: usize;
fn foo() {
Expand Down
4 changes: 4 additions & 0 deletions crates/ide-assists/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ pub fn filter_assoc_items(
(default_methods, def.body()),
(DefaultMethods::Only, Some(_)) | (DefaultMethods::No, None)
),
ast::AssocItem::Const(def) => matches!(
(default_methods, def.body()),
(DefaultMethods::Only, Some(_)) | (DefaultMethods::No, None)
),
_ => default_methods == DefaultMethods::No,
})
.collect::<Vec<_>>()
Expand Down

0 comments on commit 8050fdb

Please sign in to comment.