Skip to content

Commit 85c1669

Browse files
committed
---
yaml --- r: 97597 b: refs/heads/snap-stage3 c: 326e631 h: refs/heads/master i: 97595: c19271c v: v3
1 parent 525f168 commit 85c1669

File tree

7 files changed

+100
-44
lines changed

7 files changed

+100
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 33e866339126df3806f9cae95f2b91d38abaab32
4+
refs/heads/snap-stage3: 326e63187ff4490c30ed603158e00c0be58dd162
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/guide-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ A typical mutable container will implement at least `iter()`, `mut_iter()` and
130130
### Freezing
131131
132132
Unlike most other languages with external iterators, Rust has no *iterator
133-
invalidation*. As long as an iterator is still in scope, the compiler will prevent
133+
invalidation*. As long an iterator is still in scope, the compiler will prevent
134134
modification of the container through another handle.
135135
136136
~~~

branches/snap-stage3/src/librustc/middle/typeck/check/mod.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,11 @@ impl PurityState {
213213
}
214214
}
215215

216-
/// Whether `check_binop` is part of an assignment or not.
217-
/// Used to know wether we allow user overloads and to print
218-
/// better messages on error.
216+
/// Whether `check_binop` allows overloaded operators to be invoked.
219217
#[deriving(Eq)]
220-
enum IsBinopAssignment{
221-
SimpleBinop,
222-
BinopAssignment,
218+
enum AllowOverloadedOperatorsFlag {
219+
AllowOverloadedOperators,
220+
DontAllowOverloadedOperators,
223221
}
224222

225223
#[deriving(Clone)]
@@ -2088,7 +2086,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
20882086
rhs: @ast::Expr,
20892087
// Used only in the error case
20902088
expected_result: Option<ty::t>,
2091-
is_binop_assignment: IsBinopAssignment
2089+
allow_overloaded_operators: AllowOverloadedOperatorsFlag
20922090
) {
20932091
let tcx = fcx.ccx.tcx;
20942092

@@ -2138,9 +2136,9 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
21382136

21392137
}
21402138

2141-
// Check for overloaded operators if not an assignment.
2139+
// Check for overloaded operators if allowed.
21422140
let result_t;
2143-
if is_binop_assignment == SimpleBinop {
2141+
if allow_overloaded_operators == AllowOverloadedOperators {
21442142
result_t = check_user_binop(fcx,
21452143
callee_id,
21462144
expr,
@@ -2152,14 +2150,13 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
21522150
} else {
21532151
fcx.type_error_message(expr.span,
21542152
|actual| {
2155-
format!("binary assignment operation \
2156-
{}= cannot be applied to type `{}`",
2157-
ast_util::binop_to_str(op),
2158-
actual)
2153+
format!("binary operation {} cannot be \
2154+
applied to type `{}`",
2155+
ast_util::binop_to_str(op),
2156+
actual)
21592157
},
21602158
lhs_t,
21612159
None);
2162-
check_expr(fcx, rhs);
21632160
result_t = ty::mk_err();
21642161
}
21652162

@@ -2763,7 +2760,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
27632760
lhs,
27642761
rhs,
27652762
expected,
2766-
SimpleBinop);
2763+
AllowOverloadedOperators);
27672764

27682765
let lhs_ty = fcx.expr_ty(lhs);
27692766
let rhs_ty = fcx.expr_ty(rhs);
@@ -2784,7 +2781,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
27842781
lhs,
27852782
rhs,
27862783
expected,
2787-
BinopAssignment);
2784+
DontAllowOverloadedOperators);
27882785

27892786
let lhs_t = fcx.expr_ty(lhs);
27902787
let result_t = fcx.expr_ty(expr);

branches/snap-stage3/src/librustdoc/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -109,13 +109,7 @@ pub fn usage(argv0: &str) {
109109
}
110110

111111
pub fn main_args(args: &[~str]) -> int {
112-
let matches = match groups::getopts(args.tail(), opts()) {
113-
Ok(m) => m,
114-
Err(err) => {
115-
println(err.to_err_msg());
116-
return 1;
117-
}
118-
};
112+
let matches = groups::getopts(args.tail(), opts()).unwrap();
119113
if matches.opt_present("h") || matches.opt_present("help") {
120114
usage(args[0]);
121115
return 0;

branches/snap-stage3/src/libstd/io/extensions.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,86 @@ mod test {
465465
assert!(reader.read_le_f32() == 8.1250);
466466
}
467467

468+
#[test]
469+
fn test_u64_from_be_bytes() {
470+
use super::u64_from_be_bytes;
471+
472+
let buf = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09];
473+
474+
// Aligned access
475+
assert_eq!(u64_from_be_bytes(buf, 0, 0), 0);
476+
assert_eq!(u64_from_be_bytes(buf, 0, 1), 0x01);
477+
assert_eq!(u64_from_be_bytes(buf, 0, 2), 0x0102);
478+
assert_eq!(u64_from_be_bytes(buf, 0, 3), 0x010203);
479+
assert_eq!(u64_from_be_bytes(buf, 0, 4), 0x01020304);
480+
assert_eq!(u64_from_be_bytes(buf, 0, 5), 0x0102030405);
481+
assert_eq!(u64_from_be_bytes(buf, 0, 6), 0x010203040506);
482+
assert_eq!(u64_from_be_bytes(buf, 0, 7), 0x01020304050607);
483+
assert_eq!(u64_from_be_bytes(buf, 0, 8), 0x0102030405060708);
484+
485+
// Unaligned access
486+
assert_eq!(u64_from_be_bytes(buf, 1, 0), 0);
487+
assert_eq!(u64_from_be_bytes(buf, 1, 1), 0x02);
488+
assert_eq!(u64_from_be_bytes(buf, 1, 2), 0x0203);
489+
assert_eq!(u64_from_be_bytes(buf, 1, 3), 0x020304);
490+
assert_eq!(u64_from_be_bytes(buf, 1, 4), 0x02030405);
491+
assert_eq!(u64_from_be_bytes(buf, 1, 5), 0x0203040506);
492+
assert_eq!(u64_from_be_bytes(buf, 1, 6), 0x020304050607);
493+
assert_eq!(u64_from_be_bytes(buf, 1, 7), 0x02030405060708);
494+
assert_eq!(u64_from_be_bytes(buf, 1, 8), 0x0203040506070809);
495+
}
496+
}
497+
498+
#[cfg(test)]
499+
mod bench {
500+
use extra::test::BenchHarness;
501+
use container::Container;
502+
503+
macro_rules! u64_from_be_bytes_bench_impl(
504+
($size:expr, $stride:expr, $start_index:expr) =>
505+
({
506+
use vec;
507+
use super::u64_from_be_bytes;
508+
509+
let data = vec::from_fn($stride*100+$start_index, |i| i as u8);
510+
let mut sum = 0u64;
511+
bh.iter(|| {
512+
let mut i = $start_index;
513+
while (i < data.len()) {
514+
sum += u64_from_be_bytes(data, i, $size);
515+
i += $stride;
516+
}
517+
});
518+
})
519+
)
520+
521+
#[bench]
522+
fn u64_from_be_bytes_4_aligned(bh: &mut BenchHarness) {
523+
u64_from_be_bytes_bench_impl!(4, 4, 0);
524+
}
525+
526+
#[bench]
527+
fn u64_from_be_bytes_4_unaligned(bh: &mut BenchHarness) {
528+
u64_from_be_bytes_bench_impl!(4, 4, 1);
529+
}
530+
531+
#[bench]
532+
fn u64_from_be_bytes_7_aligned(bh: &mut BenchHarness) {
533+
u64_from_be_bytes_bench_impl!(7, 8, 0);
534+
}
535+
536+
#[bench]
537+
fn u64_from_be_bytes_7_unaligned(bh: &mut BenchHarness) {
538+
u64_from_be_bytes_bench_impl!(7, 8, 1);
539+
}
540+
541+
#[bench]
542+
fn u64_from_be_bytes_8_aligned(bh: &mut BenchHarness) {
543+
u64_from_be_bytes_bench_impl!(8, 8, 0);
544+
}
545+
546+
#[bench]
547+
fn u64_from_be_bytes_8_unaligned(bh: &mut BenchHarness) {
548+
u64_from_be_bytes_bench_impl!(8, 8, 1);
549+
}
468550
}

branches/snap-stage3/src/test/compile-fail/assignment-operator-unimplemented.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

branches/snap-stage3/src/test/compile-fail/issue-5239-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
// Regression test for issue #5239
1212

1313
fn main() {
14-
let x: |int| -> int = |ref x| { x += 1; }; //~ ERROR binary assignment operation += cannot be applied to type `&int`
14+
let x: |int| -> int = |ref x| { x += 1; }; //~ ERROR binary operation + cannot be applied to type `&int`
1515
}

0 commit comments

Comments
 (0)