File tree 2 files changed +18
-5
lines changed
ide-diagnostics/src/handlers
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -667,21 +667,21 @@ impl Module {
667
667
let items = & db. trait_data ( trait_. into ( ) ) . items ;
668
668
let required_items = items. iter ( ) . filter ( |& ( _, assoc) | match * assoc {
669
669
AssocItemId :: FunctionId ( it) => !db. function_data ( it) . has_body ( ) ,
670
- AssocItemId :: ConstId ( _ ) => true ,
670
+ AssocItemId :: ConstId ( id ) => Const :: from ( id ) . value ( db ) . is_none ( ) ,
671
671
AssocItemId :: TypeAliasId ( it) => db. type_alias_data ( it) . type_ref . is_none ( ) ,
672
672
} ) ;
673
- impl_assoc_items_scratch. extend ( db. impl_data ( impl_def. id ) . items . iter ( ) . map (
673
+ impl_assoc_items_scratch. extend ( db. impl_data ( impl_def. id ) . items . iter ( ) . filter_map (
674
674
|& item| {
675
- (
675
+ Some ( (
676
676
item,
677
677
match item {
678
678
AssocItemId :: FunctionId ( it) => db. function_data ( it) . name . clone ( ) ,
679
679
AssocItemId :: ConstId ( it) => {
680
- db. const_data ( it) . name . as_ref ( ) . unwrap ( ) . clone ( )
680
+ db. const_data ( it) . name . as_ref ( ) ? . clone ( )
681
681
}
682
682
AssocItemId :: TypeAliasId ( it) => db. type_alias_data ( it) . name . clone ( ) ,
683
683
} ,
684
- )
684
+ ) )
685
685
} ,
686
686
) ) ;
687
687
Original file line number Diff line number Diff line change @@ -35,6 +35,19 @@ pub(crate) fn trait_impl_missing_assoc_item(
35
35
mod tests {
36
36
use crate :: tests:: check_diagnostics;
37
37
38
+ #[ test]
39
+ fn trait_with_default_value ( ) {
40
+ check_diagnostics (
41
+ r#"
42
+ trait Marker {
43
+ const FLAG: bool = false;
44
+ }
45
+ struct Foo;
46
+ impl Marker for Foo {}
47
+ "# ,
48
+ )
49
+ }
50
+
38
51
#[ test]
39
52
fn simple ( ) {
40
53
check_diagnostics (
You can’t perform that action at this time.
0 commit comments