From b6f55efd5b21b2132dafa85c112b339ba498bc7c Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 3 Feb 2015 12:09:45 -0800 Subject: [PATCH] lint: Document the why and how of the no_mangle const lint --- src/librustc/lint/builtin.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 697810fa0e95..22f5ca150219 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -2107,7 +2107,10 @@ impl LintPass for InvalidNoMangleItems { }, ast::ItemConst(..) => { if attr::contains_name(it.attrs.as_slice(), "no_mangle") { - let msg = "const items should never be #[no_mangle]"; + // Const items do not refer to a particular location in memory, and therefore + // don't have anything to attach a symbol to + let msg = "const items should never be #[no_mangle], consider instead using \ + `pub static`"; cx.span_lint(NO_MANGLE_CONST_ITEMS, it.span, msg); } }