10000 Deprecate `try!` macro by tesuji · Pull Request #62672 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Deprecate try! macro #62672

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

Merged
merged 3 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Allow deprecated try macro in test crates
  • Loading branch information
tesuji committed Aug 9, 2019
commit 6842316f6ff4586465e6412edce5e6808cfcd396
4 changes: 3 additions & 1 deletion 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 All @@ -18,7 +20,7 @@ pub fn timezone_offset_zulu<F>(s: &str, colon: F) -> ParseResult<(&str, i32)>
pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()>
where I: Iterator<Item=Item<'a>> {
macro_rules! try_consume {
($e:expr) => ({ let (s_, v) = $e?; s = s_; v })
($e:expr) => ({ let (s_, v) = try!($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));
Expand Down
3 changes: 2 additions & 1 deletion 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 All @@ -10,7 +11,7 @@ fn closure<F, T>(x: F) -> Result<T, ()>
}

fn foo() -> Result<(), ()> {
closure(|| bar(core::ptr::null_mut()))?; //~ ERROR cannot find function `bar` in this scope
try!(closure(|| bar(core::ptr::null_mut()))); //~ ERROR cannot find function `bar` in this scope
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/derived-errors/issue-31997.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0425]: cannot find function `bar` in this scope
--> $DIR/issue-31997.rs:13:16
--> $DIR/issue-31997.rs:14:21
|
LL | closure(|| bar(core::ptr::null_mut()))?;
| ^^^ not found in this scope
LL | try!(closure(|| bar(core::ptr::null_mut())));
| ^^^ not found in this scope

error: aborting due to previous error

Expand Down
3 changes: 2 additions & 1 deletion 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 All @@ -9,7 +10,7 @@ fn main() {
foo::bar(); //~ ERROR: unnecessary qualification
bar();

let _ = || -> Result<(), ()> { Ok(())?; Ok(()) }; // issue #37345
let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345

macro_rules! m { () => {
$crate::foo::bar(); // issue #37357
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
3 changes: 1 addition & 2 deletions src/test/ui/macros/macro-comma-support-rpass.rs
8FD4
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 Expand Up @@ -261,9 +262,7 @@ fn thread_local() {
#[test]
fn try() {
fn inner() -> Result<(), ()> {
#[allow(deprecated)]
try!(Ok(()));
#[allow(deprecated)]
try!(Ok(()),);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/macros/try-macro.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// run-pass
#[allow(deprecated)]
#![allow(deprecated)] // for deprecated `try!()` macro
use std::num::{ParseFloatError, ParseIntError};

fn main() {
Expand Down
0