From 7b8e6a848fdec5154a7a447621b655b6c60cfec4 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 27 Dec 2023 15:16:02 -0500 Subject: [PATCH] Revert "Allow yeeting context selectors to generate errors" This reverts commit d826e6a71e58da06299b968814dfe39bc29fc6a1. We found type inference regressions in the lead up to 0.8. This feature doesn't pull its weight yet and is easiest to revert for now. When `yeet` moves along, we can revisit. See #431 --- .cirrus.yml | 4 ---- compatibility-tests/yeet-selectors/Cargo.toml | 9 --------- .../yeet-selectors/rust-toolchain | 1 - compatibility-tests/yeet-selectors/src/lib.rs | 20 ------------------- snafu-derive/src/shared.rs | 10 ---------- tests/build-leaf-error.rs | 6 ------ 6 files changed, 50 deletions(-) delete mode 100644 compatibility-tests/yeet-selectors/Cargo.toml delete mode 100644 compatibility-tests/yeet-selectors/rust-toolchain delete mode 100644 compatibility-tests/yeet-selectors/src/lib.rs diff --git a/.cirrus.yml b/.cirrus.yml index d33f774d..b171fc8a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -159,10 +159,6 @@ nightly_test_task: - cd compatibility-tests/backtrace-provider-api/ - rustc --version - cargo test - yeet_selectors_test_script: - - cd compatibility-tests/yeet-selectors/ - - rustc --version - - cargo test before_cache_script: rm -rf $CARGO_HOME/registry/index # Our Minimal Supported Rust Version (MSRV) diff --git a/compatibility-tests/yeet-selectors/Cargo.toml b/compatibility-tests/yeet-selectors/Cargo.toml deleted file mode 100644 index b62f11b3..00000000 --- a/compatibility-tests/yeet-selectors/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "yeet-selectors" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -snafu = { path = "../.." } diff --git a/compatibility-tests/yeet-selectors/rust-toolchain b/compatibility-tests/yeet-selectors/rust-toolchain deleted file mode 100644 index bf867e0a..00000000 --- a/compatibility-tests/yeet-selectors/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly diff --git a/compatibility-tests/yeet-selectors/src/lib.rs b/compatibility-tests/yeet-selectors/src/lib.rs deleted file mode 100644 index 951455c3..00000000 --- a/compatibility-tests/yeet-selectors/src/lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(yeet_expr)] -#![cfg(test)] - -use snafu::prelude::*; - -#[test] -fn can_yeet_context_selector() { - #[derive(Debug, Snafu)] - struct MyError { - name: String, - } - - fn usage() -> Result<(), MyError> { - let name = "gronk"; - do yeet MySnafu { name }; - } - - let r = usage(); - assert!(r.is_err(), "{r:?} should have been an error"); -} diff --git a/snafu-derive/src/shared.rs b/snafu-derive/src/shared.rs index 5b72a80c..6e6da13d 100644 --- a/snafu-derive/src/shared.rs +++ b/snafu-derive/src/shared.rs @@ -294,16 +294,6 @@ pub mod context_selector { ::core::result::Result::Err(self.build()) } } - - impl<#(#original_generics_without_defaults,)* #(#user_field_generics,)*> ::core::convert::From<#parameterized_selector_name> for #parameterized_error_name - where - #(#extended_where_clauses),* - { - #[track_caller] - fn from(other: #parameterized_selector_name) -> Self { - other.build() - } - } } } diff --git a/tests/build-leaf-error.rs b/tests/build-leaf-error.rs index 34cce790..a7460863 100644 --- a/tests/build-leaf-error.rs +++ b/tests/build-leaf-error.rs @@ -22,9 +22,3 @@ fn implements_error() { map_result().unwrap_err(); } - -#[test] -fn build_via_from_and_into() { - let _e = Error::from(MineSnafu); - let _e: Error = MineSnafu.into(); -}