diff options
| author | David Wood <david.wood@huawei.com> | 2022-03-31 08:35:17 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-04-05 07:01:03 +0100 |
| commit | d0fd8d78803eee2c9badde29811ba95b361aff88 (patch) | |
| tree | 858c2a206685b2dae7ae21a9769bde2fadd4ab34 /compiler/rustc_errors | |
| parent | f0de7df2048497cd701ee9a88ec44e9ac00e282e (diff) | |
| download | rust-d0fd8d78803eee2c9badde29811ba95b361aff88.tar.gz rust-d0fd8d78803eee2c9badde29811ba95b361aff88.zip | |
macros: translatable struct attrs and warnings
Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index c8281bd37d1..6a763d4d140 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -261,7 +261,7 @@ pub trait Emitter { message: &'a DiagnosticMessage, args: &'a FluentArgs<'_>, ) -> Cow<'_, str> { - trace!(?message); + trace!(?message, ?args); let (identifier, attr) = match message { DiagnosticMessage::Str(msg) => return Cow::Borrowed(&msg), DiagnosticMessage::FluentIdentifier(identifier, attr) => (identifier, attr), @@ -283,7 +283,13 @@ pub trait Emitter { let mut err = vec![]; let translated = bundle.format_pattern(value, Some(&args), &mut err); trace!(?translated, ?err); - debug_assert!(err.is_empty()); + debug_assert!( + err.is_empty(), + "identifier: {:?}, args: {:?}, errors: {:?}", + identifier, + args, + err + ); translated } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 94db957d299..c927fcb2109 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -777,6 +777,17 @@ impl Handler { result } + /// Construct a builder at the `Warn` level with the `msg` and the `code`. + pub fn struct_warn_with_code( + &self, + msg: impl Into<DiagnosticMessage>, + code: DiagnosticId, + ) -> DiagnosticBuilder<'_, ()> { + let mut result = self.struct_warn(msg); + result.code(code); + result + } + /// Construct a builder at the `Fatal` level at the given `span` and with the `msg`. pub fn struct_span_fatal( &self, |
