@@ -17,18 +17,12 @@ use middle::infer::{self, new_infer_ctxt};
17
17
use syntax:: ast:: { DefId } ;
18
18
use syntax:: ast:: { LOCAL_CRATE } ;
19
19
use syntax:: ast;
20
- use syntax:: ast_util;
21
- use syntax:: visit;
22
20
use syntax:: codemap:: Span ;
23
21
use util:: ppaux:: Repr ;
24
22
25
23
pub fn check ( tcx : & ty:: ctxt ) {
26
- let mut overlap = OverlapChecker { tcx : tcx } ;
24
+ let overlap = OverlapChecker { tcx : tcx } ;
27
25
overlap. check_for_overlapping_impls ( ) ;
28
-
29
- // this secondary walk specifically checks for impls of defaulted
30
- // traits, for which additional overlap rules exist
31
- visit:: walk_crate ( & mut overlap, tcx. map . krate ( ) ) ;
32
26
}
33
27
34
28
struct OverlapChecker < ' cx , ' tcx : ' cx > {
@@ -128,52 +122,3 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
128
122
self . tcx . map . span ( impl_did. node )
129
123
}
130
124
}
131
-
132
-
133
- impl < ' cx , ' tcx , ' v > visit:: Visitor < ' v > for OverlapChecker < ' cx , ' tcx > {
134
- fn visit_item ( & mut self , item : & ' v ast:: Item ) {
135
- match item. node {
136
- ast:: ItemImpl ( _, ast:: ImplPolarity :: Positive , _, Some ( ref ast_trait_ref) , _, _) => {
137
- let trait_ref = ty:: node_id_to_trait_ref ( self . tcx , ast_trait_ref. ref_id ) ;
138
- match ty:: trait_default_impl ( self . tcx , trait_ref. def_id ) {
139
- Some ( default_impl) => {
140
- match trait_ref. self_ty ( ) . sty {
141
- ty:: ty_struct( ..) | ty:: ty_enum( ..) => { } ,
142
- _ => {
143
- let impl_def_id = ast_util:: local_def ( item. id ) ;
144
- span_err ! ( self . tcx. sess, self . span_of_impl( impl_def_id) , E0319 ,
145
- "implementations for traits providing default \
146
- implementations are only allowed on structs and enums") ;
147
-
148
- self . report_overlap_note ( impl_def_id, default_impl) ;
149
- }
150
- }
151
- }
152
- None => { }
153
- }
154
- }
155
- ast:: ItemDefaultImpl ( _, _) => {
156
- let impl_def_id = ast_util:: local_def ( item. id ) ;
157
- match ty:: impl_trait_ref ( self . tcx , impl_def_id) {
158
- Some ( ref trait_ref) => {
159
- match ty:: trait_default_impl ( self . tcx , trait_ref. def_id ) {
160
- Some ( other_impl) if other_impl != impl_def_id => {
161
- self . report_overlap_error ( trait_ref. def_id ,
162
- other_impl,
163
- impl_def_id) ;
164
- }
165
- Some ( _) => { }
166
- None => {
167
- self . tcx . sess . bug (
168
- & format ! ( "no default implementation recorded for `{:?}`" ,
169
- item) [ ] ) ;
170
- }
171
- }
172
- }
173
- _ => { }
174
- }
175
- }
176
- _ => { }
177
- }
178
- }
179
- }
0 commit comments