This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -667,21 +667,21 @@ impl Module {
667667 let items = & db. trait_data ( trait_. into ( ) ) . items ;
668668 let required_items = items. iter ( ) . filter ( |& ( _, assoc) | match * assoc {
669669 AssocItemId :: FunctionId ( it) => !db. function_data ( it) . has_body ( ) ,
670- AssocItemId :: ConstId ( _ ) => true ,
670+ AssocItemId :: ConstId ( id ) => Const :: from ( id ) . value ( db ) . is_none ( ) ,
671671 AssocItemId :: TypeAliasId ( it) => db. type_alias_data ( it) . type_ref . is_none ( ) ,
672672 } ) ;
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 (
674674 |& item| {
675- (
675+ Some ( (
676676 item,
677677 match item {
678678 AssocItemId :: FunctionId ( it) => db. function_data ( it) . name . clone ( ) ,
679679 AssocItemId :: ConstId ( it) => {
680- db. const_data ( it) . name . as_ref ( ) . unwrap ( ) . clone ( )
680+ db. const_data ( it) . name . as_ref ( ) ? . clone ( )
681681 }
682682 AssocItemId :: TypeAliasId ( it) => db. type_alias_data ( it) . name . clone ( ) ,
683683 } ,
684- )
684+ ) )
685685 } ,
686686 ) ) ;
687687
Original file line number Diff line number Diff line change @@ -35,6 +35,19 @@ pub(crate) fn trait_impl_missing_assoc_item(
3535mod tests {
3636 use crate :: tests:: check_diagnostics;
3737
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+
3851 #[ test]
3952 fn simple ( ) {
4053 check_diagnostics (
You can’t perform that action at this time.
0 commit comments