]> git.lizzy.rs Git - rust.git/commitdiff
Stabilise `?`
authorNick Cameron <ncameron@mozilla.com>
Wed, 5 Oct 2016 22:36:36 +0000 (11:36 +1300)
committerNick Cameron <ncameron@mozilla.com>
Tue, 11 Oct 2016 19:40:22 +0000 (08:40 +1300)
cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)

38 files changed:
src/libcore/lib.rs
src/libcore/macros.rs
src/libgraphviz/lib.rs
src/liblibc
src/librustc/diagnostics.rs
src/librustc/lib.rs
src/librustc_back/lib.rs
src/librustc_borrowck/lib.rs
src/librustc_const_eval/lib.rs
src/librustc_const_math/lib.rs
src/librustc_driver/lib.rs
src/librustc_errors/lib.rs
src/librustc_incremental/lib.rs
src/librustc_metadata/lib.rs
src/librustc_mir/lib.rs
src/librustc_trans/lib.rs
src/librustc_typeck/lib.rs
src/librustdoc/lib.rs
src/libserialize/lib.rs
src/libstd/lib.rs
src/libsyntax/feature_gate.rs
src/libsyntax/lib.rs
src/libsyntax_pos/lib.rs
src/libterm/lib.rs
src/libtest/lib.rs
src/test/compile-fail/feature-gate-try-operator.rs [deleted file]
src/test/compile-fail/issue-32709.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/impl-trait/example-st.rs
src/test/run-pass/issue-17121.rs
src/test/run-pass/issue-20797.rs
src/test/run-pass/issue-21400.rs
src/test/run-pass/try-operator-hygiene.rs
src/test/run-pass/try-operator.rs
src/tools/compiletest/src/main.rs
src/tools/error_index_generator/main.rs
src/tools/linkchecker/main.rs
src/tools/rustbook/main.rs

index 1ae4cf8e5ef5f05b37c920206786768eba05d41c..28101d21fc25ecd691ae7eae8e91f43b270f652d 100644 (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)]
 
index 99c24e4c48d44a51a7a0ce0aa7f76add4845ff5d..a0768089d5264bd392f9084928eb542222b08bc9 100644 (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.
 ///
index 74cc498a7df23478effa5f7644a736caad606470..95c46ec5715e742740963b414c75195050a4ba6c 100644 (file)
 #![cfg_attr(not(stage0), deny(warnings))]
 
 #![feature(str_escape)]
-#![feature(question_mark)]
+#![cfg_attr(stage0, feature(question_mark))]
 
 use self::LabelText::*;
 
index b474785561d58efbd27add9d22339dcabad742ad..5a17b4a733a22d445fdd63326f826fcd8a584328 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b474785561d58efbd27add9d22339dcabad742ad
+Subproject commit 5a17b4a733a22d445fdd63326f826fcd8a584328
index de68cc707ad7a2020e3d7e6061f46968697ce394..12a1a4255246a43ad64fdd77b39d5180cac56aab 100644 (file)
@@ -1327,30 +1327,6 @@ fn main() {}
 //      |
 //    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##"
index c34286f0195bfb61005beb5bdc676537932ae928..25731df47785392ce6b91a28f278bf683ce2810a 100644 (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;
index c0f358ca8017bd884c3bfa53a892ee58a2e67a95..e6d1982d31c2d3370adaac3ceafe3e2ccfc6111c 100644 (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;
index 22b590592fe168d3277d3f7a4e31b28b4706debc..d3ab9c931850439f9e6f794db277a439658fed8c 100644 (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;
index f926fef065ea6c228fed4cc17a473a5ac0e7930f..7b40269ba56ad271ac459e55c88c1d111fbdd762 100644 (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)]
 
index 741dd4107e001e0886d8484fb744e01445357ad9..31fccb41ce573840ec8bcbbed5c5534e0ca07504 100644 (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;
index 492165e2f2a8e081290d8af025ea390352c5b330..0e59ea6560fee85f0e0a4448e7ea95df7b802b10 100644 (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;
index bc599a8207656aadff7a97317ce884f9c7bbd3bb..af8ac81b4fbb1d916f979e7fdee76bf4bdb68c2f 100644 (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)]
index 2c1340e566dda587f3022e019e581b6081ac3e40..67104e912f90ecc9a0a7ecfa9739b5eb1c584976 100644 (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)]
index acaafb35425d040c5913c37a39dad658abb494ec..3d8a10f6c31fcc2a24febf28c3e6878844da6f7c 100644 (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)]
index 12f1eb8535a3eb7bd27a48a060988b326d3ed06d..02f15602d708b3472a39f42aa391282213a7f8c8 100644 (file)
@@ -26,7 +26,7 @@
 #![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;
index 41c8d565d418c93a75e1639378bf76a08b84dc52..81c0c184f66b2e76441d1c79ae9443060cbbe449 100644 (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;
 
index 1f34cee5143c61e9e147bd4584efbaa3bfb121f1..cb9b162cabe11911e3180c4acee2ad39c4ad0034 100644 (file)
@@ -82,7 +82,7 @@
 #![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;
index 006dda7d661995d9e67041b156d54765d4a48d98..0be36eb3a85088d7dd7125e95e88fa21468cfd0e 100644 (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;
index 7cb02e2412c65808e6363456bce5b9c0901f90ba..884f24ddc4c75a8b739c83096d9322bc30998007 100644 (file)
@@ -35,7 +35,7 @@
 #![feature(specialization)]
 #![feature(staged_api)]
 #![feature(unicode)]
-#![feature(question_mark)]
+#![cfg_attr(stage0, feature(question_mark))]
 #![cfg_attr(test, feature(test))]
 
 // test harness access
index eee85798841254c06ea1d415528ff2b66b76f512..5a2eb1c1dc4bd31886de0d7f2eeca4045607ea91 100644 (file)
 #![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)]
index 9eed1d61244a49b80585992374881bbac9d236f8..62b88888fc878849f041d6051c7f9b9b88a43e80 100644 (file)
@@ -253,9 +253,6 @@ pub fn new() -> 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 @@ pub fn new() -> 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 @@ fn visit_expr(&mut self, e: &ast::Expr) {
                                   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);
             }
index 118ceb17ab4a4538c639e2c493348c44a95fd326..6e671c9efdcf87b2a5e3abfa0ebd64b9c0f164f5 100644 (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)]
 
index 13dcf7b188b70b4c551a8229cb774ed5992f362e..e3feaee5369d1c92474bcaebce3387bbcbcca8a0 100644 (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};
index 0244e2657969337bd2e47a4a49e55b11fca67e68..caef808f474ec9553fb436adaa39d402aa57a9ee 100644 (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::*;
index bb42351d3b7c8064def20b552b7a3edd8cbfc219..625666e641c6bed6ece2bda4dd1d3f3983a06f6d 100644 (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;
diff --git a/src/test/compile-fail/feature-gate-try-operator.rs b/src/test/compile-fail/feature-gate-try-operator.rs
deleted file mode 100644 (file)
index b05c732..0000000
+++ /dev/null
@@ -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)
-}
index f9d11f3a171c2118c294044f03c75740ebc41fc1..09538818dcdf9ccf85fc692de32f51bc9e3f43aa 100644 (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)
 }
 
index 8b5536de12e4977eec39d82ec46bdf12ad2794e9..0ebe1ca07c77180259d1b97e61ae3a154a256520 100644 (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;
index 461d4cf4ff053bc0feea5dc3923503704e4aa72f..e9326ed286aff9c49f880c069f1ea6362e1c1932 100644 (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 = ();
index b3c80041ef88b7f1e0f0d6139bde4d0208406b50..dcbcc2d44b5dd803464e625f0642bd376b10a9d4 100644 (file)
@@ -10,8 +10,6 @@
 
 // pretty-expanded FIXME #23616
 
-#![feature(question_mark)]
-
 use std::fs::File;
 use std::io::{self, BufReader, Read};
 
index de952436650828a4170e33aa894da126445db2dd..e45582dc2d39a09b11e6c95e4ea11ef5b3368d36 100644 (file)
@@ -10,8 +10,6 @@
 
 // Regression test for #20797.
 
-#![feature(question_mark)]
-
 use std::default::Default;
 use std::io;
 use std::fs;
index 0d1be964748bb9b263c191d9f85e4d98d622ceb5..6715b71a5f506eb162792c22a5714e1d4e945ec7 100644 (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));
index ae622df498f94b108306a1d5f6dd587a0015acce..53d6185020a0235ffb5f16b691780e4d66548f20 100644 (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() {
index de5ccf09c5923d4ca67331f08f3afc52537c2438..29de6364bf14760b6059cc58b143c8c812116919 100644 (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;
index b81258bd6d70289c0cbae86b44ebf3caac203a8c..81478c18d7b24ddac0b102c2b4d28a016299dd5e 100644 (file)
@@ -13,7 +13,6 @@
 #![feature(box_syntax)]
 #![feature(rustc_private)]
 #![feature(test)]
-#![feature(question_mark)]
 #![feature(libc)]
 
 #![deny(warnings)]
index 2c734c8e3e4d4cbeac69ea5b266695df6d8eea95..7bdf1343aa9ccc70a2687c460d1bc081031a0db7 100644 (file)
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 #![feature(rustc_private, rustdoc)]
-#![feature(question_mark)]
 
 extern crate syntax;
 extern crate rustdoc;
index 3e2bc9032a1ccae31c4ca3e8a60847ce2aec90d3..f79cc76e67d0045509a8a1520343f12c9288b6d6 100644 (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;
index 436dc1197533638504fb8c6e808f1e8d51137b1c..906251db1c2f216a4643a5cbd6f15c3b746f2a0d 100644 (file)
@@ -12,7 +12,6 @@
 
 #![feature(rustc_private)]
 #![feature(rustdoc)]
-#![feature(question_mark)]
 
 extern crate rustdoc;
 extern crate rustc_back;