Rollup merge of #62672 - lzutao:deprecated-try-macro, r=Centril

Deprecate `try!` macro

Replaces #62077

Fixes rust-lang/rust-clippy#1361
Fixes #61000
This commit is contained in:
Mazdak Farrokhzad 2019-08-09 14:07:26 +02:00 committed by GitHub
commit 03c524e0f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 17 additions and 4 deletions

View File

@ -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 {

View File

@ -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]

View File

@ -1,5 +1,7 @@
// check-pass
#![allow(deprecated)]
pub type ParseResult<T> = Result<T, ()>;
pub enum Item<'a> {

View File

@ -1,5 +1,6 @@
// Test that the resolve failure does not lead to downstream type errors.
// See issue #31997.
#![allow(deprecated)]
trait TheTrait { }

View File

@ -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

View File

@ -1,4 +1,5 @@
#![deny(unused_qualifications)]
#[allow(deprecated)]
mod foo {
pub fn bar() {}

View File

@ -1,5 +1,5 @@
error: unnecessary qualification
--> $DIR/lint-qualification.rs:9:5
--> $DIR/lint-qualification.rs:10:5
|
LL | foo::bar();
| ^^^^^^^^

View File

@ -15,6 +15,7 @@
#![cfg_attr(core, no_std)]
#![allow(deprecated)] // for deprecated `try!()` macro
#![feature(concat_idents)]
#[cfg(std)] use std::fmt;

View File

@ -1,4 +1,5 @@
// run-pass
#![allow(deprecated)] // for deprecated `try!()` macro
use std::num::{ParseFloatError, ParseIntError};
fn main() {

View File

@ -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);

View File

@ -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);

View File

@ -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`