1
Fork 0

Auto merge of #114054 - oli-obk:cleanups, r=estebank

Split some functions with many arguments into builder pattern functions

r? `@estebank`

This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io

Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
This commit is contained in:
bors 2023-07-26 11:17:35 +00:00
commit 52bdc37727
15 changed files with 69 additions and 108 deletions

View file

@ -9,7 +9,7 @@ use crate::lint::{
use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{emitter::SilentEmitter, Handler};
use rustc_errors::{
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic, MultiSpan, Noted, StashKey,
@ -224,15 +224,7 @@ impl ParseSess {
pub fn new(locale_resources: Vec<&'static str>, file_path_mapping: FilePathMapping) -> Self {
let fallback_bundle = fallback_fluent_bundle(locale_resources, false);
let sm = Lrc::new(SourceMap::new(file_path_mapping));
let handler = Handler::with_tty_emitter(
ColorConfig::Auto,
true,
None,
Some(sm.clone()),
None,
fallback_bundle,
None,
);
let handler = Handler::with_tty_emitter(Some(sm.clone()), fallback_bundle);
ParseSess::with_span_handler(handler, sm)
}
@ -262,21 +254,9 @@ impl ParseSess {
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let fatal_handler = Handler::with_tty_emitter(
ColorConfig::Auto,
false,
None,
None,
None,
fallback_bundle,
None,
);
let handler = Handler::with_emitter(
false,
None,
Box::new(SilentEmitter { fatal_handler, fatal_note }),
None,
);
let fatal_handler = Handler::with_tty_emitter(None, fallback_bundle).disable_warnings();
let handler = Handler::with_emitter(Box::new(SilentEmitter { fatal_handler, fatal_note }))
.disable_warnings();
ParseSess::with_span_handler(handler, sm)
}

View file

@ -1442,11 +1442,11 @@ pub fn build_session(
);
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
let span_diagnostic = rustc_errors::Handler::with_emitter_and_flags(
emitter,
sopts.unstable_opts.diagnostic_handler_flags(can_emit_warnings),
ice_file,
);
let mut span_diagnostic = rustc_errors::Handler::with_emitter(emitter)
.with_flags(sopts.unstable_opts.diagnostic_handler_flags(can_emit_warnings));
if let Some(ice_file) = ice_file {
span_diagnostic = span_diagnostic.with_ice_file(ice_file);
}
let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile
{
@ -1737,7 +1737,7 @@ pub struct EarlyErrorHandler {
impl EarlyErrorHandler {
pub fn new(output: ErrorOutputType) -> Self {
let emitter = mk_emitter(output);
Self { handler: rustc_errors::Handler::with_emitter(true, None, emitter, None) }
Self { handler: rustc_errors::Handler::with_emitter(emitter) }
}
pub fn abort_if_errors(&self) {
@ -1751,7 +1751,7 @@ impl EarlyErrorHandler {
self.handler.abort_if_errors();
let emitter = mk_emitter(output);
self.handler = Handler::with_emitter(true, None, emitter, None);
self.handler = Handler::with_emitter(emitter);
}
#[allow(rustc::untranslatable_diagnostic)]