1
Fork 0

Fewer early errors.

`build_session` is passed an `EarlyErrorHandler` and then constructs a
`Handler`. But the `EarlyErrorHandler` is still used for some time after
that.

This commit changes `build_session` so it consumes the passed
`EarlyErrorHandler`, and also drops it as soon as the `Handler` is
built. As a result, `parse_cfg` and `parse_check_cfg` now take a
`Handler` instead of an `EarlyErrorHandler`.
This commit is contained in:
Nicholas Nethercote 2023-12-05 12:47:12 +11:00
parent 35ac2816a0
commit 618409901a
7 changed files with 60 additions and 38 deletions

View file

@ -26,10 +26,9 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
let mut early_handler = EarlyErrorHandler::new(ErrorOutputType::default());
let registry = registry::Registry::new(&[]);
let sessopts = build_session_options(&mut handler, &matches);
let cfg = parse_cfg(&handler, matches.opt_strs("cfg"));
let sessopts = build_session_options(&mut early_handler, &matches);
let temps_dir = sessopts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
let io = CompilerIO {
input: Input::Str { name: FileName::Custom(String::new()), input: String::new() },
@ -38,7 +37,7 @@ fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
temps_dir,
};
let sess = build_session(
&handler,
early_handler,
sessopts,
io,
None,
@ -52,6 +51,7 @@ fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
Arc::default(),
Default::default(),
);
let cfg = parse_cfg(&sess.diagnostic(), matches.opt_strs("cfg"));
(sess, cfg)
}