<commit_before>import syntax::ast::*;
import syntax::visit;
import driver::session::session;

type ctx = {in_loop: bool, can_ret: bool};

fn check_crate(tcx: ty::ctxt, crate: @crate) {
    visit::visit_crate(*crate, {in_loop: false,can_ret: true}, visit::mk_vt(@{
        visit_item: |i, _cx, v| {
            visit::visit_item(i, {in_loop: false, can_ret: true}, v);
        },
        visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| {
            alt e.node {
              expr_while(e, b) {
                v.visit_expr(e, cx, v);
                v.visit_block(b, {in_loop: true with cx}, v);
              }
              expr_loop(b) {
                v.visit_block(b, {in_loop: true with cx}, v);
              }
              expr_fn(_, _, _, _) {
                visit::visit_expr(e, {in_loop: false, can_ret: true}, v);
              }
              expr_fn_block(_, b, _) {
                v.visit_block(b, {in_loop: false, can_ret: false}, v);
              }
              expr_loop_body(@{node: expr_fn_block(_, b, _), _}) {
                let blk = is_blockish(ty::ty_fn_proto(ty::expr_ty(tcx, e)));
                v.visit_block(b, {in_loop: true, can_ret: blk}, v);
              }
              expr_break {
                if !cx.in_loop {
                    tcx.sess.span_err(e.span, "`break` outside of loop");
                }
              }
              expr_again {
                if !cx.in_loop {
                    tcx.sess.span_err(e.span, "`cont` outside of loop");
                }
              }
              expr_ret(oe) {
                if !cx.can_ret {
                    tcx.sess.span_err(e.span, "`ret` in block function");
                }
                visit::visit_expr_opt(oe, cx, v);
              }
              _ { visit::visit_expr(e, cx, v); }
            }
        }
        with *visit::default_visitor()<commit_msg>Change cont out of loop error to again out of loop<commit_after>import syntax::ast::*;
import syntax::visit;
import driver::session::session;

type ctx = {in_loop: bool, can_ret: bool};

fn check_crate(tcx: ty::ctxt, crate: @crate) {
    visit::visit_crate(*crate, {in_loop: false,can_ret: true}, visit::mk_vt(@{
        visit_item: |i, _cx, v| {
            visit::visit_item(i, {in_loop: false, can_ret: true}, v);
        },
        visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| {
            alt e.node {
              expr_while(e, b) {
                v.visit_expr(e, cx, v);
                v.visit_block(b, {in_loop: true with cx}, v);
              }
              expr_loop(b) {
                v.visit_block(b, {in_loop: true with cx}, v);
              }
              expr_fn(_, _, _, _) {
                visit::visit_expr(e, {in_loop: false, can_ret: true}, v);
              }
              expr_fn_block(_, b, _) {
                v.visit_block(b, {in_loop: false, can_ret: false}, v);
              }
              expr_loop_body(@{node: expr_fn_block(_, b, _), _}) {
                let blk = is_blockish(ty::ty_fn_proto(ty::expr_ty(tcx, e)));
                v.visit_block(b, {in_loop: true, can_ret: blk}, v);
              }
              expr_break {
                if !cx.in_loop {
                    tcx.sess.span_err(e.span, "`break` outside of loop");
                }
              }
              expr_again {
                if !cx.in_loop {
                    tcx.sess.span_err(e.span, "`again` outside of loop");
                }
              }
              expr_ret(oe) {
                if !cx.can_ret {
                    tcx.sess.span_err(e.span, "`ret` in block function");
                }
                visit::visit_expr_opt(oe, cx, v);
              }
              _ { visit::visit_expr(e, cx, v); }
            }
        }
        with *visit::default_visitor()
{'fraction_non_alphanumeric': 0.1405263157894737, 'fraction_numerical': 0.0, 'mean_word_length': 1.4194780394653088, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5300548', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1236, 'n_words': 247}