Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::Write;

use rustc_ast::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_errors::inline_fluent;
use rustc_errors::msg;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_session::parse::feature_err;
Expand Down Expand Up @@ -67,7 +67,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&self.tcx.sess,
sym::asm_experimental_arch,
sp,
inline_fluent!("inline assembly is not stable yet on this architecture"),
msg!("inline assembly is not stable yet on this architecture"),
)
.emit();
}
Expand All @@ -84,7 +84,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
&self.tcx.sess,
sym::asm_unwind,
sp,
inline_fluent!("the `may_unwind` option is unstable"),
msg!("the `may_unwind` option is unstable"),
)
.emit();
}
Expand Down Expand Up @@ -499,9 +499,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
sess,
sym::asm_goto_with_outputs,
*op_sp,
inline_fluent!(
"using both label and output operands for inline assembly is unstable"
),
msg!("using both label and output operands for inline assembly is unstable"),
)
.emit();
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use rustc_ast::*;
use rustc_ast_pretty::pprust::expr_to_string;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::inline_fluent;
use rustc_errors::msg;
use rustc_hir as hir;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
Expand Down Expand Up @@ -1702,7 +1702,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&self.tcx.sess,
sym::yield_expr,
span,
inline_fluent!("yield syntax is experimental"),
msg!("yield syntax is experimental"),
)
.emit();
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_ast::{self as ast, AttrVec, NodeId, PatKind, attr, token};
use rustc_errors::inline_fluent;
use rustc_errors::msg;
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features};
use rustc_session::Session;
use rustc_session::parse::{feature_err, feature_warn};
Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'a> PostExpansionVisitor<'a> {
&self,
non_lifetime_binders,
non_lt_param_spans,
inline_fluent!("only lifetime parameters can be used in this context")
msg!("only lifetime parameters can be used in this context")
);

// FIXME(non_lifetime_binders): Const bound params are pretty broken.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::identity;
use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::DelimSpan;
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, ast, token};
use rustc_errors::{Applicability, PResult, inline_fluent};
use rustc_errors::{Applicability, PResult, msg};
use rustc_feature::{
AttrSuggestionStyle, AttributeTemplate, Features, GatedCfg, find_gated_cfg, template,
};
Expand Down Expand Up @@ -141,7 +141,7 @@ fn parse_cfg_entry_target<S: Stage>(
cx.sess(),
sym::cfg_target_compact,
meta_span,
inline_fluent!("compact `cfg(target(..))` is experimental and subject to change"),
msg!("compact `cfg(target(..))` is experimental and subject to change"),
)
.emit();
}
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_errors::inline_fluent;
use rustc_errors::msg;
use rustc_feature::Features;
use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection};
use rustc_hir::attrs::*;
Expand Down Expand Up @@ -316,7 +316,7 @@ impl LinkParser {
sess,
sym::raw_dylib_elf,
nv.value_span,
inline_fluent!("link kind `raw-dylib` is unstable on ELF platforms"),
msg!("link kind `raw-dylib` is unstable on ELF platforms"),
)
.emit();
} else {
Expand All @@ -331,7 +331,7 @@ impl LinkParser {
sess,
sym::link_arg_attribute,
nv.value_span,
inline_fluent!("link kind `link-arg` is unstable"),
msg!("link kind `link-arg` is unstable"),
)
.emit();
}
Expand Down Expand Up @@ -396,8 +396,7 @@ impl LinkParser {
return true;
};
if !features.link_cfg() {
feature_err(sess, sym::link_cfg, item.span(), inline_fluent!("link cfg is unstable"))
.emit();
feature_err(sess, sym::link_cfg, item.span(), msg!("link cfg is unstable")).emit();
}
*cfg = parse_cfg_entry(cx, link_cfg).ok();
true
Expand Down
18 changes: 6 additions & 12 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use std::collections::BTreeMap;

use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::{
Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, inline_fluent, listify,
};
use rustc_errors::{Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, listify, msg};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::{
self as hir, CoroutineKind, GenericBound, LangItem, WhereBoundPredicate, WherePredicateKind,
Expand Down Expand Up @@ -1313,7 +1311,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let mut span: MultiSpan = spans.clone().into();
err.arg("ty", param_ty.to_string());
let msg = err.dcx.eagerly_translate_to_string(
inline_fluent!("`{$ty}` is made to be an `FnOnce` closure here"),
msg!("`{$ty}` is made to be an `FnOnce` closure here"),
err.args.iter(),
);
err.remove_arg("ty");
Expand All @@ -1322,12 +1320,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
span.push_span_label(
fn_call_span,
inline_fluent!("this value implements `FnOnce`, which causes it to be moved when called"),
);
err.span_note(
span,
inline_fluent!("`FnOnce` closures can only be called once"),
msg!("this value implements `FnOnce`, which causes it to be moved when called"),
);
err.span_note(span, msg!("`FnOnce` closures can only be called once"));
} else {
err.subdiagnostic(CaptureReasonNote::FnOnceMoveInCall { var_span });
}
Expand Down Expand Up @@ -1573,6 +1568,5 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
}

const LIMITATION_NOTE: DiagMessage = inline_fluent!(
"due to a current limitation of the type system, this implies a `'static` lifetime"
);
const LIMITATION_NOTE: DiagMessage =
msg!("due to a current limitation of the type system, this implies a `'static` lifetime");
16 changes: 7 additions & 9 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Error reporting machinery for lifetime errors.

use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, inline_fluent};
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, msg};
use rustc_hir as hir;
use rustc_hir::GenericBound::Trait;
use rustc_hir::QPath::Resolved;
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
if suggestions.len() > 0 {
suggestions.dedup();
diag.multipart_suggestion_verbose(
inline_fluent!("consider restricting the type parameter to the `'static` lifetime"),
msg!("consider restricting the type parameter to the `'static` lifetime"),
suggestions,
Applicability::MaybeIncorrect,
);
Expand Down Expand Up @@ -982,18 +982,16 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let mut multi_span: MultiSpan = vec![*span].into();
multi_span.push_span_label(
*span,
inline_fluent!("this has an implicit `'static` lifetime requirement"),
msg!("this has an implicit `'static` lifetime requirement"),
);
multi_span.push_span_label(
ident.span,
inline_fluent!(
"calling this method introduces the `impl`'s `'static` requirement"
),
msg!("calling this method introduces the `impl`'s `'static` requirement"),
);
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
err.span_suggestion_verbose(
span.shrink_to_hi(),
inline_fluent!("consider relaxing the implicit `'static` requirement"),
msg!("consider relaxing the implicit `'static` requirement"),
" + '_",
Applicability::MaybeIncorrect,
);
Expand Down Expand Up @@ -1156,7 +1154,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() && count > 0 {
diag.span_suggestion_verbose(
tcx.hir_body(*body).value.peel_blocks().span.shrink_to_lo(),
inline_fluent!("dereference the return value"),
msg!("dereference the return value"),
"*".repeat(count),
Applicability::MachineApplicable,
);
Expand Down Expand Up @@ -1200,7 +1198,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
if let Some(closure_span) = closure_span {
diag.span_suggestion_verbose(
closure_span,
inline_fluent!("consider adding 'move' keyword before the nested closure"),
msg!("consider adding 'move' keyword before the nested closure"),
"move ",
Applicability::MaybeIncorrect,
);
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_errors::codes::*;
use rustc_errors::{
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans,
Subdiagnostic, inline_fluent,
Subdiagnostic, msg,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};
Expand Down Expand Up @@ -764,7 +764,7 @@ pub(crate) struct FormatUnusedArg {
impl Subdiagnostic for FormatUnusedArg {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
diag.arg("named", self.named);
let msg = diag.eagerly_translate(inline_fluent!(
let msg = diag.eagerly_translate(msg!(
"{$named ->
[true] named argument
*[false] argument
Expand Down Expand Up @@ -947,13 +947,12 @@ pub(crate) struct AsmClobberNoReg {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
// eager translation as `span_labels` takes `AsRef<str>`
let lbl1 = dcx.eagerly_translate_to_string(inline_fluent!("clobber_abi"), [].into_iter());
let lbl2 =
dcx.eagerly_translate_to_string(inline_fluent!("generic outputs"), [].into_iter());
let lbl1 = dcx.eagerly_translate_to_string(msg!("clobber_abi"), [].into_iter());
let lbl2 = dcx.eagerly_translate_to_string(msg!("generic outputs"), [].into_iter());
Diag::new(
dcx,
level,
inline_fluent!("asm with `clobber_abi` must specify explicit registers for outputs"),
msg!("asm with `clobber_abi` must specify explicit registers for outputs"),
)
.with_span(self.spans.clone())
.with_span_labels(self.clobbers, &lbl1)
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_codegen_llvm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::ffi::CString;
use std::path::Path;

use rustc_data_structures::small_c_str::SmallCStr;
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, inline_fluent};
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, msg};
use rustc_macros::Diagnostic;
use rustc_span::Span;

Expand All @@ -28,7 +28,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for ParseTargetMachineConfig<'_> {
Diag::new(
dcx,
level,
inline_fluent!("failed to parse target machine config to target machine: {$error}"),
msg!("failed to parse target machine config to target machine: {$error}"),
)
.with_arg("error", message)
}
Expand Down Expand Up @@ -121,25 +121,25 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
use LlvmError::*;
let msg_with_llvm_err = match &self.0 {
WriteOutput { .. } => inline_fluent!("could not write output to {$path}: {$llvm_err}"),
CreateTargetMachine { .. } => inline_fluent!(
"could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}"
),
RunLlvmPasses => inline_fluent!("failed to run LLVM passes: {$llvm_err}"),
WriteIr { .. } => inline_fluent!("failed to write LLVM IR to {$path}: {$llvm_err}"),
WriteOutput { .. } => msg!("could not write output to {$path}: {$llvm_err}"),
CreateTargetMachine { .. } => {
msg!("could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}")
}
RunLlvmPasses => msg!("failed to run LLVM passes: {$llvm_err}"),
WriteIr { .. } => msg!("failed to write LLVM IR to {$path}: {$llvm_err}"),
PrepareThinLtoContext => {
inline_fluent!("failed to prepare thin LTO context: {$llvm_err}")
msg!("failed to prepare thin LTO context: {$llvm_err}")
}
LoadBitcode { .. } => {
inline_fluent!("failed to load bitcode of module \"{$name}\": {$llvm_err}")
msg!("failed to load bitcode of module \"{$name}\": {$llvm_err}")
}
WriteThinLtoKey { .. } => {
inline_fluent!("error while writing ThinLTO key data: {$err}: {$llvm_err}")
msg!("error while writing ThinLTO key data: {$err}: {$llvm_err}")
}
PrepareThinLtoModule => {
inline_fluent!("failed to prepare thin LTO module: {$llvm_err}")
msg!("failed to prepare thin LTO module: {$llvm_err}")
}
ParseBitcode => inline_fluent!("failed to parse bitcode for LTO module: {$llvm_err}"),
ParseBitcode => msg!("failed to parse bitcode for LTO module: {$llvm_err}"),
};
self.0
.into_diag(dcx, level)
Expand Down
12 changes: 5 additions & 7 deletions compiler/rustc_codegen_ssa/src/back/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use std::process::Command;

use itertools::Itertools;
use rustc_errors::inline_fluent;
use rustc_errors::msg;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_session::Session;
pub(super) use rustc_target::spec::apple::OSVersion;
Expand Down Expand Up @@ -185,21 +185,19 @@ pub(super) fn get_sdk_root(sess: &Session) -> Option<PathBuf> {
// FIXME(madsmtm): Make this a lint, to allow deny warnings to work.
// (Or fix <https://github.com/rust-lang/rust/issues/21204>).
let mut diag = sess.dcx().create_warn(err);
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"));
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"));

// Recognize common error cases, and give more Rust-specific error messages for those.
if let Some(developer_dir) = xcode_select_developer_dir() {
diag.arg("developer_dir", &developer_dir);
diag.note(inline_fluent!(
"found active developer directory at \"{$developer_dir}\""
));
diag.note(msg!("found active developer directory at \"{$developer_dir}\""));
if developer_dir.as_os_str().to_string_lossy().contains("CommandLineTools") {
if sdk_name != "MacOSX" {
diag.help(inline_fluent!("when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode"));
diag.help(msg!("when compiling for iOS, tvOS, visionOS or watchOS, you need a full installation of Xcode"));
}
}
} else {
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"));
diag.help(msg!("pass the path of an Xcode installation via the DEVELOPER_DIR environment variable, or an SDK with the SDKROOT environment variable"));
}

diag.emit();
Expand Down
Loading
Loading