Skip to content

Commit 4a19711

Browse files
committed
Move ConstArg::span to AnonConst::span
1 parent 4dc46f7 commit 4a19711

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15921592
def_id: anon_const,
15931593
hir_id: const_id,
15941594
body: const_body,
1595+
span,
15951596
})),
15961597
is_host_effect: true,
15971598
},

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,11 +1187,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11871187
hir_id: this.lower_node_id(node_id),
11881188
body: this
11891189
.lower_const_body(path_expr.span, Some(&path_expr)),
1190+
span,
11901191
})
11911192
});
11921193
return GenericArg::Const(ConstArg {
11931194
value: ct,
1194-
span,
11951195
is_desugared_from_effects: false,
11961196
});
11971197
}
@@ -1203,7 +1203,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12031203
}
12041204
ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg {
12051205
value: self.lower_anon_const(ct),
1206-
span: self.lower_span(ct.value.span),
12071206
is_desugared_from_effects: false,
12081207
}),
12091208
}
@@ -2349,6 +2348,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23492348
def_id: this.local_def_id(c.id),
23502349
hir_id: this.lower_node_id(c.id),
23512350
body: this.lower_const_body(c.value.span, Some(&c.value)),
2351+
span: this.lower_span(c.value.span),
23522352
}))
23532353
}
23542354

@@ -2656,8 +2656,7 @@ impl<'hir> GenericArgsCtor<'hir> {
26562656

26572657
lcx.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
26582658
self.args.push(hir::GenericArg::Const(hir::ConstArg {
2659-
value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body }),
2660-
span,
2659+
value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body, span }),
26612660
is_desugared_from_effects: true,
26622661
}))
26632662
}

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ impl<'hir> PathSegment<'hir> {
232232
#[derive(Clone, Copy, Debug, HashStable_Generic)]
233233
pub struct ConstArg<'hir> {
234234
pub value: &'hir AnonConst,
235-
pub span: Span,
236235
/// Indicates whether this comes from a `~const` desugaring.
237236
pub is_desugared_from_effects: bool,
238237
}
@@ -262,7 +261,7 @@ impl GenericArg<'_> {
262261
match self {
263262
GenericArg::Lifetime(l) => l.ident.span,
264263
GenericArg::Type(t) => t.span,
265-
GenericArg::Const(c) => c.span,
264+
GenericArg::Const(c) => c.value.span,
266265
GenericArg::Infer(i) => i.span,
267266
}
268267
}
@@ -1591,6 +1590,7 @@ pub struct AnonConst {
15911590
pub hir_id: HirId,
15921591
pub def_id: LocalDefId,
15931592
pub body: BodyId,
1593+
pub span: Span,
15941594
}
15951595

15961596
/// An inline constant expression `const { something }`.

compiler/rustc_lint/src/pass_by_value.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ fn gen_args(cx: &LateContext<'_>, segment: &PathSegment<'_>) -> String {
7373
GenericArg::Type(ty) => {
7474
cx.tcx.sess.source_map().span_to_snippet(ty.span).unwrap_or_else(|_| "_".into())
7575
}
76-
GenericArg::Const(c) => {
77-
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_else(|_| "_".into())
78-
}
76+
GenericArg::Const(c) => cx
77+
.tcx
78+
.sess
79+
.source_map()
80+
.span_to_snippet(c.value.span)
81+
.unwrap_or_else(|_| "_".into()),
7982
GenericArg::Infer(_) => String::from("_"),
8083
})
8184
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)