Skip to content

Commit bbe63cb

Browse files
authored
Merge branch 'rust-lang:master' into feat/rust-doc-precise-capturing-arg
2 parents 9ece166 + 20f0108 commit bbe63cb

File tree

571 files changed

+6477
-2966
lines changed

Some content is hidden

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

571 files changed

+6477
-2966
lines changed

Diff for: .github/workflows/post-merge.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Workflow that runs after a merge to master, analyses changes in test executions
2+
# and posts the result to the merged PR.
3+
4+
name: Post merge analysis
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
analysis:
13+
runs-on: ubuntu-24.04
14+
if: github.repository == 'rust-lang/rust'
15+
permissions:
16+
pull-requests: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Perform analysis and send PR
20+
run: |
21+
# Get closest bors merge commit
22+
PARENT_COMMIT=`git rev-list --author='bors <[email protected]>' -n1 --first-parent HEAD^1`
23+
24+
# Find PR for the current commit
25+
HEAD_PR=`gh pr list --search "${{ github.sha }}" --state merged --json number --jq '.[0].number'`
26+
27+
echo "Parent: ${PARENT_COMMIT}"
28+
echo "HEAD: ${{ github.sha }} (#${HEAD_PR})"
29+
30+
cd src/ci/citool
31+
32+
echo "Post-merge analysis result" > output.log
33+
cargo run --release post-merge-analysis ${PARENT_COMMIT} ${{ github.sha }} >> output.log
34+
cat output.log
35+
36+
gh pr comment ${HEAD_PR} -F output.log

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ no_llvm_build
5353
/target
5454
/library/target
5555
/src/bootstrap/target
56+
/src/ci/citool/target
5657
/src/tools/x/target
5758
# Created by `x vendor`
5859
/vendor

Diff for: Cargo.lock

+11
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,16 @@ version = "0.2.0"
25262526
source = "registry+https://github.com/rust-lang/crates.io-index"
25272527
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
25282528

2529+
[[package]]
2530+
name = "os_pipe"
2531+
version = "1.2.1"
2532+
source = "registry+https://github.com/rust-lang/crates.io-index"
2533+
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
2534+
dependencies = [
2535+
"libc",
2536+
"windows-sys 0.59.0",
2537+
]
2538+
25292539
[[package]]
25302540
name = "overload"
25312541
version = "0.1.1"
@@ -3050,6 +3060,7 @@ dependencies = [
30503060
"gimli 0.31.1",
30513061
"libc",
30523062
"object 0.36.7",
3063+
"os_pipe",
30533064
"regex",
30543065
"serde_json",
30553066
"similar",

Diff for: compiler/rustc_abi/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ where
18121812
f.debug_struct("Layout")
18131813
.field("size", size)
18141814
.field("align", align)
1815-
.field("abi", backend_repr)
1815+
.field("backend_repr", backend_repr)
18161816
.field("fields", fields)
18171817
.field("largest_niche", largest_niche)
18181818
.field("uninhabited", uninhabited)

Diff for: compiler/rustc_ast/src/ast.rs

+31-4
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,7 @@ impl Expr {
13991399
// Never need parens
14001400
ExprKind::Array(_)
14011401
| ExprKind::Await(..)
1402+
| ExprKind::Use(..)
14021403
| ExprKind::Block(..)
14031404
| ExprKind::Call(..)
14041405
| ExprKind::ConstBlock(_)
@@ -1588,6 +1589,8 @@ pub enum ExprKind {
15881589
Gen(CaptureBy, P<Block>, GenBlockKind, Span),
15891590
/// An await expression (`my_future.await`). Span is of await keyword.
15901591
Await(P<Expr>, Span),
1592+
/// A use expression (`x.use`). Span is of use keyword.
1593+
Use(P<Expr>, Span),
15911594

15921595
/// A try block (`try { ... }`).
15931596
TryBlock(P<Block>),
@@ -1757,8 +1760,17 @@ pub enum CaptureBy {
17571760
/// The span of the `move` keyword.
17581761
move_kw: Span,
17591762
},
1760-
/// `move` keyword was not specified.
1763+
/// `move` or `use` keywords were not specified.
17611764
Ref,
1765+
/// `use |x| y + x`.
1766+
///
1767+
/// Note that if you have a regular closure like `|| x.use`, this will *not* result
1768+
/// in a `Use` capture. Instead, the `ExprUseVisitor` will look at the type
1769+
/// of `x` and treat `x.use` as either a copy/clone/move as appropriate.
1770+
Use {
1771+
/// The span of the `use` keyword.
1772+
use_kw: Span,
1773+
},
17621774
}
17631775

17641776
/// Closure lifetime binder, `for<'a, 'b>` in `for<'a, 'b> |_: &'a (), _: &'b ()|`.
@@ -2641,6 +2653,8 @@ pub enum SelfKind {
26412653
Value(Mutability),
26422654
/// `&'lt self`, `&'lt mut self`
26432655
Region(Option<Lifetime>, Mutability),
2656+
/// `&'lt pin const self`, `&'lt pin mut self`
2657+
Pinned(Option<Lifetime>, Mutability),
26442658
/// `self: TYPE`, `mut self: TYPE`
26452659
Explicit(P<Ty>, Mutability),
26462660
}
@@ -2650,6 +2664,8 @@ impl SelfKind {
26502664
match self {
26512665
SelfKind::Region(None, mutbl) => mutbl.ref_prefix_str().to_string(),
26522666
SelfKind::Region(Some(lt), mutbl) => format!("&{lt} {}", mutbl.prefix_str()),
2667+
SelfKind::Pinned(None, mutbl) => format!("&pin {}", mutbl.ptr_str()),
2668+
SelfKind::Pinned(Some(lt), mutbl) => format!("&{lt} pin {}", mutbl.ptr_str()),
26532669
SelfKind::Value(_) | SelfKind::Explicit(_, _) => {
26542670
unreachable!("if we had an explicit self, we wouldn't be here")
26552671
}
@@ -2666,11 +2682,13 @@ impl Param {
26662682
if ident.name == kw::SelfLower {
26672683
return match self.ty.kind {
26682684
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
2669-
TyKind::Ref(lt, MutTy { ref ty, mutbl })
2670-
| TyKind::PinnedRef(lt, MutTy { ref ty, mutbl })
2685+
TyKind::Ref(lt, MutTy { ref ty, mutbl }) if ty.kind.is_implicit_self() => {
2686+
Some(respan(self.pat.span, SelfKind::Region(lt, mutbl)))
2687+
}
2688+
TyKind::PinnedRef(lt, MutTy { ref ty, mutbl })
26712689
if ty.kind.is_implicit_self() =>
26722690
{
2673-
Some(respan(self.pat.span, SelfKind::Region(lt, mutbl)))
2691+
Some(respan(self.pat.span, SelfKind::Pinned(lt, mutbl)))
26742692
}
26752693
_ => Some(respan(
26762694
self.pat.span.to(self.ty.span),
@@ -2712,6 +2730,15 @@ impl Param {
27122730
tokens: None,
27132731
}),
27142732
),
2733+
SelfKind::Pinned(lt, mutbl) => (
2734+
mutbl,
2735+
P(Ty {
2736+
id: DUMMY_NODE_ID,
2737+
kind: TyKind::PinnedRef(lt, MutTy { ty: infer_ty, mutbl }),
2738+
span,
2739+
tokens: None,
2740+
}),
2741+
),
27152742
};
27162743
Param {
27172744
attrs,

Diff for: compiler/rustc_ast/src/mut_visit.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,10 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
17451745
vis.visit_expr(expr);
17461746
vis.visit_span(await_kw_span);
17471747
}
1748+
ExprKind::Use(expr, use_kw_span) => {
1749+
vis.visit_expr(expr);
1750+
vis.visit_span(use_kw_span);
1751+
}
17481752
ExprKind::Assign(el, er, span) => {
17491753
vis.visit_expr(el);
17501754
vis.visit_expr(er);
@@ -1895,6 +1899,9 @@ fn walk_capture_by<T: MutVisitor>(vis: &mut T, capture_by: &mut CaptureBy) {
18951899
CaptureBy::Value { move_kw } => {
18961900
vis.visit_span(move_kw);
18971901
}
1902+
CaptureBy::Use { use_kw } => {
1903+
vis.visit_span(use_kw);
1904+
}
18981905
}
18991906
}
19001907

Diff for: compiler/rustc_ast/src/util/classify.rs

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub fn leading_labeled_expr(mut expr: &ast::Expr) -> bool {
108108
Assign(e, _, _)
109109
| AssignOp(_, e, _)
110110
| Await(e, _)
111+
| Use(e, _)
111112
| Binary(_, e, _)
112113
| Call(e, _)
113114
| Cast(e, _)
@@ -224,6 +225,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<TrailingBrace<'_>> {
224225
| Lit(_)
225226
| Type(_, _)
226227
| Await(_, _)
228+
| Use(_, _)
227229
| Field(_, _)
228230
| Index(_, _, _)
229231
| Underscore

Diff for: compiler/rustc_ast/src/visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
12111211
}
12121212
ExprKind::Gen(_capt, body, _kind, _decl_span) => try_visit!(visitor.visit_block(body)),
12131213
ExprKind::Await(expr, _span) => try_visit!(visitor.visit_expr(expr)),
1214+
ExprKind::Use(expr, _span) => try_visit!(visitor.visit_expr(expr)),
12141215
ExprKind::Assign(lhs, rhs, _span) => {
12151216
try_visit!(visitor.visit_expr(lhs));
12161217
try_visit!(visitor.visit_expr(rhs));

Diff for: compiler/rustc_ast_lowering/src/expr.rs

+21-23
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::span_bug;
1313
use rustc_middle::ty::TyCtxt;
1414
use rustc_session::errors::report_lit_error;
1515
use rustc_span::source_map::{Spanned, respan};
16-
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym};
16+
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
1717
use thin_vec::{ThinVec, thin_vec};
1818
use visit::{Visitor, walk_expr};
1919

@@ -207,6 +207,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
207207
},
208208
),
209209
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
210+
ExprKind::Use(expr, use_kw_span) => self.lower_expr_use(*use_kw_span, expr),
210211
ExprKind::Closure(box Closure {
211212
binder,
212213
capture_clause,
@@ -483,7 +484,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
483484
if legacy_args_idx.contains(&idx) {
484485
let parent_def_id = self.current_hir_id_owner.def_id;
485486
let node_id = self.next_node_id();
486-
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
487+
self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, f.span);
487488
let mut visitor = WillCreateDefIdsVisitor {};
488489
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
489490
AstP(Expr {
@@ -1067,6 +1068,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
10671068
)
10681069
}
10691070

1071+
fn lower_expr_use(&mut self, use_kw_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
1072+
hir::ExprKind::Use(self.lower_expr(expr), use_kw_span)
1073+
}
1074+
10701075
fn lower_expr_closure(
10711076
&mut self,
10721077
binder: &ClosureBinder,
@@ -1690,6 +1695,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
16901695
let yielded =
16911696
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));
16921697

1698+
if !self.tcx.features().yield_expr()
1699+
&& !self.tcx.features().coroutines()
1700+
&& !self.tcx.features().gen_blocks()
1701+
{
1702+
rustc_session::parse::feature_err(
1703+
&self.tcx.sess,
1704+
sym::yield_expr,
1705+
span,
1706+
fluent_generated::ast_lowering_yield,
1707+
)
1708+
.emit();
1709+
}
1710+
16931711
let is_async_gen = match self.coroutine_kind {
16941712
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)) => false,
16951713
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _)) => true,
@@ -1714,28 +1732,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
17141732
None,
17151733
);
17161734
}
1717-
Some(hir::CoroutineKind::Coroutine(_)) => {
1718-
if !self.tcx.features().coroutines() {
1719-
rustc_session::parse::feature_err(
1720-
&self.tcx.sess,
1721-
sym::coroutines,
1722-
span,
1723-
fluent_generated::ast_lowering_yield,
1724-
)
1725-
.emit();
1726-
}
1727-
false
1728-
}
1735+
Some(hir::CoroutineKind::Coroutine(_)) => false,
17291736
None => {
1730-
if !self.tcx.features().coroutines() {
1731-
rustc_session::parse::feature_err(
1732-
&self.tcx.sess,
1733-
sym::coroutines,
1734-
span,
1735-
fluent_generated::ast_lowering_yield,
1736-
)
1737-
.emit();
1738-
}
17391737
let suggestion = self.current_item.map(|s| s.shrink_to_lo());
17401738
self.dcx().emit_err(YieldInClosure { span, suggestion });
17411739
self.coroutine_kind = Some(hir::CoroutineKind::Coroutine(Movability::Movable));

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct LoweringContext<'a, 'hir> {
136136

137137
allow_try_trait: Arc<[Symbol]>,
138138
allow_gen_future: Arc<[Symbol]>,
139+
allow_pattern_type: Arc<[Symbol]>,
139140
allow_async_iterator: Arc<[Symbol]>,
140141
allow_for_await: Arc<[Symbol]>,
141142
allow_async_fn_traits: Arc<[Symbol]>,
@@ -176,6 +177,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
176177
impl_trait_defs: Vec::new(),
177178
impl_trait_bounds: Vec::new(),
178179
allow_try_trait: [sym::try_trait_v2, sym::yeet_desugar_details].into(),
180+
allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
179181
allow_gen_future: if tcx.features().async_fn_track_caller() {
180182
[sym::gen_future, sym::closure_track_caller].into()
181183
} else {
@@ -492,7 +494,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
492494
&mut self,
493495
parent: LocalDefId,
494496
node_id: ast::NodeId,
495-
name: Symbol,
497+
name: Option<Symbol>,
496498
def_kind: DefKind,
497499
span: Span,
498500
) -> LocalDefId {
@@ -772,7 +774,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
772774
let _def_id = self.create_def(
773775
self.current_hir_id_owner.def_id,
774776
param,
775-
kw::UnderscoreLifetime,
777+
Some(kw::UnderscoreLifetime),
776778
DefKind::LifetimeParam,
777779
ident.span,
778780
);
@@ -926,7 +928,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
926928
if let Some(first_char) = constraint.ident.as_str().chars().next()
927929
&& first_char.is_ascii_lowercase()
928930
{
929-
tracing::info!(?data, ?data.inputs);
930931
let err = match (&data.inputs[..], &data.output) {
931932
([_, ..], FnRetTy::Default(_)) => {
932933
errors::BadReturnTypeNotation::Inputs { span: data.inputs_span }
@@ -1365,7 +1366,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13651366
}
13661367
}
13671368
TyKind::Pat(ty, pat) => {
1368-
hir::TyKind::Pat(self.lower_ty(ty, itctx), self.lower_ty_pat(pat))
1369+
hir::TyKind::Pat(self.lower_ty(ty, itctx), self.lower_ty_pat(pat, ty.span))
13691370
}
13701371
TyKind::MacCall(_) => {
13711372
span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")
@@ -2088,8 +2089,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20882089
// We're lowering a const argument that was originally thought to be a type argument,
20892090
// so the def collector didn't create the def ahead of time. That's why we have to do
20902091
// it here.
2091-
let def_id =
2092-
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, span);
2092+
let def_id = self.create_def(parent_def_id, node_id, None, DefKind::AnonConst, span);
20932093
let hir_id = self.lower_node_id(node_id);
20942094

20952095
let path_expr = Expr {

0 commit comments

Comments
 (0)