]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_lint/src/late.rs
Auto merge of #80632 - Nadrieril:fix-80501, r=varkor
[rust.git] / compiler / rustc_lint / src / late.rs
index 015e10987118296d7094272459059efe9eb1b3bb..3821a393efb8b851c959a35f94135b4cf04421fa 100644 (file)
@@ -140,6 +140,8 @@ fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
     fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
         let generics = self.context.generics.take();
         self.context.generics = it.kind.generics();
+        let old_cached_typeck_results = self.context.cached_typeck_results.take();
+        let old_enclosing_body = self.context.enclosing_body.take();
         self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
             cx.with_param_env(it.hir_id, |cx| {
                 lint_callback!(cx, check_item, it);
@@ -147,6 +149,8 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
                 lint_callback!(cx, check_item_post, it);
             });
         });
+        self.context.enclosing_body = old_enclosing_body;
+        self.context.cached_typeck_results.set(old_cached_typeck_results);
         self.context.generics = generics;
     }