Skip to content

Commit

Permalink
Rollup merge of rust-lang#62672 - lzutao:deprecated-try-macro, r=Centril
Browse files Browse the repository at this point in the history
Deprecate `try!` macro

Replaces rust-lang#62077

Fixes rust-lang/rust-clippy#1361
Fixes rust-lang#61000
  • Loading branch information
Centril authored Aug 9, 2019
2 parents d8f8be4 + 6842316 commit 03c524e
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ macro_rules! debug_assert_ne {
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")]
#[doc(alias = "?")]
macro_rules! r#try {
($expr:expr) => (match $expr {
Expand Down
6 changes: 5 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,11 @@ 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};
// FIXME: change this to `#[allow(deprecated)]` when we update nightly compiler.
#[allow(deprecated_in_future)]
#[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]
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/associated-types/cache/chrono-scan.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// check-pass

#![allow(deprecated)]

pub type ParseResult<T> = Result<T, ()>;

pub enum Item<'a> {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/derived-errors/issue-31997.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Test that the resolve failure does not lead to downstream type errors.
// See issue #31997.
#![allow(deprecated)]

trait TheTrait { }

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/derived-errors/issue-31997.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0425]: cannot find function `bar` in this scope
--> $DIR/issue-31997.rs:13:21
--> $DIR/issue-31997.rs:14:21
|
LL | try!(closure(|| bar(core::ptr::null_mut())));
| ^^^ not found in this scope
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/lint/lint-qualification.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(unused_qualifications)]
#[allow(deprecated)]

mod foo {
pub fn bar() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-qualification.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unnecessary qualification
--> $DIR/lint-qualification.rs:9:5
--> $DIR/lint-qualification.rs:10:5
|
LL | foo::bar();
| ^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/macros/macro-comma-support-rpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#![cfg_attr(core, no_std)]

#![allow(deprecated)] // for deprecated `try!()` macro
#![feature(concat_idents)]

#[cfg(std)] use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/macros/try-macro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// run-pass
#![allow(deprecated)] // for deprecated `try!()` macro
use std::num::{ParseFloatError, ParseIntError};

fn main() {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/rust-2018/try-macro.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![warn(rust_2018_compatibility)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(deprecated)]

fn foo() -> Result<usize, ()> {
let x: Result<usize, ()> = Ok(22);
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/rust-2018/try-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![warn(rust_2018_compatibility)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(deprecated)]

fn foo() -> Result<usize, ()> {
let x: Result<usize, ()> = Ok(22);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/rust-2018/try-macro.stderr
Original file line number Diff line number Diff line change
@@ -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`
Expand Down

0 comments on commit 03c524e

Please sign in to comment.