Skip to content

Commit 6c199c8

Browse files
committed
Auto merge of #129033 - cuviper:beta-next, r=cuviper
[beta] backports and bump stage0 - Disable jump threading of float equality #128271 - Normalize when equating `dyn` tails in MIR borrowck #128694 - Improve `Ord` violation help #128273 - bump stage0 to stable 1.80.1 - Revert #125915 on beta #128760 - derive(SmartPointer): register helper attributes #128925 - Fix bug in `Parser::look_ahead`. #128994 r? cuviper
2 parents 2059132 + ef56e6f commit 6c199c8

File tree

95 files changed

+1394
-1392
lines changed

Some content is hidden

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

95 files changed

+1394
-1392
lines changed

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

+10-13
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
187187
.emit();
188188
}
189189
hir::InlineAsmOperand::Const {
190-
anon_const: self.lower_anon_const_to_anon_const(anon_const),
190+
anon_const: self.lower_anon_const(anon_const),
191191
}
192192
}
193193
InlineAsmOperand::Sym { sym } => {
@@ -222,21 +222,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
222222
};
223223

224224
// Wrap the expression in an AnonConst.
225-
let parent_def_id = self.current_def_id_parent;
225+
let parent_def_id = self.current_hir_id_owner;
226226
let node_id = self.next_node_id();
227-
// HACK(min_generic_const_args): see lower_anon_const
228-
if !expr.is_potential_trivial_const_arg() {
229-
self.create_def(
230-
parent_def_id,
231-
node_id,
232-
kw::Empty,
233-
DefKind::AnonConst,
234-
*op_sp,
235-
);
236-
}
227+
self.create_def(
228+
parent_def_id.def_id,
229+
node_id,
230+
kw::Empty,
231+
DefKind::AnonConst,
232+
*op_sp,
233+
);
237234
let anon_const = AnonConst { id: node_id, value: P(expr) };
238235
hir::InlineAsmOperand::SymFn {
239-
anon_const: self.lower_anon_const_to_anon_const(&anon_const),
236+
anon_const: self.lower_anon_const(&anon_const),
240237
}
241238
}
242239
}

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

+62-73
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
7575
let kind = match &e.kind {
7676
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
7777
ExprKind::ConstBlock(c) => {
78-
let c = self.with_new_scopes(c.value.span, |this| {
79-
let def_id = this.local_def_id(c.id);
80-
hir::ConstBlock {
81-
def_id,
82-
hir_id: this.lower_node_id(c.id),
83-
body: this.with_def_id_parent(def_id, |this| {
84-
this.lower_const_body(c.value.span, Some(&c.value))
85-
}),
86-
}
78+
let c = self.with_new_scopes(c.value.span, |this| hir::ConstBlock {
79+
def_id: this.local_def_id(c.id),
80+
hir_id: this.lower_node_id(c.id),
81+
body: this.lower_const_body(c.value.span, Some(&c.value)),
8782
});
8883
hir::ExprKind::ConstBlock(c)
8984
}
@@ -382,14 +377,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
382377
let mut generic_args = ThinVec::new();
383378
for (idx, arg) in args.into_iter().enumerate() {
384379
if legacy_args_idx.contains(&idx) {
385-
let parent_def_id = self.current_def_id_parent;
380+
let parent_def_id = self.current_hir_id_owner;
386381
let node_id = self.next_node_id();
387382

388-
// HACK(min_generic_const_args): see lower_anon_const
389-
if !arg.is_potential_trivial_const_arg() {
390-
// Add a definition for the in-band const def.
391-
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
392-
}
383+
// Add a definition for the in-band const def.
384+
self.create_def(
385+
parent_def_id.def_id,
386+
node_id,
387+
kw::Empty,
388+
DefKind::AnonConst,
389+
f.span,
390+
);
393391

394392
let anon_const = AnonConst { id: node_id, value: arg };
395393
generic_args.push(AngleBracketedArg::Arg(GenericArg::Const(anon_const)));
@@ -624,7 +622,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
624622
coroutine_source: hir::CoroutineSource,
625623
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
626624
) -> hir::ExprKind<'hir> {
627-
let closure_def_id = self.local_def_id(closure_node_id);
628625
let coroutine_kind = hir::CoroutineKind::Desugared(desugaring_kind, coroutine_source);
629626

630627
// The `async` desugaring takes a resume argument and maintains a `task_context`,
@@ -675,24 +672,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
675672
lifetime_elision_allowed: false,
676673
});
677674

678-
let body = self.with_def_id_parent(closure_def_id, move |this| {
679-
this.lower_body(move |this| {
680-
this.coroutine_kind = Some(coroutine_kind);
675+
let body = self.lower_body(move |this| {
676+
this.coroutine_kind = Some(coroutine_kind);
681677

682-
let old_ctx = this.task_context;
683-
if task_context.is_some() {
684-
this.task_context = task_context;
685-
}
686-
let res = body(this);
687-
this.task_context = old_ctx;
678+
let old_ctx = this.task_context;
679+
if task_context.is_some() {
680+
this.task_context = task_context;
681+
}
682+
let res = body(this);
683+
this.task_context = old_ctx;
688684

689-
(params, res)
690-
})
685+
(params, res)
691686
});
692687

693688
// `static |<_task_context?>| -> <return_ty> { <body> }`:
694689
hir::ExprKind::Closure(self.arena.alloc(hir::Closure {
695-
def_id: closure_def_id,
690+
def_id: self.local_def_id(closure_node_id),
696691
binder: hir::ClosureBinder::Default,
697692
capture_clause,
698693
bound_generic_params: &[],
@@ -971,38 +966,35 @@ impl<'hir> LoweringContext<'_, 'hir> {
971966
fn_decl_span: Span,
972967
fn_arg_span: Span,
973968
) -> hir::ExprKind<'hir> {
974-
let closure_def_id = self.local_def_id(closure_id);
975969
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
976970

977971
let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {
978-
this.with_def_id_parent(closure_def_id, move |this| {
979-
let mut coroutine_kind = if this
980-
.attrs
981-
.get(&closure_hir_id.local_id)
982-
.is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine)))
983-
{
984-
Some(hir::CoroutineKind::Coroutine(Movability::Movable))
985-
} else {
986-
None
987-
};
988-
let body_id = this.lower_fn_body(decl, |this| {
989-
this.coroutine_kind = coroutine_kind;
990-
let e = this.lower_expr_mut(body);
991-
coroutine_kind = this.coroutine_kind;
992-
e
993-
});
994-
let coroutine_option =
995-
this.closure_movability_for_fn(decl, fn_decl_span, coroutine_kind, movability);
996-
(body_id, coroutine_option)
997-
})
972+
let mut coroutine_kind = if this
973+
.attrs
974+
.get(&closure_hir_id.local_id)
975+
.is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine)))
976+
{
977+
Some(hir::CoroutineKind::Coroutine(Movability::Movable))
978+
} else {
979+
None
980+
};
981+
let body_id = this.lower_fn_body(decl, |this| {
982+
this.coroutine_kind = coroutine_kind;
983+
let e = this.lower_expr_mut(body);
984+
coroutine_kind = this.coroutine_kind;
985+
e
986+
});
987+
let coroutine_option =
988+
this.closure_movability_for_fn(decl, fn_decl_span, coroutine_kind, movability);
989+
(body_id, coroutine_option)
998990
});
999991

1000992
let bound_generic_params = self.lower_lifetime_binder(closure_id, generic_params);
1001993
// Lower outside new scope to preserve `is_in_loop_condition`.
1002994
let fn_decl = self.lower_fn_decl(decl, closure_id, fn_decl_span, FnDeclKind::Closure, None);
1003995

1004996
let c = self.arena.alloc(hir::Closure {
1005-
def_id: closure_def_id,
997+
def_id: self.local_def_id(closure_id),
1006998
binder: binder_clause,
1007999
capture_clause,
10081000
bound_generic_params,
@@ -1074,7 +1066,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
10741066
fn_decl_span: Span,
10751067
fn_arg_span: Span,
10761068
) -> hir::ExprKind<'hir> {
1077-
let closure_def_id = self.local_def_id(closure_id);
10781069
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
10791070

10801071
assert_matches!(
@@ -1084,29 +1075,27 @@ impl<'hir> LoweringContext<'_, 'hir> {
10841075
);
10851076

10861077
let body = self.with_new_scopes(fn_decl_span, |this| {
1087-
this.with_def_id_parent(closure_def_id, |this| {
1088-
let inner_decl =
1089-
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
1090-
1091-
// Transform `async |x: u8| -> X { ... }` into
1092-
// `|x: u8| || -> X { ... }`.
1093-
let body_id = this.lower_body(|this| {
1094-
let (parameters, expr) = this.lower_coroutine_body_with_moved_arguments(
1095-
&inner_decl,
1096-
|this| this.with_new_scopes(fn_decl_span, |this| this.lower_expr_mut(body)),
1097-
fn_decl_span,
1098-
body.span,
1099-
coroutine_kind,
1100-
hir::CoroutineSource::Closure,
1101-
);
1078+
let inner_decl =
1079+
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
1080+
1081+
// Transform `async |x: u8| -> X { ... }` into
1082+
// `|x: u8| || -> X { ... }`.
1083+
let body_id = this.lower_body(|this| {
1084+
let (parameters, expr) = this.lower_coroutine_body_with_moved_arguments(
1085+
&inner_decl,
1086+
|this| this.with_new_scopes(fn_decl_span, |this| this.lower_expr_mut(body)),
1087+
fn_decl_span,
1088+
body.span,
1089+
coroutine_kind,
1090+
hir::CoroutineSource::Closure,
1091+
);
11021092

1103-
let hir_id = this.lower_node_id(coroutine_kind.closure_id());
1104-
this.maybe_forward_track_caller(body.span, closure_hir_id, hir_id);
1093+
let hir_id = this.lower_node_id(coroutine_kind.closure_id());
1094+
this.maybe_forward_track_caller(body.span, closure_hir_id, hir_id);
11051095

1106-
(parameters, expr)
1107-
});
1108-
body_id
1109-
})
1096+
(parameters, expr)
1097+
});
1098+
body_id
11101099
});
11111100

11121101
let bound_generic_params = self.lower_lifetime_binder(closure_id, generic_params);
@@ -1117,7 +1106,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11171106
self.lower_fn_decl(&decl, closure_id, fn_decl_span, FnDeclKind::Closure, None);
11181107

11191108
let c = self.arena.alloc(hir::Closure {
1120-
def_id: closure_def_id,
1109+
def_id: self.local_def_id(closure_id),
11211110
binder: binder_clause,
11221111
capture_clause,
11231112
bound_generic_params,

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

+1-11
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
181181
intravisit::walk_generic_param(self, param);
182182
}
183183

184-
fn visit_const_param_default(&mut self, param: HirId, ct: &'hir ConstArg<'hir>) {
184+
fn visit_const_param_default(&mut self, param: HirId, ct: &'hir AnonConst) {
185185
self.with_parent(param, |this| {
186186
intravisit::walk_const_param_default(this, ct);
187187
})
@@ -229,7 +229,6 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
229229
}
230230

231231
fn visit_anon_const(&mut self, constant: &'hir AnonConst) {
232-
// FIXME: use real span?
233232
self.insert(DUMMY_SP, constant.hir_id, Node::AnonConst(constant));
234233

235234
self.with_parent(constant.hir_id, |this| {
@@ -245,15 +244,6 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
245244
});
246245
}
247246

248-
fn visit_const_arg(&mut self, const_arg: &'hir ConstArg<'hir>) {
249-
// FIXME: use real span?
250-
self.insert(DUMMY_SP, const_arg.hir_id, Node::ConstArg(const_arg));
251-
252-
self.with_parent(const_arg.hir_id, |this| {
253-
intravisit::walk_const_arg(this, const_arg);
254-
});
255-
}
256-
257247
fn visit_expr(&mut self, expr: &'hir Expr<'hir>) {
258248
self.insert(expr.span, expr.hir_id, Node::Expr(expr));
259249

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

+10-19
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
6161

6262
for (def_id, info) in lctx.children {
6363
let owner = self.owners.ensure_contains_elem(def_id, || hir::MaybeOwner::Phantom);
64-
debug_assert!(
65-
matches!(owner, hir::MaybeOwner::Phantom),
66-
"duplicate copy of {def_id:?} in lctx.children"
67-
);
64+
debug_assert!(matches!(owner, hir::MaybeOwner::Phantom));
6865
*owner = info;
6966
}
7067
}
@@ -716,7 +713,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
716713
hir_id,
717714
def_id: self.local_def_id(v.id),
718715
data: self.lower_variant_data(hir_id, &v.data),
719-
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const_to_anon_const(e)),
716+
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const(e)),
720717
ident: self.lower_ident(v.ident),
721718
span: self.lower_span(v.span),
722719
}
@@ -1604,15 +1601,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
16041601

16051602
if let Some((span, hir_id, def_id)) = host_param_parts {
16061603
let const_node_id = self.next_node_id();
1607-
let anon_const_did =
1604+
let anon_const =
16081605
self.create_def(def_id, const_node_id, kw::Empty, DefKind::AnonConst, span);
16091606

16101607
let const_id = self.next_id();
16111608
let const_expr_id = self.next_id();
16121609
let bool_id = self.next_id();
16131610

16141611
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
1615-
self.children.push((anon_const_did, hir::MaybeOwner::NonOwner(const_id)));
1612+
self.children.push((anon_const, hir::MaybeOwner::NonOwner(const_id)));
16161613

16171614
let const_body = self.lower_body(|this| {
16181615
(
@@ -1627,17 +1624,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
16271624
)
16281625
});
16291626

1630-
let default_ac = self.arena.alloc(hir::AnonConst {
1631-
def_id: anon_const_did,
1632-
hir_id: const_id,
1633-
body: const_body,
1634-
span,
1635-
});
1636-
let default_ct = self.arena.alloc(hir::ConstArg {
1637-
hir_id: self.next_id(),
1638-
kind: hir::ConstArgKind::Anon(default_ac),
1639-
is_desugared_from_effects: false,
1640-
});
16411627
let param = hir::GenericParam {
16421628
def_id,
16431629
hir_id,
@@ -1662,7 +1648,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
16621648
)),
16631649
)),
16641650
// FIXME(effects) we might not need a default.
1665-
default: Some(default_ct),
1651+
default: Some(self.arena.alloc(hir::AnonConst {
1652+
def_id: anon_const,
1653+
hir_id: const_id,
1654+
body: const_body,
1655+
span,
1656+
})),
16661657
is_host_effect: true,
16671658
synthetic: true,
16681659
},

0 commit comments

Comments
 (0)