diff options
| -rw-r--r-- | compiler/rustc_ast_lowering/src/item.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/pass_by_value.rs | 9 |
4 files changed, 12 insertions, 9 deletions
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 1ac29dfb287..641b747a653 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1592,6 +1592,7 @@ impl<'hir> LoweringContext<'_, 'hir> { def_id: anon_const, hir_id: const_id, body: const_body, + span, })), is_host_effect: true, }, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 8f2c7a16525..d605d3aa514 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1187,11 +1187,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir_id: this.lower_node_id(node_id), body: this .lower_const_body(path_expr.span, Some(&path_expr)), + span, }) }); return GenericArg::Const(ConstArg { value: ct, - span, is_desugared_from_effects: false, }); } @@ -1203,7 +1203,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg { value: self.lower_anon_const(ct), - span: self.lower_span(ct.value.span), is_desugared_from_effects: false, }), } @@ -2349,6 +2348,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { def_id: this.local_def_id(c.id), hir_id: this.lower_node_id(c.id), 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))); self.args.push(hir::GenericArg::Const(hir::ConstArg { - value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body }), - span, + value: lcx.arena.alloc(hir::AnonConst { def_id, hir_id, body, span }), is_desugared_from_effects: true, })) } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 94e7db7035b..62d7e287e62 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -232,7 +232,6 @@ impl<'hir> PathSegment<'hir> { #[derive(Clone, Copy, Debug, HashStable_Generic)] pub struct ConstArg<'hir> { pub value: &'hir AnonConst, - pub span: Span, /// Indicates whether this comes from a `~const` desugaring. pub is_desugared_from_effects: bool, } @@ -262,7 +261,7 @@ impl GenericArg<'_> { match self { GenericArg::Lifetime(l) => l.ident.span, GenericArg::Type(t) => t.span, - GenericArg::Const(c) => c.span, + GenericArg::Const(c) => c.value.span, GenericArg::Infer(i) => i.span, } } @@ -1591,6 +1590,7 @@ pub struct AnonConst { pub hir_id: HirId, pub def_id: LocalDefId, pub body: BodyId, + pub span: Span, } /// An inline constant expression `const { something }`. diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs index 160d42caa9e..e5765ea804e 100644 --- a/compiler/rustc_lint/src/pass_by_value.rs +++ b/compiler/rustc_lint/src/pass_by_value.rs @@ -73,9 +73,12 @@ fn gen_args(cx: &LateContext<'_>, segment: &PathSegment<'_>) -> String { GenericArg::Type(ty) => { cx.tcx.sess.source_map().span_to_snippet(ty.span).unwrap_or_else(|_| "_".into()) } - GenericArg::Const(c) => { - cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_else(|_| "_".into()) - } + GenericArg::Const(c) => cx + .tcx + .sess + .source_map() + .span_to_snippet(c.value.span) + .unwrap_or_else(|_| "_".into()), GenericArg::Infer(_) => String::from("_"), }) .collect::<Vec<_>>(); |
