@@ -3,6 +3,7 @@ use std::fmt;
33
44use Context :: * ;
55use rustc_hir as hir;
6+ use rustc_hir:: def:: DefKind ;
67use rustc_hir:: def_id:: LocalDefId ;
78use rustc_hir:: intravisit:: { self , Visitor } ;
89use rustc_hir:: { Destination , Node } ;
@@ -72,10 +73,14 @@ struct CheckLoopVisitor<'tcx> {
7273 block_breaks : BTreeMap < Span , BlockInfo > ,
7374}
7475
75- pub ( crate ) fn check < ' tcx > ( tcx : TyCtxt < ' tcx > , _def_id : LocalDefId , body : & ' tcx hir:: Body < ' tcx > ) {
76+ pub ( crate ) fn check < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : LocalDefId , body : & ' tcx hir:: Body < ' tcx > ) {
7677 let mut check =
7778 CheckLoopVisitor { tcx, cx_stack : vec ! [ Normal ] , block_breaks : Default :: default ( ) } ;
78- check. with_context ( Fn , |v| v. visit_body ( body) ) ;
79+ let cx = match tcx. def_kind ( def_id) {
80+ DefKind :: AnonConst => AnonConst ,
81+ _ => Fn ,
82+ } ;
83+ check. with_context ( cx, |v| v. visit_body ( body) ) ;
7984 check. report_outside_loop_error ( ) ;
8085}
8186
@@ -86,8 +91,8 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
8691 self . tcx
8792 }
8893
89- fn visit_anon_const ( & mut self , c : & ' hir hir:: AnonConst ) {
90- self . with_context ( AnonConst , |v| intravisit :: walk_anon_const ( v , c ) ) ;
94+ fn visit_anon_const ( & mut self , _ : & ' hir hir:: AnonConst ) {
95+ // Typecked on its own.
9196 }
9297
9398 fn visit_inline_const ( & mut self , c : & ' hir hir:: ConstBlock ) {
0 commit comments