Skip to content

Commit c19271c

Browse files
committed
---
yaml --- r: 97595 b: refs/heads/snap-stage3 c: 02d8621 h: refs/heads/master i: 97593: 31e2838 97591: 7048f70 v: v3
1 parent 3937c78 commit c19271c

File tree

7 files changed

+27
-31
lines changed

7 files changed

+27
-31
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: ff7ecca20e116b8365d8095fa9618dc11e54cfbe
4+
refs/heads/snap-stage3: 02d86216f39d78d614c684e72250cd37e5c6339a
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/trans/adt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
730730
if discr == nndiscr {
731731
C_struct(build_const_struct(ccx, nonnull, vals), false)
732732
} else {
733+
assert_eq!(vals.len(), 0);
733734
let vals = nonnull.fields.iter().enumerate().map(|(i, &ty)| {
734735
let llty = type_of::sizing_type_of(ccx, ty);
735736
if i == ptrfield { C_null(llty) } else { C_undef(llty) }

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

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

216-
/// Whether `check_binop` allows overloaded operators to be invoked.
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.
217219
#[deriving(Eq)]
218-
enum AllowOverloadedOperatorsFlag {
219-
AllowOverloadedOperators,
220-
DontAllowOverloadedOperators,
220+
enum IsBinopAssignment{
221+
SimpleBinop,
222+
BinopAssignment,
221223
}
222224

223225
#[deriving(Clone)]
@@ -2086,7 +2088,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
20862088
rhs: @ast::Expr,
20872089
// Used only in the error case
20882090
expected_result: Option<ty::t>,
2089-
allow_overloaded_operators: AllowOverloadedOperatorsFlag
2091+
is_binop_assignment: IsBinopAssignment
20902092
) {
20912093
let tcx = fcx.ccx.tcx;
20922094

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

21372139
}
21382140

2139-
// Check for overloaded operators if allowed.
2141+
// Check for overloaded operators if not an assignment.
21402142
let result_t;
2141-
if allow_overloaded_operators == AllowOverloadedOperators {
2143+
if is_binop_assignment == SimpleBinop {
21422144
result_t = check_user_binop(fcx,
21432145
callee_id,
21442146
expr,
@@ -2150,13 +2152,14 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
21502152
} else {
21512153
fcx.type_error_message(expr.span,
21522154
|actual| {
2153-
format!("binary operation {} cannot be \
2154-
applied to type `{}`",
2155-
ast_util::binop_to_str(op),
2156-
actual)
2155+
format!("binary assignment operation \
2156+
{}= cannot be applied to type `{}`",
2157+
ast_util::binop_to_str(op),
2158+
actual)
21572159
},
21582160
lhs_t,
21592161
None);
2162+
check_expr(fcx, rhs);
21602163
result_t = ty::mk_err();
21612164
}
21622165

@@ -2760,7 +2763,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
27602763
lhs,
27612764
rhs,
27622765
expected,
2763-
AllowOverloadedOperators);
2766+
SimpleBinop);
27642767

27652768
let lhs_ty = fcx.expr_ty(lhs);
27662769
let rhs_ty = fcx.expr_ty(rhs);
@@ -2781,7 +2784,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
27812784
lhs,
27822785
rhs,
27832786
expected,
2784-
DontAllowOverloadedOperators);
2787+
BinopAssignment);
27852788

27862789
let lhs_t = fcx.expr_ty(lhs);
27872790
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/test/run-pass/enum-nullable-const-null-with-fields.rs renamed to branches/snap-stage3/src/test/compile-fail/assignment-operator-unimplemented.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::result::{Result,Ok};
12-
static C: Result<(), ~int> = Ok(());
11+
struct Foo;
1312

14-
// This is because of yet another bad assertion (ICE) about the null side of a nullable enum.
15-
// So we won't actually compile if the bug is present, but we check the value in main anyway.
16-
17-
pub fn main() {
18-
assert!(C.is_ok());
13+
fn main() {
14+
let mut a = Foo;
15+
let ref b = Foo;
16+
a += *b; //~ Error: binary assignment operation += cannot be applied to type `Foo`
1917
}

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 operation + cannot be applied to type `&int`
14+
let x: |int| -> int = |ref x| { x += 1; }; //~ ERROR binary assignment operation += cannot be applied to type `&int`
1515
}

0 commit comments

Comments
 (0)