Skip to content

Commit 03c524e

Browse files
authored
Rollup merge of rust-lang#62672 - lzutao:deprecated-try-macro, r=Centril
Deprecate `try!` macro Replaces rust-lang#62077 Fixes rust-lang/rust-clippy#1361 Fixes rust-lang#61000
2 parents d8f8be4 + 6842316 commit 03c524e

File tree

12 files changed

+17
-4
lines changed

12 files changed

+17
-4
lines changed

src/libcore/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ macro_rules! debug_assert_ne {
302302
/// ```
303303
#[macro_export]
304304
#[stable(feature = "rust1", since = "1.0.0")]
305+
#[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")]
305306
#[doc(alias = "?")]
306307
macro_rules! r#try {
307308
($expr:expr) => (match $expr {

src/libstd/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ use prelude::v1::*;
330330
#[stable(feature = "rust1", since = "1.0.0")]
331331
pub use core::{assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne};
332332
#[stable(feature = "rust1", since = "1.0.0")]
333-
pub use core::{unreachable, unimplemented, write, writeln, r#try, todo};
333+
pub use core::{unreachable, unimplemented, write, writeln, todo};
334+
// FIXME: change this to `#[allow(deprecated)]` when we update nightly compiler.
335+
#[allow(deprecated_in_future)]
336+
#[stable(feature = "rust1", since = "1.0.0")]
337+
pub use core::r#try;
334338

335339
#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
336340
#[macro_use]

src/test/ui/associated-types/cache/chrono-scan.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// check-pass
22

3+
#![allow(deprecated)]
4+
35
pub type ParseResult<T> = Result<T, ()>;
46

57
pub enum Item<'a> {

src/test/ui/derived-errors/issue-31997.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Test that the resolve failure does not lead to downstream type errors.
22
// See issue #31997.
3+
#![allow(deprecated)]
34

45
trait TheTrait { }
56

src/test/ui/derived-errors/issue-31997.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find function `bar` in this scope
2-
--> $DIR/issue-31997.rs:13:21
2+
--> $DIR/issue-31997.rs:14:21
33
|
44
LL | try!(closure(|| bar(core::ptr::null_mut())));
55
| ^^^ not found in this scope

src/test/ui/lint/lint-qualification.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![deny(unused_qualifications)]
2+
#[allow(deprecated)]
23

34
mod foo {
45
pub fn bar() {}

src/test/ui/lint/lint-qualification.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unnecessary qualification
2-
--> $DIR/lint-qualification.rs:9:5
2+
--> $DIR/lint-qualification.rs:10:5
33
|
44
LL | foo::bar();
55
| ^^^^^^^^

src/test/ui/macros/macro-comma-support-rpass.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#![cfg_attr(core, no_std)]
1717

18+
#![allow(deprecated)] // for deprecated `try!()` macro
1819
#![feature(concat_idents)]
1920

2021
#[cfg(std)] use std::fmt;

src/test/ui/macros/try-macro.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-pass
2+
#![allow(deprecated)] // for deprecated `try!()` macro
23
use std::num::{ParseFloatError, ParseIntError};
34

45
fn main() {

src/test/ui/rust-2018/try-macro.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![warn(rust_2018_compatibility)]
77
#![allow(unused_variables)]
88
#![allow(dead_code)]
9+
#![allow(deprecated)]
910

1011
fn foo() -> Result<usize, ()> {
1112
let x: Result<usize, ()> = Ok(22);

src/test/ui/rust-2018/try-macro.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![warn(rust_2018_compatibility)]
77
#![allow(unused_variables)]
88
#![allow(dead_code)]
9+
#![allow(deprecated)]
910

1011
fn foo() -> Result<usize, ()> {
1112
let x: Result<usize, ()> = Ok(22);

src/test/ui/rust-2018/try-macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: `try` is a keyword in the 2018 edition
2-
--> $DIR/try-macro.rs:12:5
2+
--> $DIR/try-macro.rs:13:5
33
|
44
LL | try!(x);
55
| ^^^ help: you can use a raw identifier to stay compatible: `r#try`

0 commit comments

Comments
 (0)