Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8a36889

Browse files
committed
Auto merge of rust-lang#2818 - saethlin:rustup, r=saethlin
rustup
2 parents 6a2eb72 + 2b223b8 commit 8a36889

File tree

213 files changed

+2111
-1291
lines changed

Some content is hidden

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

213 files changed

+2111
-1291
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ no_llvm_build
4242
/llvm/
4343
/mingw-build/
4444
build/
45+
!/compiler/rustc_mir_build/src/build/
4546
/build-rust-analyzer/
4647
/dist/
4748
/unicode-downloads

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,9 +1365,9 @@ dependencies = [
13651365

13661366
[[package]]
13671367
name = "ena"
1368-
version = "0.14.1"
1368+
version = "0.14.2"
13691369
source = "registry+https://github.com/rust-lang/crates.io-index"
1370-
checksum = "b2e5d13ca2353ab7d0230988629def93914a8c4015f621f9b13ed2955614731d"
1370+
checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1"
13711371
dependencies = [
13721372
"log",
13731373
]

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,13 +1426,9 @@ pub enum ExprKind {
14261426
Block(P<Block>, Option<Label>),
14271427
/// An async block (`async move { ... }`).
14281428
///
1429-
/// The `NodeId` is the `NodeId` for the closure that results from
1430-
/// desugaring an async block, just like the NodeId field in the
1431-
/// `Async::Yes` variant. This is necessary in order to create a def for the
1432-
/// closure which can be used as a parent of any child defs. Defs
1433-
/// created during lowering cannot be made the parent of any other
1434-
/// preexisting defs.
1435-
Async(CaptureBy, NodeId, P<Block>),
1429+
/// The async block used to have a `NodeId`, which was removed in favor of
1430+
/// using the parent `NodeId` of the parent `Expr`.
1431+
Async(CaptureBy, P<Block>),
14361432
/// An await expression (`my_future.await`).
14371433
Await(P<Expr>),
14381434

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,8 +1407,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
14071407
vis.visit_block(blk);
14081408
visit_opt(label, |label| vis.visit_label(label));
14091409
}
1410-
ExprKind::Async(_capture_by, node_id, body) => {
1411-
vis.visit_id(node_id);
1410+
ExprKind::Async(_capture_by, body) => {
14121411
vis.visit_block(body);
14131412
}
14141413
ExprKind::Await(expr) => vis.visit_expr(expr),

compiler/rustc_ast/src/util/parser.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ pub enum ExprPrecedence {
259259
Assign,
260260
AssignOp,
261261

262-
Box,
263262
AddrOf,
264263
Let,
265264
Unary,
@@ -319,8 +318,7 @@ impl ExprPrecedence {
319318
ExprPrecedence::AssignOp => AssocOp::Assign.precedence() as i8,
320319

321320
// Unary, prefix
322-
ExprPrecedence::Box
323-
| ExprPrecedence::AddrOf
321+
ExprPrecedence::AddrOf
324322
// Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`.
325323
// However, this is not exactly right. When `let _ = a` is the LHS of a binop we
326324
// need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
860860
walk_list!(visitor, visit_label, opt_label);
861861
visitor.visit_block(block);
862862
}
863-
ExprKind::Async(_, _, body) => {
863+
ExprKind::Async(_, body) => {
864864
visitor.visit_block(body);
865865
}
866866
ExprKind::Await(expr) => visitor.visit_expr(expr),

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
6363
ExprKind::ForLoop(pat, head, body, opt_label) => {
6464
return self.lower_expr_for(e, pat, head, body, *opt_label);
6565
}
66-
// Similarly, async blocks do not use `e.id` but rather `closure_node_id`.
67-
ExprKind::Async(capture_clause, closure_node_id, block) => {
68-
let hir_id = self.lower_node_id(*closure_node_id);
69-
self.lower_attrs(hir_id, &e.attrs);
70-
return self.make_async_expr(
71-
*capture_clause,
72-
hir_id,
73-
*closure_node_id,
74-
None,
75-
e.span,
76-
hir::AsyncGeneratorKind::Block,
77-
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
78-
);
79-
}
8066
_ => (),
8167
}
8268

@@ -187,6 +173,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
187173
self.arena.alloc_from_iter(arms.iter().map(|x| self.lower_arm(x))),
188174
hir::MatchSource::Normal,
189175
),
176+
ExprKind::Async(capture_clause, block) => self.make_async_expr(
177+
*capture_clause,
178+
e.id,
179+
None,
180+
e.span,
181+
hir::AsyncGeneratorKind::Block,
182+
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
183+
),
190184
ExprKind::Await(expr) => {
191185
let dot_await_span = if expr.span.hi() < e.span.hi() {
192186
let span_with_whitespace = self
@@ -320,7 +314,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
320314
),
321315
ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr),
322316

323-
ExprKind::Paren(_) | ExprKind::ForLoop(..) | ExprKind::Async(..) => {
317+
ExprKind::Paren(_) | ExprKind::ForLoop(..) => {
324318
unreachable!("already handled")
325319
}
326320

@@ -591,13 +585,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
591585
pub(super) fn make_async_expr(
592586
&mut self,
593587
capture_clause: CaptureBy,
594-
outer_hir_id: hir::HirId,
595588
closure_node_id: NodeId,
596589
ret_ty: Option<hir::FnRetTy<'hir>>,
597590
span: Span,
598591
async_gen_kind: hir::AsyncGeneratorKind,
599592
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
600-
) -> hir::Expr<'hir> {
593+
) -> hir::ExprKind<'hir> {
601594
let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
602595

603596
// Resume argument type: `ResumeTy`
@@ -644,32 +637,36 @@ impl<'hir> LoweringContext<'_, 'hir> {
644637
});
645638

646639
// `static |_task_context| -> <ret_ty> { body }`:
647-
let generator_kind = {
648-
let c = self.arena.alloc(hir::Closure {
649-
def_id: self.local_def_id(closure_node_id),
650-
binder: hir::ClosureBinder::Default,
651-
capture_clause,
652-
bound_generic_params: &[],
653-
fn_decl,
654-
body,
655-
fn_decl_span: self.lower_span(span),
656-
fn_arg_span: None,
657-
movability: Some(hir::Movability::Static),
658-
constness: hir::Constness::NotConst,
659-
});
660-
661-
hir::ExprKind::Closure(c)
662-
};
640+
hir::ExprKind::Closure(self.arena.alloc(hir::Closure {
641+
def_id: self.local_def_id(closure_node_id),
642+
binder: hir::ClosureBinder::Default,
643+
capture_clause,
644+
bound_generic_params: &[],
645+
fn_decl,
646+
body,
647+
fn_decl_span: self.lower_span(span),
648+
fn_arg_span: None,
649+
movability: Some(hir::Movability::Static),
650+
constness: hir::Constness::NotConst,
651+
}))
652+
}
663653

664-
let hir_id = self.lower_node_id(closure_node_id);
654+
/// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
655+
/// `inner_hir_id` in case the `closure_track_caller` feature is enabled.
656+
pub(super) fn maybe_forward_track_caller(
657+
&mut self,
658+
span: Span,
659+
outer_hir_id: hir::HirId,
660+
inner_hir_id: hir::HirId,
661+
) {
665662
if self.tcx.features().closure_track_caller
666663
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
667664
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
668665
{
669666
let unstable_span =
670667
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
671668
self.lower_attrs(
672-
hir_id,
669+
inner_hir_id,
673670
&[Attribute {
674671
kind: AttrKind::Normal(ptr::P(NormalAttr {
675672
item: AttrItem {
@@ -685,8 +682,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
685682
}],
686683
);
687684
}
688-
689-
hir::Expr { hir_id, kind: generator_kind, span: self.lower_span(span) }
690685
}
691686

692687
/// Desugar `<expr>.await` into:
@@ -1001,15 +996,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
1001996
None
1002997
};
1003998

1004-
this.make_async_expr(
999+
let async_body = this.make_async_expr(
10051000
capture_clause,
1006-
closure_hir_id,
10071001
inner_closure_id,
10081002
async_ret_ty,
10091003
body.span,
10101004
hir::AsyncGeneratorKind::Closure,
10111005
|this| this.with_new_scopes(|this| this.lower_expr_mut(body)),
1012-
)
1006+
);
1007+
let hir_id = this.lower_node_id(inner_closure_id);
1008+
this.maybe_forward_track_caller(body.span, closure_hir_id, hir_id);
1009+
hir::Expr { hir_id, kind: async_body, span: this.lower_span(body.span) }
10131010
});
10141011
body_id
10151012
});

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
11461146

11471147
let async_expr = this.make_async_expr(
11481148
CaptureBy::Value,
1149-
fn_id,
11501149
closure_id,
11511150
None,
11521151
body.span,
@@ -1180,7 +1179,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
11801179
},
11811180
);
11821181

1183-
(this.arena.alloc_from_iter(parameters), async_expr)
1182+
let hir_id = this.lower_node_id(closure_id);
1183+
this.maybe_forward_track_caller(body.span, fn_id, hir_id);
1184+
let expr = hir::Expr { hir_id, kind: async_expr, span: this.lower_span(body.span) };
1185+
1186+
(this.arena.alloc_from_iter(parameters), expr)
11841187
})
11851188
}
11861189

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<'a> State<'a> {
439439
self.ibox(0);
440440
self.print_block_with_attrs(blk, attrs);
441441
}
442-
ast::ExprKind::Async(capture_clause, _, blk) => {
442+
ast::ExprKind::Async(capture_clause, blk) => {
443443
self.word_nbsp("async");
444444
self.print_capture_clause(*capture_clause);
445445
// cbox/ibox in analogy to the `ExprKind::Block` arm above

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fn sccs_info<'cx, 'tcx>(
255255
let var_to_origin = infcx.reg_var_to_origin.borrow();
256256

257257
let mut var_to_origin_sorted = var_to_origin.clone().into_iter().collect::<Vec<_>>();
258-
var_to_origin_sorted.sort_by(|a, b| a.0.cmp(&b.0));
258+
var_to_origin_sorted.sort_by_key(|vto| vto.0);
259259
let mut debug_str = "region variables to origins:\n".to_string();
260260
for (reg_var, origin) in var_to_origin_sorted.into_iter() {
261261
debug_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin));
@@ -2216,7 +2216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
22162216
// is in the same SCC or something. In that case, find what
22172217
// appears to be the most interesting point to report to the
22182218
// user via an even more ad-hoc guess.
2219-
categorized_path.sort_by(|p0, p1| p0.category.cmp(&p1.category));
2219+
categorized_path.sort_by_key(|p| p.category);
22202220
debug!("sorted_path={:#?}", categorized_path);
22212221

22222222
(categorized_path.remove(0), extra_info)

0 commit comments

Comments
 (0)