Skip to content

Commit b6f55ef

Browse files
committed
lint: Document the why and how of the no_mangle const lint
1 parent 73d5d89 commit b6f55ef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc/lint/builtin.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,10 @@ impl LintPass for InvalidNoMangleItems {
21072107
},
21082108
ast::ItemConst(..) => {
21092109
if attr::contains_name(it.attrs.as_slice(), "no_mangle") {
2110-
let msg = "const items should never be #[no_mangle]";
2110+
// Const items do not refer to a particular location in memory, and therefore
2111+
// don't have anything to attach a symbol to
2112+
let msg = "const items should never be #[no_mangle], consider instead using \
2113+
`pub static`";
21112114
cx.span_lint(NO_MANGLE_CONST_ITEMS, it.span, msg);
21122115
}
21132116
}

0 commit comments

Comments
 (0)