Move ConstArg::span
to AnonConst::span
This commit is contained in:
parent
4dc46f7f17
commit
4a19711b25
4 changed files with 12 additions and 9 deletions
|
@ -1592,6 +1592,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
def_id: anon_const,
|
def_id: anon_const,
|
||||||
hir_id: const_id,
|
hir_id: const_id,
|
||||||
body: const_body,
|
body: const_body,
|
||||||
|
span,
|
||||||
})),
|
})),
|
||||||
is_host_effect: true,
|
is_host_effect: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1187,11 +1187,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
hir_id: this.lower_node_id(node_id),
|
hir_id: this.lower_node_id(node_id),
|
||||||
body: this
|
body: this
|
||||||
.lower_const_body(path_expr.span, Some(&path_expr)),
|
.lower_const_body(path_expr.span, Some(&path_expr)),
|
||||||
|
span,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
return GenericArg::Const(ConstArg {
|
return GenericArg::Const(ConstArg {
|
||||||
value: ct,
|
value: ct,
|
||||||
span,
|
|
||||||
is_desugared_from_effects: false,
|
is_desugared_from_effects: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1203,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
}
|
}
|
||||||
ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg {
|
ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg {
|
||||||
value: self.lower_anon_const(ct),
|
value: self.lower_anon_const(ct),
|
||||||
span: self.lower_span(ct.value.span),
|
|
||||||
is_desugared_from_effects: false,
|
is_desugared_from_effects: false,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -2349,6 +2348,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
def_id: this.local_def_id(c.id),
|
def_id: this.local_def_id(c.id),
|
||||||
hir_id: this.lower_node_id(c.id),
|
hir_id: this.lower_node_id(c.id),
|
||||||
body: this.lower_const_body(c.value.span, Some(&c.value)),
|
body: this.lower_const_body(c.value.span, Some(&c.value)),
|
||||||
|
span: this.lower_span(c.value.span),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2656,8 +2656,7 @@ impl<'hir> GenericArgsCtor<'hir> {
|
||||||
|
|
||||||
lcx.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
|
lcx.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
|
||||||
self.args.push(hir::GenericArg::Const(hir::ConstArg {
|
self.args.push(hir::GenericArg::Const(hir::ConstArg {
|
||||||
value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body }),
|
value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body, span }),
|
||||||
span,
|
|
||||||
is_desugared_from_effects: true,
|
is_desugared_from_effects: true,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,6 @@ impl<'hir> PathSegment<'hir> {
|
||||||
#[derive(Clone, Copy, Debug, HashStable_Generic)]
|
#[derive(Clone, Copy, Debug, HashStable_Generic)]
|
||||||
pub struct ConstArg<'hir> {
|
pub struct ConstArg<'hir> {
|
||||||
pub value: &'hir AnonConst,
|
pub value: &'hir AnonConst,
|
||||||
pub span: Span,
|
|
||||||
/// Indicates whether this comes from a `~const` desugaring.
|
/// Indicates whether this comes from a `~const` desugaring.
|
||||||
pub is_desugared_from_effects: bool,
|
pub is_desugared_from_effects: bool,
|
||||||
}
|
}
|
||||||
|
@ -262,7 +261,7 @@ impl GenericArg<'_> {
|
||||||
match self {
|
match self {
|
||||||
GenericArg::Lifetime(l) => l.ident.span,
|
GenericArg::Lifetime(l) => l.ident.span,
|
||||||
GenericArg::Type(t) => t.span,
|
GenericArg::Type(t) => t.span,
|
||||||
GenericArg::Const(c) => c.span,
|
GenericArg::Const(c) => c.value.span,
|
||||||
GenericArg::Infer(i) => i.span,
|
GenericArg::Infer(i) => i.span,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1591,6 +1590,7 @@ pub struct AnonConst {
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub def_id: LocalDefId,
|
pub def_id: LocalDefId,
|
||||||
pub body: BodyId,
|
pub body: BodyId,
|
||||||
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An inline constant expression `const { something }`.
|
/// An inline constant expression `const { something }`.
|
||||||
|
|
|
@ -73,9 +73,12 @@ fn gen_args(cx: &LateContext<'_>, segment: &PathSegment<'_>) -> String {
|
||||||
GenericArg::Type(ty) => {
|
GenericArg::Type(ty) => {
|
||||||
cx.tcx.sess.source_map().span_to_snippet(ty.span).unwrap_or_else(|_| "_".into())
|
cx.tcx.sess.source_map().span_to_snippet(ty.span).unwrap_or_else(|_| "_".into())
|
||||||
}
|
}
|
||||||
GenericArg::Const(c) => {
|
GenericArg::Const(c) => cx
|
||||||
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_else(|_| "_".into())
|
.tcx
|
||||||
}
|
.sess
|
||||||
|
.source_map()
|
||||||
|
.span_to_snippet(c.value.span)
|
||||||
|
.unwrap_or_else(|_| "_".into()),
|
||||||
GenericArg::Infer(_) => String::from("_"),
|
GenericArg::Infer(_) => String::from("_"),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue