Skip to content

Commit

Permalink
Check Session reference count
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Jan 16, 2020
1 parent 0a36b4d commit 3e2090c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/librustc_interface/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_lint::LintStore;
use rustc_parse::new_parser_from_source_str;
use rustc_span::edition;
use rustc_span::source_map::{FileLoader, FileName, SourceMap};
use std::mem;
use std::path::PathBuf;
use std::result;
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -165,7 +166,7 @@ pub fn run_compiler_in_existing_thread_pool<R>(
registry.clone(),
);

let compiler = Compiler {
let mut compiler = Compiler {
sess,
codegen_backend,
source_map,
Expand All @@ -179,11 +180,20 @@ pub fn run_compiler_in_existing_thread_pool<R>(
};

let r = {
let _sess_abort_error = OnDrop(|| {
let sess_abort_error = OnDrop(|| {
compiler.sess.diagnostic().print_error_count(registry);
});

f(&compiler)
let r = f(&compiler);

mem::forget(sess_abort_error);

// Ensure there are no more references to Session so no more errors can be generated.
Lrc::get_mut(&mut compiler.sess).expect("no references to Session");

compiler.sess.diagnostic().print_error_count(registry);

r
};

let prof = compiler.sess.prof.clone();
Expand Down

0 comments on commit 3e2090c

Please sign in to comment.