Skip to content

Commit 794dc32

Browse files
authored
Merge pull request rust-lang#4467 from rust-lang/rustup-2025-07-14
Automatic Rustup
2 parents 91a52ca + 8812d74 commit 794dc32

File tree

526 files changed

+6168
-3999
lines changed

Some content is hidden

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

526 files changed

+6168
-3999
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ jobs:
152152
- name: show the current environment
153153
run: src/ci/scripts/dump-environment.sh
154154

155+
- name: install rust
156+
run: src/ci/scripts/install-rust.sh
157+
155158
- name: install awscli
156159
run: src/ci/scripts/install-awscli.sh
157160

Cargo.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4358,6 +4358,7 @@ dependencies = [
43584358
"rustc_ast_lowering",
43594359
"rustc_ast_pretty",
43604360
"rustc_attr_data_structures",
4361+
"rustc_attr_parsing",
43614362
"rustc_data_structures",
43624363
"rustc_errors",
43634364
"rustc_expand",
@@ -5250,9 +5251,9 @@ dependencies = [
52505251

52515252
[[package]]
52525253
name = "sysinfo"
5253-
version = "0.35.2"
5254+
version = "0.36.0"
52545255
source = "registry+https://github.com/rust-lang/crates.io-index"
5255-
checksum = "3c3ffa3e4ff2b324a57f7aeb3c349656c7b127c3c189520251a648102a92496e"
5256+
checksum = "aab138f5c1bb35231de19049060a87977ad23e04f2303e953bc5c2947ac7dec4"
52565257
dependencies = [
52575258
"libc",
52585259
"objc2-core-foundation",

compiler/rustc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ features = ['unprefixed_malloc_on_supported_platforms']
2727

2828
[features]
2929
# tidy-alphabetical-start
30+
check_only = ['rustc_driver_impl/check_only']
3031
jemalloc = ['dep:tikv-jemalloc-sys']
3132
llvm = ['rustc_driver_impl/llvm']
3233
max_level_info = ['rustc_driver_impl/max_level_info']

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use rustc_errors::ErrorGuaranteed;
4747
use rustc_hir::def_id::DefId;
4848
use rustc_middle::span_bug;
4949
use rustc_middle::ty::{Asyncness, ResolverAstLowering};
50+
use rustc_span::symbol::kw;
5051
use rustc_span::{Ident, Span, Symbol};
5152
use {rustc_ast as ast, rustc_hir as hir};
5253

@@ -61,21 +62,6 @@ pub(crate) struct DelegationResults<'hir> {
6162
}
6263

6364
impl<'hir> LoweringContext<'_, 'hir> {
64-
/// Defines whether the delegatee is an associated function whose first parameter is `self`.
65-
pub(crate) fn delegatee_is_method(
66-
&self,
67-
item_id: NodeId,
68-
path_id: NodeId,
69-
span: Span,
70-
is_in_trait_impl: bool,
71-
) -> bool {
72-
let sig_id = self.get_delegation_sig_id(item_id, path_id, span, is_in_trait_impl);
73-
let Ok(sig_id) = sig_id else {
74-
return false;
75-
};
76-
self.is_method(sig_id, span)
77-
}
78-
7965
fn is_method(&self, def_id: DefId, span: Span) -> bool {
8066
match self.tcx.def_kind(def_id) {
8167
DefKind::Fn => false,
@@ -101,10 +87,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
10187
let sig_id = self.get_delegation_sig_id(item_id, delegation.id, span, is_in_trait_impl);
10288
match sig_id {
10389
Ok(sig_id) => {
90+
let is_method = self.is_method(sig_id, span);
10491
let (param_count, c_variadic) = self.param_count(sig_id);
10592
let decl = self.lower_delegation_decl(sig_id, param_count, c_variadic, span);
10693
let sig = self.lower_delegation_sig(sig_id, decl, span);
107-
let body_id = self.lower_delegation_body(delegation, param_count, span);
94+
let body_id = self.lower_delegation_body(delegation, is_method, param_count, span);
10895
let ident = self.lower_ident(delegation.ident);
10996
let generics = self.lower_delegation_generics(span);
11097
DelegationResults { body_id, sig, ident, generics }
@@ -234,10 +221,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
234221
hir::FnSig { decl, header, span }
235222
}
236223

237-
fn generate_param(&mut self, idx: usize, span: Span) -> (hir::Param<'hir>, NodeId) {
224+
fn generate_param(
225+
&mut self,
226+
is_method: bool,
227+
idx: usize,
228+
span: Span,
229+
) -> (hir::Param<'hir>, NodeId) {
238230
let pat_node_id = self.next_node_id();
239231
let pat_id = self.lower_node_id(pat_node_id);
240-
let ident = Ident::with_dummy_span(Symbol::intern(&format!("arg{idx}")));
232+
// FIXME(cjgillot) AssocItem currently relies on self parameter being exactly named `self`.
233+
let name = if is_method && idx == 0 {
234+
kw::SelfLower
235+
} else {
236+
Symbol::intern(&format!("arg{idx}"))
237+
};
238+
let ident = Ident::with_dummy_span(name);
241239
let pat = self.arena.alloc(hir::Pat {
242240
hir_id: pat_id,
243241
kind: hir::PatKind::Binding(hir::BindingMode::NONE, pat_id, ident, None),
@@ -248,9 +246,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
248246
(hir::Param { hir_id: self.next_id(), pat, ty_span: span, span }, pat_node_id)
249247
}
250248

251-
fn generate_arg(&mut self, idx: usize, param_id: HirId, span: Span) -> hir::Expr<'hir> {
249+
fn generate_arg(
250+
&mut self,
251+
is_method: bool,
252+
idx: usize,
253+
param_id: HirId,
254+
span: Span,
255+
) -> hir::Expr<'hir> {
256+
// FIXME(cjgillot) AssocItem currently relies on self parameter being exactly named `self`.
257+
let name = if is_method && idx == 0 {
258+
kw::SelfLower
259+
} else {
260+
Symbol::intern(&format!("arg{idx}"))
261+
};
252262
let segments = self.arena.alloc_from_iter(iter::once(hir::PathSegment {
253-
ident: Ident::with_dummy_span(Symbol::intern(&format!("arg{idx}"))),
263+
ident: Ident::with_dummy_span(name),
254264
hir_id: self.next_id(),
255265
res: Res::Local(param_id),
256266
args: None,
@@ -264,6 +274,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
264274
fn lower_delegation_body(
265275
&mut self,
266276
delegation: &Delegation,
277+
is_method: bool,
267278
param_count: usize,
268279
span: Span,
269280
) -> BodyId {
@@ -274,7 +285,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
274285
let mut args: Vec<hir::Expr<'_>> = Vec::with_capacity(param_count);
275286

276287
for idx in 0..param_count {
277-
let (param, pat_node_id) = this.generate_param(idx, span);
288+
let (param, pat_node_id) = this.generate_param(is_method, idx, span);
278289
parameters.push(param);
279290

280291
let arg = if let Some(block) = block
@@ -290,7 +301,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
290301
this.ident_and_label_to_local_id.insert(pat_node_id, param.pat.hir_id.local_id);
291302
this.lower_target_expr(&block)
292303
} else {
293-
this.generate_arg(idx, param.pat.hir_id, span)
304+
this.generate_arg(is_method, idx, param.pat.hir_id, span)
294305
};
295306
args.push(arg);
296307
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
528528
then: &Block,
529529
else_opt: Option<&Expr>,
530530
) -> hir::ExprKind<'hir> {
531-
let lowered_cond = self.lower_cond(cond);
531+
let lowered_cond = self.lower_expr(cond);
532532
let then_expr = self.lower_block_expr(then);
533533
if let Some(rslt) = else_opt {
534534
hir::ExprKind::If(
@@ -541,44 +541,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
541541
}
542542
}
543543

544-
// Lowers a condition (i.e. `cond` in `if cond` or `while cond`), wrapping it in a terminating scope
545-
// so that temporaries created in the condition don't live beyond it.
546-
fn lower_cond(&mut self, cond: &Expr) -> &'hir hir::Expr<'hir> {
547-
fn has_let_expr(expr: &Expr) -> bool {
548-
match &expr.kind {
549-
ExprKind::Binary(_, lhs, rhs) => has_let_expr(lhs) || has_let_expr(rhs),
550-
ExprKind::Let(..) => true,
551-
_ => false,
552-
}
553-
}
554-
555-
// We have to take special care for `let` exprs in the condition, e.g. in
556-
// `if let pat = val` or `if foo && let pat = val`, as we _do_ want `val` to live beyond the
557-
// condition in this case.
558-
//
559-
// In order to maintain the drop behavior for the non `let` parts of the condition,
560-
// we still wrap them in terminating scopes, e.g. `if foo && let pat = val` essentially
561-
// gets transformed into `if { let _t = foo; _t } && let pat = val`
562-
match &cond.kind {
563-
ExprKind::Binary(op @ Spanned { node: ast::BinOpKind::And, .. }, lhs, rhs)
564-
if has_let_expr(cond) =>
565-
{
566-
let op = self.lower_binop(*op);
567-
let lhs = self.lower_cond(lhs);
568-
let rhs = self.lower_cond(rhs);
569-
570-
self.arena.alloc(self.expr(cond.span, hir::ExprKind::Binary(op, lhs, rhs)))
571-
}
572-
ExprKind::Let(..) => self.lower_expr(cond),
573-
_ => {
574-
let cond = self.lower_expr(cond);
575-
let reason = DesugaringKind::CondTemporary;
576-
let span_block = self.mark_span_with_reason(reason, cond.span, None);
577-
self.expr_drop_temps(span_block, cond)
578-
}
579-
}
580-
}
581-
582544
// We desugar: `'label: while $cond $body` into:
583545
//
584546
// ```
@@ -602,7 +564,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
602564
body: &Block,
603565
opt_label: Option<Label>,
604566
) -> hir::ExprKind<'hir> {
605-
let lowered_cond = self.with_loop_condition_scope(|t| t.lower_cond(cond));
567+
let lowered_cond = self.with_loop_condition_scope(|t| t.lower_expr(cond));
606568
let then = self.lower_block_expr(body);
607569
let expr_break = self.expr_break(span);
608570
let stmt_break = self.stmt_expr(span, expr_break);
@@ -2091,7 +2053,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
20912053
/// In terms of drop order, it has the same effect as wrapping `expr` in
20922054
/// `{ let _t = $expr; _t }` but should provide better compile-time performance.
20932055
///
2094-
/// The drop order can be important in e.g. `if expr { .. }`.
2056+
/// The drop order can be important, e.g. to drop temporaries from an `async fn`
2057+
/// body before its parameters.
20952058
pub(super) fn expr_drop_temps(
20962059
&mut self,
20972060
span: Span,

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -381,28 +381,16 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
381381
})
382382
}
383383

384-
fn visit_trait_item_ref(&mut self, ii: &'hir TraitItemRef) {
385-
// Do not visit the duplicate information in TraitItemRef. We want to
386-
// map the actual nodes, not the duplicate ones in the *Ref.
387-
let TraitItemRef { id, ident: _, kind: _, span: _ } = *ii;
388-
389-
self.visit_nested_trait_item(id);
384+
fn visit_trait_item_ref(&mut self, id: &'hir TraitItemId) {
385+
self.visit_nested_trait_item(*id);
390386
}
391387

392-
fn visit_impl_item_ref(&mut self, ii: &'hir ImplItemRef) {
393-
// Do not visit the duplicate information in ImplItemRef. We want to
394-
// map the actual nodes, not the duplicate ones in the *Ref.
395-
let ImplItemRef { id, ident: _, kind: _, span: _, trait_item_def_id: _ } = *ii;
396-
397-
self.visit_nested_impl_item(id);
388+
fn visit_impl_item_ref(&mut self, id: &'hir ImplItemId) {
389+
self.visit_nested_impl_item(*id);
398390
}
399391

400-
fn visit_foreign_item_ref(&mut self, fi: &'hir ForeignItemRef) {
401-
// Do not visit the duplicate information in ForeignItemRef. We want to
402-
// map the actual nodes, not the duplicate ones in the *Ref.
403-
let ForeignItemRef { id, ident: _, span: _ } = *fi;
404-
405-
self.visit_nested_foreign_item(id);
392+
fn visit_foreign_item_ref(&mut self, id: &'hir ForeignItemId) {
393+
self.visit_nested_foreign_item(*id);
406394
}
407395

408396
fn visit_where_predicate(&mut self, predicate: &'hir WherePredicate<'hir>) {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 13 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
393393
(trait_ref, lowered_ty)
394394
});
395395

396-
let new_impl_items = self.arena.alloc_from_iter(
397-
impl_items
398-
.iter()
399-
.map(|item| self.lower_impl_item_ref(item, trait_ref.is_some())),
400-
);
396+
let new_impl_items = self
397+
.arena
398+
.alloc_from_iter(impl_items.iter().map(|item| self.lower_impl_item_ref(item)));
401399

402400
// `defaultness.has_value()` is never called for an `impl`, always `true` in order
403401
// to not cause an assertion failure inside the `lower_defaultness` function.
@@ -706,14 +704,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
706704
self.arena.alloc(item)
707705
}
708706

709-
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef {
710-
hir::ForeignItemRef {
711-
id: hir::ForeignItemId { owner_id: self.owner_id(i.id) },
712-
// `unwrap` is safe because `ForeignItemKind::MacCall` is the only foreign item kind
713-
// without an identifier and it cannot reach here.
714-
ident: self.lower_ident(i.kind.ident().unwrap()),
715-
span: self.lower_span(i.span),
716-
}
707+
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemId {
708+
hir::ForeignItemId { owner_id: self.owner_id(i.id) }
717709
}
718710

719711
fn lower_variant(&mut self, item_kind: &ItemKind, v: &Variant) -> hir::Variant<'hir> {
@@ -972,32 +964,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
972964
self.arena.alloc(item)
973965
}
974966

975-
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
976-
let (ident, kind) = match &i.kind {
977-
AssocItemKind::Const(box ConstItem { ident, .. }) => {
978-
(*ident, hir::AssocItemKind::Const)
979-
}
980-
AssocItemKind::Type(box TyAlias { ident, .. }) => (*ident, hir::AssocItemKind::Type),
981-
AssocItemKind::Fn(box Fn { ident, sig, .. }) => {
982-
(*ident, hir::AssocItemKind::Fn { has_self: sig.decl.has_self() })
983-
}
984-
AssocItemKind::Delegation(box delegation) => (
985-
delegation.ident,
986-
hir::AssocItemKind::Fn {
987-
has_self: self.delegatee_is_method(i.id, delegation.id, i.span, false),
988-
},
989-
),
990-
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
991-
panic!("macros should have been expanded by now")
992-
}
993-
};
994-
let id = hir::TraitItemId { owner_id: self.owner_id(i.id) };
995-
hir::TraitItemRef {
996-
id,
997-
ident: self.lower_ident(ident),
998-
span: self.lower_span(i.span),
999-
kind,
1000-
}
967+
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemId {
968+
hir::TraitItemId { owner_id: self.owner_id(i.id) }
1001969
}
1002970

1003971
/// Construct `ExprKind::Err` for the given `span`.
@@ -1128,41 +1096,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
11281096
span: self.lower_span(i.span),
11291097
defaultness,
11301098
has_delayed_lints: !self.delayed_lints.is_empty(),
1131-
};
1132-
self.arena.alloc(item)
1133-
}
1134-
1135-
fn lower_impl_item_ref(&mut self, i: &AssocItem, is_in_trait_impl: bool) -> hir::ImplItemRef {
1136-
hir::ImplItemRef {
1137-
id: hir::ImplItemId { owner_id: self.owner_id(i.id) },
1138-
// `unwrap` is safe because `AssocItemKind::{MacCall,DelegationMac}` are the only
1139-
// assoc item kinds without an identifier and they cannot reach here.
1140-
ident: self.lower_ident(i.kind.ident().unwrap()),
1141-
span: self.lower_span(i.span),
1142-
kind: match &i.kind {
1143-
AssocItemKind::Const(..) => hir::AssocItemKind::Const,
1144-
AssocItemKind::Type(..) => hir::AssocItemKind::Type,
1145-
AssocItemKind::Fn(box Fn { sig, .. }) => {
1146-
hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }
1147-
}
1148-
AssocItemKind::Delegation(box delegation) => hir::AssocItemKind::Fn {
1149-
has_self: self.delegatee_is_method(
1150-
i.id,
1151-
delegation.id,
1152-
i.span,
1153-
is_in_trait_impl,
1154-
),
1155-
},
1156-
AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
1157-
panic!("macros should have been expanded by now")
1158-
}
1159-
},
11601099
trait_item_def_id: self
11611100
.resolver
11621101
.get_partial_res(i.id)
11631102
.map(|r| r.expect_full_res().opt_def_id())
11641103
.unwrap_or(None),
1165-
}
1104+
};
1105+
self.arena.alloc(item)
1106+
}
1107+
1108+
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemId {
1109+
hir::ImplItemId { owner_id: self.owner_id(i.id) }
11661110
}
11671111

11681112
fn lower_defaultness(

0 commit comments

Comments
 (0)