1
Fork 0

Remove Session methods that duplicate DiagCtxt methods.

Also add some `dcx` methods to types that wrap `TyCtxt`, for easier
access.
This commit is contained in:
Nicholas Nethercote 2023-12-18 22:21:37 +11:00
parent d51db05d7e
commit 99472c7049
298 changed files with 1806 additions and 2064 deletions

View file

@ -371,7 +371,7 @@ fn collect_items_rec<'tcx>(
// current step of mono items collection.
//
// FIXME: don't rely on global state, instead bubble up errors. Note: this is very hard to do.
let error_count = tcx.sess.dcx().err_count();
let error_count = tcx.dcx().err_count();
match starting_item.node {
MonoItem::Static(def_id) => {
@ -459,12 +459,12 @@ fn collect_items_rec<'tcx>(
// Check for PMEs and emit a diagnostic if one happened. To try to show relevant edges of the
// mono item graph.
if tcx.sess.dcx().err_count() > error_count
if tcx.dcx().err_count() > error_count
&& starting_item.node.is_generic_fn(tcx)
&& starting_item.node.is_user_defined()
{
let formatted_item = with_no_trimmed_paths!(starting_item.node.to_string());
tcx.sess.emit_note(EncounteredErrorWhileInstantiating {
tcx.dcx().emit_note(EncounteredErrorWhileInstantiating {
span: starting_item.span,
formatted_item,
});
@ -541,7 +541,7 @@ fn check_recursion_limit<'tcx>(
} else {
None
};
tcx.sess.emit_fatal(RecursionLimit {
tcx.dcx().emit_fatal(RecursionLimit {
span,
shrunk,
def_span,
@ -584,7 +584,7 @@ fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
} else {
None
};
tcx.sess.emit_fatal(TypeLengthLimit { span, shrunk, was_written, path, type_length });
tcx.dcx().emit_fatal(TypeLengthLimit { span, shrunk, was_written, path, type_length });
}
}
@ -997,7 +997,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
}
if !tcx.is_mir_available(def_id) {
tcx.sess.emit_fatal(NoOptimizedMir {
tcx.dcx().emit_fatal(NoOptimizedMir {
span: tcx.def_span(def_id),
crate_name: tcx.crate_name(def_id.krate),
});

View file

@ -1079,7 +1079,7 @@ where
(span1, span2) => span1.or(span2),
};
tcx.sess.emit_fatal(SymbolAlreadyDefined { span, symbol: sym1.to_string() });
tcx.dcx().emit_fatal(SymbolAlreadyDefined { span, symbol: sym1.to_string() });
}
}
}
@ -1093,7 +1093,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
MonoItemCollectionMode::Eager
} else {
if mode != "lazy" {
tcx.sess.emit_warning(UnknownCguCollectionMode { mode });
tcx.dcx().emit_warning(UnknownCguCollectionMode { mode });
}
MonoItemCollectionMode::Lazy
@ -1148,7 +1148,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
if let Err(err) =
dump_mono_items_stats(tcx, codegen_units, path, tcx.crate_name(LOCAL_CRATE))
{
tcx.sess.emit_fatal(CouldntDumpMonoStats { error: err.to_string() });
tcx.dcx().emit_fatal(CouldntDumpMonoStats { error: err.to_string() });
}
}

View file

@ -215,7 +215,7 @@ fn emit_unused_generic_params_error<'tcx>(
next_generics = generics.parent.map(|did| tcx.generics_of(did));
}
tcx.sess.emit_err(UnusedGenericParamsHint { span: fn_span, param_spans, param_names });
tcx.dcx().emit_err(UnusedGenericParamsHint { span: fn_span, param_spans, param_names });
}
/// Visitor used to aggregate generic parameter uses.