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 @@ -754,7 +754,7 @@ impl Module {
754
754
GenericDef :: Impl ( impl_def) . diagnostics ( db, acc) ;
755
755
756
756
let loc = impl_def. id . lookup ( db) ;
757
- let source_map = db. impl_signature_with_source_map ( impl_def. id ) . 1 ;
757
+ let ( impl_signature , source_map) = db. impl_signature_with_source_map ( impl_def. id ) ;
758
758
expr_store_diagnostics ( db, acc, & source_map) ;
759
759
760
760
let file_id = loc. id . file_id ;
@@ -783,10 +783,17 @@ impl Module {
783
783
}
784
784
785
785
let trait_ = impl_def. trait_ ( db) ;
786
- let trait_is_unsafe = trait_. is_some_and ( |t| t. is_unsafe ( db) ) ;
786
+ let mut trait_is_unsafe = trait_. is_some_and ( |t| t. is_unsafe ( db) ) ;
787
787
let impl_is_negative = impl_def. is_negative ( db) ;
788
788
let impl_is_unsafe = impl_def. is_unsafe ( db) ;
789
789
790
+ let trait_is_unresolved = trait_. is_none ( ) && impl_signature. target_trait . is_some ( ) ;
791
+ if trait_is_unresolved {
792
+ // Ignore trait safety errors when the trait is unresolved, as otherwise we'll treat it as safe,
793
+ // which may not be correct.
794
+ trait_is_unsafe = impl_is_unsafe;
795
+ }
796
+
790
797
let drop_maybe_dangle = ( || {
791
798
// FIXME: This can be simplified a lot by exposing hir-ty's utils.rs::Generics helper
792
799
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