Skip to content

Commit 30aab08

Browse files
committed
Merge branch 'master' into rust-lld-with-runtime-dlls
2 parents 7fbb1cb + 80eb5a8 commit 30aab08

File tree

918 files changed

+12480
-8471
lines changed

Some content is hidden

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

918 files changed

+12480
-8471
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Session.vim
2020
.vscode
2121
.project
2222
.vim/
23+
.helix/
24+
.zed/
2325
.favorites.json
2426
.settings/
2527
.vs/

Cargo.lock

+6-5
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,15 @@ dependencies = [
564564
"termize",
565565
"tokio",
566566
"toml 0.7.8",
567-
"ui_test 0.24.0",
567+
"ui_test 0.25.0",
568568
"walkdir",
569569
]
570570

571571
[[package]]
572572
name = "clippy_config"
573573
version = "0.1.82"
574574
dependencies = [
575+
"itertools",
575576
"rustc-semver",
576577
"serde",
577578
"toml 0.7.8",
@@ -4936,9 +4937,9 @@ dependencies = [
49364937

49374938
[[package]]
49384939
name = "spanned"
4939-
version = "0.2.1"
4940+
version = "0.3.0"
49404941
source = "registry+https://github.com/rust-lang/crates.io-index"
4941-
checksum = "ed14ba8b4b82241bd5daba2c49185d4a0581a0058355fe96537338f002b8605d"
4942+
checksum = "86af297923fbcfd107c20a189a6e9c872160df71a7190ae4a7a6c5dce4b2feb6"
49424943
dependencies = [
49434944
"bstr",
49444945
"color-eyre",
@@ -5562,9 +5563,9 @@ dependencies = [
55625563

55635564
[[package]]
55645565
name = "ui_test"
5565-
version = "0.24.0"
5566+
version = "0.25.0"
55665567
source = "registry+https://github.com/rust-lang/crates.io-index"
5567-
checksum = "bc1c6c78d55482388711c8d417b8e547263046a607512278fed274c54633bbe4"
5568+
checksum = "f7e4f339f62edc873975c47115f9e71c5454ddaa37c1142b42fc0b2672c8dacb"
55685569
dependencies = [
55695570
"annotate-snippets 0.11.4",
55705571
"anyhow",

compiler/rustc/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
2+
#![feature(rustc_private)]
3+
14
// A note about jemalloc: rustc uses jemalloc when built for CI and
25
// distribution. The obvious way to do this is with the `#[global_allocator]`
36
// mechanism. However, for complicated reasons (see

compiler/rustc_ast/src/ast.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ impl Pat {
585585
}
586586
// A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array,
587587
// when `P` can be reparsed as a type `T`.
588-
PatKind::Slice(pats) if pats.len() == 1 => pats[0].to_ty().map(TyKind::Slice)?,
588+
PatKind::Slice(pats) if let [pat] = pats.as_slice() => {
589+
pat.to_ty().map(TyKind::Slice)?
590+
}
589591
// A tuple pattern `(P0, .., Pn)` can be reparsed as `(T0, .., Tn)`
590592
// assuming `T0` to `Tn` are all syntactically valid as types.
591593
PatKind::Tuple(pats) => {
@@ -1187,8 +1189,8 @@ impl Expr {
11871189
/// Does not ensure that the path resolves to a const param, the caller should check this.
11881190
pub fn is_potential_trivial_const_arg(&self) -> bool {
11891191
let this = if let ExprKind::Block(block, None) = &self.kind
1190-
&& block.stmts.len() == 1
1191-
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
1192+
&& let [stmt] = block.stmts.as_slice()
1193+
&& let StmtKind::Expr(expr) = &stmt.kind
11921194
{
11931195
expr
11941196
} else {
@@ -1248,7 +1250,9 @@ impl Expr {
12481250
expr.to_ty().map(|ty| TyKind::Array(ty, expr_len.clone()))?
12491251
}
12501252

1251-
ExprKind::Array(exprs) if exprs.len() == 1 => exprs[0].to_ty().map(TyKind::Slice)?,
1253+
ExprKind::Array(exprs) if let [expr] = exprs.as_slice() => {
1254+
expr.to_ty().map(TyKind::Slice)?
1255+
}
12521256

12531257
ExprKind::Tup(exprs) => {
12541258
let tys = exprs.iter().map(|expr| expr.to_ty()).collect::<Option<ThinVec<_>>>()?;

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/delegation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
275275
// FIXME(fn_delegation): Alternatives for target expression lowering:
276276
// https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2197170600.
277277
fn lower_target_expr(&mut self, block: &Block) -> hir::Expr<'hir> {
278-
if block.stmts.len() == 1
279-
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
278+
if let [stmt] = block.stmts.as_slice()
279+
&& let StmtKind::Expr(expr) = &stmt.kind
280280
{
281281
return self.lower_expr_mut(expr);
282282
}

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_ast_pretty/src/pprust/state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
502502
if !self.is_beginning_of_line() {
503503
self.word(" ");
504504
}
505-
if cmnt.lines.len() == 1 {
506-
self.word(cmnt.lines[0].clone());
505+
if let [line] = cmnt.lines.as_slice() {
506+
self.word(line.clone());
507507
self.hardbreak()
508508
} else {
509509
self.visual_align();

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ impl<'a> State<'a> {
783783
}
784784
if items.is_empty() {
785785
self.word("{}");
786-
} else if items.len() == 1 {
787-
self.print_use_tree(&items[0].0);
786+
} else if let [(item, _)] = items.as_slice() {
787+
self.print_use_tree(item);
788788
} else {
789789
self.cbox(INDENT_UNIT);
790790
self.word("{");

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

+9-10
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,
@@ -665,12 +664,12 @@ pub fn eval_condition(
665664
res & eval_condition(mi.meta_item().unwrap(), sess, features, eval)
666665
}),
667666
sym::not => {
668-
if mis.len() != 1 {
667+
let [mi] = mis.as_slice() else {
669668
dcx.emit_err(session_diagnostics::ExpectedOneCfgPattern { span: cfg.span });
670669
return false;
671-
}
670+
};
672671

673-
!eval_condition(mis[0].meta_item().unwrap(), sess, features, eval)
672+
!eval_condition(mi.meta_item().unwrap(), sess, features, eval)
674673
}
675674
sym::target => {
676675
if let Some(features) = features
@@ -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
}
@@ -1051,10 +1050,10 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
10511050
MetaItemKind::List(nested_items) => {
10521051
if meta_item.has_name(sym::align) {
10531052
recognised = true;
1054-
if nested_items.len() == 1 {
1053+
if let [nested_item] = nested_items.as_slice() {
10551054
sess.dcx().emit_err(
10561055
session_diagnostics::IncorrectReprFormatExpectInteger {
1057-
span: nested_items[0].span(),
1056+
span: nested_item.span(),
10581057
},
10591058
);
10601059
} else {
@@ -1066,10 +1065,10 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
10661065
}
10671066
} else if meta_item.has_name(sym::packed) {
10681067
recognised = true;
1069-
if nested_items.len() == 1 {
1068+
if let [nested_item] = nested_items.as_slice() {
10701069
sess.dcx().emit_err(
10711070
session_diagnostics::IncorrectReprFormatPackedExpectInteger {
1072-
span: nested_items[0].span(),
1071+
span: nested_item.span(),
10731072
},
10741073
);
10751074
} else {

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/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11241124
err.multipart_suggestion(
11251125
"consider moving the expression out of the loop so it is only moved once",
11261126
vec![
1127-
(parent.span, "value".to_string()),
11281127
(span.shrink_to_lo(), format!("let mut value = {value};{indent}")),
1128+
(parent.span, "value".to_string()),
11291129
],
11301130
Applicability::MaybeIncorrect,
11311131
);

0 commit comments

Comments
 (0)