Skip to content

Commit 0461a01

Browse files
Rollup merge of #152612 - JonathanBrouwer:rename_to_msg, r=jdonszelmann
Rename `inline_fluent!` to `msg!` This was the most popular name for the macro as voted in [#t-compiler > Bikeshed the new `inline_fluent!` macro @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Bikeshed.20the.20new.20.60inline_fluent!.60.20macro/near/572751863)
2 parents d2ec126 + 018a5ef commit 0461a01

64 files changed

Lines changed: 647 additions & 840 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt::Write;
33

44
use rustc_ast::*;
55
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
6-
use rustc_errors::inline_fluent;
6+
use rustc_errors::msg;
77
use rustc_hir as hir;
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_session::parse::feature_err;
@@ -67,7 +67,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6767
&self.tcx.sess,
6868
sym::asm_experimental_arch,
6969
sp,
70-
inline_fluent!("inline assembly is not stable yet on this architecture"),
70+
msg!("inline assembly is not stable yet on this architecture"),
7171
)
7272
.emit();
7373
}
@@ -84,7 +84,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
8484
&self.tcx.sess,
8585
sym::asm_unwind,
8686
sp,
87-
inline_fluent!("the `may_unwind` option is unstable"),
87+
msg!("the `may_unwind` option is unstable"),
8888
)
8989
.emit();
9090
}
@@ -499,9 +499,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
499499
sess,
500500
sym::asm_goto_with_outputs,
501501
*op_sp,
502-
inline_fluent!(
503-
"using both label and output operands for inline assembly is unstable"
504-
),
502+
msg!("using both label and output operands for inline assembly is unstable"),
505503
)
506504
.emit();
507505
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55
use rustc_ast::*;
66
use rustc_ast_pretty::pprust::expr_to_string;
77
use rustc_data_structures::stack::ensure_sufficient_stack;
8-
use rustc_errors::inline_fluent;
8+
use rustc_errors::msg;
99
use rustc_hir as hir;
1010
use rustc_hir::attrs::AttributeKind;
1111
use rustc_hir::def::{DefKind, Res};
@@ -1702,7 +1702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17021702
&self.tcx.sess,
17031703
sym::yield_expr,
17041704
span,
1705-
inline_fluent!("yield syntax is experimental"),
1705+
msg!("yield syntax is experimental"),
17061706
)
17071707
.emit();
17081708
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
22
use rustc_ast::{self as ast, AttrVec, NodeId, PatKind, attr, token};
3-
use rustc_errors::inline_fluent;
3+
use rustc_errors::msg;
44
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features};
55
use rustc_session::Session;
66
use rustc_session::parse::{feature_err, feature_warn};
@@ -125,7 +125,7 @@ impl<'a> PostExpansionVisitor<'a> {
125125
&self,
126126
non_lifetime_binders,
127127
non_lt_param_spans,
128-
inline_fluent!("only lifetime parameters can be used in this context")
128+
msg!("only lifetime parameters can be used in this context")
129129
);
130130

131131
// FIXME(non_lifetime_binders): Const bound params are pretty broken.

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::convert::identity;
33
use rustc_ast::token::Delimiter;
44
use rustc_ast::tokenstream::DelimSpan;
55
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, ast, token};
6-
use rustc_errors::{Applicability, PResult, inline_fluent};
6+
use rustc_errors::{Applicability, PResult, msg};
77
use rustc_feature::{
88
AttrSuggestionStyle, AttributeTemplate, Features, GatedCfg, find_gated_cfg, template,
99
};
@@ -141,7 +141,7 @@ fn parse_cfg_entry_target<S: Stage>(
141141
cx.sess(),
142142
sym::cfg_target_compact,
143143
meta_span,
144-
inline_fluent!("compact `cfg(target(..))` is experimental and subject to change"),
144+
msg!("compact `cfg(target(..))` is experimental and subject to change"),
145145
)
146146
.emit();
147147
}

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::inline_fluent;
1+
use rustc_errors::msg;
22
use rustc_feature::Features;
33
use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection};
44
use rustc_hir::attrs::*;
@@ -316,7 +316,7 @@ impl LinkParser {
316316
sess,
317317
sym::raw_dylib_elf,
318318
nv.value_span,
319-
inline_fluent!("link kind `raw-dylib` is unstable on ELF platforms"),
319+
msg!("link kind `raw-dylib` is unstable on ELF platforms"),
320320
)
321321
.emit();
322322
} else {
@@ -331,7 +331,7 @@ impl LinkParser {
331331
sess,
332332
sym::link_arg_attribute,
333333
nv.value_span,
334-
inline_fluent!("link kind `link-arg` is unstable"),
334+
msg!("link kind `link-arg` is unstable"),
335335
)
336336
.emit();
337337
}
@@ -396,8 +396,7 @@ impl LinkParser {
396396
return true;
397397
};
398398
if !features.link_cfg() {
399-
feature_err(sess, sym::link_cfg, item.span(), inline_fluent!("link cfg is unstable"))
400-
.emit();
399+
feature_err(sess, sym::link_cfg, item.span(), msg!("link cfg is unstable")).emit();
401400
}
402401
*cfg = parse_cfg_entry(cx, link_cfg).ok();
403402
true

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use std::collections::BTreeMap;
44

55
use rustc_abi::{FieldIdx, VariantIdx};
66
use rustc_data_structures::fx::FxIndexMap;
7-
use rustc_errors::{
8-
Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, inline_fluent, listify,
9-
};
7+
use rustc_errors::{Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, listify, msg};
108
use rustc_hir::def::{CtorKind, Namespace};
119
use rustc_hir::{
1210
self as hir, CoroutineKind, GenericBound, LangItem, WhereBoundPredicate, WherePredicateKind,
@@ -1313,7 +1311,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13131311
let mut span: MultiSpan = spans.clone().into();
13141312
err.arg("ty", param_ty.to_string());
13151313
let msg = err.dcx.eagerly_translate_to_string(
1316-
inline_fluent!("`{$ty}` is made to be an `FnOnce` closure here"),
1314+
msg!("`{$ty}` is made to be an `FnOnce` closure here"),
13171315
err.args.iter(),
13181316
);
13191317
err.remove_arg("ty");
@@ -1322,12 +1320,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13221320
}
13231321
span.push_span_label(
13241322
fn_call_span,
1325-
inline_fluent!("this value implements `FnOnce`, which causes it to be moved when called"),
1326-
);
1327-
err.span_note(
1328-
span,
1329-
inline_fluent!("`FnOnce` closures can only be called once"),
1323+
msg!("this value implements `FnOnce`, which causes it to be moved when called"),
13301324
);
1325+
err.span_note(span, msg!("`FnOnce` closures can only be called once"));
13311326
} else {
13321327
err.subdiagnostic(CaptureReasonNote::FnOnceMoveInCall { var_span });
13331328
}
@@ -1573,6 +1568,5 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
15731568
}
15741569
}
15751570

1576-
const LIMITATION_NOTE: DiagMessage = inline_fluent!(
1577-
"due to a current limitation of the type system, this implies a `'static` lifetime"
1578-
);
1571+
const LIMITATION_NOTE: DiagMessage =
1572+
msg!("due to a current limitation of the type system, this implies a `'static` lifetime");

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Error reporting machinery for lifetime errors.
22
33
use rustc_data_structures::fx::FxIndexSet;
4-
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, inline_fluent};
4+
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, msg};
55
use rustc_hir as hir;
66
use rustc_hir::GenericBound::Trait;
77
use rustc_hir::QPath::Resolved;
@@ -291,7 +291,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
291291
if suggestions.len() > 0 {
292292
suggestions.dedup();
293293
diag.multipart_suggestion_verbose(
294-
inline_fluent!("consider restricting the type parameter to the `'static` lifetime"),
294+
msg!("consider restricting the type parameter to the `'static` lifetime"),
295295
suggestions,
296296
Applicability::MaybeIncorrect,
297297
);
@@ -982,18 +982,16 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
982982
let mut multi_span: MultiSpan = vec![*span].into();
983983
multi_span.push_span_label(
984984
*span,
985-
inline_fluent!("this has an implicit `'static` lifetime requirement"),
985+
msg!("this has an implicit `'static` lifetime requirement"),
986986
);
987987
multi_span.push_span_label(
988988
ident.span,
989-
inline_fluent!(
990-
"calling this method introduces the `impl`'s `'static` requirement"
991-
),
989+
msg!("calling this method introduces the `impl`'s `'static` requirement"),
992990
);
993991
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
994992
err.span_suggestion_verbose(
995993
span.shrink_to_hi(),
996-
inline_fluent!("consider relaxing the implicit `'static` requirement"),
994+
msg!("consider relaxing the implicit `'static` requirement"),
997995
" + '_",
998996
Applicability::MaybeIncorrect,
999997
);
@@ -1156,7 +1154,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11561154
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() && count > 0 {
11571155
diag.span_suggestion_verbose(
11581156
tcx.hir_body(*body).value.peel_blocks().span.shrink_to_lo(),
1159-
inline_fluent!("dereference the return value"),
1157+
msg!("dereference the return value"),
11601158
"*".repeat(count),
11611159
Applicability::MachineApplicable,
11621160
);
@@ -1200,7 +1198,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
12001198
if let Some(closure_span) = closure_span {
12011199
diag.span_suggestion_verbose(
12021200
closure_span,
1203-
inline_fluent!("consider adding 'move' keyword before the nested closure"),
1201+
msg!("consider adding 'move' keyword before the nested closure"),
12041202
"move ",
12051203
Applicability::MaybeIncorrect,
12061204
);

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_errors::codes::*;
22
use rustc_errors::{
33
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans,
4-
Subdiagnostic, inline_fluent,
4+
Subdiagnostic, msg,
55
};
66
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
77
use rustc_span::{Ident, Span, Symbol};
@@ -764,7 +764,7 @@ pub(crate) struct FormatUnusedArg {
764764
impl Subdiagnostic for FormatUnusedArg {
765765
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
766766
diag.arg("named", self.named);
767-
let msg = diag.eagerly_translate(inline_fluent!(
767+
let msg = diag.eagerly_translate(msg!(
768768
"{$named ->
769769
[true] named argument
770770
*[false] argument
@@ -947,13 +947,12 @@ pub(crate) struct AsmClobberNoReg {
947947
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
948948
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
949949
// eager translation as `span_labels` takes `AsRef<str>`
950-
let lbl1 = dcx.eagerly_translate_to_string(inline_fluent!("clobber_abi"), [].into_iter());
951-
let lbl2 =
952-
dcx.eagerly_translate_to_string(inline_fluent!("generic outputs"), [].into_iter());
950+
let lbl1 = dcx.eagerly_translate_to_string(msg!("clobber_abi"), [].into_iter());
951+
let lbl2 = dcx.eagerly_translate_to_string(msg!("generic outputs"), [].into_iter());
953952
Diag::new(
954953
dcx,
955954
level,
956-
inline_fluent!("asm with `clobber_abi` must specify explicit registers for outputs"),
955+
msg!("asm with `clobber_abi` must specify explicit registers for outputs"),
957956
)
958957
.with_span(self.spans.clone())
959958
.with_span_labels(self.clobbers, &lbl1)

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::ffi::CString;
22
use std::path::Path;
33

44
use rustc_data_structures::small_c_str::SmallCStr;
5-
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, inline_fluent};
5+
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, msg};
66
use rustc_macros::Diagnostic;
77
use rustc_span::Span;
88

@@ -28,7 +28,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
2828
Diag::new(
2929
dcx,
3030
level,
31-
inline_fluent!("failed to parse target machine config to target machine: {$error}"),
31+
msg!("failed to parse target machine config to target machine: {$error}"),
3232
)
3333
.with_arg("error", message)
3434
}
@@ -121,25 +121,25 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
121121
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
122122
use LlvmError::*;
123123
let msg_with_llvm_err = match &self.0 {
124-
WriteOutput { .. } => inline_fluent!("could not write output to {$path}: {$llvm_err}"),
125-
CreateTargetMachine { .. } => inline_fluent!(
126-
"could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}"
127-
),
128-
RunLlvmPasses => inline_fluent!("failed to run LLVM passes: {$llvm_err}"),
129-
WriteIr { .. } => inline_fluent!("failed to write LLVM IR to {$path}: {$llvm_err}"),
124+
WriteOutput { .. } => msg!("could not write output to {$path}: {$llvm_err}"),
125+
CreateTargetMachine { .. } => {
126+
msg!("could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}")
127+
}
128+
RunLlvmPasses => msg!("failed to run LLVM passes: {$llvm_err}"),
129+
WriteIr { .. } => msg!("failed to write LLVM IR to {$path}: {$llvm_err}"),
130130
PrepareThinLtoContext => {
131-
inline_fluent!("failed to prepare thin LTO context: {$llvm_err}")
131+
msg!("failed to prepare thin LTO context: {$llvm_err}")
132132
}
133133
LoadBitcode { .. } => {
134-
inline_fluent!("failed to load bitcode of module \"{$name}\": {$llvm_err}")
134+
msg!("failed to load bitcode of module \"{$name}\": {$llvm_err}")
135135
}
136136
WriteThinLtoKey { .. } => {
137-
inline_fluent!("error while writing ThinLTO key data: {$err}: {$llvm_err}")
137+
msg!("error while writing ThinLTO key data: {$err}: {$llvm_err}")
138138
}
139139
PrepareThinLtoModule => {
140-
inline_fluent!("failed to prepare thin LTO module: {$llvm_err}")
140+
msg!("failed to prepare thin LTO module: {$llvm_err}")
141141
}
142-
ParseBitcode => inline_fluent!("failed to parse bitcode for LTO module: {$llvm_err}"),
142+
ParseBitcode => msg!("failed to parse bitcode for LTO module: {$llvm_err}"),
143143
};
144144
self.0
145145
.into_diag(dcx, level)

compiler/rustc_codegen_ssa/src/back/apple.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::PathBuf;
33
use std::process::Command;
44

55
use itertools::Itertools;
6-
use rustc_errors::inline_fluent;
6+
use rustc_errors::msg;
77
use rustc_middle::middle::exported_symbols::SymbolExportKind;
88
use rustc_session::Session;
99
pub(super) use rustc_target::spec::apple::OSVersion;
@@ -185,21 +185,19 @@ pub(super) fn get_sdk_root(sess: &Session) -> Option<PathBuf> {
185185
// FIXME(madsmtm): Make this a lint, to allow deny warnings to work.
186186
// (Or fix <https://github.com/rust-lang/rust/issues/21204>).
187187
let mut diag = sess.dcx().create_warn(err);
188-
diag.note(inline_fluent!("the SDK is needed by the linker to know where to find symbols in system libraries and for embedding the SDK version in the final object file"));
188+
diag.note(msg!("the SDK is needed by the linker to know where to find symbols in system libraries and for embedding the SDK version in the final object file"));
189189

190190
// Recognize common error cases, and give more Rust-specific error messages for those.
191191
if let Some(developer_dir) = xcode_select_developer_dir() {
192192
diag.arg("developer_dir", &developer_dir);
193-
diag.note(inline_fluent!(
194-
"found active developer directory at \"{$developer_dir}\""
195-
));
193+
diag.note(msg!("found active developer directory at \"{$developer_dir}\""));
196194
if developer_dir.as_os_str().to_string_lossy().contains("CommandLineTools") {
197195
if sdk_name != "MacOSX" {
198-
diag.help(inline_fluent!("when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode"));
196+
diag.help(msg!("when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode"));
199197
}
200198
}
201199
} else {
202-
diag.help(inline_fluent!("pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable"));
200+
diag.help(msg!("pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable"));
203201
}
204202

205203
diag.emit();

0 commit comments

Comments
 (0)