diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 58ea0207c5609..c243ecb49dd24 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -300,6 +300,7 @@ macro_rules! debug_assert_ne { /// Ok(()) /// } /// ``` +#[rustc_deprecated(since = "1.38.0", reason = "use the `?` operator instead")] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[doc(alias = "?")] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index fb9a228880eb7..05854d9b6242c 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -322,7 +322,10 @@ use prelude::v1::*; #[stable(feature = "rust1", since = "1.0.0")] pub use core::{assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne}; #[stable(feature = "rust1", since = "1.0.0")] -pub use core::{unreachable, unimplemented, write, writeln, r#try, todo}; +pub use core::{unreachable, unimplemented, write, writeln, todo}; +#[allow(deprecated)] +#[stable(feature = "rust1", since = "1.0.0")] +pub use core::r#try; #[allow(unused_imports)] // macros from `alloc` are not used on all platforms #[macro_use] diff --git a/src/test/run-pass/macros/macro-comma-support.rs b/src/test/run-pass/macros/macro-comma-support.rs index 12a612c153ad6..17c27b7cda473 100644 --- a/src/test/run-pass/macros/macro-comma-support.rs +++ b/src/test/run-pass/macros/macro-comma-support.rs @@ -261,7 +261,9 @@ fn thread_local() { #[test] fn try() { fn inner() -> Result<(), ()> { + #[allow(deprecated)] try!(Ok(())); + #[allow(deprecated)] try!(Ok(()),); Ok(()) } diff --git a/src/test/run-pass/macros/try-macro.rs b/src/test/run-pass/macros/try-macro.rs index 83b30a8b7ba11..643312654493a 100644 --- a/src/test/run-pass/macros/try-macro.rs +++ b/src/test/run-pass/macros/try-macro.rs @@ -1,4 +1,5 @@ // run-pass +#[allow(deprecated)] use std::num::{ParseFloatError, ParseIntError}; fn main() { diff --git a/src/test/ui/associated-types/cache/chrono-scan.rs b/src/test/ui/associated-types/cache/chrono-scan.rs index 8ddd347ff3607..5c05240552761 100644 --- a/src/test/ui/associated-types/cache/chrono-scan.rs +++ b/src/test/ui/associated-types/cache/chrono-scan.rs @@ -18,7 +18,7 @@ pub fn timezone_offset_zulu(s: &str, colon: F) -> ParseResult<(&str, i32)> pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()> where I: Iterator> { macro_rules! try_consume { - ($e:expr) => ({ let (s_, v) = try!($e); s = s_; v }) + ($e:expr) => ({ let (s_, v) = $e?; s = s_; v }) } let offset = try_consume!(timezone_offset_zulu(s.trim_start(), colon_or_space)); let offset = try_consume!(timezone_offset_zulu(s.trim_start(), colon_or_space)); diff --git a/src/test/ui/derived-errors/issue-31997.rs b/src/test/ui/derived-errors/issue-31997.rs index cfdee26c5599c..6d7d21e367322 100644 --- a/src/test/ui/derived-errors/issue-31997.rs +++ b/src/test/ui/derived-errors/issue-31997.rs @@ -10,7 +10,7 @@ fn closure(x: F) -> Result } fn foo() -> Result<(), ()> { - try!(closure(|| bar(core::ptr::null_mut()))); //~ ERROR cannot find function `bar` in this scope + closure(|| bar(core::ptr::null_mut()))?; //~ ERROR cannot find function `bar` in this scope Ok(()) } diff --git a/src/test/ui/derived-errors/issue-31997.stderr b/src/test/ui/derived-errors/issue-31997.stderr index e9fe0d3971ee6..d9260f79f2742 100644 --- a/src/test/ui/derived-errors/issue-31997.stderr +++ b/src/test/ui/derived-errors/issue-31997.stderr @@ -1,8 +1,8 @@ error[E0425]: cannot find function `bar` in this scope - --> $DIR/issue-31997.rs:13:21 + --> $DIR/issue-31997.rs:13:16 | -LL | try!(closure(|| bar(core::ptr::null_mut()))); - | ^^^ not found in this scope +LL | closure(|| bar(core::ptr::null_mut()))?; + | ^^^ not found in this scope error: aborting due to previous error diff --git a/src/test/ui/lint/lint-qualification.rs b/src/test/ui/lint/lint-qualification.rs index 2aa4526b8169b..d458c31dc4926 100644 --- a/src/test/ui/lint/lint-qualification.rs +++ b/src/test/ui/lint/lint-qualification.rs @@ -9,7 +9,7 @@ fn main() { foo::bar(); //~ ERROR: unnecessary qualification bar(); - let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345 + let _ = || -> Result<(), ()> { Ok(())?; Ok(()) }; // issue #37345 macro_rules! m { () => { $crate::foo::bar(); // issue #37357 diff --git a/src/test/ui/rust-2018/try-macro.fixed b/src/test/ui/rust-2018/try-macro.fixed index 7c1692fd7fb13..a7b7d3faf5ee9 100644 --- a/src/test/ui/rust-2018/try-macro.fixed +++ b/src/test/ui/rust-2018/try-macro.fixed @@ -6,6 +6,7 @@ #![warn(rust_2018_compatibility)] #![allow(unused_variables)] #![allow(dead_code)] +#![allow(deprecated)] fn foo() -> Result { let x: Result = Ok(22); diff --git a/src/test/ui/rust-2018/try-macro.rs b/src/test/ui/rust-2018/try-macro.rs index 2089d367be698..986e158eb644e 100644 --- a/src/test/ui/rust-2018/try-macro.rs +++ b/src/test/ui/rust-2018/try-macro.rs @@ -6,6 +6,7 @@ #![warn(rust_2018_compatibility)] #![allow(unused_variables)] #![allow(dead_code)] +#![allow(deprecated)] fn foo() -> Result { let x: Result = Ok(22); diff --git a/src/test/ui/rust-2018/try-macro.stderr b/src/test/ui/rust-2018/try-macro.stderr index 40a4564cc3d6d..ba3e1a79f4b80 100644 --- a/src/test/ui/rust-2018/try-macro.stderr +++ b/src/test/ui/rust-2018/try-macro.stderr @@ -1,5 +1,5 @@ warning: `try` is a keyword in the 2018 edition - --> $DIR/try-macro.rs:12:5 + --> $DIR/try-macro.rs:13:5 | LL | try!(x); | ^^^ help: you can use a raw identifier to stay compatible: `r#try`