diff options
| author | Luis Cardoso <61982523+LuisCardosoOliveira@users.noreply.github.com> | 2022-08-24 17:15:08 +0200 |
|---|---|---|
| committer | Luis Cardoso <61982523+LuisCardosoOliveira@users.noreply.github.com> | 2022-08-26 16:10:11 +0200 |
| commit | 2c77f3e9c5804edc0bb520c7b4774424cea6beb0 (patch) | |
| tree | c28579cb1f13a93c8614a6a71d6154b10e0bf202 /compiler/rustc_session/src | |
| parent | d5262a945246a624113faaadbbdae4ec5013c862 (diff) | |
| download | rust-2c77f3e9c5804edc0bb520c7b4774424cea6beb0.tar.gz rust-2c77f3e9c5804edc0bb520c7b4774424cea6beb0.zip | |
translations(rustc_session): migrate check_expected_reuse
This commit migrates the errors in the function check_expected_reuse to use the new SessionDiagnostic. It also does some small refactor for the IncorrectCguReuseType to include the 'at least' word in the fluent translation file
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/cgu_reuse_tracker.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 15 |
2 files changed, 12 insertions, 20 deletions
diff --git a/compiler/rustc_session/src/cgu_reuse_tracker.rs b/compiler/rustc_session/src/cgu_reuse_tracker.rs index 0b75a89c4d8..2a4a772f610 100644 --- a/compiler/rustc_session/src/cgu_reuse_tracker.rs +++ b/compiler/rustc_session/src/cgu_reuse_tracker.rs @@ -2,7 +2,8 @@ //! compilation. This is used for incremental compilation tests and debug //! output. -use crate::errors::IncorrectCguReuseType; +use crate::errors::{CguNotRecorded, IncorrectCguReuseType}; +use crate::Session; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; use rustc_span::{Span, Symbol}; @@ -104,7 +105,7 @@ impl CguReuseTracker { } } - pub fn check_expected_reuse(&self, diag: &rustc_errors::Handler) { + pub fn check_expected_reuse(&self, sess: &Session) { if let Some(ref data) = self.data { let data = data.lock().unwrap(); @@ -118,7 +119,7 @@ impl CguReuseTracker { }; if error { - let at_least = if at_least { "at least " } else { "" }; + let at_least = if at_least { 1 } else { 0 }; IncorrectCguReuseType { span: error_span.0, cgu_user_name: &cgu_user_name, @@ -128,15 +129,7 @@ impl CguReuseTracker { }; } } else { - //FIXME: Remove this once PR #100694 that implements `[fatal(..)]` is merged - let msg = format!( - "CGU-reuse for `{cgu_user_name}` (mangled: `{cgu_name}`) was \ - not recorded" - ); - diag.span_fatal(error_span.0, &msg) - - //FIXME: Uncomment this once PR #100694 that implements `[fatal(..)]` is merged - // CguNotRecorded { cgu_user_name, cgu_name }; + sess.emit_fatal(CguNotRecorded { cgu_user_name, cgu_name }); } } } diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 54e5fe82f5c..7252f1799da 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -14,16 +14,15 @@ pub struct IncorrectCguReuseType<'a> { pub cgu_user_name: &'a str, pub actual_reuse: CguReuse, pub expected_reuse: CguReuse, - pub at_least: &'a str, + pub at_least: u8, } -//FIXME: Uncomment this once PR #100694 that implements `[fatal(..)]` is merged -// #[derive(SessionDiagnostic)] -// #[fatal(session::cgu_not_recorded)] -// pub struct CguNotRecorded<'a> { -// pub cgu_user_name: &'a str, -// pub cgu_name: &'a str, -// } +#[derive(SessionDiagnostic)] +#[diag(session::cgu_not_recorded)] +pub struct CguNotRecorded<'a> { + pub cgu_user_name: &'a str, + pub cgu_name: &'a str, +} #[derive(SessionDiagnostic)] #[diag(session::feature_gate_error, code = "E0658")] |
