Skip to content

Commit 3f9f574

Browse files
committed
Expand try! to ? breaking change - DO NOT LAND!
1 parent c6fa5ee commit 3f9f574

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/libcore/macros.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ macro_rules! debug_assert_eq {
189189
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
190190
}
191191

192-
/// Helper macro for unwrapping `Result` values while returning early with an
193192
/// error if the value of the expression is `Err`. Can only be used in
194193
/// functions that return `Result` because of the early return of `Err` that
195194
/// it provides.
@@ -218,6 +217,7 @@ macro_rules! debug_assert_eq {
218217
/// Ok(())
219218
/// }
220219
/// ```
220+
#[cfg(stage0)]
221221
#[macro_export]
222222
#[stable(feature = "rust1", since = "1.0.0")]
223223
macro_rules! try {
@@ -228,6 +228,13 @@ macro_rules! try {
228228
}
229229
})
230230
}
231+
/// Helper macro for unwrapping `Result` values while returning early with an
232+
#[cfg(not(stage0))]
233+
#[macro_export]
234+
#[stable(feature = "rust1", since = "1.0.0")]
235+
macro_rules! try {
236+
($expr:expr) => ($expr?)
237+
}
231238

232239
/// Use the `format!` syntax to write data into a buffer.
233240
///

src/librustc_const_eval/eval.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
275275
hir::ExprTup(ref exprs) =>
276276
PatKind::Tuple(try!(exprs.iter()
277277
.map(|expr| const_expr_to_pat(tcx, &expr, pat_id, span))
278-
.collect()), None),
278+
.collect::<Result<_, _>>()), None),
279279

280280
hir::ExprCall(ref callee, ref args) => {
281281
let def = tcx.expect_def(callee.id);
@@ -295,7 +295,7 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
295295
let pats = try!(args.iter()
296296
.map(|expr| const_expr_to_pat(tcx, &**expr,
297297
pat_id, span))
298-
.collect());
298+
.collect::<Result<_, _>>());
299299
PatKind::TupleStruct(path, pats, None)
300300
}
301301

@@ -311,15 +311,15 @@ pub fn const_expr_to_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
311311
is_shorthand: false,
312312
},
313313
}))
314-
.collect());
314+
.collect::<Result<_, _>>());
315315
PatKind::Struct(path.clone(), field_pats, false)
316316
}
317317

318318
hir::ExprVec(ref exprs) => {
319319
let pats = try!(exprs.iter()
320320
.map(|expr| const_expr_to_pat(tcx, &expr,
321321
pat_id, span))
322-
.collect());
322+
.collect::<Result<_, _>>());
323323
PatKind::Vec(pats, None, hir::HirVec::new())
324324
}
325325

src/libsyntax/feature_gate.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ declare_features! (
261261
// a...b and ...b
262262
(active, inclusive_range_syntax, "1.7.0", Some(28237)),
263263

264-
// `expr?`
265-
(active, question_mark, "1.9.0", Some(31436)),
266-
267264
// impl specialization (RFC 1210)
268265
(active, specialization, "1.7.0", Some(31844)),
269266

267+
// `expr?`
268+
(active, question_mark, "1.9.0", Some(31436)),
269+
270270
// pub(restricted) visibilities (RFC 1422)
271271
(active, pub_restricted, "1.9.0", Some(32409)),
272272

@@ -971,9 +971,6 @@ impl<'a> Visitor for PostExpansionVisitor<'a> {
971971
e.span,
972972
"inclusive range syntax is experimental");
973973
}
974-
ast::ExprKind::Try(..) => {
975-
gate_feature_post!(&self, question_mark, e.span, "the `?` operator is not stable");
976-
}
977974
ast::ExprKind::InPlace(..) => {
978975
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
979976
}

0 commit comments

Comments
 (0)