mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-28 16:35:57 +00:00
lint: Document the why and how of the no_mangle const lint
This commit is contained in:
parent
73d5d89567
commit
b6f55efd5b
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user