Skip to content

Commit edabe39

Browse files
committed
---
yaml --- r: 210941 b: refs/heads/try c: 5ed02b5 h: refs/heads/master i: 210939: ff73d16 v: v3
1 parent 7e03e5c commit edabe39

File tree

7 files changed

+46
-32
lines changed

7 files changed

+46
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: e70c8584d562c86fdca9c98895fb981683d18859
5+
refs/heads/try: 5ed02b5c0eced7c9e4aa72b2096e537bede31df8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/trpl/closures.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ The second is that the syntax is similar, but a bit different. I’ve added spac
5454
here to make them look a little closer:
5555

5656
```rust
57-
fn plus_one_v1 (x: i32 ) -> i32 { x + 1 }
58-
let plus_one_v2 = |x: i32 | -> i32 { x + 1 };
59-
let plus_one_v3 = |x: i32 | x + 1 ;
57+
fn plus_one_v1 (x: i32) -> i32 { x + 1 }
58+
let plus_one_v2 = |x: i32| -> i32 { x + 1 };
59+
let plus_one_v3 = |x: i32| x + 1 ;
6060
```
6161

6262
Small differences, but they’re similar in ways.
@@ -136,7 +136,7 @@ This gives us:
136136
note: `nums` moved into closure environment here because it has type
137137
`[closure(()) -> collections::vec::Vec<i32>]`, which is non-copyable
138138
let takes_nums = || nums;
139-
^~~~~~~
139+
^~~~~~~
140140
```
141141

142142
`Vec<T>` has ownership over its contents, and therefore, when we refer to it
@@ -352,8 +352,8 @@ error: the trait `core::marker::Sized` is not implemented for the type
352352
factory() -> (Fn(i32) -> Vec<i32>) {
353353
^~~~~~~~~~~~~~~~~~~~~
354354
note: `core::ops::Fn(i32) -> collections::vec::Vec<i32>` does not have a constant size known at compile-time
355-
fa ctory() -> (Fn(i32) -> Vec<i32>) {
356-
^~~~~~~~~~~~~~~~~~~~~
355+
factory() -> (Fn(i32) -> Vec<i32>) {
356+
^~~~~~~~~~~~~~~~~~~~~
357357
358358
```
359359

branches/try/src/doc/trpl/references-and-borrowing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ We can’t modify `v` because it’s borrowed by the loop.
297297
References must live as long as the resource they refer to. Rust will check the
298298
scopes of your references to ensure that this is true.
299299

300-
If Rust didn’t check that this property, we could accidentally use a reference
300+
If Rust didn’t check this property, we could accidentally use a reference
301301
which was invalid. For example:
302302

303303
```rust,ignore

branches/try/src/librustc/middle/const_eval.rs

Lines changed: 13 additions & 3 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-2015 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
//
@@ -34,7 +34,7 @@ use std::borrow::{Cow, IntoCow};
3434
use std::num::wrapping::OverflowingOps;
3535
use std::cmp::Ordering;
3636
use std::collections::hash_map::Entry::Vacant;
37-
use std::{i8, i16, i32, i64};
37+
use std::{i8, i16, i32, i64, u8, u16, u32, u64};
3838
use std::rc::Rc;
3939

4040
fn lookup_const<'a>(tcx: &'a ty::ctxt, e: &Expr) -> Option<&'a Expr> {
@@ -461,6 +461,16 @@ pub fn const_uint_checked_neg<'a>(
461461
Ok(const_uint((!a).wrapping_add(1)))
462462
}
463463

464+
fn const_uint_not(a: u64, opt_ety: Option<UintTy>) -> const_val {
465+
let mask = match opt_ety {
466+
Some(UintTy::U8) => u8::MAX as u64,
467+
Some(UintTy::U16) => u16::MAX as u64,
468+
Some(UintTy::U32) => u32::MAX as u64,
469+
None | Some(UintTy::U64) => u64::MAX,
470+
};
471+
const_uint(!a & mask)
472+
}
473+
464474
macro_rules! overflow_checking_body {
465475
($a:ident, $b:ident, $ety:ident, $overflowing_op:ident,
466476
lhs: $to_8_lhs:ident $to_16_lhs:ident $to_32_lhs:ident,
@@ -677,7 +687,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
677687
ast::ExprUnary(ast::UnNot, ref inner) => {
678688
match try!(eval_const_expr_partial(tcx, &**inner, ety)) {
679689
const_int(i) => const_int(!i),
680-
const_uint(i) => const_uint(!i),
690+
const_uint(i) => const_uint_not(i, expr_uint_type),
681691
const_bool(b) => const_bool(!b),
682692
const_str(_) => signal!(e, NotOnString),
683693
const_float(_) => signal!(e, NotOnFloat),

branches/try/src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,26 +3153,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
31533153
Some(&**oprnd), oprnd_t, lvalue_pref) {
31543154
Some(mt) => mt.ty,
31553155
None => {
3156-
let is_newtype = match oprnd_t.sty {
3157-
ty::ty_struct(did, substs) => {
3158-
let fields = ty::struct_fields(fcx.tcx(), did, substs);
3159-
fields.len() == 1
3160-
&& fields[0].name ==
3161-
token::special_idents::unnamed_field.name
3162-
}
3163-
_ => false
3164-
};
3165-
if is_newtype {
3166-
// This is an obsolete struct deref
3167-
span_err!(tcx.sess, expr.span, E0068,
3168-
"single-field tuple-structs can \
3169-
no longer be dereferenced");
3170-
} else {
3171-
fcx.type_error_message(expr.span, |actual| {
3172-
format!("type `{}` cannot be \
3173-
dereferenced", actual)
3174-
}, oprnd_t, None);
3175-
}
3156+
fcx.type_error_message(expr.span, |actual| {
3157+
format!("type `{}` cannot be \
3158+
dereferenced", actual)
3159+
}, oprnd_t, None);
31763160
tcx.types.err
31773161
}
31783162
}

branches/try/src/libsyntax/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
258258
("no_builtins", Whitelisted),
259259
("no_mangle", Whitelisted),
260260
("no_stack_check", Whitelisted),
261-
("packed", Whitelisted),
262261
("static_assert", Gated("static_assert",
263262
"`#[static_assert]` is an experimental feature, and has a poor API")),
264263
("no_debug", Whitelisted),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
const U8_MAX_HALF: u8 = !0u8 / 2;
12+
const U16_MAX_HALF: u16 = !0u16 / 2;
13+
const U32_MAX_HALF: u32 = !0u32 / 2;
14+
const U64_MAX_HALF: u64 = !0u64 / 2;
15+
16+
fn main() {
17+
assert_eq!(U8_MAX_HALF, 0x7f);
18+
assert_eq!(U16_MAX_HALF, 0x7fff);
19+
assert_eq!(U32_MAX_HALF, 0x7fff_ffff);
20+
assert_eq!(U64_MAX_HALF, 0x7fff_ffff_ffff_ffff);
21+
}

0 commit comments

Comments
 (0)