Skip to content

Commit a162071

Browse files
committed
Auto merge of rust-lang#120437 - matthiaskrgr:rollup-h1uai71, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#120358 (Bump Fuchsia, build tests, and use 8 core bots) - rust-lang#120402 (Make the coroutine def id of an async closure the child of the closure def id) - rust-lang#120420 (Stop using derivative in rustc_pattern_analysis) - rust-lang#120425 (Remove unnecessary unit returns in query declarations) - rust-lang#120428 (hir: Two preparatory changes for rust-lang#120206) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6351247 + 4a759f0 commit a162071

File tree

28 files changed

+293
-91
lines changed

28 files changed

+293
-91
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ jobs:
291291
- name: x86_64-gnu-integration
292292
env:
293293
CI_ONLY_WHEN_CHANNEL: nightly
294-
os: ubuntu-20.04-16core-64gb
294+
os: ubuntu-20.04-8core-32gb
295295
- name: x86_64-gnu-debug
296296
os: ubuntu-20.04-8core-32gb
297297
env: {}

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4342,7 +4342,6 @@ dependencies = [
43424342
name = "rustc_pattern_analysis"
43434343
version = "0.0.0"
43444344
dependencies = [
4345-
"derivative",
43464345
"rustc-hash",
43474346
"rustc_apfloat",
43484347
"rustc_arena",

compiler/rustc_ast_lowering/src/expr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
153153
}
154154
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
155155
hir::ExprKind::Let(self.arena.alloc(hir::Let {
156-
hir_id: self.next_id(),
157156
span: self.lower_span(*span),
158157
pat: self.lower_pat(pat),
159158
ty: None,

compiler/rustc_ast_lowering/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23052305
match c.value.kind {
23062306
ExprKind::Underscore => {
23072307
if self.tcx.features().generic_arg_infer {
2308-
hir::ArrayLen::Infer(self.lower_node_id(c.id), self.lower_span(c.value.span))
2308+
hir::ArrayLen::Infer(hir::InferArg {
2309+
hir_id: self.lower_node_id(c.id),
2310+
span: self.lower_span(c.value.span),
2311+
})
23092312
} else {
23102313
feature_err(
23112314
&self.tcx.sess,

compiler/rustc_hir/src/hir.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ pub struct Arm<'hir> {
12731273
/// desugaring to if-let. Only let-else supports the type annotation at present.
12741274
#[derive(Debug, Clone, Copy, HashStable_Generic)]
12751275
pub struct Let<'hir> {
1276-
pub hir_id: HirId,
12771276
pub span: Span,
12781277
pub pat: &'hir Pat<'hir>,
12791278
pub ty: Option<&'hir Ty<'hir>>,
@@ -1532,14 +1531,16 @@ pub type Lit = Spanned<LitKind>;
15321531

15331532
#[derive(Copy, Clone, Debug, HashStable_Generic)]
15341533
pub enum ArrayLen {
1535-
Infer(HirId, Span),
1534+
Infer(InferArg),
15361535
Body(AnonConst),
15371536
}
15381537

15391538
impl ArrayLen {
15401539
pub fn hir_id(&self) -> HirId {
15411540
match self {
1542-
&ArrayLen::Infer(hir_id, _) | &ArrayLen::Body(AnonConst { hir_id, .. }) => hir_id,
1541+
ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(AnonConst { hir_id, .. }) => {
1542+
*hir_id
1543+
}
15431544
}
15441545
}
15451546
}
@@ -2424,7 +2425,7 @@ impl<'hir> Ty<'hir> {
24242425
TyKind::Infer => true,
24252426
TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
24262427
TyKind::Array(ty, length) => {
2427-
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(_, _))
2428+
ty.is_suggestable_infer_ty() || matches!(length, ArrayLen::Infer(..))
24282429
}
24292430
TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
24302431
TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),

compiler/rustc_hir/src/intravisit.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@ pub trait Visitor<'v>: Sized {
341341
fn visit_expr(&mut self, ex: &'v Expr<'v>) {
342342
walk_expr(self, ex)
343343
}
344-
fn visit_let_expr(&mut self, lex: &'v Let<'v>) {
345-
walk_let_expr(self, lex)
346-
}
347344
fn visit_expr_field(&mut self, field: &'v ExprField<'v>) {
348345
walk_expr_field(self, field)
349346
}
@@ -672,7 +669,7 @@ pub fn walk_pat_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v PatField<'
672669

673670
pub fn walk_array_len<'v, V: Visitor<'v>>(visitor: &mut V, len: &'v ArrayLen) {
674671
match len {
675-
&ArrayLen::Infer(hir_id, _span) => visitor.visit_id(hir_id),
672+
ArrayLen::Infer(InferArg { hir_id, span: _ }) => visitor.visit_id(*hir_id),
676673
ArrayLen::Body(c) => visitor.visit_anon_const(c),
677674
}
678675
}
@@ -729,7 +726,12 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
729726
ExprKind::DropTemps(ref subexpression) => {
730727
visitor.visit_expr(subexpression);
731728
}
732-
ExprKind::Let(ref let_expr) => visitor.visit_let_expr(let_expr),
729+
ExprKind::Let(Let { span: _, pat, ty, init, is_recovered: _ }) => {
730+
// match the visit order in walk_local
731+
visitor.visit_expr(init);
732+
visitor.visit_pat(pat);
733+
walk_list!(visitor, visit_ty, ty);
734+
}
733735
ExprKind::If(ref cond, ref then, ref else_opt) => {
734736
visitor.visit_expr(cond);
735737
visitor.visit_expr(then);
@@ -806,14 +808,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
806808
}
807809
}
808810

809-
pub fn walk_let_expr<'v, V: Visitor<'v>>(visitor: &mut V, let_expr: &'v Let<'v>) {
810-
// match the visit order in walk_local
811-
visitor.visit_expr(let_expr.init);
812-
visitor.visit_id(let_expr.hir_id);
813-
visitor.visit_pat(let_expr.pat);
814-
walk_list!(visitor, visit_ty, let_expr.ty);
815-
}
816-
817811
pub fn walk_expr_field<'v, V: Visitor<'v>>(visitor: &mut V, field: &'v ExprField<'v>) {
818812
visitor.visit_id(field.hir_id);
819813
visitor.visit_ident(field.ident);

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25292529
}
25302530
hir::TyKind::Array(ty, length) => {
25312531
let length = match length {
2532-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(tcx.types.usize, None, span),
2532+
hir::ArrayLen::Infer(inf) => self.ct_infer(tcx.types.usize, None, inf.span),
25332533
hir::ArrayLen::Body(constant) => {
25342534
ty::Const::from_anon_const(tcx, constant.def_id)
25352535
}

compiler/rustc_hir_analysis/src/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
146146
}
147147
}
148148
fn visit_array_length(&mut self, length: &'v hir::ArrayLen) {
149-
if let &hir::ArrayLen::Infer(_, span) = length {
150-
self.0.push(span);
149+
if let hir::ArrayLen::Infer(inf) = length {
150+
self.0.push(inf.span);
151151
}
152152
intravisit::walk_array_len(self, length)
153153
}

compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl<'a> State<'a> {
956956

957957
fn print_array_length(&mut self, len: &hir::ArrayLen) {
958958
match len {
959-
hir::ArrayLen::Infer(_, _) => self.word("_"),
959+
hir::ArrayLen::Infer(..) => self.word("_"),
960960
hir::ArrayLen::Body(ct) => self.print_anon_const(ct),
961961
}
962962
}

compiler/rustc_hir_typeck/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
320320
}
321321
ExprKind::Ret(ref expr_opt) => self.check_expr_return(expr_opt.as_deref(), expr),
322322
ExprKind::Become(call) => self.check_expr_become(call, expr),
323-
ExprKind::Let(let_expr) => self.check_expr_let(let_expr),
323+
ExprKind::Let(let_expr) => self.check_expr_let(let_expr, expr.hir_id),
324324
ExprKind::Loop(body, _, source, _) => {
325325
self.check_expr_loop(body, source, expected, expr)
326326
}
@@ -1259,12 +1259,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12591259
}
12601260
}
12611261

1262-
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>) -> Ty<'tcx> {
1262+
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>, hir_id: HirId) -> Ty<'tcx> {
12631263
// for let statements, this is done in check_stmt
12641264
let init = let_expr.init;
12651265
self.warn_if_unreachable(init.hir_id, init.span, "block in `let` expression");
12661266
// otherwise check exactly as a let statement
1267-
self.check_decl(let_expr.into());
1267+
self.check_decl((let_expr, hir_id).into());
12681268
// but return a bool, for this is a boolean expression
12691269
if let Some(error_guaranteed) = let_expr.is_recovered {
12701270
self.set_tainted_by_errors(error_guaranteed);

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
405405

406406
pub fn array_length_to_const(&self, length: &hir::ArrayLen) -> ty::Const<'tcx> {
407407
match length {
408-
&hir::ArrayLen::Infer(_, span) => self.ct_infer(self.tcx.types.usize, None, span),
408+
hir::ArrayLen::Infer(inf) => self.ct_infer(self.tcx.types.usize, None, inf.span),
409409
hir::ArrayLen::Body(anon_const) => {
410410
let span = self.tcx.def_span(anon_const.def_id);
411411
let c = ty::Const::from_anon_const(self.tcx, anon_const.def_id);

compiler/rustc_hir_typeck/src/gather_locals.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ impl<'a> From<&'a hir::Local<'a>> for Declaration<'a> {
4848
}
4949
}
5050

51-
impl<'a> From<&'a hir::Let<'a>> for Declaration<'a> {
52-
fn from(let_expr: &'a hir::Let<'a>) -> Self {
53-
let hir::Let { hir_id, pat, ty, span, init, is_recovered: _ } = *let_expr;
51+
impl<'a> From<(&'a hir::Let<'a>, hir::HirId)> for Declaration<'a> {
52+
fn from((let_expr, hir_id): (&'a hir::Let<'a>, hir::HirId)) -> Self {
53+
let hir::Let { pat, ty, span, init, is_recovered: _ } = *let_expr;
5454
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
5555
}
5656
}
@@ -125,9 +125,11 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
125125
intravisit::walk_local(self, local)
126126
}
127127

128-
fn visit_let_expr(&mut self, let_expr: &'tcx hir::Let<'tcx>) {
129-
self.declare(let_expr.into());
130-
intravisit::walk_let_expr(self, let_expr);
128+
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
129+
if let hir::ExprKind::Let(let_expr) = expr.kind {
130+
self.declare((let_expr, expr.hir_id).into());
131+
}
132+
intravisit::walk_expr(self, expr)
131133
}
132134

133135
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {

compiler/rustc_middle/src/query/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue
109109
// as they will raise an fatal error on query cycles instead.
110110
rustc_queries! {
111111
/// This exists purely for testing the interactions between span_delayed_bug and incremental.
112-
query trigger_span_delayed_bug(key: DefId) -> () {
112+
query trigger_span_delayed_bug(key: DefId) {
113113
desc { "triggering a span delayed bug for testing incremental" }
114114
}
115115

@@ -119,7 +119,7 @@ rustc_queries! {
119119
desc { "compute registered tools for crate" }
120120
}
121121

122-
query early_lint_checks(_: ()) -> () {
122+
query early_lint_checks(_: ()) {
123123
desc { "perform lints prior to macro expansion" }
124124
}
125125

@@ -299,7 +299,7 @@ rustc_queries! {
299299
/// name. This is useful for cases were not all linting code from rustc
300300
/// was called. With the default `None` all registered lints will also
301301
/// be checked for expectation fulfillment.
302-
query check_expectations(key: Option<Symbol>) -> () {
302+
query check_expectations(key: Option<Symbol>) {
303303
eval_always
304304
desc { "checking lint expectations (RFC 2383)" }
305305
}
@@ -906,39 +906,39 @@ rustc_queries! {
906906
}
907907

908908
/// Performs lint checking for the module.
909-
query lint_mod(key: LocalModDefId) -> () {
909+
query lint_mod(key: LocalModDefId) {
910910
desc { |tcx| "linting {}", describe_as_module(key, tcx) }
911911
}
912912

913-
query check_unused_traits(_: ()) -> () {
913+
query check_unused_traits(_: ()) {
914914
desc { "checking unused trait imports in crate" }
915915
}
916916

917917
/// Checks the attributes in the module.
918-
query check_mod_attrs(key: LocalModDefId) -> () {
918+
query check_mod_attrs(key: LocalModDefId) {
919919
desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
920920
}
921921

922922
/// Checks for uses of unstable APIs in the module.
923-
query check_mod_unstable_api_usage(key: LocalModDefId) -> () {
923+
query check_mod_unstable_api_usage(key: LocalModDefId) {
924924
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
925925
}
926926

927927
/// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
928-
query check_mod_const_bodies(key: LocalModDefId) -> () {
928+
query check_mod_const_bodies(key: LocalModDefId) {
929929
desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
930930
}
931931

932932
/// Checks the loops in the module.
933-
query check_mod_loops(key: LocalModDefId) -> () {
933+
query check_mod_loops(key: LocalModDefId) {
934934
desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
935935
}
936936

937-
query check_mod_naked_functions(key: LocalModDefId) -> () {
937+
query check_mod_naked_functions(key: LocalModDefId) {
938938
desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
939939
}
940940

941-
query check_mod_privacy(key: LocalModDefId) -> () {
941+
query check_mod_privacy(key: LocalModDefId) {
942942
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
943943
}
944944

@@ -958,7 +958,7 @@ rustc_queries! {
958958
desc { "finding live symbols in crate" }
959959
}
960960

961-
query check_mod_deathness(key: LocalModDefId) -> () {
961+
query check_mod_deathness(key: LocalModDefId) {
962962
desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
963963
}
964964

@@ -972,7 +972,7 @@ rustc_queries! {
972972
ensure_forwards_result_if_red
973973
}
974974

975-
query collect_mod_item_types(key: LocalModDefId) -> () {
975+
query collect_mod_item_types(key: LocalModDefId) {
976976
desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
977977
}
978978

@@ -1121,7 +1121,7 @@ rustc_queries! {
11211121
eval_always
11221122
desc { "checking effective visibilities" }
11231123
}
1124-
query check_private_in_public(_: ()) -> () {
1124+
query check_private_in_public(_: ()) {
11251125
eval_always
11261126
desc { "checking for private elements in public interfaces" }
11271127
}

compiler/rustc_passes/src/hir_stats.rs

-5
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,6 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
328328
hir_visit::walk_expr(self, e)
329329
}
330330

331-
fn visit_let_expr(&mut self, lex: &'v hir::Let<'v>) {
332-
self.record("Let", Id::Node(lex.hir_id), lex);
333-
hir_visit::walk_let_expr(self, lex)
334-
}
335-
336331
fn visit_expr_field(&mut self, f: &'v hir::ExprField<'v>) {
337332
self.record("ExprField", Id::Node(f.hir_id), f);
338333
hir_visit::walk_expr_field(self, f)

compiler/rustc_pattern_analysis/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
derivative = "2.2.0"
98
rustc-hash = "1.1.0"
109
rustc_apfloat = "0.2.0"
1110
rustc_arena = { path = "../rustc_arena", optional = true }

0 commit comments

Comments
 (0)