@@ -13,7 +13,6 @@ use rustc_hir as hir;
1313use rustc_hir:: def_id:: LocalDefId ;
1414use rustc_hir:: intravisit:: { self , Visitor } ;
1515use rustc_middle:: hir:: nested_filter;
16- use rustc_middle:: ty;
1716use rustc_middle:: ty:: query:: Providers ;
1817use rustc_middle:: ty:: TyCtxt ;
1918use rustc_session:: parse:: feature_err;
@@ -64,66 +63,6 @@ pub(crate) fn provide(providers: &mut Providers) {
6463 * providers = Providers { check_mod_const_bodies, ..* providers } ;
6564}
6665
67- fn check_item < ' tcx > ( tcx : TyCtxt < ' tcx > , item : & ' tcx hir:: Item < ' tcx > ) {
68- let _: Option < _ > = try {
69- if let hir:: ItemKind :: Impl ( ref imp) = item. kind && let hir:: Constness :: Const = imp. constness {
70- let trait_def_id = imp. of_trait . as_ref ( ) ?. trait_def_id ( ) ?;
71- let ancestors = tcx
72- . trait_def ( trait_def_id)
73- . ancestors ( tcx, item. def_id . to_def_id ( ) )
74- . ok ( ) ?;
75- let mut to_implement = Vec :: new ( ) ;
76-
77- for trait_item in tcx. associated_items ( trait_def_id) . in_definition_order ( )
78- {
79- if let ty:: AssocItem {
80- kind : ty:: AssocKind :: Fn ,
81- defaultness,
82- def_id : trait_item_id,
83- ..
84- } = * trait_item
85- {
86- // we can ignore functions that do not have default bodies:
87- // if those are unimplemented it will be caught by typeck.
88- if !defaultness. has_value ( )
89- || tcx
90- . has_attr ( trait_item_id, sym:: default_method_body_is_const)
91- {
92- continue ;
93- }
94-
95- let is_implemented = ancestors
96- . leaf_def ( tcx, trait_item_id)
97- . map ( |node_item| !node_item. defining_node . is_from_trait ( ) )
98- . unwrap_or ( false ) ;
99-
100- if !is_implemented {
101- to_implement. push ( trait_item_id) ;
102- }
103- }
104- }
105-
106- // all nonconst trait functions (not marked with #[default_method_body_is_const])
107- // must be implemented
108- if !to_implement. is_empty ( ) {
109- let not_implemented = to_implement
110- . into_iter ( )
111- . map ( |did| tcx. item_name ( did) . to_string ( ) )
112- . collect :: < Vec < _ > > ( )
113- . join ( "`, `" ) ;
114- tcx
115- . sess
116- . struct_span_err (
117- item. span ,
118- "const trait implementations may not use non-const default functions" ,
119- )
120- . note ( & format ! ( "`{}` not implemented" , not_implemented) )
121- . emit ( ) ;
122- }
123- }
124- } ;
125- }
126-
12766#[ derive( Copy , Clone ) ]
12867struct CheckConstVisitor < ' tcx > {
12968 tcx : TyCtxt < ' tcx > ,
@@ -254,7 +193,6 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
254193
255194 fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
256195 intravisit:: walk_item ( self , item) ;
257- check_item ( self . tcx , item) ;
258196 }
259197
260198 fn visit_anon_const ( & mut self , anon : & ' tcx hir:: AnonConst ) {
0 commit comments