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;

0 commit comments

Comments
 (0)