Skip to content

Use shorter path for std::hash::Hash #77687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ where
}

if *self == DUMMY_SP {
std::hash::Hash::hash(&TAG_INVALID_SPAN, hasher);
Hash::hash(&TAG_INVALID_SPAN, hasher);
return;
}

Expand All @@ -1872,28 +1872,28 @@ where
let (file_lo, line_lo, col_lo) = match ctx.byte_pos_to_line_and_col(span.lo) {
Some(pos) => pos,
None => {
std::hash::Hash::hash(&TAG_INVALID_SPAN, hasher);
Hash::hash(&TAG_INVALID_SPAN, hasher);
span.ctxt.hash_stable(ctx, hasher);
return;
}
};

if !file_lo.contains(span.hi) {
std::hash::Hash::hash(&TAG_INVALID_SPAN, hasher);
Hash::hash(&TAG_INVALID_SPAN, hasher);
span.ctxt.hash_stable(ctx, hasher);
return;
}

std::hash::Hash::hash(&TAG_VALID_SPAN, hasher);
Hash::hash(&TAG_VALID_SPAN, hasher);
// We truncate the stable ID hash and line and column numbers. The chances
// of causing a collision this way should be minimal.
std::hash::Hash::hash(&(file_lo.name_hash as u64), hasher);
Hash::hash(&(file_lo.name_hash as u64), hasher);

let col = (col_lo.0 as u64) & 0xFF;
let line = ((line_lo as u64) & 0xFF_FF_FF) << 8;
let len = ((span.hi - span.lo).0 as u64) << 32;
let line_col_len = col | line | len;
std::hash::Hash::hash(&line_col_len, hasher);
Hash::hash(&line_col_len, hasher);
span.ctxt.hash_stable(ctx, hasher);
}
}
Expand Down