Skip to content

Commit ce9b15c

Browse files
committed
Auto merge of #152264 - JonathanBrouwer:rollup-pBsxN9G, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - #152126 (Convert to inline diagnostics in `rustc_mir_build`) - #152186 (Convert to inline diagnostics in `rustc_const_eval`) - #152234 (Dont strip const blocks in array lengths) - #152243 (Use relative paths for std links in rustc-docs)
2 parents efc9e1b + 7f514e2 commit ce9b15c

File tree

31 files changed

+1277
-1642
lines changed

31 files changed

+1277
-1642
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,7 +3703,6 @@ dependencies = [
37033703
"rustc_ast",
37043704
"rustc_data_structures",
37053705
"rustc_errors",
3706-
"rustc_fluent_macro",
37073706
"rustc_hir",
37083707
"rustc_index",
37093708
"rustc_infer",
@@ -4281,7 +4280,6 @@ dependencies = [
42814280
"rustc_ast",
42824281
"rustc_data_structures",
42834282
"rustc_errors",
4284-
"rustc_fluent_macro",
42854283
"rustc_hir",
42864284
"rustc_index",
42874285
"rustc_infer",

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
827827
hir_id,
828828
def_id: self.local_def_id(v.id),
829829
data: self.lower_variant_data(hir_id, item_kind, &v.data),
830-
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const_to_anon_const(e)),
830+
disr_expr: v
831+
.disr_expr
832+
.as_ref()
833+
.map(|e| self.lower_anon_const_to_anon_const(e, e.value.span)),
831834
ident: self.lower_ident(v.ident),
832835
span: self.lower_span(v.span),
833836
}
@@ -917,7 +920,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
917920
None => Ident::new(sym::integer(index), self.lower_span(f.span)),
918921
},
919922
vis_span: self.lower_span(f.vis.span),
920-
default: f.default.as_ref().map(|v| self.lower_anon_const_to_anon_const(v)),
923+
default: f
924+
.default
925+
.as_ref()
926+
.map(|v| self.lower_anon_const_to_anon_const(v, v.value.span)),
921927
ty,
922928
safety: self.lower_safety(f.safety, hir::Safety::Safe),
923929
}

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,15 +2425,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24252425
);
24262426

24272427
let lowered_args = self.arena.alloc_from_iter(args.iter().map(|arg| {
2428-
let const_arg = if let ExprKind::ConstBlock(anon_const) = &arg.kind {
2429-
let def_id = self.local_def_id(anon_const.id);
2430-
let def_kind = self.tcx.def_kind(def_id);
2431-
assert_eq!(DefKind::AnonConst, def_kind);
2432-
self.lower_anon_const_to_const_arg(anon_const)
2433-
} else {
2434-
self.lower_expr_to_const_arg_direct(arg)
2435-
};
2436-
2428+
let const_arg = self.lower_expr_to_const_arg_direct(arg);
24372429
&*self.arena.alloc(const_arg)
24382430
}));
24392431

@@ -2445,16 +2437,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24452437
}
24462438
ExprKind::Tup(exprs) => {
24472439
let exprs = self.arena.alloc_from_iter(exprs.iter().map(|expr| {
2448-
let expr = if let ExprKind::ConstBlock(anon_const) = &expr.kind {
2449-
let def_id = self.local_def_id(anon_const.id);
2450-
let def_kind = self.tcx.def_kind(def_id);
2451-
assert_eq!(DefKind::AnonConst, def_kind);
2452-
2453-
self.lower_anon_const_to_const_arg(anon_const)
2454-
} else {
2455-
self.lower_expr_to_const_arg_direct(&expr)
2456-
};
2457-
2440+
let expr = self.lower_expr_to_const_arg_direct(&expr);
24582441
&*self.arena.alloc(expr)
24592442
}));
24602443

@@ -2494,16 +2477,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24942477
// then go unused as the `Target::ExprField` is not actually
24952478
// corresponding to `Node::ExprField`.
24962479
self.lower_attrs(hir_id, &f.attrs, f.span, Target::ExprField);
2497-
2498-
let expr = if let ExprKind::ConstBlock(anon_const) = &f.expr.kind {
2499-
let def_id = self.local_def_id(anon_const.id);
2500-
let def_kind = self.tcx.def_kind(def_id);
2501-
assert_eq!(DefKind::AnonConst, def_kind);
2502-
2503-
self.lower_anon_const_to_const_arg(anon_const)
2504-
} else {
2505-
self.lower_expr_to_const_arg_direct(&f.expr)
2506-
};
2480+
let expr = self.lower_expr_to_const_arg_direct(&f.expr);
25072481

25082482
&*self.arena.alloc(hir::ConstArgExprField {
25092483
hir_id,
@@ -2521,13 +2495,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25212495
}
25222496
ExprKind::Array(elements) => {
25232497
let lowered_elems = self.arena.alloc_from_iter(elements.iter().map(|element| {
2524-
let const_arg = if let ExprKind::ConstBlock(anon_const) = &element.kind {
2525-
let def_id = self.local_def_id(anon_const.id);
2526-
assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
2527-
self.lower_anon_const_to_const_arg(anon_const)
2528-
} else {
2529-
self.lower_expr_to_const_arg_direct(element)
2530-
};
2498+
let const_arg = self.lower_expr_to_const_arg_direct(element);
25312499
&*self.arena.alloc(const_arg)
25322500
}));
25332501
let array_expr = self.arena.alloc(hir::ConstArgArrayExpr {
@@ -2557,6 +2525,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25572525
| ExprKind::Call(..)
25582526
| ExprKind::Tup(..)
25592527
| ExprKind::Array(..)
2528+
| ExprKind::ConstBlock(..)
25602529
)
25612530
{
25622531
return self.lower_expr_to_const_arg_direct(expr);
@@ -2586,6 +2555,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25862555
span,
25872556
}
25882557
}
2558+
ExprKind::ConstBlock(anon_const) => {
2559+
let def_id = self.local_def_id(anon_const.id);
2560+
assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
2561+
self.lower_anon_const_to_const_arg(anon_const, span)
2562+
}
25892563
_ => overly_complex_const(self),
25902564
}
25912565
}
@@ -2596,11 +2570,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25962570
&mut self,
25972571
anon: &AnonConst,
25982572
) -> &'hir hir::ConstArg<'hir> {
2599-
self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
2573+
self.arena.alloc(self.lower_anon_const_to_const_arg(anon, anon.value.span))
26002574
}
26012575

26022576
#[instrument(level = "debug", skip(self))]
2603-
fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
2577+
fn lower_anon_const_to_const_arg(
2578+
&mut self,
2579+
anon: &AnonConst,
2580+
span: Span,
2581+
) -> hir::ConstArg<'hir> {
26042582
let tcx = self.tcx;
26052583

26062584
// We cannot change parsing depending on feature gates available,
@@ -2611,7 +2589,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
26112589
if tcx.features().min_generic_const_args() {
26122590
return match anon.mgca_disambiguation {
26132591
MgcaDisambiguation::AnonConst => {
2614-
let lowered_anon = self.lower_anon_const_to_anon_const(anon);
2592+
let lowered_anon = self.lower_anon_const_to_anon_const(anon, span);
26152593
ConstArg {
26162594
hir_id: self.next_id(),
26172595
kind: hir::ConstArgKind::Anon(lowered_anon),
@@ -2657,7 +2635,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
26572635
};
26582636
}
26592637

2660-
let lowered_anon = self.lower_anon_const_to_anon_const(anon);
2638+
let lowered_anon = self.lower_anon_const_to_anon_const(anon, anon.value.span);
26612639
ConstArg {
26622640
hir_id: self.next_id(),
26632641
kind: hir::ConstArgKind::Anon(lowered_anon),
@@ -2667,15 +2645,19 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
26672645

26682646
/// See [`hir::ConstArg`] for when to use this function vs
26692647
/// [`Self::lower_anon_const_to_const_arg`].
2670-
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
2648+
fn lower_anon_const_to_anon_const(
2649+
&mut self,
2650+
c: &AnonConst,
2651+
span: Span,
2652+
) -> &'hir hir::AnonConst {
26712653
self.arena.alloc(self.with_new_scopes(c.value.span, |this| {
26722654
let def_id = this.local_def_id(c.id);
26732655
let hir_id = this.lower_node_id(c.id);
26742656
hir::AnonConst {
26752657
def_id,
26762658
hir_id,
26772659
body: this.lower_const_body(c.value.span, Some(&c.value)),
2678-
span: this.lower_span(c.value.span),
2660+
span: this.lower_span(span),
26792661
}
26802662
}))
26812663
}

compiler/rustc_const_eval/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ rustc_apfloat = "0.2.0"
1111
rustc_ast = { path = "../rustc_ast" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_errors = { path = "../rustc_errors" }
14-
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1514
rustc_hir = { path = "../rustc_hir" }
1615
rustc_index = { path = "../rustc_index" }
1716
rustc_infer = { path = "../rustc_infer" }

0 commit comments

Comments
 (0)