Stabilise ?

cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)
This commit is contained in:
Nick Cameron 2016-10-06 11:36:36 +13:00
parent 9d4d0da7af
commit 9bc6d26092
38 changed files with 29 additions and 90 deletions

View File

@ -89,7 +89,7 @@
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(never_type)]
#![feature(prelude_import)]

View File

@ -255,6 +255,9 @@ macro_rules! debug_assert_ne {
/// Helper macro for reducing boilerplate code for matching `Result` together
/// with converting downstream errors.
///
/// Prefer using `?` syntax to `try!`. `?` is built in to the language and is
/// more succinct than `try!`, it is the standard method for error propogation.
///
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
/// expression has the value of the wrapped value.
///

View File

@ -295,7 +295,7 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(str_escape)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
use self::LabelText::*;

@ -1 +1 @@
Subproject commit b474785561d58efbd27add9d22339dcabad742ad
Subproject commit 5a17b4a733a22d445fdd63326f826fcd8a584328

View File

@ -1327,30 +1327,6 @@ let x: i32 = "I am not a number!";
// |
// type `i32` assigned to variable `x`
```
Another situation in which this occurs is when you attempt to use the `try!`
macro inside a function that does not return a `Result<T, E>`:
```compile_fail,E0308
use std::fs::File;
fn main() {
let mut f = try!(File::create("foo.txt"));
}
```
This code gives an error like this:
```text
<std macros>:5:8: 6:42 error: mismatched types:
expected `()`,
found `core::result::Result<_, _>`
(expected (),
found enum `core::result::Result`) [E0308]
```
`try!` returns a `Result<T, E>`, and so the function must. But `main()` has
`()` as its return type, hence the error.
"##,
E0309: r##"

View File

@ -40,7 +40,7 @@
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test))]
extern crate arena;

View File

@ -37,7 +37,7 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(step_by)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test, rand))]
extern crate syntax;

View File

@ -26,7 +26,7 @@
#![feature(staged_api)]
#![feature(associated_consts)]
#![feature(nonzero)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_pos;

View File

@ -27,7 +27,7 @@
#![feature(staged_api)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_patterns)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(box_patterns)]
#![feature(box_syntax)]

View File

@ -25,7 +25,7 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -31,7 +31,7 @@
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
extern crate arena;
extern crate flate;

View File

@ -21,7 +21,7 @@
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(range_contains)]
#![feature(libc)]
#![feature(unicode)]

View File

@ -20,7 +20,7 @@
#![cfg_attr(not(stage0), deny(warnings))]
#![feature(dotdot_in_tuple_patterns)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(rand)]

View File

@ -23,7 +23,7 @@
#![feature(dotdot_in_tuple_patterns)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_lib)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]

View File

@ -26,7 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
extern crate graphviz as dot;

View File

@ -36,7 +36,7 @@
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
use rustc::dep_graph::WorkProduct;

View File

@ -82,7 +82,7 @@ This API is completely unstable and subject to change.
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -28,7 +28,7 @@
#![feature(staged_api)]
#![feature(test)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
extern crate arena;
extern crate getopts;

View File

@ -35,7 +35,7 @@ Core encoding and decoding interfaces.
#![feature(specialization)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![cfg_attr(test, feature(test))]
// test harness access

View File

@ -255,7 +255,7 @@
#![feature(panic_unwind)]
#![feature(placement_in_syntax)]
#![feature(prelude_import)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rand)]
#![feature(raw)]
#![feature(reflect_marker)]

View File

@ -253,9 +253,6 @@ declare_features! (
// a...b and ...b
(active, inclusive_range_syntax, "1.7.0", Some(28237)),
// `expr?`
(active, question_mark, "1.9.0", Some(31436)),
// impl specialization (RFC 1210)
(active, specialization, "1.7.0", Some(31844)),
@ -348,6 +345,8 @@ declare_features! (
(accepted, while_let, "1.0.0", None),
// Allows `#[deprecated]` attribute
(accepted, deprecated, "1.9.0", Some(29935)),
// `expr?`
(accepted, question_mark, "1.14.0", Some(31436)),
);
// (changing above list without updating src/doc/reference.md makes @cmr sad)
@ -1072,9 +1071,6 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
e.span,
"inclusive range syntax is experimental");
}
ast::ExprKind::Try(..) => {
gate_feature_post!(&self, question_mark, e.span, "the `?` operator is not stable");
}
ast::ExprKind::InPlace(..) => {
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
}

View File

@ -31,7 +31,7 @@
#![feature(staged_api)]
#![feature(str_escape)]
#![feature(unicode)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(rustc_diagnostic_macros)]
#![feature(specialization)]

View File

@ -27,7 +27,7 @@
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(specialization)]
use std::cell::{Cell, RefCell};

View File

@ -59,7 +59,7 @@
#![cfg_attr(windows, feature(libc))]
// Handle rustfmt skips
#![feature(custom_attribute)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![allow(unused_attributes)]
use std::io::prelude::*;

View File

@ -38,7 +38,7 @@
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(question_mark)]
#![cfg_attr(stage0, feature(question_mark))]
#![feature(panic_unwind)]
extern crate getopts;

View File

@ -1,18 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
macro_rules! id {
($e:expr) => { $e }
}
fn main() {
id!(x?); //~ error: the `?` operator is not stable (see issue #31436)
y?; //~ error: the `?` operator is not stable (see issue #31436)
}

View File

@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(question_mark)]
// Make sure that the span of try shorthand does not include the trailing
// semicolon;
fn a() -> Result<i32, ()> {
Err(5)?; //~ ERROR 16:5: 16:12
Err(5)?; //~ ERROR 14:5: 14:12
Ok(1)
}

View File

@ -14,7 +14,6 @@
#![allow(unused_must_use)]
#![allow(unused_features)]
#![feature(box_syntax)]
#![feature(question_mark)]
use std::fmt::{self, Write};
use std::usize;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(conservative_impl_trait, question_mark)]
#![feature(conservative_impl_trait)]
struct State;
type Error = ();

View File

@ -10,8 +10,6 @@
// pretty-expanded FIXME #23616
#![feature(question_mark)]
use std::fs::File;
use std::io::{self, BufReader, Read};

View File

@ -10,8 +10,6 @@
// Regression test for #20797.
#![feature(question_mark)]
use std::default::Default;
use std::io;
use std::fs;

View File

@ -11,8 +11,6 @@
// Regression test for #21400 which itself was extracted from
// stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580
#![feature(question_mark)]
fn main() {
let mut t = Test;
assert_eq!(t.method1("one"), Ok(1));

View File

@ -18,8 +18,6 @@
// This test verifies that the expansion is hygienic, i.e. it's not affected by other `val` and
// `err` bindings that may be in scope.
#![feature(question_mark)]
use std::num::ParseIntError;
fn main() {

View File

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(question_mark)]
use std::fs::File;
use std::io::{Read, self};
use std::num::ParseIntError;

View File

@ -13,7 +13,6 @@
#![feature(box_syntax)]
#![feature(rustc_private)]
#![feature(test)]
#![feature(question_mark)]
#![feature(libc)]
#![deny(warnings)]

View File

@ -9,7 +9,6 @@
// except according to those terms.
#![feature(rustc_private, rustdoc)]
#![feature(question_mark)]
extern crate syntax;
extern crate rustdoc;

View File

@ -24,8 +24,6 @@
//! A few whitelisted exceptions are allowed as there's known bugs in rustdoc,
//! but this should catch the majority of "broken link" cases.
#![feature(question_mark)]
extern crate url;
use std::env;

View File

@ -12,7 +12,6 @@
#![feature(rustc_private)]
#![feature(rustdoc)]
#![feature(question_mark)]
extern crate rustdoc;
extern crate rustc_back;