[librsvg: 1/9] Replace deprecated 'cfg_attr' for rustfmt



commit 242d7e5a4f1cc19909f698c5cedbc01a29dbd2d3
Author: Sven Neumann <sven svenfoo org>
Date:   Wed Jan 29 22:47:49 2020 +0100

    Replace deprecated 'cfg_attr' for rustfmt
    
    This can be replaced by the shorter and cleaner #[rustfmt::skip].
    
    In some places a straight-forward replacement wasn't possible and at
    least in one place I decided to let rustfmt win instead of trying to
    wrestle it down.

 librsvg/c_api.rs                           |  4 ++--
 librsvg/lib.rs                             |  3 ++-
 rsvg_internals/benches/lighting.rs         |  2 +-
 rsvg_internals/src/create_node.rs          |  4 ++--
 rsvg_internals/src/filters/color_matrix.rs |  6 +-----
 rsvg_internals/src/path_parser.rs          |  2 +-
 rsvg_internals/src/properties.rs           |  4 ++--
 rsvg_internals/src/xml2.rs                 | 29 +++++++++++++----------------
 rsvg_internals/src/xml2_load.rs            |  2 +-
 9 files changed, 25 insertions(+), 31 deletions(-)
---
diff --git a/librsvg/c_api.rs b/librsvg/c_api.rs
index fa4e60b1..98585ac2 100644
--- a/librsvg/c_api.rs
+++ b/librsvg/c_api.rs
@@ -44,7 +44,7 @@ mod handle_flags {
     use super::*;
 
     // Keep these in sync with rsvg.h:RsvgHandleFlags
-    #[cfg_attr(rustfmt, rustfmt_skip)]
+    #[rustfmt::skip]
     bitflags! {
         pub struct HandleFlags: u32 {
             const NONE            = 0;
@@ -420,7 +420,7 @@ impl ObjectImpl for CHandle {
         }
     }
 
-    #[cfg_attr(rustfmt, rustfmt_skip)]
+    #[rustfmt::skip]
     fn get_property(&self, _obj: &glib::Object, id: usize) -> Result<glib::Value, ()> {
         let prop = &PROPERTIES[id];
 
diff --git a/librsvg/lib.rs b/librsvg/lib.rs
index 60efd427..6a5b8c16 100644
--- a/librsvg/lib.rs
+++ b/librsvg/lib.rs
@@ -2,8 +2,8 @@
 #![allow(clippy::not_unsafe_ptr_arg_deref)]
 #![allow(clippy::too_many_arguments)]
 #![warn(unused)]
-#![cfg_attr(rustfmt, rustfmt_skip)]
 
+#[rustfmt::skip]
 pub use crate::c_api::{
     rsvg_rust_error_get_type,
     rsvg_rust_handle_close,
@@ -40,6 +40,7 @@ pub use crate::c_api::{
 
 pub use crate::color_utils::rsvg_css_parse_color;
 
+#[rustfmt::skip]
 pub use crate::pixbuf_utils::{
     rsvg_rust_pixbuf_from_file_at_max_size,
     rsvg_rust_pixbuf_from_file_at_size,
diff --git a/rsvg_internals/benches/lighting.rs b/rsvg_internals/benches/lighting.rs
index c8630386..c08fba83 100644
--- a/rsvg_internals/benches/lighting.rs
+++ b/rsvg_internals/benches/lighting.rs
@@ -24,7 +24,7 @@ fn normal(surface: &SharedImageSurface, bounds: IRect, x: u32, y: u32) -> Normal
 
     // Get the correct sobel kernel and factor for the pixel position.
     // Performance note: it's possible to replace the matrices with normal arrays.
-    #[cfg_attr(rustfmt, rustfmt_skip)]
+    #[rustfmt::skip]
     let (factor_x, kx, factor_y, ky) = match (x as i32, y as i32) {
         (x, y) if (x, y) == (bounds.x0, bounds.y0) => (
             2. / 3.,
diff --git a/rsvg_internals/src/create_node.rs b/rsvg_internals/src/create_node.rs
index e6d5df70..92e71734 100644
--- a/rsvg_internals/src/create_node.rs
+++ b/rsvg_internals/src/create_node.rs
@@ -57,7 +57,7 @@ macro_rules! n {
     };
 }
 
-#[cfg_attr(rustfmt, rustfmt_skip)]
+#[rustfmt::skip]
 mod creators {
     use super::*;
 
@@ -133,7 +133,7 @@ use creators::*;
 type NodeCreateFn = fn(element_name: &QualName, id: Option<&str>, class: Option<&str>) -> RsvgNode;
 
 // Lines in comments are elements that we don't support.
-#[cfg_attr(rustfmt, rustfmt_skip)]
+#[rustfmt::skip]
 static NODE_CREATORS: Lazy<HashMap<&'static str, (bool, NodeCreateFn)>> = Lazy::new(|| {
     let creators_table: Vec<(&str, bool, NodeCreateFn)> = vec![
         // name, supports_class, create_fn
diff --git a/rsvg_internals/src/filters/color_matrix.rs b/rsvg_internals/src/filters/color_matrix.rs
index 4db2d24c..d9232d57 100644
--- a/rsvg_internals/src/filters/color_matrix.rs
+++ b/rsvg_internals/src/filters/color_matrix.rs
@@ -48,6 +48,7 @@ impl Default for FeColorMatrix {
     }
 }
 
+#[rustfmt::skip]
 impl NodeTrait for FeColorMatrix {
     impl_node_as_filter_effect!();
 
@@ -67,7 +68,6 @@ impl NodeTrait for FeColorMatrix {
         // LuminanceToAlpha doesn't accept any matrix.
         if operation_type == OperationType::LuminanceToAlpha {
             self.matrix = {
-                #[cfg_attr(rustfmt, rustfmt_skip)]
                 Matrix5::new(
                     0.0,    0.0,    0.0,    0.0, 0.0,
                     0.0,    0.0,    0.0,    0.0, 0.0,
@@ -101,7 +101,6 @@ impl NodeTrait for FeColorMatrix {
                             }
                         })?;
 
-                        #[cfg_attr(rustfmt, rustfmt_skip)]
                         Matrix5::new(
                             0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0.0, 0.0,
                             0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s, 0.0, 0.0,
@@ -114,21 +113,18 @@ impl NodeTrait for FeColorMatrix {
                         let degrees: f64 = attr.parse(value)?;
                         let (sin, cos) = degrees.to_radians().sin_cos();
 
-                        #[cfg_attr(rustfmt, rustfmt_skip)]
                         let a = Matrix3::new(
                             0.213, 0.715, 0.072,
                             0.213, 0.715, 0.072,
                             0.213, 0.715, 0.072,
                         );
 
-                        #[cfg_attr(rustfmt, rustfmt_skip)]
                         let b = Matrix3::new(
                              0.787, -0.715, -0.072,
                             -0.213,  0.285, -0.072,
                             -0.213, -0.715,  0.928,
                         );
 
-                        #[cfg_attr(rustfmt, rustfmt_skip)]
                         let c = Matrix3::new(
                             -0.213, -0.715,  0.928,
                              0.143,  0.140, -0.283,
diff --git a/rsvg_internals/src/path_parser.rs b/rsvg_internals/src/path_parser.rs
index 061eb8d1..994e40e5 100644
--- a/rsvg_internals/src/path_parser.rs
+++ b/rsvg_internals/src/path_parser.rs
@@ -942,7 +942,7 @@ pub fn parse_path_into_builder(
 }
 
 #[cfg(test)]
-#[cfg_attr(rustfmt, rustfmt_skip)]
+#[rustfmt::skip]
 mod tests {
     use super::*;
 
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 89e6a48d..ba78c485 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -226,7 +226,7 @@ pub struct ComputedValues {
     pub xml_space: XmlSpace, // not a property, but a non-presentation attribute
 }
 
-#[cfg_attr(rustfmt, rustfmt_skip)]
+#[rustfmt::skip]
 pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, accept_shorthands: bool) -> 
Result<ParsedProperty, ParseError<'i>> {
     // please keep these sorted
     match prop_name.expanded() {
@@ -405,7 +405,7 @@ macro_rules! compute_value {
 }
 
 impl SpecifiedValues {
-    #[cfg_attr(rustfmt, rustfmt_skip)]
+    #[rustfmt::skip]
     pub fn set_parsed_property(&mut self, prop: &ParsedProperty) {
         use crate::properties::ParsedProperty::*;
 
diff --git a/rsvg_internals/src/xml2.rs b/rsvg_internals/src/xml2.rs
index fc8da338..cbcd2e40 100644
--- a/rsvg_internals/src/xml2.rs
+++ b/rsvg_internals/src/xml2.rs
@@ -1,7 +1,6 @@
 //! Hand-written binding to the very minimal part of libxml2 that we need.
 
 #![allow(non_snake_case, non_camel_case_types)]
-#![cfg_attr(rustfmt, rustfmt_skip)]
 
 use glib_sys::gpointer;
 use libc;
@@ -10,8 +9,8 @@ pub const XML_CHAR_ENCODING_NONE: libc::c_int = 0;
 
 pub const XML_INTERNAL_GENERAL_ENTITY: libc::c_int = 1;
 
-pub const XML_PARSE_NONET:     libc::c_int = 1 << 11;
-pub const XML_PARSE_HUGE:      libc::c_int = 1 << 19;
+pub const XML_PARSE_NONET: libc::c_int = 1 << 11;
+pub const XML_PARSE_HUGE: libc::c_int = 1 << 19;
 pub const XML_PARSE_BIG_LINES: libc::c_int = 1 << 22;
 
 pub const XML_SAX2_MAGIC: libc::c_uint = 0xDEEDBEAF;
@@ -22,7 +21,7 @@ pub type xmlEntityPtr = gpointer;
 
 pub type UnusedFn = Option<unsafe extern "C" fn()>;
 
-#[cfg_attr(rustfmt, rustfmt_skip)]
+#[rustfmt::skip]
 #[repr(C)]
 pub struct xmlSAXHandler {
     pub internalSubset:    UnusedFn,
@@ -165,15 +164,16 @@ pub struct xmlError {
 
 pub type xmlErrorPtr = *mut xmlError;
 
-pub type xmlInputReadCallback = Option<unsafe extern "C" fn(
-    context: *mut libc::c_void,
-    buffer: *mut libc::c_char,
-    len: libc::c_int,
-) -> libc::c_int>;
+pub type xmlInputReadCallback = Option<
+    unsafe extern "C" fn(
+        context: *mut libc::c_void,
+        buffer: *mut libc::c_char,
+        len: libc::c_int,
+    ) -> libc::c_int,
+>;
 
-pub type xmlInputCloseCallback = Option<unsafe extern "C" fn(
-    context: *mut libc::c_void,
-) -> libc::c_int>;
+pub type xmlInputCloseCallback =
+    Option<unsafe extern "C" fn(context: *mut libc::c_void) -> libc::c_int>;
 
 pub type xmlCharEncoding = libc::c_int;
 
@@ -199,10 +199,7 @@ extern "C" {
 
     pub fn xmlCtxtGetLastError(ctxt: *mut libc::c_void) -> xmlErrorPtr;
 
-    pub fn xmlCtxtUseOptions(
-        ctxt: xmlParserCtxtPtr,
-        options: libc::c_int,
-    ) -> libc::c_int;
+    pub fn xmlCtxtUseOptions(ctxt: xmlParserCtxtPtr, options: libc::c_int) -> libc::c_int;
 
     pub fn xmlNewEntity(
         doc: xmlDocPtr,
diff --git a/rsvg_internals/src/xml2_load.rs b/rsvg_internals/src/xml2_load.rs
index 97dda12c..6683954a 100644
--- a/rsvg_internals/src/xml2_load.rs
+++ b/rsvg_internals/src/xml2_load.rs
@@ -22,7 +22,7 @@ use crate::util::{cstr, opt_utf8_cstr, utf8_cstr};
 use crate::xml::XmlState;
 use crate::xml2::*;
 
-#[cfg_attr(rustfmt, rustfmt_skip)]
+#[rustfmt::skip]
 fn get_xml2_sax_handler() -> xmlSAXHandler {
     xmlSAXHandler {
         // first the unused callbacks


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]