Skip to content

Commit 2bb72b2

Browse files
authored
Merge branch 'master' into enzyme-backend
2 parents 0aeaeb9 + 79f5c16 commit 2bb72b2

File tree

1,013 files changed

+15133
-9323
lines changed

Some content is hidden

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

1,013 files changed

+15133
-9323
lines changed

.github/workflows/dependencies.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: cargo update rustbook
6868
run: |
6969
echo -e "\nrustbook dependencies:" >> cargo_update.log
70-
cargo update --manifest-path src/tools/rustbook 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
70+
cargo update --manifest-path src/tools/rustbook/Cargo.toml 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
7171
- name: upload Cargo.lock artifact for use in PR
7272
uses: actions/upload-artifact@v4
7373
with:

Cargo.lock

+3-2
Original file line numberDiff line numberDiff line change
@@ -1775,9 +1775,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
17751775

17761776
[[package]]
17771777
name = "indexmap"
1778-
version = "2.2.6"
1778+
version = "2.4.0"
17791779
source = "registry+https://github.com/rust-lang/crates.io-index"
1780-
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
1780+
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
17811781
dependencies = [
17821782
"equivalent",
17831783
"hashbrown",
@@ -3149,6 +3149,7 @@ dependencies = [
31493149
"gimli 0.31.0",
31503150
"object 0.36.2",
31513151
"regex",
3152+
"serde_json",
31523153
"similar",
31533154
"wasmparser 0.214.0",
31543155
]

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

+10
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,21 @@ 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_label_operands =
179+
label operands for inline assembly are unstable
180+
ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
181+
174182
ast_lowering_use_angle_brackets = use angle brackets instead
183+
184+
ast_lowering_yield = yield syntax is experimental
175185
ast_lowering_yield_in_closure =
176186
`yield` can only be used in `#[coroutine]` closures, or `gen` blocks
177187
.suggestion = use `#[coroutine]` to make this closure a coroutine

compiler/rustc_ast_lowering/src/asm.rs

+16-20
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();
@@ -176,20 +183,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
176183
out_expr: out_expr.as_ref().map(|expr| self.lower_expr(expr)),
177184
}
178185
}
179-
InlineAsmOperand::Const { anon_const } => {
180-
if !self.tcx.features().asm_const {
181-
feature_err(
182-
sess,
183-
sym::asm_const,
184-
*op_sp,
185-
"const operands for inline assembly are unstable",
186-
)
187-
.emit();
188-
}
189-
hir::InlineAsmOperand::Const {
190-
anon_const: self.lower_anon_const_to_anon_const(anon_const),
191-
}
192-
}
186+
InlineAsmOperand::Const { anon_const } => hir::InlineAsmOperand::Const {
187+
anon_const: self.lower_anon_const_to_anon_const(anon_const),
188+
},
193189
InlineAsmOperand::Sym { sym } => {
194190
let static_def_id = self
195191
.resolver
@@ -246,7 +242,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
246242
sess,
247243
sym::asm_goto,
248244
*op_sp,
249-
"label operands for inline assembly are unstable",
245+
fluent::ast_lowering_unstable_inline_assembly_label_operands,
250246
)
251247
.emit();
252248
}

compiler/rustc_ast_lowering/src/delegation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
189189
) -> hir::FnSig<'hir> {
190190
let header = if let Some(local_sig_id) = sig_id.as_local() {
191191
match self.resolver.delegation_fn_sigs.get(&local_sig_id) {
192-
Some(sig) => self.lower_fn_header(sig.header),
192+
Some(sig) => self.lower_fn_header(sig.header, hir::Safety::Safe),
193193
None => self.generate_header_error(),
194194
}
195195
} else {
@@ -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/item.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
237237
});
238238
let sig = hir::FnSig {
239239
decl,
240-
header: this.lower_fn_header(*header),
240+
header: this.lower_fn_header(*header, hir::Safety::Safe),
241241
span: this.lower_span(*fn_sig_span),
242242
};
243243
hir::ItemKind::Fn(sig, generics, body_id)
@@ -668,7 +668,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
668668
ForeignItemKind::Fn(box Fn { sig, generics, .. }) => {
669669
let fdec = &sig.decl;
670670
let itctx = ImplTraitContext::Universal;
671-
let (generics, (fn_dec, fn_args)) =
671+
let (generics, (decl, fn_args)) =
672672
self.lower_generics(generics, Const::No, false, i.id, itctx, |this| {
673673
(
674674
// Disallow `impl Trait` in foreign items.
@@ -682,9 +682,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
682682
this.lower_fn_params_to_names(fdec),
683683
)
684684
});
685-
let safety = self.lower_safety(sig.header.safety, hir::Safety::Unsafe);
686685

687-
hir::ForeignItemKind::Fn(fn_dec, fn_args, generics, safety)
686+
// Unmarked safety in unsafe block defaults to unsafe.
687+
let header = self.lower_fn_header(sig.header, hir::Safety::Unsafe);
688+
689+
hir::ForeignItemKind::Fn(
690+
hir::FnSig { header, decl, span: self.lower_span(sig.span) },
691+
fn_args,
692+
generics,
693+
)
688694
}
689695
ForeignItemKind::Static(box StaticItem { ty, mutability, expr: _, safety }) => {
690696
let ty = self
@@ -1390,7 +1396,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13901396
coroutine_kind: Option<CoroutineKind>,
13911397
parent_constness: Const,
13921398
) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) {
1393-
let header = self.lower_fn_header(sig.header);
1399+
let header = self.lower_fn_header(sig.header, hir::Safety::Safe);
13941400
// Don't pass along the user-provided constness of trait associated functions; we don't want to
13951401
// synthesize a host effect param for them. We reject `const` on them during AST validation.
13961402
let constness =
@@ -1403,14 +1409,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
14031409
(generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })
14041410
}
14051411

1406-
pub(super) fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
1412+
pub(super) fn lower_fn_header(
1413+
&mut self,
1414+
h: FnHeader,
1415+
default_safety: hir::Safety,
1416+
) -> hir::FnHeader {
14071417
let asyncness = if let Some(CoroutineKind::Async { span, .. }) = h.coroutine_kind {
14081418
hir::IsAsync::Async(span)
14091419
} else {
14101420
hir::IsAsync::NotAsync
14111421
};
14121422
hir::FnHeader {
1413-
safety: self.lower_safety(h.safety, hir::Safety::Safe),
1423+
safety: self.lower_safety(h.safety, default_safety),
14141424
asyncness: asyncness,
14151425
constness: self.lower_constness(h.constness),
14161426
abi: self.lower_extern(h.ext),

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_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
887887

888888
impl<'a> Visitor<'a> for AstValidator<'a> {
889889
fn visit_attribute(&mut self, attr: &Attribute) {
890-
validate_attr::check_attr(&self.features, &self.session.psess, attr);
890+
validate_attr::check_attr(&self.session.psess, attr);
891891
}
892892

893893
fn visit_ty(&mut self, ty: &'a Ty) {

compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
559559
gate_all!(mut_ref, "mutable by-reference bindings are experimental");
560560
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
561561
gate_all!(global_registration, "global registration is experimental");
562-
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
563562
gate_all!(return_type_notation, "return type notation is experimental");
564563

565564
if !visitor.features.never_patterns {

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 =

0 commit comments

Comments
 (0)