From 02b3ae63e2d3fd2fe7496eaa8b6862322aaf38b3 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Thu, 31 Aug 2017 00:12:34 +0300 Subject: enable desugaring-sensitive error messages and use them in Try Maybe I should allow error messages to check the *specific* desugaring? Thanks @huntiep for the idea! --- src/libcore/ops/try.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs index 78326c3e639..694d5b8296f 100644 --- a/src/libcore/ops/try.rs +++ b/src/libcore/ops/try.rs @@ -15,8 +15,16 @@ /// extracting those success or failure values from an existing instance and /// creating a new instance from a success or failure value. #[unstable(feature = "try_trait", issue = "42327")] -#[rustc_on_unimplemented = "the `?` operator can only be used in a function that returns `Result` \ - (or another type that implements `{Try}`)"] +#[cfg_attr(stage0, + rustc_on_unimplemented = "the `?` operator can only be used in a \ + function that returns `Result` \ + (or another type that implements `{Try}`)")] +#[cfg_attr(not(stage0), + rustc_on_unimplemented( + on(all(direct, from_desugaring), + message="the `?` operator can only be used in a \ + function that returns `Result` \ + (or another type that implements `{Try}`)")))] pub trait Try { /// The type of this value when viewed as successful. #[unstable(feature = "try_trait", issue = "42327")] -- cgit 1.4.1-3-g733a5