Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate try! macro #62672

Merged
merged 3 commits into from
Aug 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
@@ -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")]
Copy link
Member

@RalfJung RalfJung Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that this means that nightly will start warning in a week -- which is an entire cycle before the deprecation is announced on the release notes.

We usually deprecate 3 releases in the future, so that between the deprecation announcement on a stable release and nightly starting to warn, there is still a full cycle. (Well, "usually" as in, both times I was involved in a future deprecation this is what we did -- in one case after some pushback when we wanted to go faster.) Right now, that would mean deprecating with Rust 1.41.

Copy link
Contributor

@Centril Centril Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that matters much; try! has been deprecated for a long time in the docs and since ? was stabilized -- the change here is only due to a bugfix in the language.

#[doc(alias = "?")]
macro_rules! r#try {
($expr:expr) => (match $expr {
6 changes: 5 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
@@ -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]
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> {
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 { }

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
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() {}
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();
| ^^^^^^^^
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
@@ -15,6 +15,7 @@

#![cfg_attr(core, no_std)]

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

#[cfg(std)] use std::fmt;
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() {
1 change: 1 addition & 0 deletions src/test/ui/rust-2018/try-macro.fixed
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions src/test/ui/rust-2018/try-macro.rs
Original file line number Diff line number Diff line change
@@ -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);
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`