File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -753,7 +753,7 @@ impl Module {
753
753
GenericDef :: Impl ( impl_def) . diagnostics ( db, acc) ;
754
754
755
755
let loc = impl_def. id . lookup ( db) ;
756
- let source_map = db. impl_signature_with_source_map ( impl_def. id ) . 1 ;
756
+ let ( impl_signature , source_map) = db. impl_signature_with_source_map ( impl_def. id ) ;
757
757
expr_store_diagnostics ( db, acc, & source_map) ;
758
758
759
759
let file_id = loc. id . file_id ;
@@ -782,10 +782,17 @@ impl Module {
782
782
}
783
783
784
784
let trait_ = impl_def. trait_ ( db) ;
785
- let trait_is_unsafe = trait_. is_some_and ( |t| t. is_unsafe ( db) ) ;
785
+ let mut trait_is_unsafe = trait_. is_some_and ( |t| t. is_unsafe ( db) ) ;
786
786
let impl_is_negative = impl_def. is_negative ( db) ;
787
787
let impl_is_unsafe = impl_def. is_unsafe ( db) ;
788
788
789
+ let trait_is_unresolved = trait_. is_none ( ) && impl_signature. target_trait . is_some ( ) ;
790
+ if trait_is_unresolved {
791
+ // Ignore trait safety errors when the trait is unresolved, as otherwise we'll treat it as safe,
792
+ // which may not be correct.
793
+ trait_is_unsafe = impl_is_unsafe;
794
+ }
795
+
789
796
let drop_maybe_dangle = ( || {
790
797
// FIXME: This can be simplified a lot by exposing hir-ty's utils.rs::Generics helper
791
798
let trait_ = trait_?;
Original file line number Diff line number Diff line change @@ -127,4 +127,13 @@ struct S;
127
127
"# ,
128
128
) ;
129
129
}
130
+
131
+ #[ test]
132
+ fn unsafe_unresolved_trait ( ) {
133
+ check_diagnostics (
134
+ r#"
135
+ unsafe impl TestTrait for u32 {}
136
+ "# ,
137
+ ) ;
138
+ }
130
139
}
You can’t perform that action at this time.
0 commit comments