Skip to content

Commit cf21668

Browse files
committed
Inline fluent messages
1 parent cf816fb commit cf21668

7 files changed

Lines changed: 26 additions & 70 deletions

File tree

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/binary_analysis/build_error.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ use crate::ctxt::AnalysisCtxt;
77
use crate::diagnostic::use_stack::{UseSite, UseSiteKind};
88

99
#[derive(Diagnostic)]
10-
#[diag(klint_build_error_referenced_without_symbol)]
10+
#[diag("found a reference to `build_error` in the object file, but no associated symbol is found")]
1111
struct BuildErrorReferencedWithoutSymbol;
1212

1313
#[derive(Diagnostic)]
14-
#[diag(klint_build_error_referenced_without_instance)]
14+
#[diag(
15+
"symbol `{$symbol}` references `build_error` in the object file, but no associated instance is found"
16+
)]
1517
struct BuildErrorReferencedWithoutInstance<'a> {
1618
pub symbol: &'a str,
1719
}
1820

1921
#[derive(Diagnostic)]
20-
#[diag(klint_build_error_referenced_without_debug)]
21-
#[note]
22+
#[diag("`{$kind} {$instance}` contains reference to `build_error`")]
23+
#[note("attempt to reconstruct line information from DWARF failed: {$err}")]
2224
struct BuildErrorReferencedWithoutDebug<'tcx> {
2325
#[primary_span]
2426
pub span: Span,
@@ -28,7 +30,7 @@ struct BuildErrorReferencedWithoutDebug<'tcx> {
2830
}
2931

3032
#[derive(Diagnostic)]
31-
#[diag(klint_build_error_referenced)]
33+
#[diag("this `build_error` reference is not optimized away")]
3234
struct BuildErrorReferenced;
3335

3436
pub fn build_error_detection<'tcx, 'obj>(cx: &AnalysisCtxt<'tcx>, file: &File<'obj>) {

src/binary_analysis/stack_size.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ declare_tool_lint! {
1919
}
2020

2121
#[derive(Diagnostic)]
22-
#[diag(klint_stack_frame_limit_missing)]
23-
#[help(klint_stack_frame_limit_help)]
22+
#[diag("stack size limit is not set, default to {$default} bytes")]
23+
#[help("set stack size limit with `--cfg CONFIG_FRAME_WARN=\"<size-in-bytes>\"`")]
2424
struct StackFrameLimitMissing {
2525
#[primary_span]
2626
pub span: Span,
2727
pub default: u32,
2828
}
2929

3030
#[derive(Diagnostic)]
31-
#[diag(klint_stack_frame_limit_invalid)]
32-
#[help(klint_stack_frame_limit_help)]
31+
#[diag("stack size limit is set to `{$setting}` bytes, which cannot be parsed as integer")]
32+
#[help("set stack size limit with `--cfg CONFIG_FRAME_WARN=\"<size-in-bytes>\"`")]
3333
struct StackFrameLimitInvalid {
3434
#[primary_span]
3535
pub span: Span,
3636
pub setting: Symbol,
3737
}
3838

3939
#[derive(Diagnostic)]
40-
#[diag(klint_stack_frame_too_large)]
41-
#[note]
40+
#[diag("stack size of `{$instance}` is {$stack_size} bytes, exceeds the {$frame_limit}-byte limit")]
41+
#[note("the stack size is inferred from instruction `{$insn}` at {$section}+{$offset}")]
4242
struct StackFrameTooLarge<'a, 'tcx> {
4343
pub section: &'a str,
4444
pub offset: u64,

src/diagnostic_items/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use crate::ctxt::{AnalysisCtxt, QueryValueDecodable};
1414
use crate::{attribute::KlintAttribute, ctxt::PersistentQuery};
1515

1616
#[derive(Diagnostic)]
17-
#[diag(klint_duplicate_diagnostic_item_in_crate)]
17+
#[diag("duplicate klint diagnostic item in crate `{$crate_name}`: `{$name}`")]
1818
struct DuplicateDiagnosticItemInCrate {
1919
#[primary_span]
2020
pub duplicate_span: Option<Span>,
21-
#[note(klint_diagnostic_item_first_defined)]
21+
#[note("the klint diagnostic item is first defined here")]
2222
pub orig_span: Option<Span>,
23-
#[note]
23+
#[note("the diagnostic item is first defined in crate `{$orig_crate_name}`")]
2424
pub different_crates: bool,
2525
pub crate_name: Symbol,
2626
pub orig_crate_name: Symbol,

src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extern crate rustc_codegen_ssa;
2929
extern crate rustc_data_structures;
3030
extern crate rustc_driver;
3131
extern crate rustc_errors;
32-
extern crate rustc_fluent_macro;
3332
extern crate rustc_hir;
3433
extern crate rustc_index;
3534
extern crate rustc_infer;
@@ -96,7 +95,6 @@ impl Callbacks for MyCallbacks {
9695
_ => (),
9796
}
9897

99-
config.locale_resources.push(crate::DEFAULT_LOCALE_RESOURCE);
10098
config.extra_symbols = crate::symbol::EXTRA_SYMBOLS.to_owned();
10199

102100
config.override_queries = Some(|_, provider| {
@@ -176,5 +174,3 @@ fn main() {
176174

177175
driver::run_compiler(&args, MyCallbacks);
178176
}
179-
180-
rustc_fluent_macro::fluent_messages! { "./messages.ftl" }

src/messages.ftl

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/monomorphize_collector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::cell::OnceCell;
3939

4040
// From rustc_monomorphize/errors.rs
4141
#[derive(Diagnostic)]
42-
#[diag(klint_monomorphize_encountered_error_while_instantiating)]
42+
#[diag("the above error was encountered while instantiating `{$kind} {$instance}`")]
4343
struct EncounteredErrorWhileInstantiating<'tcx> {
4444
#[primary_span]
4545
pub span: Span,
@@ -48,19 +48,19 @@ struct EncounteredErrorWhileInstantiating<'tcx> {
4848
}
4949

5050
#[derive(Diagnostic)]
51-
#[diag(klint_monomorphize_encountered_error_while_instantiating_global_asm)]
51+
#[diag("the above error was encountered while instantiating `global_asm`")]
5252
struct EncounteredErrorWhileInstantiatingGlobalAsm {
5353
#[primary_span]
5454
pub span: Span,
5555
}
5656

5757
#[derive(Diagnostic)]
58-
#[diag(klint_monomorphize_recursion_limit)]
58+
#[diag("reached the recursion limit while instantiating `{$instance}`")]
5959
struct RecursionLimit<'tcx> {
6060
#[primary_span]
6161
pub span: Span,
6262
pub instance: Instance<'tcx>,
63-
#[note]
63+
#[note("`{$def_path_str}` defined here")]
6464
pub def_span: Span,
6565
pub def_path_str: String,
6666
}

0 commit comments

Comments
 (0)