librustc: Make addresses of immutable statics insignificant unless

`#[inline(never)]` is used.

Closes #8958.

This can break some code that relied on the addresses of statics
being distinct; add `#[inline(never)]` to the affected statics.

[breaking-change]
This commit is contained in:
Patrick Walton
2014-06-11 22:31:02 -07:00
parent db298145c7
commit cad760b770
9 changed files with 55 additions and 38 deletions

View File

@@ -11,6 +11,8 @@
use ast::*;
use ast;
use ast_util;
use attr::{InlineNever, InlineNone};
use attr;
use codemap;
use codemap::Span;
use owned_slice::OwnedSlice;
@@ -742,6 +744,17 @@ pub fn get_inner_tys(ty: P<Ty>) -> Vec<P<Ty>> {
}
}
/// Returns true if the static with the given mutability and attributes
/// has a significant address and false otherwise.
pub fn static_has_significant_address(mutbl: ast::Mutability,
attrs: &[ast::Attribute])
-> bool {
if mutbl == ast::MutMutable {
return true
}
let inline = attr::find_inline_attr(attrs);
inline == InlineNever || inline == InlineNone
}
#[cfg(test)]
mod test {