@@ -9,7 +9,7 @@ use rustc_middle::ty::TyCtxt;
9
9
10
10
pub fn check ( tcx : TyCtxt < ' _ > ) {
11
11
for id in tcx. hir ( ) . items ( ) {
12
- if matches ! ( tcx. hir ( ) . def_kind( id. def_id) , DefKind :: Impl ) {
12
+ if matches ! ( tcx. def_kind( id. def_id) , DefKind :: Impl ) {
13
13
let item = tcx. hir ( ) . item ( id) ;
14
14
if let hir:: ItemKind :: Impl ( ref impl_) = item. kind {
15
15
check_unsafety_coherence (
@@ -83,74 +83,3 @@ fn check_unsafety_coherence<'tcx>(
83
83
}
84
84
}
85
85
}
86
-
87
- // struct UnsafetyChecker<'tcx> {
88
- // tcx: TyCtxt<'tcx>,
89
- // }
90
- //
91
- // impl<'tcx> UnsafetyChecker<'tcx> {
92
- // fn check_unsafety_coherence(
93
- // &mut self,
94
- // item: &hir::Item<'_>,
95
- // impl_generics: Option<&hir::Generics<'_>>,
96
- // unsafety: hir::Unsafety,
97
- // polarity: hir::ImplPolarity,
98
- // ) {
99
- // if let Some(trait_ref) = self.tcx.impl_trait_ref(item.def_id) {
100
- // let trait_def = self.tcx.trait_def(trait_ref.def_id);
101
- // let unsafe_attr = impl_generics.and_then(|generics| {
102
- // generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle")
103
- // });
104
- // match (trait_def.unsafety, unsafe_attr, unsafety, polarity) {
105
- // (Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => {
106
- // struct_span_err!(
107
- // self.tcx.sess,
108
- // item.span,
109
- // E0199,
110
- // "implementing the trait `{}` is not unsafe",
111
- // trait_ref.print_only_trait_path()
112
- // )
113
- // .emit();
114
- // }
115
- //
116
- // (Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => {
117
- // struct_span_err!(
118
- // self.tcx.sess,
119
- // item.span,
120
- // E0200,
121
- // "the trait `{}` requires an `unsafe impl` declaration",
122
- // trait_ref.print_only_trait_path()
123
- // )
124
- // .emit();
125
- // }
126
- //
127
- // (
128
- // Unsafety::Normal,
129
- // Some(attr_name),
130
- // Unsafety::Normal,
131
- // hir::ImplPolarity::Positive,
132
- // ) => {
133
- // struct_span_err!(
134
- // self.tcx.sess,
135
- // item.span,
136
- // E0569,
137
- // "requires an `unsafe impl` declaration due to `#[{}]` attribute",
138
- // attr_name
139
- // )
140
- // .emit();
141
- // }
142
- //
143
- // (_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative(_)) => {
144
- // // Reported in AST validation
145
- // self.tcx.sess.delay_span_bug(item.span, "unsafe negative impl");
146
- // }
147
- // (_, _, Unsafety::Normal, hir::ImplPolarity::Negative(_))
148
- // | (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive)
149
- // | (Unsafety::Normal, Some(_), Unsafety::Unsafe, hir::ImplPolarity::Positive)
150
- // | (Unsafety::Normal, None, Unsafety::Normal, _) => {
151
- // // OK
152
- // }
153
- // }
154
- // }
155
- // }
156
- // }
0 commit comments