Skip to content

Commit 9911f0e

Browse files
authored
Merge pull request #38377 from brson/beta-next
[beta] backports and bump
2 parents 8f23633 + 41a998d commit 9911f0e

File tree

8 files changed

+163
-15
lines changed

8 files changed

+163
-15
lines changed

mk/main.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CFG_RELEASE_NUM=1.14.0
1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release
2020
# versions (section 9)
21-
CFG_PRERELEASE_VERSION=.3
21+
CFG_PRERELEASE_VERSION=.4
2222

2323
ifeq ($(CFG_RELEASE_CHANNEL),stable)
2424
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"

src/doc/book/syntax-index.md

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
* `|=` (`var |= expr`): bitwise or & assignment. Overloadable (`BitOrAssign`).
9595
* `||` (`expr || expr`): logical or.
9696
* `_`: "ignored" pattern binding (see [Patterns (Ignoring bindings)]). Also used to make integer-literals readable (see [Reference (Integer literals)]).
97+
* `?` (`expr?`): Error propagation. Returns early when `Err(_)` is encountered, unwraps otherwise. Similar to the [`try!` macro].
9798

9899
## Other Syntax
99100

@@ -210,6 +211,7 @@
210211
[Functions]: functions.html
211212
[Generics]: generics.html
212213
[Iterators]: iterators.html
214+
[`try!` macro]: error-handling.html#the-try-macro
213215
[Lifetimes]: lifetimes.html
214216
[Loops (`for`)]: loops.html#for
215217
[Loops (`loop`)]: loops.html#loop

src/doc/reference.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -2858,8 +2858,8 @@ assert_eq!(x, y);
28582858

28592859
### Unary operator expressions
28602860

2861-
Rust defines the following unary operators. They are all written as prefix operators,
2862-
before the expression they apply to.
2861+
Rust defines the following unary operators. With the exception of `?`, they are
2862+
all written as prefix operators, before the expression they apply to.
28632863

28642864
* `-`
28652865
: Negation. Signed integer types and floating-point types support negation. It
@@ -2888,6 +2888,10 @@ before the expression they apply to.
28882888
If the `&` or `&mut` operators are applied to an rvalue, a
28892889
temporary value is created; the lifetime of this temporary value
28902890
is defined by [syntactic rules](#temporary-lifetimes).
2891+
* `?`
2892+
: Propagating errors if applied to `Err(_)` and unwrapping if
2893+
applied to `Ok(_)`. Only works on the `Result<T, E>` type,
2894+
and written in postfix notation.
28912895

28922896
### Binary operator expressions
28932897

src/libcore/macros.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,15 @@ macro_rules! unimplemented {
520520
/// into libsyntax itself.
521521
///
522522
/// For more information, see documentation for `std`'s macros.
523-
#[cfg(dox)]
524-
pub mod builtin {
523+
mod builtin {
525524
/// The core macro for formatted string creation & output.
526525
///
527526
/// For more information, see the documentation for [`std::format_args!`].
528527
///
529528
/// [`std::format_args!`]: ../std/macro.format_args.html
530529
#[stable(feature = "rust1", since = "1.0.0")]
531530
#[macro_export]
531+
#[cfg(dox)]
532532
macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
533533
/* compiler built-in */
534534
}) }
@@ -540,6 +540,7 @@ pub mod builtin {
540540
/// [`std::env!`]: ../std/macro.env.html
541541
#[stable(feature = "rust1", since = "1.0.0")]
542542
#[macro_export]
543+
#[cfg(dox)]
543544
macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
544545

545546
/// Optionally inspect an environment variable at compile time.
@@ -549,6 +550,7 @@ pub mod builtin {
549550
/// [`std::option_env!`]: ../std/macro.option_env.html
550551
#[stable(feature = "rust1", since = "1.0.0")]
551552
#[macro_export]
553+
#[cfg(dox)]
552554
macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
553555

554556
/// Concatenate identifiers into one identifier.
@@ -558,6 +560,7 @@ pub mod builtin {
558560
/// [`std::concat_idents!`]: ../std/macro.concat_idents.html
559561
#[unstable(feature = "concat_idents_macro", issue = "29599")]
560562
#[macro_export]
563+
#[cfg(dox)]
561564
macro_rules! concat_idents {
562565
($($e:ident),*) => ({ /* compiler built-in */ })
563566
}
@@ -569,6 +572,7 @@ pub mod builtin {
569572
/// [`std::concat!`]: ../std/macro.concat.html
570573
#[stable(feature = "rust1", since = "1.0.0")]
571574
#[macro_export]
575+
#[cfg(dox)]
572576
macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) }
573577

574578
/// A macro which expands to the line number on which it was invoked.
@@ -578,6 +582,7 @@ pub mod builtin {
578582
/// [`std::line!`]: ../std/macro.line.html
579583
#[stable(feature = "rust1", since = "1.0.0")]
580584
#[macro_export]
585+
#[cfg(dox)]
581586
macro_rules! line { () => ({ /* compiler built-in */ }) }
582587

583588
/// A macro which expands to the column number on which it was invoked.
@@ -587,6 +592,7 @@ pub mod builtin {
587592
/// [`std::column!`]: ../std/macro.column.html
588593
#[stable(feature = "rust1", since = "1.0.0")]
589594
#[macro_export]
595+
#[cfg(dox)]
590596
macro_rules! column { () => ({ /* compiler built-in */ }) }
591597

592598
/// A macro which expands to the file name from which it was invoked.
@@ -596,6 +602,7 @@ pub mod builtin {
596602
/// [`std::file!`]: ../std/macro.file.html
597603
#[stable(feature = "rust1", since = "1.0.0")]
598604
#[macro_export]
605+
#[cfg(dox)]
599606
macro_rules! file { () => ({ /* compiler built-in */ }) }
600607

601608
/// A macro which stringifies its argument.
@@ -605,6 +612,7 @@ pub mod builtin {
605612
/// [`std::stringify!`]: ../std/macro.stringify.html
606613
#[stable(feature = "rust1", since = "1.0.0")]
607614
#[macro_export]
615+
#[cfg(dox)]
608616
macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) }
609617

610618
/// Includes a utf8-encoded file as a string.
@@ -614,6 +622,7 @@ pub mod builtin {
614622
/// [`std::include_str!`]: ../std/macro.include_str.html
615623
#[stable(feature = "rust1", since = "1.0.0")]
616624
#[macro_export]
625+
#[cfg(dox)]
617626
macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) }
618627

619628
/// Includes a file as a reference to a byte array.
@@ -623,6 +632,7 @@ pub mod builtin {
623632
/// [`std::include_bytes!`]: ../std/macro.include_bytes.html
624633
#[stable(feature = "rust1", since = "1.0.0")]
625634
#[macro_export]
635+
#[cfg(dox)]
626636
macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }
627637

628638
/// Expands to a string that represents the current module path.
@@ -632,6 +642,7 @@ pub mod builtin {
632642
/// [`std::module_path!`]: ../std/macro.module_path.html
633643
#[stable(feature = "rust1", since = "1.0.0")]
634644
#[macro_export]
645+
#[cfg(dox)]
635646
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
636647

637648
/// Boolean evaluation of configuration flags.
@@ -641,6 +652,7 @@ pub mod builtin {
641652
/// [`std::cfg!`]: ../std/macro.cfg.html
642653
#[stable(feature = "rust1", since = "1.0.0")]
643654
#[macro_export]
655+
#[cfg(dox)]
644656
macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
645657

646658
/// Parse a file as an expression or an item according to the context.
@@ -650,5 +662,6 @@ pub mod builtin {
650662
/// [`std::include!`]: ../std/macro.include.html
651663
#[stable(feature = "rust1", since = "1.0.0")]
652664
#[macro_export]
665+
#[cfg(dox)]
653666
macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }
654667
}

src/librustc/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,8 @@ fn confirm_closure_candidate<'cx, 'gcx, 'tcx>(
12221222
obligation,
12231223
&closure_type.sig,
12241224
util::TupleArgumentsFlag::No)
1225-
.with_addl_obligations(obligations)
12261225
.with_addl_obligations(vtable.nested)
1226+
.with_addl_obligations(obligations)
12271227
}
12281228

12291229
fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(

src/librustc_trans/adt.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,8 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, discr: D
689689
let lldiscr = C_integral(Type::from_integer(ccx, d), discr.0 as u64, true);
690690
let mut vals_with_discr = vec![lldiscr];
691691
vals_with_discr.extend_from_slice(vals);
692-
let mut contents = build_const_struct(ccx, &variant,
693-
&vals_with_discr[..]);
694-
let needed_padding = l.size(dl).bytes() - variant.min_size.bytes();
692+
let mut contents = build_const_struct(ccx, &variant, &vals_with_discr[..]);
693+
let needed_padding = l.size(dl).bytes() - variant.stride().bytes();
695694
if needed_padding > 0 {
696695
contents.push(padding(ccx, needed_padding));
697696
}
@@ -704,8 +703,7 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, discr: D
704703
}
705704
layout::Univariant { ref variant, .. } => {
706705
assert_eq!(discr, Disr(0));
707-
let contents = build_const_struct(ccx,
708-
&variant, vals);
706+
let contents = build_const_struct(ccx, &variant, vals);
709707
C_struct(ccx, &contents[..], variant.packed)
710708
}
711709
layout::Vector { .. } => {
@@ -722,17 +720,15 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, discr: D
722720
}
723721
layout::StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
724722
if discr.0 == nndiscr {
725-
C_struct(ccx, &build_const_struct(ccx, &nonnull, vals),
726-
false)
723+
C_struct(ccx, &build_const_struct(ccx, &nonnull, vals), false)
727724
} else {
728725
let fields = compute_fields(ccx, t, nndiscr as usize, false);
729726
let vals = fields.iter().map(|&ty| {
730727
// Always use null even if it's not the `discrfield`th
731728
// field; see #8506.
732729
C_null(type_of::sizing_type_of(ccx, ty))
733730
}).collect::<Vec<ValueRef>>();
734-
C_struct(ccx, &build_const_struct(ccx, &nonnull, &vals[..]),
735-
false)
731+
C_struct(ccx, &build_const_struct(ccx, &nonnull, &vals[..]), false)
736732
}
737733
}
738734
_ => bug!("trans_const: cannot handle type {} repreented as {:#?}", t, l)

src/test/run-pass/issue-38002.rs

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2016 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+
// Check that constant ADTs are translated OK, part k of N.
12+
13+
#![feature(slice_patterns)]
14+
15+
enum Bar {
16+
C
17+
}
18+
19+
enum Foo {
20+
A {},
21+
B {
22+
y: usize,
23+
z: Bar
24+
},
25+
}
26+
27+
const LIST: [(usize, Foo); 2] = [
28+
(51, Foo::B { y: 42, z: Bar::C }),
29+
(52, Foo::B { y: 45, z: Bar::C }),
30+
];
31+
32+
pub fn main() {
33+
match LIST {
34+
[
35+
(51, Foo::B { y: 42, z: Bar::C }),
36+
(52, Foo::B { y: 45, z: Bar::C })
37+
] => {}
38+
_ => {
39+
// I would want to print the enum here, but if
40+
// the discriminant is garbage this causes an
41+
// `unreachable` and silent process exit.
42+
panic!("trivial match failed")
43+
}
44+
}
45+
}

src/test/run-pass/issue-38033.rs

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright 2016 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+
use std::marker;
12+
use std::mem;
13+
14+
fn main() {
15+
let workers = (0..0).map(|_| result::<u32, ()>());
16+
drop(join_all(workers).poll());
17+
}
18+
19+
trait Future {
20+
type Item;
21+
type Error;
22+
23+
fn poll(&mut self) -> Result<Self::Item, Self::Error>;
24+
}
25+
26+
trait IntoFuture {
27+
type Future: Future<Item=Self::Item, Error=Self::Error>;
28+
type Item;
29+
type Error;
30+
31+
fn into_future(self) -> Self::Future;
32+
}
33+
34+
impl<F: Future> IntoFuture for F {
35+
type Future = F;
36+
type Item = F::Item;
37+
type Error = F::Error;
38+
39+
fn into_future(self) -> F {
40+
self
41+
}
42+
}
43+
44+
struct FutureResult<T, E> {
45+
_inner: marker::PhantomData<(T, E)>,
46+
}
47+
48+
fn result<T, E>() -> FutureResult<T, E> {
49+
loop {}
50+
}
51+
52+
impl<T, E> Future for FutureResult<T, E> {
53+
type Item = T;
54+
type Error = E;
55+
56+
fn poll(&mut self) -> Result<T, E> {
57+
loop {}
58+
}
59+
}
60+
61+
struct JoinAll<I>
62+
where I: IntoIterator,
63+
I::Item: IntoFuture,
64+
{
65+
elems: Vec<<I::Item as IntoFuture>::Item>,
66+
}
67+
68+
fn join_all<I>(_: I) -> JoinAll<I>
69+
where I: IntoIterator,
70+
I::Item: IntoFuture,
71+
{
72+
JoinAll { elems: vec![] }
73+
}
74+
75+
impl<I> Future for JoinAll<I>
76+
where I: IntoIterator,
77+
I::Item: IntoFuture,
78+
{
79+
type Item = Vec<<I::Item as IntoFuture>::Item>;
80+
type Error = <I::Item as IntoFuture>::Error;
81+
82+
fn poll(&mut self) -> Result<Self::Item, Self::Error> {
83+
let elems = mem::replace(&mut self.elems, Vec::new());
84+
Ok(elems.into_iter().map(|e| {
85+
e
86+
}).collect::<Vec<_>>())
87+
}
88+
}

0 commit comments

Comments
 (0)