session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
d45004806d
commit
2575b1abc9
33 changed files with 510 additions and 162 deletions
|
@ -201,7 +201,9 @@ use rustc_target::abi::Size;
|
|||
use std::ops::Range;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::errors::{LargeAssignmentsLint, RecursionLimit, TypeLengthLimit};
|
||||
use crate::errors::{
|
||||
EncounteredErrorWhileInstantiating, LargeAssignmentsLint, RecursionLimit, TypeLengthLimit,
|
||||
};
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum MonoItemCollectionMode {
|
||||
|
@ -524,10 +526,10 @@ fn collect_items_rec<'tcx>(
|
|||
&& starting_point.node.is_user_defined()
|
||||
{
|
||||
let formatted_item = with_no_trimmed_paths!(starting_point.node.to_string());
|
||||
tcx.sess.span_note_without_error(
|
||||
starting_point.span,
|
||||
&format!("the above error was encountered while instantiating `{formatted_item}`"),
|
||||
);
|
||||
tcx.sess.emit_note(EncounteredErrorWhileInstantiating {
|
||||
span: starting_point.span,
|
||||
formatted_item,
|
||||
});
|
||||
}
|
||||
inlining_map.lock_mut().record_accesses(starting_point.node, &neighbors.items);
|
||||
|
||||
|
|
|
@ -83,3 +83,17 @@ pub struct SymbolAlreadyDefined {
|
|||
pub struct CouldntDumpMonoStats {
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(monomorphize_encountered_error_while_instantiating)]
|
||||
pub struct EncounteredErrorWhileInstantiating {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub formatted_item: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(monomorphize_unknown_cgu_collection_mode)]
|
||||
pub struct UnknownCguCollectionMode<'a> {
|
||||
pub mode: &'a str,
|
||||
}
|
||||
|
|
|
@ -114,7 +114,9 @@ use rustc_span::symbol::Symbol;
|
|||
|
||||
use crate::collector::InliningMap;
|
||||
use crate::collector::{self, MonoItemCollectionMode};
|
||||
use crate::errors::{CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownPartitionStrategy};
|
||||
use crate::errors::{
|
||||
CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownCguCollectionMode, UnknownPartitionStrategy,
|
||||
};
|
||||
|
||||
pub struct PartitioningCx<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -348,17 +350,13 @@ where
|
|||
fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[CodegenUnit<'_>]) {
|
||||
let collection_mode = match tcx.sess.opts.unstable_opts.print_mono_items {
|
||||
Some(ref s) => {
|
||||
let mode_string = s.to_lowercase();
|
||||
let mode_string = mode_string.trim();
|
||||
if mode_string == "eager" {
|
||||
let mode = s.to_lowercase();
|
||||
let mode = mode.trim();
|
||||
if mode == "eager" {
|
||||
MonoItemCollectionMode::Eager
|
||||
} else {
|
||||
if mode_string != "lazy" {
|
||||
let message = format!(
|
||||
"Unknown codegen-item collection mode '{mode_string}'. \
|
||||
Falling back to 'lazy' mode."
|
||||
);
|
||||
tcx.sess.warn(&message);
|
||||
if mode != "lazy" {
|
||||
tcx.sess.emit_warning(UnknownCguCollectionMode { mode });
|
||||
}
|
||||
|
||||
MonoItemCollectionMode::Lazy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue