parent
4576544fd0
commit
1e6c0758d6
@ -0,0 +1 @@
|
||||
/err-derive-0.2.1.crate
|
@ -0,0 +1,241 @@
|
||||
diff -up err-derive-0.2.1/build.rs.orig err-derive-0.2.1/build.rs
|
||||
--- err-derive-0.2.1/build.rs.orig 2019-10-09 12:21:01.000000000 +0200
|
||||
+++ err-derive-0.2.1/build.rs 2019-12-06 22:41:25.114969835 +0100
|
||||
@@ -1,22 +1,7 @@
|
||||
-use rustc_version::version;
|
||||
-
|
||||
-fn version_ge(minor_min: u64) -> bool {
|
||||
- let version = version().unwrap();
|
||||
-
|
||||
- version.major == 1 && version.minor >= minor_min
|
||||
-}
|
||||
+#[rustversion::before(1.32)]
|
||||
+compile_error!("`err-derive` depends on `skeptic`, which requires rustc >= 1.32");
|
||||
|
||||
fn main() {
|
||||
- if !version_ge(32) {
|
||||
- panic!("`err-derive` depends on `quote 1.0`, which requires rustc >= 1.32");
|
||||
- }
|
||||
- generate_doc_tests()
|
||||
-}
|
||||
-
|
||||
-#[cfg(feature = "skeptic")]
|
||||
-fn generate_doc_tests() {
|
||||
+ #[cfg(feature = "skeptic")]
|
||||
skeptic::generate_doc_tests(&["README.md"]);
|
||||
}
|
||||
-
|
||||
-#[cfg(not(feature = "skeptic"))]
|
||||
-fn generate_doc_tests() { }
|
||||
diff -up err-derive-0.2.1/Cargo.toml.orig err-derive-0.2.1/Cargo.toml
|
||||
--- err-derive-0.2.1/Cargo.toml.orig 2019-12-06 22:41:25.113969837 +0100
|
||||
+++ err-derive-0.2.1/Cargo.toml 2019-12-06 22:42:14.978892161 +0100
|
||||
@@ -40,8 +40,8 @@ version = "1.0.5"
|
||||
version = "0.12.0"
|
||||
[dev-dependencies.skeptic]
|
||||
version = "0.13"
|
||||
-[build-dependencies.rustc_version]
|
||||
-version = "0.2.3"
|
||||
+[build-dependencies.rustversion]
|
||||
+version = "1.0"
|
||||
|
||||
[build-dependencies.skeptic]
|
||||
version = "0.13"
|
||||
diff -up err-derive-0.2.1/src/lib.rs.orig err-derive-0.2.1/src/lib.rs
|
||||
--- err-derive-0.2.1/src/lib.rs.orig 2019-10-09 13:08:03.000000000 +0200
|
||||
+++ err-derive-0.2.1/src/lib.rs 2019-12-06 22:41:25.115969834 +0100
|
||||
@@ -132,21 +132,13 @@ use syn::spanned::Spanned;
|
||||
|
||||
extern crate proc_macro_error;
|
||||
|
||||
-use proc_macro_error::{filter_macro_errors, span_error};
|
||||
+use proc_macro_error::{abort, proc_macro_error};
|
||||
use syn::Attribute;
|
||||
|
||||
decl_derive!([Error, attributes(error, source, cause)] => error_derive);
|
||||
|
||||
+#[proc_macro_error(allow_not_macro, assert_unwind_safe)]
|
||||
fn error_derive(s: synstructure::Structure) -> TokenStream {
|
||||
- // proc_macro_error requires all `quote!` call to be inside the `filter_macro_errors!` macro,
|
||||
- // by using an inner method we satisfy this requirement while still getting proper syntax
|
||||
- // highlighting
|
||||
- filter_macro_errors! {
|
||||
- error_derive_inner(s).into()
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-fn error_derive_inner(s: synstructure::Structure) -> TokenStream2 {
|
||||
let source_body = s.each_variant(|v| {
|
||||
if let Some(source) = v.bindings().iter().find(|binding| {
|
||||
has_attr(&binding.ast().attrs, "source") || has_attr(&binding.ast().attrs, "cause")
|
||||
@@ -205,11 +197,7 @@ fn error_derive_inner(s: synstructure::S
|
||||
|
||||
let from = from_body(&s);
|
||||
|
||||
- quote! {
|
||||
- #error
|
||||
- #display
|
||||
- #from
|
||||
- }
|
||||
+ quote!(#error #display #from).into()
|
||||
}
|
||||
|
||||
fn display_body(s: &synstructure::Structure) -> quote::__rt::TokenStream {
|
||||
@@ -217,10 +205,10 @@ fn display_body(s: &synstructure::Struct
|
||||
let span = v.ast().ident.span();
|
||||
let msg = match find_error_msg(&v.ast().attrs) {
|
||||
Some(msg) => msg,
|
||||
- None => span_error!(span, "Variant is missing display attribute."),
|
||||
+ None => abort!(span, "Variant is missing display attribute."),
|
||||
};
|
||||
if msg.nested.is_empty() {
|
||||
- span_error!(span, "Expected at least one argument to error attribute");
|
||||
+ abort!(span, "Expected at least one argument to error attribute");
|
||||
}
|
||||
|
||||
let format_string = match msg.nested[0] {
|
||||
@@ -232,7 +220,7 @@ fn display_body(s: &synstructure::Struct
|
||||
{
|
||||
nv.lit.clone()
|
||||
}
|
||||
- _ => span_error!(
|
||||
+ _ => abort!(
|
||||
msg.nested.span(),
|
||||
"Error attribute must begin `display = \"\"` to control the Display message."
|
||||
),
|
||||
@@ -241,14 +229,14 @@ fn display_body(s: &synstructure::Struct
|
||||
syn::NestedMeta::Lit(syn::Lit::Int(ref i)) => {
|
||||
let bi = &v.bindings()[i
|
||||
.base10_parse::<usize>()
|
||||
- .unwrap_or_else(|_| span_error!(i.span(), "integer literal overflows usize"))];
|
||||
+ .unwrap_or_else(|_| abort!(i.span(), "integer literal overflows usize"))];
|
||||
quote!(#bi)
|
||||
}
|
||||
syn::NestedMeta::Meta(syn::Meta::Path(ref path)) => {
|
||||
let id = match path.get_ident() {
|
||||
Some(id) => id,
|
||||
// Allows std::u8::MAX (for example)
|
||||
- None => return quote!(#arg)
|
||||
+ None => return quote!(#arg),
|
||||
};
|
||||
let id_s = id.to_string();
|
||||
if id_s.starts_with('_') {
|
||||
@@ -256,7 +244,7 @@ fn display_body(s: &synstructure::Struct
|
||||
let bi = match v.bindings().get(idx) {
|
||||
Some(bi) => bi,
|
||||
None => {
|
||||
- span_error!(
|
||||
+ abort!(
|
||||
id.span(),
|
||||
"display attempted to access field `{}` in `{}::{}` which \
|
||||
does not exist (there {} {} field{})",
|
||||
@@ -279,10 +267,10 @@ fn display_body(s: &synstructure::Struct
|
||||
}
|
||||
// Arg is not a field - might be in global scope
|
||||
return quote!(#id);
|
||||
- },
|
||||
+ }
|
||||
// Allows u8::max_value() (for example)
|
||||
syn::NestedMeta::Meta(syn::Meta::List(ref list)) => return quote!(#list),
|
||||
- _ => span_error!(msg.nested.span(), "Invalid argument to error attribute!"),
|
||||
+ _ => abort!(msg.nested.span(), "Invalid argument to error attribute!"),
|
||||
});
|
||||
|
||||
quote! {
|
||||
@@ -302,11 +290,11 @@ fn find_error_msg(attrs: &[syn::Attribut
|
||||
{
|
||||
let span = attr.span();
|
||||
if error_msg.is_some() {
|
||||
- span_error!(span, "Cannot have two display attributes")
|
||||
+ abort!(span, "Cannot have two display attributes")
|
||||
} else if let syn::Meta::List(list) = meta {
|
||||
error_msg = Some(list);
|
||||
} else {
|
||||
- span_error!(span, "error attribute must take a list in parentheses")
|
||||
+ abort!(span, "error attribute must take a list in parentheses")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,7 +312,7 @@ fn has_attr(attributes: &[Attribute], at
|
||||
.map_or(false, |ident| ident == attr_name)
|
||||
{
|
||||
if found_attr {
|
||||
- span_error!(attr.span(), "Cannot have two `{}` attributes", attr_name);
|
||||
+ abort!(attr.span(), "Cannot have two `{}` attributes", attr_name);
|
||||
}
|
||||
found_attr = true;
|
||||
}
|
||||
@@ -341,7 +329,7 @@ fn has_attr(attributes: &[Attribute], at
|
||||
ident.to_string().split(", ").any(|part| part == attr_name)
|
||||
}) {
|
||||
if found_attr {
|
||||
- span_error!(
|
||||
+ abort!(
|
||||
path.span(),
|
||||
"Cannot have two `{}` attributes",
|
||||
attr_name
|
||||
@@ -371,7 +359,7 @@ fn from_body(s: &synstructure::Structure
|
||||
let exclude = has_attr(&binding.ast().attrs, "no_from");
|
||||
|
||||
if is_source && is_cause {
|
||||
- span_error!(
|
||||
+ abort!(
|
||||
span,
|
||||
"#[error(cause)] is deprecated, use #[error(source)] instead"
|
||||
)
|
||||
@@ -387,7 +375,7 @@ fn from_body(s: &synstructure::Structure
|
||||
}) {
|
||||
if v.bindings().len() > 1 {
|
||||
if is_explicit {
|
||||
- span_error!(
|
||||
+ abort!(
|
||||
span,
|
||||
"Variants containing `from` can only contain a single field"
|
||||
);
|
||||
@@ -402,15 +390,18 @@ fn from_body(s: &synstructure::Structure
|
||||
.iter()
|
||||
.any(|existing_from_type| *existing_from_type == from_ident)
|
||||
{
|
||||
- span_error!(
|
||||
- from_ident.span(),
|
||||
- "`from` can only be applied for a type once{}",
|
||||
- if is_explicit {
|
||||
- ""
|
||||
- } else {
|
||||
- ", hint: use #[error(no_from)] to disable automatic From derive"
|
||||
- }
|
||||
- );
|
||||
+ if is_explicit {
|
||||
+ abort!(
|
||||
+ from_ident.span(),
|
||||
+ "`from` can only be applied for a type once"
|
||||
+ );
|
||||
+ } else {
|
||||
+ abort!(
|
||||
+ from_ident.span(),
|
||||
+ "`from` can only be applied for a type once";
|
||||
+ hint = "use #[error(no_from)] to disable automatic From derive"
|
||||
+ );
|
||||
+ }
|
||||
}
|
||||
|
||||
from_types.push(from_ident);
|
||||
diff -up err-derive-0.2.1/tests/tests.rs.orig err-derive-0.2.1/tests/tests.rs
|
||||
--- err-derive-0.2.1/tests/tests.rs.orig 2019-10-08 21:38:59.000000000 +0200
|
||||
+++ err-derive-0.2.1/tests/tests.rs 2019-12-06 22:41:25.115969834 +0100
|
||||
@@ -125,7 +125,7 @@ pub enum TestsNonFieldDisplayValues {
|
||||
#[error(display = "{}", u8::max_value())]
|
||||
D,
|
||||
#[error(display = "{}", std::u8::MAX)]
|
||||
- E
|
||||
+ E,
|
||||
}
|
||||
|
||||
impl TestsNonFieldDisplayValues {
|
||||
@@ -156,4 +156,4 @@ fn non_field_display() {
|
||||
|
||||
let s = format!("{}", TestsNonFieldDisplayValues::E);
|
||||
assert_eq!(&s, "255");
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+}
|
@ -0,0 +1,11 @@
|
||||
--- err-derive-0.2.1/Cargo.toml 1970-01-01T00:00:00+00:00
|
||||
+++ err-derive-0.2.1/Cargo.toml 2019-12-06T21:22:49.380718+00:00
|
||||
@@ -25,7 +25,7 @@
|
||||
[lib]
|
||||
proc-macro = true
|
||||
[dependencies.proc-macro-error]
|
||||
-version = "0.2.6"
|
||||
+version = "0.4"
|
||||
|
||||
[dependencies.proc-macro2]
|
||||
version = "1.0.1"
|
@ -0,0 +1,104 @@
|
||||
# Generated by rust2rpm 12
|
||||
%bcond_without check
|
||||
%global debug_package %{nil}
|
||||
|
||||
%global crate err-derive
|
||||
|
||||
Name: rust-%{crate}
|
||||
Version: 0.2.1
|
||||
Release: 1%{?dist}
|
||||
Summary: Derive macro for `std::error::Error`
|
||||
|
||||
# Upstream license specification: MIT/Apache-2.0
|
||||
License: MIT or ASL 2.0
|
||||
URL: https://crates.io/crates/err-derive
|
||||
Source: %{crates_source}
|
||||
# Initial patched metadata
|
||||
# - Bump proc-macro-error to 0.4
|
||||
Patch0: err-derive-fix-metadata.diff
|
||||
# https://gitlab.com/torkleyy/err-derive/commit/d78cdb827e42b64fc8a820633048ae733ad857de
|
||||
Patch1: 0001-Move-to-proc-macro-error-v0.3.4.patch
|
||||
|
||||
ExclusiveArch: %{rust_arches}
|
||||
%if %{__cargo_skip_build}
|
||||
BuildArch: noarch
|
||||
%endif
|
||||
|
||||
BuildRequires: rust-packaging
|
||||
|
||||
%global _description %{expand:
|
||||
Derive macro for `std::error::Error`.}
|
||||
|
||||
%description %{_description}
|
||||
|
||||
%package devel
|
||||
Summary: %{summary}
|
||||
BuildArch: noarch
|
||||
|
||||
%description devel %{_description}
|
||||
|
||||
This package contains library source intended for building other packages
|
||||
which use "%{crate}" crate.
|
||||
|
||||
%files devel
|
||||
%license LICENSE LICENSE-APACHE LICENSE-MIT
|
||||
%doc README.md
|
||||
%{cargo_registry}/%{crate}-%{version_no_tilde}/
|
||||
|
||||
%package -n %{name}+default-devel
|
||||
Summary: %{summary}
|
||||
BuildArch: noarch
|
||||
|
||||
%description -n %{name}+default-devel %{_description}
|
||||
|
||||
This package contains library source intended for building other packages
|
||||
which use "default" feature of "%{crate}" crate.
|
||||
|
||||
%files -n %{name}+default-devel
|
||||
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
|
||||
|
||||
%package -n %{name}+skeptic-devel
|
||||
Summary: %{summary}
|
||||
BuildArch: noarch
|
||||
|
||||
%description -n %{name}+skeptic-devel %{_description}
|
||||
|
||||
This package contains library source intended for building other packages
|
||||
which use "skeptic" feature of "%{crate}" crate.
|
||||
|
||||
%files -n %{name}+skeptic-devel
|
||||
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
|
||||
|
||||
%package -n %{name}+std-devel
|
||||
Summary: %{summary}
|
||||
BuildArch: noarch
|
||||
|
||||
%description -n %{name}+std-devel %{_description}
|
||||
|
||||
This package contains library source intended for building other packages
|
||||
which use "std" feature of "%{crate}" crate.
|
||||
|
||||
%files -n %{name}+std-devel
|
||||
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
|
||||
|
||||
%prep
|
||||
%autosetup -n %{crate}-%{version_no_tilde} -p1
|
||||
%cargo_prep
|
||||
|
||||
%generate_buildrequires
|
||||
%cargo_generate_buildrequires
|
||||
|
||||
%build
|
||||
%cargo_build
|
||||
|
||||
%install
|
||||
%cargo_install
|
||||
|
||||
%if %{with check}
|
||||
%check
|
||||
%cargo_test
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Dec 06 22:22:49 CET 2019 Robert-André Mauchin <zebob.m@gmail.com> - 0.2.1-1
|
||||
- Initial package
|
@ -0,0 +1 @@
|
||||
SHA512 (err-derive-0.2.1.crate) = d5aa26b8088272612b78057b89535cf9f032c22e25c86c65cdf872dd57c0f4ca5dbcaf7ea72319833d4487b634160e2d9ffa266cc09d4e00e67f82f68457affd
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
standard-inventory-qcow2:
|
||||
qemu:
|
||||
# `cargo test` usually eats more than 1G.
|
||||
m: 4G
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- role: standard-test-basic
|
||||
tags:
|
||||
- classic
|
||||
repositories:
|
||||
- repo: "https://src.fedoraproject.org/tests/rust.git"
|
||||
dest: rust
|
||||
tests:
|
||||
- rust/cargo-test
|
||||
environment:
|
||||
pkg: rust-err-derive
|
Loading…
Reference in new issue