Skip to content

Commit 91376f4

Browse files
committed
Auto merge of #129008 - GuillaumeGomez:rollup-6citttb, r=GuillaumeGomez
Rollup of 10 pull requests Successful merges: - #128149 (nontemporal_store: make sure that the intrinsic is truly just a hint) - #128394 (Unify run button display with "copy code" button and with mdbook buttons) - #128537 (const vector passed through to codegen) - #128632 (std: do not overwrite style in `get_backtrace_style`) - #128878 (Slightly refactor `Flags` in bootstrap) - #128886 (Get rid of some `#[allow(rustc::untranslatable_diagnostic)]`) - #128929 (Fix codegen-units tests that were disabled 8 years ago) - #128937 (Fix warnings in rmake tests on `x86_64-unknown-linux-gnu`) - #128978 (Use `assert_matches` around the compiler more) - #128994 (Fix bug in `Parser::look_ahead`.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e08b80c + 99a785d commit 91376f4

File tree

132 files changed

+789
-449
lines changed

Some content is hidden

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

132 files changed

+789
-449
lines changed

compiler/rustc_ast_lowering/messages.ftl

+12
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,23 @@ ast_lowering_template_modifier = template modifier
167167
168168
ast_lowering_this_not_async = this is not `async`
169169
170+
ast_lowering_underscore_array_length_unstable =
171+
using `_` for array lengths is unstable
172+
170173
ast_lowering_underscore_expr_lhs_assign =
171174
in expressions, `_` can only be used on the left-hand side of an assignment
172175
.label = `_` not allowed here
173176
177+
ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
178+
ast_lowering_unstable_inline_assembly_const_operands =
179+
const operands for inline assembly are unstable
180+
ast_lowering_unstable_inline_assembly_label_operands =
181+
label operands for inline assembly are unstable
182+
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
183+
174184
ast_lowering_use_angle_brackets = use angle brackets instead
185+
186+
ast_lowering_yield = yield syntax is experimental
175187
ast_lowering_yield_in_closure =
176188
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks
177189
.suggestion = use `#[coroutine]` to make this closure a coroutine

compiler/rustc_ast_lowering/src/asm.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ use super::errors::{
1919
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
2020
};
2121
use super::LoweringContext;
22-
use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};
22+
use crate::{
23+
fluent_generated as fluent, ImplTraitContext, ImplTraitPosition, ParamMode,
24+
ResolverAstLoweringExt,
25+
};
2326

2427
impl<'a, 'hir> LoweringContext<'a, 'hir> {
25-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
2628
pub(crate) fn lower_inline_asm(
2729
&mut self,
2830
sp: Span,
@@ -52,7 +54,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
5254
&self.tcx.sess,
5355
sym::asm_experimental_arch,
5456
sp,
55-
"inline assembly is not stable yet on this architecture",
57+
fluent::ast_lowering_unstable_inline_assembly,
5658
)
5759
.emit();
5860
}
@@ -64,8 +66,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6466
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
6567
}
6668
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
67-
feature_err(&self.tcx.sess, sym::asm_unwind, sp, "the `may_unwind` option is unstable")
68-
.emit();
69+
feature_err(
70+
&self.tcx.sess,
71+
sym::asm_unwind,
72+
sp,
73+
fluent::ast_lowering_unstable_may_unwind,
74+
)
75+
.emit();
6976
}
7077

7178
let mut clobber_abis = FxIndexMap::default();
@@ -182,7 +189,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
182189
sess,
183190
sym::asm_const,
184191
*op_sp,
185-
"const operands for inline assembly are unstable",
192+
fluent::ast_lowering_unstable_inline_assembly_const_operands,
186193
)
187194
.emit();
188195
}
@@ -246,7 +253,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
246253
sess,
247254
sym::asm_goto,
248255
*op_sp,
249-
"label operands for inline assembly are unstable",
256+
fluent::ast_lowering_unstable_inline_assembly_label_operands,
250257
)
251258
.emit();
252259
}

compiler/rustc_ast_lowering/src/expr.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{
2323
ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt,
2424
};
2525
use crate::errors::YieldInClosure;
26-
use crate::{FnDeclKind, ImplTraitPosition};
26+
use crate::{fluent_generated, FnDeclKind, ImplTraitPosition};
2727

2828
impl<'hir> LoweringContext<'_, 'hir> {
2929
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@@ -1540,7 +1540,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
15401540
}
15411541
}
15421542

1543-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
15441543
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind<'hir> {
15451544
let yielded =
15461545
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));
@@ -1575,7 +1574,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15751574
&self.tcx.sess,
15761575
sym::coroutines,
15771576
span,
1578-
"yield syntax is experimental",
1577+
fluent_generated::ast_lowering_yield,
15791578
)
15801579
.emit();
15811580
}
@@ -1587,7 +1586,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15871586
&self.tcx.sess,
15881587
sym::coroutines,
15891588
span,
1590-
"yield syntax is experimental",
1589+
fluent_generated::ast_lowering_yield,
15911590
)
15921591
.emit();
15931592
}

compiler/rustc_ast_lowering/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23262326
self.expr_block(block)
23272327
}
23282328

2329-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
23302329
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen<'hir> {
23312330
match c.value.kind {
23322331
ExprKind::Underscore => {
@@ -2340,7 +2339,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23402339
&self.tcx.sess,
23412340
sym::generic_arg_infer,
23422341
c.value.span,
2343-
"using `_` for array lengths is unstable",
2342+
fluent_generated::ast_lowering_underscore_array_length_unstable,
23442343
)
23452344
.stash(c.value.span, StashKey::UnderscoreForArrayLengths);
23462345
hir::ArrayLen::Body(self.lower_anon_const_to_const_arg(c))

compiler/rustc_attr/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ attr_unknown_meta_item =
104104
attr_unknown_version_literal =
105105
unknown version literal format, assuming it refers to a future version
106106
107+
attr_unstable_cfg_target_compact =
108+
compact `cfg(target(..))` is experimental and subject to change
109+
107110
attr_unsupported_literal_cfg_string =
108111
literal in `cfg` predicate value must be a string
109112
attr_unsupported_literal_deprecated_kv_pair =

compiler/rustc_attr/src/builtin.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_span::hygiene::Transparency;
2020
use rustc_span::symbol::{sym, Symbol};
2121
use rustc_span::Span;
2222

23+
use crate::fluent_generated;
2324
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2425

2526
/// The version placeholder that recently stabilized features contain inside the
@@ -521,7 +522,6 @@ pub struct Condition {
521522
}
522523

523524
/// Tests if a cfg-pattern matches the cfg set
524-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
525525
pub fn cfg_matches(
526526
cfg: &ast::MetaItem,
527527
sess: &Session,
@@ -593,7 +593,6 @@ pub fn parse_version(s: Symbol) -> Option<RustcVersion> {
593593

594594
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
595595
/// evaluate individual items.
596-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
597596
pub fn eval_condition(
598597
cfg: &ast::MetaItem,
599598
sess: &Session,
@@ -680,7 +679,7 @@ pub fn eval_condition(
680679
sess,
681680
sym::cfg_target_compact,
682681
cfg.span,
683-
"compact `cfg(target(..))` is experimental and subject to change",
682+
fluent_generated::attr_unstable_cfg_target_compact,
684683
)
685684
.emit();
686685
}

compiler/rustc_borrowck/messages.ftl

+21
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ borrowck_could_not_normalize =
6262
borrowck_could_not_prove =
6363
could not prove `{$predicate}`
6464
65+
borrowck_dereference_suggestion =
66+
dereference the return value
67+
6568
borrowck_func_take_self_moved_place =
6669
`{$func}` takes ownership of the receiver `self`, which moves {$place_name}
6770
@@ -74,9 +77,24 @@ borrowck_higher_ranked_lifetime_error =
7477
borrowck_higher_ranked_subtype_error =
7578
higher-ranked subtype error
7679
80+
borrowck_implicit_static =
81+
this has an implicit `'static` lifetime requirement
82+
83+
borrowck_implicit_static_introduced =
84+
calling this method introduces the `impl`'s `'static` requirement
85+
86+
borrowck_implicit_static_relax =
87+
consider relaxing the implicit `'static` requirement
88+
7789
borrowck_lifetime_constraints_error =
7890
lifetime may not live long enough
7991
92+
borrowck_limitations_implies_static =
93+
due to current limitations in the borrow checker, this implies a `'static` lifetime
94+
95+
borrowck_move_closure_suggestion =
96+
consider adding 'move' keyword before the nested closure
97+
8098
borrowck_move_out_place_here =
8199
{$place} is moved here
82100
@@ -163,6 +181,9 @@ borrowck_partial_var_move_by_use_in_coroutine =
163181
*[false] moved
164182
} due to use in coroutine
165183
184+
borrowck_restrict_to_static =
185+
consider restricting the type parameter to the `'static` lifetime
186+
166187
borrowck_returned_async_block_escaped =
167188
returns an `async` block that contains a reference to a captured variable, which then escapes the closure body
168189

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![allow(rustc::diagnostic_outside_of_impl)]
44
#![allow(rustc::untranslatable_diagnostic)]
55

6+
use std::assert_matches::assert_matches;
7+
68
use rustc_errors::{Applicability, Diag};
79
use rustc_hir as hir;
810
use rustc_hir::intravisit::Visitor;
@@ -116,7 +118,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
116118
// path_span must be `Some` as otherwise the if condition is true
117119
let path_span = path_span.unwrap();
118120
// path_span is only present in the case of closure capture
119-
assert!(matches!(later_use_kind, LaterUseKind::ClosureCapture));
121+
assert_matches!(later_use_kind, LaterUseKind::ClosureCapture);
120122
if !borrow_span.is_some_and(|sp| sp.overlaps(var_or_use_span)) {
121123
let path_label = "used here by closure";
122124
let capture_kind_label = message;
@@ -147,7 +149,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
147149
// path_span must be `Some` as otherwise the if condition is true
148150
let path_span = path_span.unwrap();
149151
// path_span is only present in the case of closure capture
150-
assert!(matches!(later_use_kind, LaterUseKind::ClosureCapture));
152+
assert_matches!(later_use_kind, LaterUseKind::ClosureCapture);
151153
if borrow_span.map(|sp| !sp.overlaps(var_or_use_span)).unwrap_or(true) {
152154
let path_label = "used here by closure";
153155
let capture_kind_label = message;

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+31-33
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::session_diagnostics::{
3535
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
3636
};
3737
use crate::universal_regions::DefiningTy;
38-
use crate::{borrowck_errors, MirBorrowckCtxt};
38+
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};
3939

4040
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
4141
fn description(&self) -> &'static str {
@@ -198,7 +198,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
198198
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
199199
// and the span which bounded to the trait for adding 'static lifetime suggestion
200200
#[allow(rustc::diagnostic_outside_of_impl)]
201-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
202201
fn suggest_static_lifetime_for_gat_from_hrtb(
203202
&self,
204203
diag: &mut Diag<'_>,
@@ -251,23 +250,28 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
251250
debug!(?hrtb_bounds);
252251

253252
hrtb_bounds.iter().for_each(|bound| {
254-
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
255-
diag.span_note(
256-
*trait_span,
257-
"due to current limitations in the borrow checker, this implies a `'static` lifetime"
258-
);
259-
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
260-
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
253+
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else {
254+
return;
255+
};
256+
diag.span_note(*trait_span, fluent::borrowck_limitations_implies_static);
257+
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local())
258+
else {
259+
return;
260+
};
261+
let Def(_, trait_res_defid) = trait_ref.path.res else {
262+
return;
263+
};
261264
debug!(?generics_fn);
262265
generics_fn.predicates.iter().for_each(|predicate| {
263-
let BoundPredicate(
264-
WhereBoundPredicate {
265-
span: bounded_span,
266-
bounded_ty,
267-
bounds,
268-
..
269-
}
270-
) = predicate else { return; };
266+
let BoundPredicate(WhereBoundPredicate {
267+
span: bounded_span,
268+
bounded_ty,
269+
bounds,
270+
..
271+
}) = predicate
272+
else {
273+
return;
274+
};
271275
bounds.iter().for_each(|bd| {
272276
if let Trait(PolyTraitRef { trait_ref: tr_ref, .. }, _) = bd
273277
&& let Def(_, res_defid) = tr_ref.path.res
@@ -277,16 +281,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
277281
&& generics_fn.params
278282
.iter()
279283
.rfind(|param| param.def_id.to_def_id() == defid)
280-
.is_some() {
281-
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
282-
}
284+
.is_some()
285+
{
286+
suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string()));
287+
}
283288
});
284289
});
285290
});
286291
if suggestions.len() > 0 {
287292
suggestions.dedup();
288293
diag.multipart_suggestion_verbose(
289-
"consider restricting the type parameter to the `'static` lifetime",
294+
fluent::borrowck_restrict_to_static,
290295
suggestions,
291296
Applicability::MaybeIncorrect,
292297
);
@@ -976,7 +981,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
976981
}
977982

978983
#[allow(rustc::diagnostic_outside_of_impl)]
979-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
980984
#[instrument(skip(self, err), level = "debug")]
981985
fn suggest_constrain_dyn_trait_in_impl(
982986
&self,
@@ -994,16 +998,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
994998
debug!("trait spans found: {:?}", traits);
995999
for span in &traits {
9961000
let mut multi_span: MultiSpan = vec![*span].into();
997-
multi_span
998-
.push_span_label(*span, "this has an implicit `'static` lifetime requirement");
999-
multi_span.push_span_label(
1000-
ident.span,
1001-
"calling this method introduces the `impl`'s `'static` requirement",
1002-
);
1001+
multi_span.push_span_label(*span, fluent::borrowck_implicit_static);
1002+
multi_span.push_span_label(ident.span, fluent::borrowck_implicit_static_introduced);
10031003
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
10041004
err.span_suggestion_verbose(
10051005
span.shrink_to_hi(),
1006-
"consider relaxing the implicit `'static` requirement",
1006+
fluent::borrowck_implicit_static_relax,
10071007
" + '_",
10081008
Applicability::MaybeIncorrect,
10091009
);
@@ -1045,7 +1045,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
10451045
}
10461046

10471047
#[allow(rustc::diagnostic_outside_of_impl)]
1048-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
10491048
/// When encountering a lifetime error caused by the return type of a closure, check the
10501049
/// corresponding trait bound and see if dereferencing the closure return value would satisfy
10511050
/// them. If so, we produce a structured suggestion.
@@ -1166,15 +1165,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11661165
if ocx.select_all_or_error().is_empty() && count > 0 {
11671166
diag.span_suggestion_verbose(
11681167
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
1169-
"dereference the return value",
1168+
fluent::borrowck_dereference_suggestion,
11701169
"*".repeat(count),
11711170
Applicability::MachineApplicable,
11721171
);
11731172
}
11741173
}
11751174

11761175
#[allow(rustc::diagnostic_outside_of_impl)]
1177-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
11781176
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
11791177
let map = self.infcx.tcx.hir();
11801178
let body = map.body_owned_by(self.mir_def_id());
@@ -1213,7 +1211,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
12131211
if let Some(closure_span) = closure_span {
12141212
diag.span_suggestion_verbose(
12151213
closure_span,
1216-
"consider adding 'move' keyword before the nested closure",
1214+
fluent::borrowck_move_closure_suggestion,
12171215
"move ",
12181216
Applicability::MaybeIncorrect,
12191217
);

0 commit comments

Comments
 (0)