File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
crates/formality-check/src Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -52,18 +52,24 @@ impl super::Check<'_> {
52
52
Ok ( ( ) )
53
53
}
54
54
55
- pub ( super ) fn check_neg_trait_impl ( & self , i : & NegTraitImpl ) -> Fallible < ( ) > {
55
+ #[ context( "check_neg_trait_impl({trait_impl:?})" ) ]
56
+ pub ( super ) fn check_neg_trait_impl ( & self , trait_impl : & NegTraitImpl ) -> Fallible < ( ) > {
56
57
let mut env = Env :: default ( ) ;
57
58
58
59
let NegTraitImplBoundData {
59
60
trait_id,
60
61
self_ty,
61
62
trait_parameters,
62
63
where_clauses,
63
- } = env. instantiate_universally ( & i . binder ) ;
64
+ } = env. instantiate_universally ( & trait_impl . binder ) ;
64
65
65
66
let trait_ref = trait_id. with ( self_ty, trait_parameters) ;
66
67
68
+ // Negative impls are always safe (rustc E0198) regardless of the trait's safety.
69
+ if trait_impl. safety == Safety :: Unsafe {
70
+ bail ! ( "negative impls cannot be unsafe" ) ;
71
+ }
72
+
67
73
self . prove_where_clauses_well_formed ( & env, & where_clauses, & where_clauses) ?;
68
74
69
75
self . prove_goal ( & env, & where_clauses, trait_ref. not_implemented ( ) ) ?;
You can’t perform that action at this time.
0 commit comments