Skip to content

Commit 020bbe4

Browse files
committed
Auto merge of rust-lang#122947 - matthiaskrgr:rollup-10j7orh, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#120577 (Stabilize slice_split_at_unchecked) - rust-lang#122698 (Cancel `cargo update` job if there's no updates) - rust-lang#122780 (Rename `hir::Local` into `hir::LetStmt`) - rust-lang#122915 (Delay a bug if no RPITITs were found) - rust-lang#122916 (docs(sync): normalize dot in fn summaries) - rust-lang#122921 (Enable more mir-opt tests in debug builds) - rust-lang#122922 (-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.) - rust-lang#122927 (Change an ICE regression test to use the original reproducer) - rust-lang#122930 (add panic location to 'panicked while processing panic') - rust-lang#122931 (Fix some typos in the pin.rs) - rust-lang#122933 (tag_for_variant follow-ups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d6eb0f5 + fce8039 commit 020bbe4

File tree

113 files changed

+567
-280
lines changed

Some content is hidden

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

113 files changed

+567
-280
lines changed

.github/workflows/dependencies.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
# Exit with error if open and S-waiting-on-bors
4444
if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then
45-
exit 1
45+
gh run cancel ${{ github.run_id }}
4646
fi
4747
4848
update:
@@ -65,7 +65,10 @@ jobs:
6565
6666
- name: cargo update
6767
# Remove first line that always just says "Updating crates.io index"
68-
run: cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
68+
# If there are no changes, cancel the job here
69+
run: |
70+
cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log
71+
git status --porcelain | grep -q Cargo.lock || gh run cancel ${{ github.run_id }}
6972
- name: upload Cargo.lock artifact for use in PR
7073
uses: actions/upload-artifact@v3
7174
with:
@@ -131,7 +134,7 @@ jobs:
131134
# Exit with error if PR is closed
132135
STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state')
133136
if [[ "$STATE" != "OPEN" ]]; then
134-
exit 1
137+
gh run cancel ${{ github.run_id }}
135138
fi
136139
137140
gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY

compiler/rustc_ast_lowering/src/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
8181
(self.arena.alloc_from_iter(stmts), expr)
8282
}
8383

84-
fn lower_local(&mut self, l: &Local) -> &'hir hir::Local<'hir> {
84+
fn lower_local(&mut self, l: &Local) -> &'hir hir::LetStmt<'hir> {
8585
let ty = l
8686
.ty
8787
.as_ref()
@@ -97,7 +97,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
9797
let span = self.lower_span(l.span);
9898
let source = hir::LocalSource::Normal;
9999
self.lower_attrs(hir_id, &l.attrs);
100-
self.arena.alloc(hir::Local { hir_id, ty, pat, init, els, span, source })
100+
self.arena.alloc(hir::LetStmt { hir_id, ty, pat, init, els, span, source })
101101
}
102102

103103
fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {

compiler/rustc_ast_lowering/src/index.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
302302
});
303303
}
304304

305-
fn visit_local(&mut self, l: &'hir Local<'hir>) {
306-
self.insert(l.span, l.hir_id, Node::Local(l));
305+
fn visit_local(&mut self, l: &'hir LetStmt<'hir>) {
306+
self.insert(l.span, l.hir_id, Node::LetStmt(l));
307307
self.with_parent(l.hir_id, |this| {
308308
intravisit::walk_local(this, l);
309309
})

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23412341
debug_assert!(!a.is_empty());
23422342
self.attrs.insert(hir_id.local_id, a);
23432343
}
2344-
let local = hir::Local {
2344+
let local = hir::LetStmt {
23452345
hir_id,
23462346
init,
23472347
pat,

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
622622

623623
// FIXME: We make sure that this is a normal top-level binding,
624624
// but we could suggest `todo!()` for all uninitalized bindings in the pattern pattern
625-
if let hir::StmtKind::Let(hir::Local { span, ty, init: None, pat, .. }) =
625+
if let hir::StmtKind::Let(hir::LetStmt { span, ty, init: None, pat, .. }) =
626626
&ex.kind
627627
&& let hir::PatKind::Binding(..) = pat.kind
628628
&& span.contains(self.decl_span)
@@ -800,7 +800,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
800800
for (_, node) in tcx.hir().parent_iter(expr.hir_id) {
801801
let e = match node {
802802
hir::Node::Expr(e) => e,
803-
hir::Node::Local(hir::Local { els: Some(els), .. }) => {
803+
hir::Node::LetStmt(hir::LetStmt { els: Some(els), .. }) => {
804804
let mut finder = BreakFinder { found_breaks: vec![], found_continues: vec![] };
805805
finder.visit_block(els);
806806
if !finder.found_breaks.is_empty() {
@@ -2124,7 +2124,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21242124
hir::intravisit::walk_expr(self, e);
21252125
}
21262126

2127-
fn visit_local(&mut self, local: &'hir hir::Local<'hir>) {
2127+
fn visit_local(&mut self, local: &'hir hir::LetStmt<'hir>) {
21282128
if let hir::Pat { kind: hir::PatKind::Binding(_, hir_id, _ident, _), .. } =
21292129
local.pat
21302130
&& let Some(init) = local.init

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
558558
hir::intravisit::walk_stmt(self, stmt);
559559
let expr = match stmt.kind {
560560
hir::StmtKind::Semi(expr) | hir::StmtKind::Expr(expr) => expr,
561-
hir::StmtKind::Let(hir::Local { init: Some(expr), .. }) => expr,
561+
hir::StmtKind::Let(hir::LetStmt { init: Some(expr), .. }) => expr,
562562
_ => {
563563
return;
564564
}
@@ -737,7 +737,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
737737
&& let body = self.infcx.tcx.hir().body(body_id)
738738
&& let Some(hir_id) = (BindingFinder { span: pat_span }).visit_body(body).break_value()
739739
&& let node = self.infcx.tcx.hir_node(hir_id)
740-
&& let hir::Node::Local(hir::Local {
740+
&& let hir::Node::LetStmt(hir::LetStmt {
741741
pat: hir::Pat { kind: hir::PatKind::Ref(_, _), .. },
742742
..
743743
})
@@ -1170,7 +1170,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
11701170
};
11711171

11721172
if let Some(hir_id) = hir_id
1173-
&& let hir::Node::Local(local) = self.infcx.tcx.hir_node(hir_id)
1173+
&& let hir::Node::LetStmt(local) = self.infcx.tcx.hir_node(hir_id)
11741174
{
11751175
let tables = self.infcx.tcx.typeck(def_id.as_local().unwrap());
11761176
if let Some(clone_trait) = self.infcx.tcx.lang_items().clone_trait()

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use either::{Left, Right};
33
use rustc_hir::def::DefKind;
44
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
55
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
6-
use rustc_middle::query::{Key, TyCtxtAt};
6+
use rustc_middle::query::TyCtxtAt;
77
use rustc_middle::traits::Reveal;
88
use rustc_middle::ty::layout::LayoutOf;
99
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -243,24 +243,6 @@ pub(crate) fn turn_into_const_value<'tcx>(
243243
op_to_const(&ecx, &mplace.into(), /* for diagnostics */ false)
244244
}
245245

246-
/// Computes the tag (if any) for a given type and variant.
247-
#[instrument(skip(tcx), level = "debug")]
248-
pub fn tag_for_variant_provider<'tcx>(
249-
tcx: TyCtxt<'tcx>,
250-
(ty, variant_index): (Ty<'tcx>, abi::VariantIdx),
251-
) -> Option<ty::ScalarInt> {
252-
assert!(ty.is_enum());
253-
254-
let ecx = InterpCx::new(
255-
tcx,
256-
ty.default_span(tcx),
257-
ty::ParamEnv::reveal_all(),
258-
crate::const_eval::DummyMachine,
259-
);
260-
261-
ecx.tag_for_variant(ty, variant_index).unwrap().map(|(tag, _tag_field)| tag)
262-
}
263-
264246
#[instrument(skip(tcx), level = "debug")]
265247
pub fn eval_to_const_value_raw_provider<'tcx>(
266248
tcx: TyCtxt<'tcx>,

compiler/rustc_const_eval/src/const_eval/mod.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
use rustc_middle::mir;
44
use rustc_middle::mir::interpret::InterpErrorInfo;
5-
use rustc_middle::query::TyCtxtAt;
6-
use rustc_middle::ty::{self, Ty};
5+
use rustc_middle::query::{Key, TyCtxtAt};
6+
use rustc_middle::ty::{self, Ty, TyCtxt};
7+
use rustc_target::abi::VariantIdx;
78

8-
use crate::interpret::format_interp_error;
9+
use crate::interpret::{format_interp_error, InterpCx};
910

1011
mod dummy_machine;
1112
mod error;
@@ -77,3 +78,21 @@ pub(crate) fn try_destructure_mir_constant_for_user_output<'tcx>(
7778

7879
Some(mir::DestructuredConstant { variant, fields })
7980
}
81+
82+
/// Computes the tag (if any) for a given type and variant.
83+
#[instrument(skip(tcx), level = "debug")]
84+
pub fn tag_for_variant_provider<'tcx>(
85+
tcx: TyCtxt<'tcx>,
86+
(ty, variant_index): (Ty<'tcx>, VariantIdx),
87+
) -> Option<ty::ScalarInt> {
88+
assert!(ty.is_enum());
89+
90+
let ecx = InterpCx::new(
91+
tcx,
92+
ty.default_span(tcx),
93+
ty::ParamEnv::reveal_all(),
94+
crate::const_eval::DummyMachine,
95+
);
96+
97+
ecx.tag_for_variant(ty, variant_index).unwrap().map(|(tag, _tag_field)| tag)
98+
}

compiler/rustc_const_eval/src/interpret/discriminant.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
3838
}
3939
None => {
4040
// No need to write the tag here, because an untagged variant is
41-
// implicitly encoded. For `Niche`-optimized enums, it's by
41+
// implicitly encoded. For `Niche`-optimized enums, this works by
4242
// simply by having a value that is outside the niche variants.
4343
// But what if the data stored here does not actually encode
4444
// this variant? That would be bad! So let's double-check...
@@ -227,8 +227,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
227227
Ok(ImmTy::from_scalar(discr_value, discr_layout))
228228
}
229229

230-
/// Computes the tag value and its field number (if any) of a given variant
231-
/// of type `ty`.
230+
/// Computes how to write the tag of a given variant of enum `ty`:
231+
/// - `None` means that nothing needs to be done as the variant is encoded implicitly
232+
/// - `Some((val, field_idx))` means that the given integer value needs to be stored at the
233+
/// given field index.
232234
pub(crate) fn tag_for_variant(
233235
&self,
234236
ty: Ty<'tcx>,

compiler/rustc_hir/src/hir.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ pub struct Stmt<'hir> {
12201220
#[derive(Debug, Clone, Copy, HashStable_Generic)]
12211221
pub enum StmtKind<'hir> {
12221222
/// A local (`let`) binding.
1223-
Let(&'hir Local<'hir>),
1223+
Let(&'hir LetStmt<'hir>),
12241224

12251225
/// An item binding.
12261226
Item(ItemId),
@@ -1234,7 +1234,7 @@ pub enum StmtKind<'hir> {
12341234

12351235
/// Represents a `let` statement (i.e., `let <pat>:<ty> = <init>;`).
12361236
#[derive(Debug, Clone, Copy, HashStable_Generic)]
1237-
pub struct Local<'hir> {
1237+
pub struct LetStmt<'hir> {
12381238
pub pat: &'hir Pat<'hir>,
12391239
/// Type annotation, if any (otherwise the type will be inferred).
12401240
pub ty: Option<&'hir Ty<'hir>>,
@@ -1264,7 +1264,7 @@ pub struct Arm<'hir> {
12641264
pub body: &'hir Expr<'hir>,
12651265
}
12661266

1267-
/// Represents a `let <pat>[: <ty>] = <expr>` expression (not a [`Local`]), occurring in an `if-let`
1267+
/// Represents a `let <pat>[: <ty>] = <expr>` expression (not a [`LetStmt`]), occurring in an `if-let`
12681268
/// or `let-else`, evaluating to a boolean. Typically the pattern is refutable.
12691269
///
12701270
/// In an `if let`, imagine it as `if (let <pat> = <expr>) { ... }`; in a let-else, it is part of
@@ -1861,7 +1861,7 @@ pub enum ExprKind<'hir> {
18611861
DropTemps(&'hir Expr<'hir>),
18621862
/// A `let $pat = $expr` expression.
18631863
///
1864-
/// These are not `Local` and only occur as expressions.
1864+
/// These are not [`LetStmt`] and only occur as expressions.
18651865
/// The `let Some(x) = foo()` in `if let Some(x) = foo()` is an example of `Let(..)`.
18661866
Let(&'hir LetExpr<'hir>),
18671867
/// An `if` block, with an optional else block.
@@ -3529,7 +3529,7 @@ pub enum Node<'hir> {
35293529
PatField(&'hir PatField<'hir>),
35303530
Arm(&'hir Arm<'hir>),
35313531
Block(&'hir Block<'hir>),
3532-
Local(&'hir Local<'hir>),
3532+
LetStmt(&'hir LetStmt<'hir>),
35333533
/// `Ctor` refers to the constructor of an enum variant or struct. Only tuple or unit variants
35343534
/// with synthesized constructors.
35353535
Ctor(&'hir VariantData<'hir>),
@@ -3585,7 +3585,7 @@ impl<'hir> Node<'hir> {
35853585
| Node::Ctor(..)
35863586
| Node::Pat(..)
35873587
| Node::Arm(..)
3588-
| Node::Local(..)
3588+
| Node::LetStmt(..)
35893589
| Node::Crate(..)
35903590
| Node::Ty(..)
35913591
| Node::TraitRef(..)
@@ -3757,7 +3757,7 @@ impl<'hir> Node<'hir> {
37573757
expect_pat_field, &'hir PatField<'hir>, Node::PatField(n), n;
37583758
expect_arm, &'hir Arm<'hir>, Node::Arm(n), n;
37593759
expect_block, &'hir Block<'hir>, Node::Block(n), n;
3760-
expect_local, &'hir Local<'hir>, Node::Local(n), n;
3760+
expect_let_stmt, &'hir LetStmt<'hir>, Node::LetStmt(n), n;
37613761
expect_ctor, &'hir VariantData<'hir>, Node::Ctor(n), n;
37623762
expect_lifetime, &'hir Lifetime, Node::Lifetime(n), n;
37633763
expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
@@ -3787,7 +3787,7 @@ mod size_asserts {
37873787
static_assert_size!(ImplItemKind<'_>, 40);
37883788
static_assert_size!(Item<'_>, 88);
37893789
static_assert_size!(ItemKind<'_>, 56);
3790-
static_assert_size!(Local<'_>, 64);
3790+
static_assert_size!(LetStmt<'_>, 64);
37913791
static_assert_size!(Param<'_>, 32);
37923792
static_assert_size!(Pat<'_>, 72);
37933793
static_assert_size!(Path<'_>, 40);

compiler/rustc_hir/src/intravisit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ pub trait Visitor<'v>: Sized {
320320
fn visit_foreign_item(&mut self, i: &'v ForeignItem<'v>) -> Self::Result {
321321
walk_foreign_item(self, i)
322322
}
323-
fn visit_local(&mut self, l: &'v Local<'v>) -> Self::Result {
323+
fn visit_local(&mut self, l: &'v LetStmt<'v>) -> Self::Result {
324324
walk_local(self, l)
325325
}
326326
fn visit_block(&mut self, b: &'v Block<'v>) -> Self::Result {
@@ -606,7 +606,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
606606
V::Result::output()
607607
}
608608

609-
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local<'v>) -> V::Result {
609+
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v LetStmt<'v>) -> V::Result {
610610
// Intentionally visiting the expr first - the initialization expr
611611
// dominates the local's definition.
612612
visit_opt!(visitor, visit_expr, local.init);

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,9 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
639639
}
640640
}
641641

642-
if !unnormalized_trait_sig.output().references_error() {
643-
debug_assert!(
644-
!collector.types.is_empty(),
645-
"expect >0 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`"
642+
if !unnormalized_trait_sig.output().references_error() && collector.types.is_empty() {
643+
tcx.dcx().delayed_bug(
644+
"expect >0 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`",
646645
);
647646
}
648647

compiler/rustc_hir_analysis/src/check/region.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet;
1111
use rustc_hir as hir;
1212
use rustc_hir::def_id::DefId;
1313
use rustc_hir::intravisit::{self, Visitor};
14-
use rustc_hir::{Arm, Block, Expr, Local, Pat, PatKind, Stmt};
14+
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
1515
use rustc_index::Idx;
1616
use rustc_middle::middle::region::*;
1717
use rustc_middle::ty::TyCtxt;
@@ -123,7 +123,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
123123

124124
for (i, statement) in blk.stmts.iter().enumerate() {
125125
match statement.kind {
126-
hir::StmtKind::Let(hir::Local { els: Some(els), .. }) => {
126+
hir::StmtKind::Let(LetStmt { els: Some(els), .. }) => {
127127
// Let-else has a special lexical structure for variables.
128128
// First we take a checkpoint of the current scope context here.
129129
let mut prev_cx = visitor.cx;
@@ -855,7 +855,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
855855
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
856856
resolve_expr(self, ex);
857857
}
858-
fn visit_local(&mut self, l: &'tcx Local<'tcx>) {
858+
fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) {
859859
resolve_local(self, Some(l.pat), l.init)
860860
}
861861
}

compiler/rustc_hir_pretty/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a> State<'a> {
113113
// `hir_map` to reconstruct their full structure for pretty
114114
// printing.
115115
Node::Ctor(..) => panic!("cannot print isolated Ctor"),
116-
Node::Local(a) => self.print_local_decl(a),
116+
Node::LetStmt(a) => self.print_local_decl(a),
117117
Node::Crate(..) => panic!("cannot print Crate"),
118118
Node::WhereBoundPredicate(pred) => {
119119
self.print_formal_generic_params(pred.bound_generic_params);
@@ -1544,7 +1544,7 @@ impl<'a> State<'a> {
15441544
self.end()
15451545
}
15461546

1547-
fn print_local_decl(&mut self, loc: &hir::Local<'_>) {
1547+
fn print_local_decl(&mut self, loc: &hir::LetStmt<'_>) {
15481548
self.print_pat(loc.pat);
15491549
if let Some(ty) = loc.ty {
15501550
self.word_space(":");

compiler/rustc_hir_typeck/src/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
408408
}
409409
}
410410
}
411-
if let hir::Node::Local(hir::Local { ty: Some(_), pat, .. }) = node {
411+
if let hir::Node::LetStmt(hir::LetStmt { ty: Some(_), pat, .. }) = node {
412412
return Some((pat.span, "expected because of this assignment".to_string()));
413413
}
414414
None

0 commit comments

Comments
 (0)