<commit_before>use crate::prelude::*;

pub fn trans_mono_item<'a, 'tcx: 'a>(
    cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>,
    context: &mut Context,
    mono_item: MonoItem<'tcx>,
) {
    let tcx = cx.tcx;

    match mono_item {
        MonoItem::Fn(inst) => match inst {
            Instance {
                def: InstanceDef::Item(def_id),
                substs: _,
            } => {
                let mut mir = ::std::io::Cursor::new(Vec::new());
                ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap();
                tcx.sess.warn(&format!(
                    "{:?}:\n\n{}",
                    inst,
                    String::from_utf8_lossy(&mir.into_inner())
                ));

                let (func_id, mut func) = cx.predefine_function(inst);

                let comments = trans_fn(cx, &mut func, inst);

                let mut writer = crate::pretty_clif::CommentWriter(comments);
                let mut cton = String::new();
                ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None)
                    .unwrap();
                tcx.sess.warn(&cton);

                let flags = settings::Flags::new(settings::builder());
                match ::cranelift::codegen::verify_function(&func, &flags) {
                    Ok(_) => {}
                    Err(err) => {
                        tcx.sess.err(&format!("{:?}", err));
                        let pretty_error =
                            ::cranelift::codegen::print_errors::pretty_verifier_error(
                                &func,
                                None,
                                Some(Box::new(writer)),
                                &err,
                            );
                        tcx.sess
                            .fatal(&format!("cretonne verify error:\n{}", pretty_error));
                    }
                }

                context.func = func;
                // TODO: cranelift doesn't yet support some of the things needed
                if cx
                    .tcx
                    .sess
                    .crate_types
                    .get()
                    .contains(&CrateType::Executable)
                {
                    cx.module.define_function(func_id, context).unwrap();
                    cx.defined_functions.push(func_id);
                }

                context.clear();
            }<commit_msg>Group drop glue instances in unimpl log<commit_after>use crate::prelude::*;

pub fn trans_mono_item<'a, 'tcx: 'a>(
    cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>,
    context: &mut Context,
    mono_item: MonoItem<'tcx>,
) {
    let tcx = cx.tcx;

    match mono_item {
        MonoItem::Fn(inst) => match inst {
            Instance {
                def: InstanceDef::Item(def_id),
                substs: _,
            } => {
                let mut mir = ::std::io::Cursor::new(Vec::new());
                ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap();
                tcx.sess.warn(&format!(
                    "{:?}:\n\n{}",
                    inst,
                    String::from_utf8_lossy(&mir.into_inner())
                ));

                let (func_id, mut func) = cx.predefine_function(inst);

                let comments = trans_fn(cx, &mut func, inst);

                let mut writer = crate::pretty_clif::CommentWriter(comments);
                let mut cton = String::new();
                ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None)
                    .unwrap();
                tcx.sess.warn(&cton);

                let flags = settings::Flags::new(settings::builder());
                match ::cranelift::codegen::verify_function(&func, &flags) {
                    Ok(_) => {}
                    Err(err) => {
                        tcx.sess.err(&format!("{:?}", err));
                        let pretty_error =
                            ::cranelift::codegen::print_errors::pretty_verifier_error(
                                &func,
                                None,
                                Some(Box::new(writer)),
                                &err,
                            );
                        tcx.sess
                            .fatal(&format!("cretonne verify error:\n{}", pretty_error));
                    }
                }

                context.func = func;
                // TODO: cranelift doesn't yet support some of the things needed
                if cx
                    .tcx
                    .sess
                    .crate_types
                    .get()
                    .contains(&CrateType::Executable)
                {
                    cx.module.define_function(func_id, context).unwrap();
                    cx.defined_functions.push(func_id);
                }

                context.clear();
            }
            Instance {
                def: InstanceDef::DropGlue(_, _),
                substs: _
            } => unimpl!("Unimplemented drop glue instance"),
{'fraction_non_alphanumeric': 0.1250244188318031, 'fraction_numerical': 0.0003907013088493846, 'mean_word_length': 1.162162162162162, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 18, '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': '5027659', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1330, 'n_words': 240}