Skip to content

Commit f5418b0

Browse files
committed
Auto merge of rust-lang#105425 - matthiaskrgr:rollup-3ngvxmt, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#105267 (Don't ICE in ExprUseVisitor on FRU for non-existent struct) - rust-lang#105343 (Simplify attribute handling in rustc_ast_lowering) - rust-lang#105368 (Remove more `ref` patterns from the compiler) - rust-lang#105400 (normalize before handling simple checks for evaluatability of `ty::Const`) - rust-lang#105403 (rustdoc: simplify CSS selectors for item table `.stab`) - rust-lang#105418 (fix: remove hack from link.rs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 01fbc5a + 4968af0 commit f5418b0

File tree

50 files changed

+535
-560
lines changed

Some content is hidden

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

50 files changed

+535
-560
lines changed

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

+39-94
Original file line numberDiff line numberDiff line change
@@ -436,18 +436,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
436436
let lhs = self.lower_cond(lhs);
437437
let rhs = self.lower_cond(rhs);
438438

439-
self.arena.alloc(self.expr(
440-
cond.span,
441-
hir::ExprKind::Binary(op, lhs, rhs),
442-
AttrVec::new(),
443-
))
439+
self.arena.alloc(self.expr(cond.span, hir::ExprKind::Binary(op, lhs, rhs)))
444440
}
445441
ExprKind::Let(..) => self.lower_expr(cond),
446442
_ => {
447443
let cond = self.lower_expr(cond);
448444
let reason = DesugaringKind::CondTemporary;
449445
let span_block = self.mark_span_with_reason(reason, cond.span, None);
450-
self.expr_drop_temps(span_block, cond, AttrVec::new())
446+
self.expr_drop_temps(span_block, cond)
451447
}
452448
}
453449
}
@@ -477,12 +473,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
477473
) -> hir::ExprKind<'hir> {
478474
let lowered_cond = self.with_loop_condition_scope(|t| t.lower_cond(cond));
479475
let then = self.lower_block_expr(body);
480-
let expr_break = self.expr_break(span, AttrVec::new());
476+
let expr_break = self.expr_break(span);
481477
let stmt_break = self.stmt_expr(span, expr_break);
482478
let else_blk = self.block_all(span, arena_vec![self; stmt_break], None);
483-
let else_expr = self.arena.alloc(self.expr_block(else_blk, AttrVec::new()));
479+
let else_expr = self.arena.alloc(self.expr_block(else_blk));
484480
let if_kind = hir::ExprKind::If(lowered_cond, self.arena.alloc(then), Some(else_expr));
485-
let if_expr = self.expr(span, if_kind, AttrVec::new());
481+
let if_expr = self.expr(span, if_kind);
486482
let block = self.block_expr(self.arena.alloc(if_expr));
487483
let span = self.lower_span(span.with_hi(cond.span.hi()));
488484
let opt_label = self.lower_label(opt_label);
@@ -538,12 +534,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
538534
expr: &'hir hir::Expr<'hir>,
539535
overall_span: Span,
540536
) -> &'hir hir::Expr<'hir> {
541-
let constructor = self.arena.alloc(self.expr_lang_item_path(
542-
method_span,
543-
lang_item,
544-
AttrVec::new(),
545-
None,
546-
));
537+
let constructor = self.arena.alloc(self.expr_lang_item_path(method_span, lang_item, None));
547538
self.expr_call(overall_span, constructor, std::slice::from_ref(expr))
548539
}
549540

@@ -715,12 +706,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
715706
// E0700 in src/test/ui/self/self_lifetime-async.rs
716707

717708
// `future::identity_future`:
718-
let identity_future = self.expr_lang_item_path(
719-
unstable_span,
720-
hir::LangItem::IdentityFuture,
721-
AttrVec::new(),
722-
None,
723-
);
709+
let identity_future =
710+
self.expr_lang_item_path(unstable_span, hir::LangItem::IdentityFuture, None);
724711

725712
// `future::identity_future(generator)`:
726713
hir::ExprKind::Call(self.arena.alloc(identity_future), arena_vec![self; generator])
@@ -817,7 +804,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
817804
let break_x = self.with_loop_scope(loop_node_id, move |this| {
818805
let expr_break =
819806
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
820-
this.arena.alloc(this.expr(gen_future_span, expr_break, AttrVec::new()))
807+
this.arena.alloc(this.expr(gen_future_span, expr_break))
821808
});
822809
self.arm(ready_pat, break_x)
823810
};
@@ -850,17 +837,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
850837
let yield_expr = self.expr(
851838
span,
852839
hir::ExprKind::Yield(unit, hir::YieldSource::Await { expr: Some(expr_hir_id) }),
853-
AttrVec::new(),
854840
);
855841
let yield_expr = self.arena.alloc(yield_expr);
856842

857843
if let Some(task_context_hid) = self.task_context {
858844
let lhs = self.expr_ident(span, task_context_ident, task_context_hid);
859-
let assign = self.expr(
860-
span,
861-
hir::ExprKind::Assign(lhs, yield_expr, self.lower_span(span)),
862-
AttrVec::new(),
863-
);
845+
let assign =
846+
self.expr(span, hir::ExprKind::Assign(lhs, yield_expr, self.lower_span(span)));
864847
self.stmt_expr(span, assign)
865848
} else {
866849
// Use of `await` outside of an async context. Return `yield_expr` so that we can
@@ -1044,7 +1027,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10441027
hir::AsyncGeneratorKind::Closure,
10451028
|this| this.with_new_scopes(|this| this.lower_expr_mut(body)),
10461029
);
1047-
this.expr(fn_decl_span, async_body, AttrVec::new())
1030+
this.expr(fn_decl_span, async_body)
10481031
});
10491032
body_id
10501033
});
@@ -1304,7 +1287,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13041287
let ident = self.expr_ident(lhs.span, ident, binding);
13051288
let assign =
13061289
hir::ExprKind::Assign(self.lower_expr(lhs), ident, self.lower_span(eq_sign_span));
1307-
let expr = self.expr(lhs.span, assign, AttrVec::new());
1290+
let expr = self.expr(lhs.span, assign);
13081291
assignments.push(self.stmt_expr(lhs.span, expr));
13091292
pat
13101293
}
@@ -1345,8 +1328,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13451328
let e2 = self.lower_expr_mut(e2);
13461329
let fn_path =
13471330
hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span), None);
1348-
let fn_expr =
1349-
self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path), AttrVec::new()));
1331+
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
13501332
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
13511333
}
13521334

@@ -1518,8 +1500,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15181500

15191501
// `None => break`
15201502
let none_arm = {
1521-
let break_expr =
1522-
self.with_loop_scope(e.id, |this| this.expr_break_alloc(for_span, AttrVec::new()));
1503+
let break_expr = self.with_loop_scope(e.id, |this| this.expr_break_alloc(for_span));
15231504
let pat = self.pat_none(for_span);
15241505
self.arm(pat, break_expr)
15251506
};
@@ -1528,7 +1509,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15281509
let some_arm = {
15291510
let some_pat = self.pat_some(pat_span, pat);
15301511
let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
1531-
let body_expr = self.arena.alloc(self.expr_block(body_block, AttrVec::new()));
1512+
let body_expr = self.arena.alloc(self.expr_block(body_block));
15321513
self.arm(some_pat, body_expr)
15331514
};
15341515

@@ -1591,7 +1572,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
15911572
// surrounding scope of the `match` since the `match` is not a terminating scope.
15921573
//
15931574
// Also, add the attributes to the outer returned expr node.
1594-
self.expr_drop_temps_mut(for_span, match_expr, e.attrs.clone())
1575+
let expr = self.expr_drop_temps_mut(for_span, match_expr);
1576+
self.lower_attrs(expr.hir_id, &e.attrs);
1577+
expr
15951578
}
15961579

15971580
/// Desugar `ExprKind::Try` from: `<expr>?` into:
@@ -1646,12 +1629,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
16461629
let continue_arm = {
16471630
let val_ident = Ident::with_dummy_span(sym::val);
16481631
let (val_pat, val_pat_nid) = self.pat_ident(span, val_ident);
1649-
let val_expr = self.arena.alloc(self.expr_ident_with_attrs(
1650-
span,
1651-
val_ident,
1652-
val_pat_nid,
1653-
attrs.clone(),
1654-
));
1632+
let val_expr = self.expr_ident(span, val_ident, val_pat_nid);
1633+
self.lower_attrs(val_expr.hir_id, &attrs);
16551634
let continue_pat = self.pat_cf_continue(unstable_span, val_pat);
16561635
self.arm(continue_pat, val_expr)
16571636
};
@@ -1677,15 +1656,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
16771656
hir::Destination { label: None, target_id },
16781657
Some(from_residual_expr),
16791658
),
1680-
attrs,
16811659
))
16821660
} else {
1683-
self.arena.alloc(self.expr(
1684-
try_span,
1685-
hir::ExprKind::Ret(Some(from_residual_expr)),
1686-
attrs,
1687-
))
1661+
self.arena.alloc(self.expr(try_span, hir::ExprKind::Ret(Some(from_residual_expr))))
16881662
};
1663+
self.lower_attrs(ret_expr.hir_id, &attrs);
16891664

16901665
let break_pat = self.pat_cf_break(try_span, residual_local);
16911666
self.arm(break_pat, ret_expr)
@@ -1750,18 +1725,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
17501725
&mut self,
17511726
span: Span,
17521727
expr: &'hir hir::Expr<'hir>,
1753-
attrs: AttrVec,
17541728
) -> &'hir hir::Expr<'hir> {
1755-
self.arena.alloc(self.expr_drop_temps_mut(span, expr, attrs))
1729+
self.arena.alloc(self.expr_drop_temps_mut(span, expr))
17561730
}
17571731

17581732
pub(super) fn expr_drop_temps_mut(
17591733
&mut self,
17601734
span: Span,
17611735
expr: &'hir hir::Expr<'hir>,
1762-
attrs: AttrVec,
17631736
) -> hir::Expr<'hir> {
1764-
self.expr(span, hir::ExprKind::DropTemps(expr), attrs)
1737+
self.expr(span, hir::ExprKind::DropTemps(expr))
17651738
}
17661739

17671740
fn expr_match(
@@ -1771,29 +1744,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
17711744
arms: &'hir [hir::Arm<'hir>],
17721745
source: hir::MatchSource,
17731746
) -> hir::Expr<'hir> {
1774-
self.expr(span, hir::ExprKind::Match(arg, arms, source), AttrVec::new())
1747+
self.expr(span, hir::ExprKind::Match(arg, arms, source))
17751748
}
17761749

1777-
fn expr_break(&mut self, span: Span, attrs: AttrVec) -> hir::Expr<'hir> {
1750+
fn expr_break(&mut self, span: Span) -> hir::Expr<'hir> {
17781751
let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None);
1779-
self.expr(span, expr_break, attrs)
1752+
self.expr(span, expr_break)
17801753
}
17811754

1782-
fn expr_break_alloc(&mut self, span: Span, attrs: AttrVec) -> &'hir hir::Expr<'hir> {
1783-
let expr_break = self.expr_break(span, attrs);
1755+
fn expr_break_alloc(&mut self, span: Span) -> &'hir hir::Expr<'hir> {
1756+
let expr_break = self.expr_break(span);
17841757
self.arena.alloc(expr_break)
17851758
}
17861759

17871760
fn expr_mut_addr_of(&mut self, span: Span, e: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
1788-
self.expr(
1789-
span,
1790-
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mut, e),
1791-
AttrVec::new(),
1792-
)
1761+
self.expr(span, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Mut, e))
17931762
}
17941763

17951764
fn expr_unit(&mut self, sp: Span) -> &'hir hir::Expr<'hir> {
1796-
self.arena.alloc(self.expr(sp, hir::ExprKind::Tup(&[]), AttrVec::new()))
1765+
self.arena.alloc(self.expr(sp, hir::ExprKind::Tup(&[])))
17971766
}
17981767

17991768
fn expr_call_mut(
@@ -1802,7 +1771,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18021771
e: &'hir hir::Expr<'hir>,
18031772
args: &'hir [hir::Expr<'hir>],
18041773
) -> hir::Expr<'hir> {
1805-
self.expr(span, hir::ExprKind::Call(e, args), AttrVec::new())
1774+
self.expr(span, hir::ExprKind::Call(e, args))
18061775
}
18071776

18081777
fn expr_call(
@@ -1821,8 +1790,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18211790
args: &'hir [hir::Expr<'hir>],
18221791
hir_id: Option<hir::HirId>,
18231792
) -> hir::Expr<'hir> {
1824-
let path =
1825-
self.arena.alloc(self.expr_lang_item_path(span, lang_item, AttrVec::new(), hir_id));
1793+
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item, hir_id));
18261794
self.expr_call_mut(span, path, args)
18271795
}
18281796

@@ -1840,13 +1808,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
18401808
&mut self,
18411809
span: Span,
18421810
lang_item: hir::LangItem,
1843-
attrs: AttrVec,
18441811
hir_id: Option<hir::HirId>,
18451812
) -> hir::Expr<'hir> {
18461813
self.expr(
18471814
span,
18481815
hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id)),
1849-
attrs,
18501816
)
18511817
}
18521818

@@ -1860,20 +1826,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
18601826
}
18611827

18621828
pub(super) fn expr_ident_mut(
1863-
&mut self,
1864-
sp: Span,
1865-
ident: Ident,
1866-
binding: hir::HirId,
1867-
) -> hir::Expr<'hir> {
1868-
self.expr_ident_with_attrs(sp, ident, binding, AttrVec::new())
1869-
}
1870-
1871-
fn expr_ident_with_attrs(
18721829
&mut self,
18731830
span: Span,
18741831
ident: Ident,
18751832
binding: hir::HirId,
1876-
attrs: AttrVec,
18771833
) -> hir::Expr<'hir> {
18781834
let hir_id = self.next_id();
18791835
let res = Res::Local(binding);
@@ -1886,7 +1842,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18861842
}),
18871843
));
18881844

1889-
self.expr(span, expr_path, attrs)
1845+
self.expr(span, expr_path)
18901846
}
18911847

18921848
fn expr_unsafe(&mut self, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
@@ -1905,32 +1861,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
19051861
}),
19061862
None,
19071863
),
1908-
AttrVec::new(),
19091864
)
19101865
}
19111866

19121867
fn expr_block_empty(&mut self, span: Span) -> &'hir hir::Expr<'hir> {
19131868
let blk = self.block_all(span, &[], None);
1914-
let expr = self.expr_block(blk, AttrVec::new());
1869+
let expr = self.expr_block(blk);
19151870
self.arena.alloc(expr)
19161871
}
19171872

1918-
pub(super) fn expr_block(
1919-
&mut self,
1920-
b: &'hir hir::Block<'hir>,
1921-
attrs: AttrVec,
1922-
) -> hir::Expr<'hir> {
1923-
self.expr(b.span, hir::ExprKind::Block(b, None), attrs)
1873+
pub(super) fn expr_block(&mut self, b: &'hir hir::Block<'hir>) -> hir::Expr<'hir> {
1874+
self.expr(b.span, hir::ExprKind::Block(b, None))
19241875
}
19251876

1926-
pub(super) fn expr(
1927-
&mut self,
1928-
span: Span,
1929-
kind: hir::ExprKind<'hir>,
1930-
attrs: AttrVec,
1931-
) -> hir::Expr<'hir> {
1877+
pub(super) fn expr(&mut self, span: Span, kind: hir::ExprKind<'hir>) -> hir::Expr<'hir> {
19321878
let hir_id = self.next_id();
1933-
self.lower_attrs(hir_id, &attrs);
19341879
hir::Expr { hir_id, kind, span: self.lower_span(span) }
19351880
}
19361881

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

+5-11
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
796796

797797
/// Construct `ExprKind::Err` for the given `span`.
798798
pub(crate) fn expr_err(&mut self, span: Span) -> hir::Expr<'hir> {
799-
self.expr(span, hir::ExprKind::Err, AttrVec::new())
799+
self.expr(span, hir::ExprKind::Err)
800800
}
801801

802802
fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
@@ -1151,11 +1151,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
11511151
// Transform into `drop-temps { <user-body> }`, an expression:
11521152
let desugared_span =
11531153
this.mark_span_with_reason(DesugaringKind::Async, user_body.span, None);
1154-
let user_body = this.expr_drop_temps(
1155-
desugared_span,
1156-
this.arena.alloc(user_body),
1157-
AttrVec::new(),
1158-
);
1154+
let user_body =
1155+
this.expr_drop_temps(desugared_span, this.arena.alloc(user_body));
11591156

11601157
// As noted above, create the final block like
11611158
//
@@ -1172,14 +1169,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
11721169
Some(user_body),
11731170
);
11741171

1175-
this.expr_block(body, AttrVec::new())
1172+
this.expr_block(body)
11761173
},
11771174
);
11781175

1179-
(
1180-
this.arena.alloc_from_iter(parameters),
1181-
this.expr(body.span, async_expr, AttrVec::new()),
1182-
)
1176+
(this.arena.alloc_from_iter(parameters), this.expr(body.span, async_expr))
11831177
})
11841178
}
11851179

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22912291
/// has no attributes and is not targeted by a `break`.
22922292
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
22932293
let block = self.lower_block(b, false);
2294-
self.expr_block(block, AttrVec::new())
2294+
self.expr_block(block)
22952295
}
22962296

22972297
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen {

0 commit comments

Comments
 (0)