pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self,
item_attrs: &[ast::Attribute],
+ is_const: bool,
f: F) {
let prev_overflow_checks = self.overflow_checks_enabled;
- if attr::contains_name(item_attrs, "rustc_inherit_overflow_checks") {
+ if is_const || attr::contains_name(item_attrs, "rustc_inherit_overflow_checks") {
self.overflow_checks_enabled = true;
}
let prev_hash_node_ids = self.node_id_hashing_mode;
// If this is not an empty or invalid span, we want to hash the last
// position that belongs to it, as opposed to hashing the first
// position past it.
- let span_hi = if self.hi() > self.lo() {
+ let span = self.data();
+ let span_hi = if span.hi > span.lo {
// We might end up in the middle of a multibyte character here,
// but that's OK, since we are not trying to decode anything at
// this position.
- self.hi() - ::syntax_pos::BytePos(1)
+ span.hi - ::syntax_pos::BytePos(1)
} else {
- self.hi()
+ span.hi
};
{
- let loc1 = hcx.codemap().byte_pos_to_line_and_col(self.lo());
+ let loc1 = hcx.codemap().byte_pos_to_line_and_col(span.lo);
let loc1 = loc1.as_ref()
.map(|&(ref fm, line, col)| (&fm.name[..], line, col.to_usize()))
.unwrap_or(("???", 0, 0));
}
}
- if self.ctxt() == SyntaxContext::empty() {
+ if span.ctxt == SyntaxContext::empty() {
0u8.hash_stable(hcx, hasher);
} else {
1u8.hash_stable(hcx, hasher);