提交 6842316f 编写于 作者: L Lzu Tao

Allow deprecated try macro in test crates

上级 90fa7901
// check-pass
#![allow(deprecated)]
pub type ParseResult<T> = Result<T, ()>;
pub enum Item<'a> {
......@@ -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));
......
// Test that the resolve failure does not lead to downstream type errors.
// See issue #31997.
#![allow(deprecated)]
trait TheTrait { }
......@@ -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(())
}
......
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
......
#![deny(unused_qualifications)]
#[allow(deprecated)]
mod foo {
pub fn bar() {}
......@@ -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
......
error: unnecessary qualification
--> $DIR/lint-qualification.rs:9:5
--> $DIR/lint-qualification.rs:10:5
|
LL | foo::bar();
| ^^^^^^^^
......
......@@ -15,6 +15,7 @@
#![cfg_attr(core, no_std)]
#![allow(deprecated)] // for deprecated `try!()` macro
#![feature(concat_idents)]
#[cfg(std)] use std::fmt;
......@@ -261,9 +262,7 @@ fn thread_local() {
#[test]
fn try() {
fn inner() -> Result<(), ()> {
#[allow(deprecated)]
try!(Ok(()));
#[allow(deprecated)]
try!(Ok(()),);
Ok(())
}
......
// run-pass
#[allow(deprecated)]
#![allow(deprecated)] // for deprecated `try!()` macro
use std::num::{ParseFloatError, ParseIntError};
fn main() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册