Skip to content

Commit 8dc1c24

Browse files
nrcbrson
authored andcommitted
Stabilise ?
cc [`?` tracking issue](#31436)
1 parent 8aa0c6b commit 8dc1c24

File tree

37 files changed

+28
-89
lines changed

37 files changed

+28
-89
lines changed

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
#![feature(specialization)]
9090
#![feature(staged_api)]
9191
#![feature(unboxed_closures)]
92-
#![feature(question_mark)]
92+
#![cfg_attr(stage0, feature(question_mark))]
9393
#![feature(never_type)]
9494
#![feature(prelude_import)]
9595

src/libcore/macros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ macro_rules! debug_assert_ne {
255255
/// Helper macro for reducing boilerplate code for matching `Result` together
256256
/// with converting downstream errors.
257257
///
258+
/// Prefer using `?` syntax to `try!`. `?` is built in to the language and is
259+
/// more succinct than `try!`, it is the standard method for error propogation.
260+
///
258261
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
259262
/// expression has the value of the wrapped value.
260263
///

src/libgraphviz/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
#![cfg_attr(not(stage0), deny(warnings))]
296296

297297
#![feature(str_escape)]
298-
#![feature(question_mark)]
298+
#![cfg_attr(stage0, feature(question_mark))]
299299

300300
use self::LabelText::*;
301301

src/librustc/diagnostics.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,30 +1327,6 @@ let x: i32 = "I am not a number!";
13271327
// |
13281328
// type `i32` assigned to variable `x`
13291329
```
1330-
1331-
Another situation in which this occurs is when you attempt to use the `try!`
1332-
macro inside a function that does not return a `Result<T, E>`:
1333-
1334-
```compile_fail,E0308
1335-
use std::fs::File;
1336-
1337-
fn main() {
1338-
let mut f = try!(File::create("foo.txt"));
1339-
}
1340-
```
1341-
1342-
This code gives an error like this:
1343-
1344-
```text
1345-
<std macros>:5:8: 6:42 error: mismatched types:
1346-
expected `()`,
1347-
found `core::result::Result<_, _>`
1348-
(expected (),
1349-
found enum `core::result::Result`) [E0308]
1350-
```
1351-
1352-
`try!` returns a `Result<T, E>`, and so the function must. But `main()` has
1353-
`()` as its return type, hence the error.
13541330
"##,
13551331

13561332
E0309: r##"

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#![feature(rustc_private)]
4141
#![feature(slice_patterns)]
4242
#![feature(staged_api)]
43-
#![feature(question_mark)]
43+
#![cfg_attr(stage0, feature(question_mark))]
4444
#![cfg_attr(test, feature(test))]
4545

4646
extern crate arena;

src/librustc_back/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#![feature(rustc_private)]
3838
#![feature(staged_api)]
3939
#![feature(step_by)]
40-
#![feature(question_mark)]
40+
#![cfg_attr(stage0, feature(question_mark))]
4141
#![cfg_attr(test, feature(test, rand))]
4242

4343
extern crate syntax;

src/librustc_borrowck/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#![feature(staged_api)]
2727
#![feature(associated_consts)]
2828
#![feature(nonzero)]
29-
#![feature(question_mark)]
29+
#![cfg_attr(stage0, feature(question_mark))]
3030
#[macro_use] extern crate log;
3131
#[macro_use] extern crate syntax;
3232
extern crate syntax_pos;

src/librustc_const_eval/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![feature(staged_api)]
2828
#![feature(rustc_diagnostic_macros)]
2929
#![feature(slice_patterns)]
30-
#![feature(question_mark)]
30+
#![cfg_attr(stage0, feature(question_mark))]
3131
#![feature(box_patterns)]
3232
#![feature(box_syntax)]
3333

src/librustc_const_math/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#![feature(rustc_private)]
2727
#![feature(staged_api)]
28-
#![feature(question_mark)]
28+
#![cfg_attr(stage0, feature(question_mark))]
2929

3030
#[macro_use] extern crate log;
3131
#[macro_use] extern crate syntax;

src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#![feature(rustc_private)]
3232
#![feature(set_stdio)]
3333
#![feature(staged_api)]
34-
#![feature(question_mark)]
34+
#![cfg_attr(stage0, feature(question_mark))]
3535

3636
extern crate arena;
3737
extern crate flate;

src/librustc_errors/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#![allow(unused_attributes)]
2222
#![feature(rustc_private)]
2323
#![feature(staged_api)]
24-
#![feature(question_mark)]
24+
#![cfg_attr(stage0, feature(question_mark))]
2525
#![feature(range_contains)]
2626
#![feature(libc)]
2727
#![feature(unicode)]

src/librustc_incremental/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![cfg_attr(not(stage0), deny(warnings))]
2121

2222
#![feature(dotdot_in_tuple_patterns)]
23-
#![feature(question_mark)]
23+
#![cfg_attr(stage0, feature(question_mark))]
2424
#![feature(rustc_private)]
2525
#![feature(staged_api)]
2626
#![feature(rand)]

src/librustc_metadata/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#![feature(core_intrinsics)]
2222
#![feature(box_patterns)]
2323
#![feature(dotdot_in_tuple_patterns)]
24-
#![feature(question_mark)]
24+
#![cfg_attr(stage0, feature(question_mark))]
2525
#![feature(quote)]
2626
#![feature(rustc_diagnostic_macros)]
2727
#![feature(rustc_macro_lib)]

src/librustc_mir/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2626
#![feature(rustc_diagnostic_macros)]
2727
#![feature(rustc_private)]
2828
#![feature(staged_api)]
29-
#![feature(question_mark)]
29+
#![cfg_attr(stage0, feature(question_mark))]
3030

3131
#[macro_use] extern crate log;
3232
extern crate graphviz as dot;

src/librustc_trans/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#![feature(slice_patterns)]
3737
#![feature(staged_api)]
3838
#![feature(unicode)]
39-
#![feature(question_mark)]
39+
#![cfg_attr(stage0, feature(question_mark))]
4040

4141
use rustc::dep_graph::WorkProduct;
4242

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ This API is completely unstable and subject to change.
8282
#![feature(rustc_diagnostic_macros)]
8383
#![feature(rustc_private)]
8484
#![feature(staged_api)]
85-
#![feature(question_mark)]
85+
#![cfg_attr(stage0, feature(question_mark))]
8686

8787
#[macro_use] extern crate log;
8888
#[macro_use] extern crate syntax;

src/librustdoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#![feature(staged_api)]
2929
#![feature(test)]
3030
#![feature(unicode)]
31-
#![feature(question_mark)]
31+
#![cfg_attr(stage0, feature(question_mark))]
3232

3333
extern crate arena;
3434
extern crate getopts;

src/libserialize/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Core encoding and decoding interfaces.
3535
#![feature(specialization)]
3636
#![feature(staged_api)]
3737
#![feature(unicode)]
38-
#![feature(question_mark)]
38+
#![cfg_attr(stage0, feature(question_mark))]
3939
#![cfg_attr(test, feature(test))]
4040

4141
// test harness access

src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
#![feature(panic_unwind)]
256256
#![feature(placement_in_syntax)]
257257
#![feature(prelude_import)]
258-
#![feature(question_mark)]
258+
#![cfg_attr(stage0, feature(question_mark))]
259259
#![feature(rand)]
260260
#![feature(raw)]
261261
#![feature(reflect_marker)]

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,6 @@ declare_features! (
253253
// a...b and ...b
254254
(active, inclusive_range_syntax, "1.7.0", Some(28237)),
255255

256-
// `expr?`
257-
(active, question_mark, "1.9.0", Some(31436)),
258-
259256
// impl specialization (RFC 1210)
260257
(active, specialization, "1.7.0", Some(31844)),
261258

@@ -345,6 +342,8 @@ declare_features! (
345342
(accepted, while_let, "1.0.0", None),
346343
// Allows `#[deprecated]` attribute
347344
(accepted, deprecated, "1.9.0", Some(29935)),
345+
// `expr?`
346+
(accepted, question_mark, "1.14.0", Some(31436)),
348347
);
349348
// (changing above list without updating src/doc/reference.md makes @cmr sad)
350349

@@ -1069,9 +1068,6 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
10691068
e.span,
10701069
"inclusive range syntax is experimental");
10711070
}
1072-
ast::ExprKind::Try(..) => {
1073-
gate_feature_post!(&self, question_mark, e.span, "the `?` operator is not stable");
1074-
}
10751071
ast::ExprKind::InPlace(..) => {
10761072
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
10771073
}

src/libsyntax/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#![feature(staged_api)]
3232
#![feature(str_escape)]
3333
#![feature(unicode)]
34-
#![feature(question_mark)]
34+
#![cfg_attr(stage0, feature(question_mark))]
3535
#![feature(rustc_diagnostic_macros)]
3636
#![feature(specialization)]
3737

src/libsyntax_pos/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![allow(unused_attributes)]
2828
#![feature(rustc_private)]
2929
#![feature(staged_api)]
30-
#![feature(question_mark)]
30+
#![cfg_attr(stage0, feature(question_mark))]
3131
#![feature(specialization)]
3232

3333
use std::cell::{Cell, RefCell};

src/libterm/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#![cfg_attr(windows, feature(libc))]
6060
// Handle rustfmt skips
6161
#![feature(custom_attribute)]
62-
#![feature(question_mark)]
62+
#![cfg_attr(stage0, feature(question_mark))]
6363
#![allow(unused_attributes)]
6464

6565
use std::io::prelude::*;

src/libtest/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#![feature(rustc_private)]
4141
#![feature(set_stdio)]
4242
#![feature(staged_api)]
43-
#![feature(question_mark)]
43+
#![cfg_attr(stage0, feature(question_mark))]
4444
#![feature(panic_unwind)]
4545

4646
extern crate getopts;

src/test/compile-fail/feature-gate-try-operator.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/test/compile-fail/issue-32709.rs

Lines changed: 1 addition & 3 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-
#![feature(question_mark)]
12-
1311
// Make sure that the span of try shorthand does not include the trailing
1412
// semicolon;
1513
fn a() -> Result<i32, ()> {
16-
Err(5)?; //~ ERROR 16:5: 16:12
14+
Err(5)?; //~ ERROR 14:5: 14:12
1715
Ok(1)
1816
}
1917

src/test/run-pass/ifmt.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![allow(unused_must_use)]
1515
#![allow(unused_features)]
1616
#![feature(box_syntax)]
17-
#![feature(question_mark)]
1817

1918
use std::fmt::{self, Write};
2019
use std::usize;

src/test/run-pass/impl-trait/example-st.rs

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

11-
#![feature(conservative_impl_trait, question_mark)]
11+
#![feature(conservative_impl_trait)]
1212

1313
struct State;
1414
type Error = ();

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// pretty-expanded FIXME #23616
1212

13-
#![feature(question_mark)]
14-
1513
use std::fs::File;
1614
use std::io::{self, BufReader, Read};
1715

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Regression test for #20797.
1212

13-
#![feature(question_mark)]
14-
1513
use std::default::Default;
1614
use std::io;
1715
use std::fs;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
// Regression test for #21400 which itself was extracted from
1212
// stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580
1313

14-
#![feature(question_mark)]
15-
1614
fn main() {
1715
let mut t = Test;
1816
assert_eq!(t.method1("one"), Ok(1));

src/test/run-pass/try-operator-hygiene.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
// This test verifies that the expansion is hygienic, i.e. it's not affected by other `val` and
1919
// `err` bindings that may be in scope.
2020

21-
#![feature(question_mark)]
22-
2321
use std::num::ParseIntError;
2422

2523
fn main() {

src/test/run-pass/try-operator.rs

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

11-
#![feature(question_mark)]
12-
1311
use std::fs::File;
1412
use std::io::{Read, self};
1513
use std::num::ParseIntError;

src/tools/compiletest/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(box_syntax)]
1414
#![feature(rustc_private)]
1515
#![feature(test)]
16-
#![feature(question_mark)]
1716
#![feature(libc)]
1817

1918
#![deny(warnings)]

src/tools/error_index_generator/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![feature(rustc_private, rustdoc)]
12-
#![feature(question_mark)]
1312

1413
extern crate syntax;
1514
extern crate rustdoc;

src/tools/linkchecker/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
//! A few whitelisted exceptions are allowed as there's known bugs in rustdoc,
2525
//! but this should catch the majority of "broken link" cases.
2626
27-
#![feature(question_mark)]
28-
2927
extern crate url;
3028

3129
use std::env;

src/tools/rustbook/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(rustc_private)]
1414
#![feature(rustdoc)]
15-
#![feature(question_mark)]
1615

1716
extern crate rustdoc;
1817
extern crate rustc_back;

0 commit comments

Comments
 (0)