Add rustc_interface::interface::Config::parse_sess_created
This commit is contained in:
parent
3963c3da02
commit
d7ab3c77b3
@ -215,6 +215,7 @@ fn run_compiler(
|
||||
diagnostic_output,
|
||||
stderr: None,
|
||||
lint_caps: Default::default(),
|
||||
parse_sess_created: None,
|
||||
register_lints: None,
|
||||
override_queries: None,
|
||||
make_codegen_backend: make_codegen_backend.take().unwrap(),
|
||||
@ -298,6 +299,7 @@ fn run_compiler(
|
||||
diagnostic_output,
|
||||
stderr: None,
|
||||
lint_caps: Default::default(),
|
||||
parse_sess_created: None,
|
||||
register_lints: None,
|
||||
override_queries: None,
|
||||
make_codegen_backend: make_codegen_backend.unwrap(),
|
||||
|
@ -142,6 +142,9 @@ pub struct Config {
|
||||
|
||||
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
||||
|
||||
/// This is a callback from the driver that is called when [`ParseSess`] is created.
|
||||
pub parse_sess_created: Option<Box<dyn FnOnce(&mut ParseSess) + Send>>,
|
||||
|
||||
/// This is a callback from the driver that is called when we're registering lints;
|
||||
/// it is called during plugin registration when we have the LintStore in a non-shared state.
|
||||
///
|
||||
@ -166,7 +169,7 @@ pub struct Config {
|
||||
|
||||
pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) -> R {
|
||||
let registry = &config.registry;
|
||||
let (sess, codegen_backend) = util::create_session(
|
||||
let (mut sess, codegen_backend) = util::create_session(
|
||||
config.opts,
|
||||
config.crate_cfg,
|
||||
config.diagnostic_output,
|
||||
@ -177,6 +180,10 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
|
||||
registry.clone(),
|
||||
);
|
||||
|
||||
if let Some(parse_sess_created) = config.parse_sess_created {
|
||||
parse_sess_created(&mut Lrc::get_mut(&mut sess).unwrap().parse_sess);
|
||||
}
|
||||
|
||||
let compiler = Compiler {
|
||||
sess,
|
||||
codegen_backend,
|
||||
|
@ -311,6 +311,7 @@ impl<'tcx> DocContext<'tcx> {
|
||||
diagnostic_output: DiagnosticOutput::Default,
|
||||
stderr: None,
|
||||
lint_caps,
|
||||
parse_sess_created: None,
|
||||
register_lints: Some(box crate::lint::register_lints),
|
||||
override_queries: Some(|_sess, providers, _external_providers| {
|
||||
// Most lints will require typechecking, so just don't run them.
|
||||
|
@ -95,6 +95,7 @@
|
||||
diagnostic_output: DiagnosticOutput::Default,
|
||||
stderr: None,
|
||||
lint_caps,
|
||||
parse_sess_created: None,
|
||||
register_lints: Some(box crate::lint::register_lints),
|
||||
override_queries: None,
|
||||
make_codegen_backend: None,
|
||||
|
Loading…
Reference in New Issue
Block a user