Skip to content

Commit

Permalink
lint: Document the why and how of the no_mangle const lint
Browse files Browse the repository at this point in the history
  • Loading branch information
richo committed Feb 9, 2015
1 parent 73d5d89 commit b6f55ef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librustc/lint/builtin.rs
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit b6f55ef

Please sign in to comment.