Skip to content

Commit 9cb215a

Browse files
authored
Merge pull request rust-lang#4656 from rust-lang/rustup-2025-10-30
Automatic Rustup
2 parents 8fef16e + 3048ef2 commit 9cb215a

File tree

664 files changed

+15659
-17461
lines changed

Some content is hidden

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

664 files changed

+15659
-17461
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ Valerii Lashmanov <[email protected]>
680680
Vitali Haravy <[email protected]> Vitali Haravy <[email protected]>
681681
Vitaly Shukela <[email protected]>
682682
Waffle Lapkin <[email protected]>
683+
Waffle Lapkin <[email protected]> <Waffle Lapkin>
683684
684685
Weihang Lo <[email protected]>
685686

Cargo.lock

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
7575
checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4"
7676
dependencies = [
7777
"anstyle",
78-
"unicode-width 0.2.1",
78+
"unicode-width 0.2.2",
79+
]
80+
81+
[[package]]
82+
name = "annotate-snippets"
83+
version = "0.12.7"
84+
source = "registry+https://github.com/rust-lang/crates.io-index"
85+
checksum = "47224528f74de27d1d06aad6a5dda4f865b6ebe2e56c538943d746a7270cb67e"
86+
dependencies = [
87+
"anstyle",
88+
"unicode-width 0.2.2",
7989
]
8090

8191
[[package]]
@@ -136,7 +146,7 @@ dependencies = [
136146
"anstyle-lossy",
137147
"anstyle-parse",
138148
"html-escape",
139-
"unicode-width 0.2.1",
149+
"unicode-width 0.2.2",
140150
]
141151

142152
[[package]]
@@ -464,10 +474,11 @@ version = "0.1.0"
464474

465475
[[package]]
466476
name = "cc"
467-
version = "1.2.16"
477+
version = "1.2.39"
468478
source = "registry+https://github.com/rust-lang/crates.io-index"
469-
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
479+
checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f"
470480
dependencies = [
481+
"find-msvc-tools",
471482
"jobserver",
472483
"libc",
473484
"shlex",
@@ -677,7 +688,7 @@ checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
677688
dependencies = [
678689
"serde",
679690
"termcolor",
680-
"unicode-width 0.2.1",
691+
"unicode-width 0.2.2",
681692
]
682693

683694
[[package]]
@@ -808,7 +819,7 @@ dependencies = [
808819
"encode_unicode",
809820
"libc",
810821
"once_cell",
811-
"unicode-width 0.2.1",
822+
"unicode-width 0.2.2",
812823
"windows-sys 0.59.0",
813824
]
814825

@@ -1485,7 +1496,7 @@ version = "0.2.24"
14851496
source = "registry+https://github.com/rust-lang/crates.io-index"
14861497
checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df"
14871498
dependencies = [
1488-
"unicode-width 0.2.1",
1499+
"unicode-width 0.2.2",
14891500
]
14901501

14911502
[[package]]
@@ -1887,7 +1898,7 @@ dependencies = [
18871898
"console",
18881899
"number_prefix",
18891900
"portable-atomic",
1890-
"unicode-width 0.2.1",
1901+
"unicode-width 0.2.2",
18911902
"web-time",
18921903
]
18931904

@@ -3756,7 +3767,7 @@ dependencies = [
37563767
name = "rustc_errors"
37573768
version = "0.0.0"
37583769
dependencies = [
3759-
"annotate-snippets 0.11.5",
3770+
"annotate-snippets 0.12.7",
37603771
"anstream",
37613772
"anstyle",
37623773
"derive_setters",
@@ -4331,7 +4342,7 @@ dependencies = [
43314342
"thin-vec",
43324343
"tracing",
43334344
"unicode-normalization",
4334-
"unicode-width 0.2.1",
4345+
"unicode-width 0.2.2",
43354346
]
43364347

43374348
[[package]]
@@ -4590,7 +4601,7 @@ dependencies = [
45904601
"sha1",
45914602
"sha2",
45924603
"tracing",
4593-
"unicode-width 0.2.1",
4604+
"unicode-width 0.2.2",
45944605
]
45954606

45964607
[[package]]
@@ -5936,9 +5947,9 @@ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
59365947

59375948
[[package]]
59385949
name = "unicode-width"
5939-
version = "0.2.1"
5950+
version = "0.2.2"
59405951
source = "registry+https://github.com/rust-lang/crates.io-index"
5941-
checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c"
5952+
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
59425953

59435954
[[package]]
59445955
name = "unicode-xid"
@@ -6223,7 +6234,7 @@ dependencies = [
62236234
"bumpalo",
62246235
"leb128fmt",
62256236
"memchr",
6226-
"unicode-width 0.2.1",
6237+
"unicode-width 0.2.2",
62276238
"wasm-encoder 0.240.0",
62286239
]
62296240

RELEASES.md

Lines changed: 211 additions & 0 deletions
Large diffs are not rendered by default.

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,9 @@ pub struct TraitImplHeader {
36803680

36813681
#[derive(Clone, Encodable, Decodable, Debug, Default, Walkable)]
36823682
pub struct FnContract {
3683+
/// Declarations of variables accessible both in the `requires` and
3684+
/// `ensures` clauses.
3685+
pub declarations: ThinVec<Stmt>,
36833686
pub requires: Option<Box<Expr>>,
36843687
pub ensures: Option<Box<Expr>>,
36853688
}

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2727
hir::Block { hir_id, stmts, expr, rules, span: self.lower_span(b.span), targeted_by_break }
2828
}
2929

30-
fn lower_stmts(
30+
pub(super) fn lower_stmts(
3131
&mut self,
3232
mut ast_stmts: &[Stmt],
3333
) -> (&'hir [hir::Stmt<'hir>], Option<&'hir hir::Expr<'hir>>) {

compiler/rustc_ast_lowering/src/contract.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1818
body: impl FnOnce(&mut Self) -> rustc_hir::Expr<'hir>,
1919
contract: &rustc_ast::FnContract,
2020
) -> rustc_hir::Expr<'hir> {
21+
// The order in which things are lowered is important! I.e to
22+
// refer to variables in contract_decls from postcond/precond,
23+
// we must lower it first!
24+
let contract_decls = self.lower_stmts(&contract.declarations).0;
25+
2126
match (&contract.requires, &contract.ensures) {
2227
(Some(req), Some(ens)) => {
2328
// Lower the fn contract, which turns:
@@ -27,6 +32,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2732
// into:
2833
//
2934
// let __postcond = if contract_checks {
35+
// CONTRACT_DECLARATIONS;
3036
// contract_check_requires(PRECOND);
3137
// Some(|ret_val| POSTCOND)
3238
// } else {
@@ -45,8 +51,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
4551
let precond = self.lower_precond(req);
4652
let postcond_checker = self.lower_postcond_checker(ens);
4753

48-
let contract_check =
49-
self.lower_contract_check_with_postcond(Some(precond), postcond_checker);
54+
let contract_check = self.lower_contract_check_with_postcond(
55+
contract_decls,
56+
Some(precond),
57+
postcond_checker,
58+
);
5059

5160
let wrapped_body =
5261
self.wrap_body_with_contract_check(body, contract_check, postcond_checker.span);
@@ -68,15 +77,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6877
// let ret = { body };
6978
//
7079
// if contract_checks {
80+
// CONTRACT_DECLARATIONS;
7181
// contract_check_ensures(__postcond, ret)
7282
// } else {
7383
// ret
7484
// }
7585
// }
76-
7786
let postcond_checker = self.lower_postcond_checker(ens);
7887
let contract_check =
79-
self.lower_contract_check_with_postcond(None, postcond_checker);
88+
self.lower_contract_check_with_postcond(contract_decls, None, postcond_checker);
8089

8190
let wrapped_body =
8291
self.wrap_body_with_contract_check(body, contract_check, postcond_checker.span);
@@ -91,12 +100,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
91100
//
92101
// {
93102
// if contracts_checks {
103+
// CONTRACT_DECLARATIONS;
94104
// contract_requires(PRECOND);
95105
// }
96106
// body
97107
// }
98108
let precond = self.lower_precond(req);
99-
let precond_check = self.lower_contract_check_just_precond(precond);
109+
let precond_check = self.lower_contract_check_just_precond(contract_decls, precond);
100110

101111
let body = self.arena.alloc(body(self));
102112

@@ -145,9 +155,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
145155

146156
fn lower_contract_check_just_precond(
147157
&mut self,
158+
contract_decls: &'hir [rustc_hir::Stmt<'hir>],
148159
precond: rustc_hir::Stmt<'hir>,
149160
) -> rustc_hir::Stmt<'hir> {
150-
let stmts = self.arena.alloc_from_iter([precond].into_iter());
161+
let stmts = self
162+
.arena
163+
.alloc_from_iter(contract_decls.into_iter().map(|d| *d).chain([precond].into_iter()));
151164

152165
let then_block_stmts = self.block_all(precond.span, stmts, None);
153166
let then_block = self.arena.alloc(self.expr_block(&then_block_stmts));
@@ -164,10 +177,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
164177

165178
fn lower_contract_check_with_postcond(
166179
&mut self,
180+
contract_decls: &'hir [rustc_hir::Stmt<'hir>],
167181
precond: Option<rustc_hir::Stmt<'hir>>,
168182
postcond_checker: &'hir rustc_hir::Expr<'hir>,
169183
) -> &'hir rustc_hir::Expr<'hir> {
170-
let stmts = self.arena.alloc_from_iter(precond.into_iter());
184+
let stmts = self
185+
.arena
186+
.alloc_from_iter(contract_decls.into_iter().map(|d| *d).chain(precond.into_iter()));
171187
let span = match precond {
172188
Some(precond) => precond.span,
173189
None => postcond_checker.span,

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
77
use rustc_hir as hir;
88
use rustc_hir::attrs::AttributeKind;
99
use rustc_hir::def::{DefKind, Res};
10+
use rustc_hir::definitions::DefPathData;
1011
use rustc_hir::{HirId, Target, find_attr};
1112
use rustc_middle::span_bug;
1213
use rustc_middle::ty::TyCtxt;
@@ -62,13 +63,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
6263

6364
pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
6465
ensure_sufficient_stack(|| {
66+
let mut span = self.lower_span(e.span);
6567
match &e.kind {
6668
// Parenthesis expression does not have a HirId and is handled specially.
6769
ExprKind::Paren(ex) => {
6870
let mut ex = self.lower_expr_mut(ex);
6971
// Include parens in span, but only if it is a super-span.
7072
if e.span.contains(ex.span) {
71-
ex.span = self.lower_span(e.span);
73+
ex.span = self.lower_span(e.span.with_ctxt(ex.span.ctxt()));
7274
}
7375
// Merge attributes into the inner expression.
7476
if !e.attrs.is_empty() {
@@ -287,7 +289,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
287289
self.lower_span(*brackets_span),
288290
),
289291
ExprKind::Range(e1, e2, lims) => {
290-
self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), *lims)
292+
span = self.mark_span_with_reason(DesugaringKind::RangeExpr, span, None);
293+
self.lower_expr_range(span, e1.as_deref(), e2.as_deref(), *lims)
291294
}
292295
ExprKind::Underscore => {
293296
let guar = self.dcx().emit_err(UnderscoreExprLhsAssign { span: e.span });
@@ -379,7 +382,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
379382
ExprKind::MacCall(_) => panic!("{:?} shouldn't exist here", e.span),
380383
};
381384

382-
hir::Expr { hir_id: expr_hir_id, kind, span: self.lower_span(e.span) }
385+
hir::Expr { hir_id: expr_hir_id, kind, span }
383386
})
384387
}
385388

@@ -461,7 +464,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
461464
for (idx, arg) in args.iter().cloned().enumerate() {
462465
if legacy_args_idx.contains(&idx) {
463466
let node_id = self.next_node_id();
464-
self.create_def(node_id, None, DefKind::AnonConst, f.span);
467+
self.create_def(
468+
node_id,
469+
None,
470+
DefKind::AnonConst,
471+
DefPathData::LateAnonConst,
472+
f.span,
473+
);
465474
let mut visitor = WillCreateDefIdsVisitor {};
466475
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
467476
Box::new(Expr {
@@ -1233,13 +1242,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
12331242
let rhs = self.lower_expr(rhs);
12341243

12351244
// Introduce a `let` for destructuring: `let (lhs1, lhs2) = t`.
1236-
let destructure_let = self.stmt_let_pat(
1237-
None,
1238-
whole_span,
1239-
Some(rhs),
1240-
pat,
1241-
hir::LocalSource::AssignDesugar(self.lower_span(eq_sign_span)),
1242-
);
1245+
let destructure_let =
1246+
self.stmt_let_pat(None, whole_span, Some(rhs), pat, hir::LocalSource::AssignDesugar);
12431247

12441248
// `a = lhs1; b = lhs2;`.
12451249
let stmts = self.arena.alloc_from_iter(std::iter::once(destructure_let).chain(assignments));
@@ -1475,7 +1479,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14751479
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
14761480
let e1 = self.lower_expr_mut(e1);
14771481
let e2 = self.lower_expr_mut(e2);
1478-
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
1482+
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, span);
14791483
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
14801484
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
14811485
}
@@ -1552,14 +1556,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
15521556
)
15531557
}))
15541558
.map(|(s, e)| {
1559+
let span = self.lower_span(e.span);
1560+
let span = self.mark_span_with_reason(DesugaringKind::RangeExpr, span, None);
15551561
let expr = self.lower_expr(e);
1556-
let ident = Ident::new(s, self.lower_span(e.span));
1557-
self.expr_field(ident, expr, e.span)
1562+
let ident = Ident::new(s, span);
1563+
self.expr_field(ident, expr, span)
15581564
}),
15591565
);
15601566

15611567
hir::ExprKind::Struct(
1562-
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
1568+
self.arena.alloc(hir::QPath::LangItem(lang_item, span)),
15631569
fields,
15641570
hir::StructTailExpr::None,
15651571
)

0 commit comments

Comments
 (0)