1
Fork 0

Use a dedicated type instead of a reference for the diagnostic context

This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
This commit is contained in:
Oli Scherer 2024-06-18 10:35:56 +00:00
parent c91edc3888
commit 7ba82d61eb
77 changed files with 363 additions and 328 deletions

View file

@ -9,7 +9,7 @@ use rustc_data_structures::jobserver;
use rustc_data_structures::stable_hasher::StableHasher;
use rustc_data_structures::sync::Lrc;
use rustc_errors::registry::Registry;
use rustc_errors::{DiagCtxt, ErrorGuaranteed};
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
use rustc_lint::LintStore;
use rustc_middle::ty;
use rustc_middle::ty::CurrentGcx;
@ -46,7 +46,7 @@ pub struct Compiler {
}
/// Converts strings provided as `--cfg [cfgspec]` into a `Cfg`.
pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
cfgs.into_iter()
.map(|s| {
let psess = ParseSess::with_silent_emitter(
@ -105,7 +105,7 @@ pub(crate) fn parse_cfg(dcx: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
}
/// Converts strings provided as `--check-cfg [specs]` into a `CheckCfg`.
pub(crate) fn parse_check_cfg(dcx: &DiagCtxt, specs: Vec<String>) -> CheckCfg {
pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> CheckCfg {
// If any --check-cfg is passed then exhaustive_values and exhaustive_names
// are enabled by default.
let exhaustive_names = !specs.is_empty();
@ -451,12 +451,12 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
codegen_backend.init(&sess);
let cfg = parse_cfg(&sess.dcx(), config.crate_cfg);
let cfg = parse_cfg(sess.dcx(), config.crate_cfg);
let mut cfg = config::build_configuration(&sess, cfg);
util::add_configuration(&mut cfg, &mut sess, &*codegen_backend);
sess.psess.config = cfg;
let mut check_cfg = parse_check_cfg(&sess.dcx(), config.crate_check_cfg);
let mut check_cfg = parse_check_cfg(sess.dcx(), config.crate_check_cfg);
check_cfg.fill_well_known(&sess.target);
sess.psess.check_config = check_cfg;
@ -529,7 +529,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
}
pub fn try_print_query_stack(
dcx: &DiagCtxt,
dcx: DiagCtxtHandle<'_>,
num_frames: Option<usize>,
file: Option<std::fs::File>,
) {

View file

@ -70,7 +70,7 @@ where
Arc::default(),
Default::default(),
);
let cfg = parse_cfg(&sess.dcx(), matches.opt_strs("cfg"));
let cfg = parse_cfg(sess.dcx(), matches.opt_strs("cfg"));
let cfg = build_configuration(&sess, cfg);
f(sess, cfg)
});