Skip to content

Commit 124eb21

Browse files
committed
auto merge of #9026 : jbclements/rust/let-var-hygiene, r=jbclements
This is a rebase of my approved pull request from ... the end of June? It introduces hygiene for let-bound variables.
2 parents 3e6de6b + b6f3d3f commit 124eb21

38 files changed

+1625
-636
lines changed

src/libextra/crypto/sha2.rs

+40-22
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,8 @@ use cryptoutil::{write_u64_be, write_u32_be, read_u64v_be, read_u32v_be, add_byt
1414
add_bytes_to_bits_tuple, FixedBuffer, FixedBuffer128, FixedBuffer64, StandardPadding};
1515
use digest::Digest;
1616

17-
18-
// Sha-512 and Sha-256 use basically the same calculations which are implemented by these macros.
19-
// Inlining the calculations seems to result in better generated code.
20-
macro_rules! schedule_round( ($t:expr) => (
21-
W[$t] = sigma1(W[$t - 2]) + W[$t - 7] + sigma0(W[$t - 15]) + W[$t - 16];
22-
)
23-
)
24-
25-
macro_rules! sha2_round(
26-
($A:ident, $B:ident, $C:ident, $D:ident,
27-
$E:ident, $F:ident, $G:ident, $H:ident, $K:ident, $t:expr) => (
28-
{
29-
$H += sum1($E) + ch($E, $F, $G) + $K[$t] + W[$t];
30-
$D += $H;
31-
$H += sum0($A) + maj($A, $B, $C);
32-
}
33-
)
34-
)
35-
36-
37-
// A structure that represents that state of a digest computation for the SHA-2 512 family of digest
38-
// functions
17+
// A structure that represents that state of a digest computation for the SHA-2 512 family
18+
// of digest functions
3919
struct Engine512State {
4020
H0: u64,
4121
H1: u64,
@@ -108,6 +88,25 @@ impl Engine512State {
10888

10989
let mut W = [0u64, ..80];
11090

91+
// Sha-512 and Sha-256 use basically the same calculations which are implemented by
92+
// these macros. Inlining the calculations seems to result in better generated code.
93+
macro_rules! schedule_round( ($t:expr) => (
94+
W[$t] = sigma1(W[$t - 2]) + W[$t - 7] + sigma0(W[$t - 15]) + W[$t - 16];
95+
)
96+
)
97+
98+
macro_rules! sha2_round(
99+
($A:ident, $B:ident, $C:ident, $D:ident,
100+
$E:ident, $F:ident, $G:ident, $H:ident, $K:ident, $t:expr) => (
101+
{
102+
$H += sum1($E) + ch($E, $F, $G) + $K[$t] + W[$t];
103+
$D += $H;
104+
$H += sum0($A) + maj($A, $B, $C);
105+
}
106+
)
107+
)
108+
109+
111110
read_u64v_be(W.mut_slice(0, 16), data);
112111

113112
// Putting the message schedule inside the same loop as the round calculations allows for
@@ -505,6 +504,25 @@ impl Engine256State {
505504

506505
let mut W = [0u32, ..64];
507506

507+
// Sha-512 and Sha-256 use basically the same calculations which are implemented
508+
// by these macros. Inlining the calculations seems to result in better generated code.
509+
macro_rules! schedule_round( ($t:expr) => (
510+
W[$t] = sigma1(W[$t - 2]) + W[$t - 7] + sigma0(W[$t - 15]) + W[$t - 16];
511+
)
512+
)
513+
514+
macro_rules! sha2_round(
515+
($A:ident, $B:ident, $C:ident, $D:ident,
516+
$E:ident, $F:ident, $G:ident, $H:ident, $K:ident, $t:expr) => (
517+
{
518+
$H += sum1($E) + ch($E, $F, $G) + $K[$t] + W[$t];
519+
$D += $H;
520+
$H += sum0($A) + maj($A, $B, $C);
521+
}
522+
)
523+
)
524+
525+
508526
read_u32v_be(W.mut_slice(0, 16), data);
509527

510528
// Putting the message schedule inside the same loop as the round calculations allows for

src/librustc/middle/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl BorrowckCtxt {
788788
match fname {
789789
mc::NamedField(ref fname) => {
790790
out.push_char('.');
791-
out.push_str(token::ident_to_str(fname));
791+
out.push_str(token::interner_get(*fname));
792792
}
793793
mc::PositionalField(idx) => {
794794
out.push_char('#'); // invent a notation here

src/librustc/middle/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map)
8181
fn find_item(item: @item, ctxt: @mut EntryContext, visitor: &mut EntryVisitor) {
8282
match item.node {
8383
item_fn(*) => {
84-
if item.ident == special_idents::main {
84+
if item.ident.name == special_idents::main.name {
8585
match ctxt.ast_map.find(&item.id) {
8686
Some(&ast_map::node_item(_, path)) => {
8787
if path.len() == 0 {

src/librustc/middle/mem_categorization.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use syntax::ast::{MutImmutable, MutMutable};
5656
use syntax::ast;
5757
use syntax::codemap::Span;
5858
use syntax::print::pprust;
59+
use syntax::parse::token;
5960

6061
#[deriving(Eq)]
6162
pub enum categorization {
@@ -99,7 +100,7 @@ pub enum InteriorKind {
99100

100101
#[deriving(Eq, IterBytes)]
101102
pub enum FieldName {
102-
NamedField(ast::Ident),
103+
NamedField(ast::Name),
103104
PositionalField(uint)
104105
}
105106

@@ -619,7 +620,7 @@ impl mem_categorization_ctxt {
619620
@cmt_ {
620621
id: node.id(),
621622
span: node.span(),
622-
cat: cat_interior(base_cmt, InteriorField(NamedField(f_name))),
623+
cat: cat_interior(base_cmt, InteriorField(NamedField(f_name.name))),
623624
mutbl: base_cmt.mutbl.inherit(),
624625
ty: f_ty
625626
}
@@ -1224,9 +1225,9 @@ pub fn ptr_sigil(ptr: PointerKind) -> ~str {
12241225
}
12251226
12261227
impl Repr for InteriorKind {
1227-
fn repr(&self, tcx: ty::ctxt) -> ~str {
1228+
fn repr(&self, _tcx: ty::ctxt) -> ~str {
12281229
match *self {
1229-
InteriorField(NamedField(fld)) => tcx.sess.str_of(fld).to_owned(),
1230+
InteriorField(NamedField(fld)) => token::interner_get(fld).to_owned(),
12301231
InteriorField(PositionalField(i)) => fmt!("#%?", i),
12311232
InteriorElement(_) => ~"[]",
12321233
}

src/librustc/middle/moves.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl VisitContext {
429429
// specified and (2) have a type that
430430
// moves-by-default:
431431
let consume_with = with_fields.iter().any(|tf| {
432-
!fields.iter().any(|f| f.ident == tf.ident) &&
432+
!fields.iter().any(|f| f.ident.name == tf.ident.name) &&
433433
ty::type_moves_by_default(self.tcx, tf.mt.ty)
434434
});
435435

src/librustc/middle/privacy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl PrivacyVisitor {
206206
fn check_field(&mut self, span: Span, id: ast::DefId, ident: ast::Ident) {
207207
let fields = ty::lookup_struct_fields(self.tcx, id);
208208
for field in fields.iter() {
209-
if field.ident != ident { loop; }
209+
if field.ident.name != ident.name { loop; }
210210
if field.vis == private {
211211
self.tcx.sess.span_err(span, fmt!("field `%s` is private",
212212
token::ident_to_str(&ident)));

0 commit comments

Comments
 (0)