translations(rustc_session): migrate the file cgu_reuse_tracker
This commit migrates the errors that indicates an incorrect CGU type and the fatal error that indicates that a CGU has not been correctly recorded
This commit is contained in:
parent
8a13871b69
commit
706452eba7
5 changed files with 60 additions and 5 deletions
5
compiler/rustc_error_messages/locales/en-US/session.ftl
Normal file
5
compiler/rustc_error_messages/locales/en-US/session.ftl
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
incorrect_cgu_reuse_type =
|
||||||
|
CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be `{$at_least}``${expected_reuse}`
|
||||||
|
|
||||||
|
cgu_not_recorded =
|
||||||
|
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded`
|
|
@ -37,6 +37,7 @@ fluent_messages! {
|
||||||
builtin_macros => "../locales/en-US/builtin_macros.ftl",
|
builtin_macros => "../locales/en-US/builtin_macros.ftl",
|
||||||
const_eval => "../locales/en-US/const_eval.ftl",
|
const_eval => "../locales/en-US/const_eval.ftl",
|
||||||
expand => "../locales/en-US/expand.ftl",
|
expand => "../locales/en-US/expand.ftl",
|
||||||
|
session => "../locales/en-US/session.ftl",
|
||||||
interface => "../locales/en-US/interface.ftl",
|
interface => "../locales/en-US/interface.ftl",
|
||||||
lint => "../locales/en-US/lint.ftl",
|
lint => "../locales/en-US/lint.ftl",
|
||||||
parser => "../locales/en-US/parser.ftl",
|
parser => "../locales/en-US/parser.ftl",
|
||||||
|
|
|
@ -2,8 +2,13 @@
|
||||||
//! compilation. This is used for incremental compilation tests and debug
|
//! compilation. This is used for incremental compilation tests and debug
|
||||||
//! output.
|
//! output.
|
||||||
|
|
||||||
|
use crate::errors::IncorrectCguReuseType;
|
||||||
|
// use crate::errors::{CguNotRecorded, IncorrectCguReuseType};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::fmt::{self};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
@ -14,6 +19,22 @@ pub enum CguReuse {
|
||||||
PostLto,
|
PostLto,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CguReuse {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match *self {
|
||||||
|
CguReuse::No => write!(f, "No"),
|
||||||
|
CguReuse::PreLto => write!(f, "PreLto "),
|
||||||
|
CguReuse::PostLto => write!(f, "PostLto "),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoDiagnosticArg for CguReuse {
|
||||||
|
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||||
|
DiagnosticArgValue::Str(Cow::Owned(self.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
pub enum ComparisonKind {
|
pub enum ComparisonKind {
|
||||||
Exact,
|
Exact,
|
||||||
|
@ -99,11 +120,13 @@ impl CguReuseTracker {
|
||||||
|
|
||||||
if error {
|
if error {
|
||||||
let at_least = if at_least { "at least " } else { "" };
|
let at_least = if at_least { "at least " } else { "" };
|
||||||
let msg = format!(
|
IncorrectCguReuseType {
|
||||||
"CGU-reuse for `{cgu_user_name}` is `{actual_reuse:?}` but \
|
span: error_span.0,
|
||||||
should be {at_least}`{expected_reuse:?}`"
|
cgu_user_name: &cgu_user_name,
|
||||||
);
|
actual_reuse,
|
||||||
diag.span_err(error_span.0, &msg);
|
expected_reuse,
|
||||||
|
at_least,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
|
@ -111,6 +134,7 @@ impl CguReuseTracker {
|
||||||
not recorded"
|
not recorded"
|
||||||
);
|
);
|
||||||
diag.span_fatal(error_span.0, &msg)
|
diag.span_fatal(error_span.0, &msg)
|
||||||
|
// CguNotRecorded { cgu_user_name, cgu_name };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
compiler/rustc_session/src/errors.rs
Normal file
22
compiler/rustc_session/src/errors.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
use crate as rustc_session;
|
||||||
|
use crate::cgu_reuse_tracker::CguReuse;
|
||||||
|
use rustc_macros::SessionDiagnostic;
|
||||||
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[error(session::incorrect_cgu_reuse_type)]
|
||||||
|
pub struct IncorrectCguReuseType<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub cgu_user_name: &'a str,
|
||||||
|
pub actual_reuse: CguReuse,
|
||||||
|
pub expected_reuse: CguReuse,
|
||||||
|
pub at_least: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
// #[derive(SessionDiagnostic)]
|
||||||
|
// #[fatal(session::cgu_not_recorded)]
|
||||||
|
// pub struct CguNotRecorded<'a> {
|
||||||
|
// pub cgu_user_name: &'a str,
|
||||||
|
// pub cgu_name: &'a str,
|
||||||
|
// }
|
|
@ -8,9 +8,12 @@
|
||||||
#![feature(map_many_mut)]
|
#![feature(map_many_mut)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_macros;
|
extern crate rustc_macros;
|
||||||
|
pub mod errors;
|
||||||
|
|
||||||
pub mod cgu_reuse_tracker;
|
pub mod cgu_reuse_tracker;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue