Bug 1516365 - Update the Rust target version for bindgen. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 25 Dec 2018 23:09:29 +0000
changeset 509026 af22225148f7
parent 509025 59cdd33a1ddf
child 509027 90370fd4bc2a
child 509038 4c79ecbb8b53
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1516365
milestone66.0a1
first release with
nightly linux32
af22225148f7 / 66.0a1 / 20181226093642 / files
nightly linux64
af22225148f7 / 66.0a1 / 20181226093642 / files
nightly mac
af22225148f7 / 66.0a1 / 20181226093642 / files
nightly win32
af22225148f7 / 66.0a1 / 20181226093642 / files
nightly win64
af22225148f7 / 66.0a1 / 20181226093642 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516365 - Update the Rust target version for bindgen. r=xidorn This brings us alignas support and also associated constants for bitfield enums. Differential Revision: https://phabricator.services.mozilla.com/D15334
servo/components/style/build_gecko.rs
servo/components/style/gecko/pseudo_element_definition.mako.rs
servo/components/style/gecko/restyle_damage.rs
servo/components/style/gecko/wrapper.rs
servo/components/style/gecko_bindings/sugar/origin_flags.rs
servo/components/style/invalidation/element/restyle_hints.rs
servo/components/style/properties/gecko.mako.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -134,17 +134,19 @@ mod bindings {
     }
 
     impl BuilderExt for Builder {
         fn get_initial_builder() -> Builder {
             use bindgen::RustTarget;
 
             // Disable rust unions, because we replace some types inside of
             // them.
-            let mut builder = Builder::default().rust_target(RustTarget::Stable_1_0);
+            let mut builder = Builder::default()
+                .rust_target(RustTarget::Stable_1_25)
+                .disable_untagged_union();
 
             let rustfmt_path = env::var_os("RUSTFMT")
                 // This can be replaced with
                 // > .filter(|p| !p.is_empty()).map(PathBuf::from)
                 // once we can use 1.27+.
                 .and_then(|p| {
                     if p.is_empty() {
                         None
--- a/servo/components/style/gecko/pseudo_element_definition.mako.rs
+++ b/servo/components/style/gecko/pseudo_element_definition.mako.rs
@@ -151,26 +151,24 @@ impl PseudoElement {
             % endfor
             _ => None,
         }
     }
 
     /// Construct a `CSSPseudoElementType` from a pseudo-element
     #[inline]
     fn pseudo_type(&self) -> CSSPseudoElementType {
-        use crate::gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;
-
         match *self {
             % for pseudo in PSEUDOS:
                 % if not pseudo.is_anon_box():
                     PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::${pseudo.pseudo_ident},
                 % elif pseudo.is_tree_pseudo_element():
                     PseudoElement::${pseudo.capitalized_pseudo()}(..) => CSSPseudoElementType::XULTree,
                 % elif pseudo.is_inheriting_anon_box():
-                    PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType_InheritingAnonBox,
+                    PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::InheritingAnonBox,
                 % else:
                     PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::NonInheritingAnonBox,
                 % endif
             % endfor
             PseudoElement::UnknownWebkit(..) => unreachable!(),
         }
     }
 
--- a/servo/components/style/gecko/restyle_damage.rs
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -78,17 +78,17 @@ impl GeckoRestyleDamage {
     /// Returns true if this restyle damage contains all the damage of |other|.
     pub fn contains(self, other: Self) -> bool {
         self & other == other
     }
 
     /// Gets restyle damage to reconstruct the entire frame, subsuming all
     /// other damage.
     pub fn reconstruct() -> Self {
-        GeckoRestyleDamage(structs::nsChangeHint_nsChangeHint_ReconstructFrame)
+        GeckoRestyleDamage(structs::nsChangeHint::nsChangeHint_ReconstructFrame)
     }
 }
 
 impl Default for GeckoRestyleDamage {
     fn default() -> Self {
         Self::empty()
     }
 }
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -1494,36 +1494,33 @@ impl<'le> TElement for GeckoElement<'le>
             });
         }
         self.as_node()
             .get_bool_flag(nsINode_BooleanFlag::ElementHasAnimations)
     }
 
     /// Process various tasks that are a result of animation-only restyle.
     fn process_post_animation(&self, tasks: PostAnimationTasks) {
-        use crate::gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty;
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree;
-
         debug_assert!(!tasks.is_empty(), "Should be involved a task");
 
         // If display style was changed from none to other, we need to resolve
         // the descendants in the display:none subtree. Instead of resolving
         // those styles in animation-only restyle, we defer it to a subsequent
         // normal restyle.
         if tasks.intersects(PostAnimationTasks::DISPLAY_CHANGED_FROM_NONE_FOR_SMIL) {
             debug_assert!(
                 self.implemented_pseudo_element()
                     .map_or(true, |p| !p.is_before_or_after()),
                 "display property animation shouldn't run on pseudo elements \
                  since it's only for SMIL"
             );
             unsafe {
                 self.note_explicit_hints(
-                    nsRestyleHint_eRestyle_Subtree,
-                    nsChangeHint_nsChangeHint_Empty,
+                    nsRestyleHint::eRestyle_Subtree,
+                    nsChangeHint::nsChangeHint_Empty,
                 );
             }
         }
     }
 
     /// Update various animation-related state on a given (pseudo-)element as
     /// results of normal restyle.
     fn update_animations(
--- a/servo/components/style/gecko_bindings/sugar/origin_flags.rs
+++ b/servo/components/style/gecko_bindings/sugar/origin_flags.rs
@@ -1,26 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 //! Helper to iterate over `OriginFlags` bits.
 
 use crate::gecko_bindings::structs::OriginFlags;
-use crate::gecko_bindings::structs::OriginFlags_Author;
-use crate::gecko_bindings::structs::OriginFlags_User;
-use crate::gecko_bindings::structs::OriginFlags_UserAgent;
 use crate::stylesheets::OriginSet;
 
 /// Checks that the values for OriginFlags are the ones we expect.
 pub fn assert_flags_match() {
     use crate::stylesheets::origin::*;
-    debug_assert_eq!(OriginFlags_UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits());
-    debug_assert_eq!(OriginFlags_Author.0, OriginSet::ORIGIN_AUTHOR.bits());
-    debug_assert_eq!(OriginFlags_User.0, OriginSet::ORIGIN_USER.bits());
+    debug_assert_eq!(OriginFlags::UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits());
+    debug_assert_eq!(OriginFlags::Author.0, OriginSet::ORIGIN_AUTHOR.bits());
+    debug_assert_eq!(OriginFlags::User.0, OriginSet::ORIGIN_USER.bits());
 }
 
 impl From<OriginFlags> for OriginSet {
     fn from(flags: OriginFlags) -> Self {
         Self::from_bits_truncate(flags.0)
     }
 }
 
--- a/servo/components/style/invalidation/element/restyle_hints.rs
+++ b/servo/components/style/invalidation/element/restyle_hints.rs
@@ -188,48 +188,41 @@ impl Default for RestyleHint {
     fn default() -> Self {
         Self::empty()
     }
 }
 
 #[cfg(feature = "gecko")]
 impl From<nsRestyleHint> for RestyleHint {
     fn from(mut raw: nsRestyleHint) -> Self {
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Force as eRestyle_Force;
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_ForceDescendants as eRestyle_ForceDescendants;
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_LaterSiblings as eRestyle_LaterSiblings;
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Self as eRestyle_Self;
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_SomeDescendants as eRestyle_SomeDescendants;
-        use crate::gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree as eRestyle_Subtree;
-
         let mut hint = RestyleHint::empty();
 
         debug_assert!(
-            raw.0 & eRestyle_LaterSiblings.0 == 0,
+            raw.0 & nsRestyleHint::eRestyle_LaterSiblings.0 == 0,
             "Handle later siblings manually if necessary plz."
         );
 
-        if (raw.0 & (eRestyle_Self.0 | eRestyle_Subtree.0)) != 0 {
-            raw.0 &= !eRestyle_Self.0;
+        if (raw.0 & (nsRestyleHint::eRestyle_Self.0 | nsRestyleHint::eRestyle_Subtree.0)) != 0 {
+            raw.0 &= !nsRestyleHint::eRestyle_Self.0;
             hint.insert(RestyleHint::RESTYLE_SELF);
         }
 
-        if (raw.0 & (eRestyle_Subtree.0 | eRestyle_SomeDescendants.0)) != 0 {
-            raw.0 &= !eRestyle_Subtree.0;
-            raw.0 &= !eRestyle_SomeDescendants.0;
+        if (raw.0 & (nsRestyleHint::eRestyle_Subtree.0 | nsRestyleHint::eRestyle_SomeDescendants.0)) != 0 {
+            raw.0 &= !nsRestyleHint::eRestyle_Subtree.0;
+            raw.0 &= !nsRestyleHint::eRestyle_SomeDescendants.0;
             hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
         }
 
-        if (raw.0 & (eRestyle_ForceDescendants.0 | eRestyle_Force.0)) != 0 {
-            raw.0 &= !eRestyle_Force.0;
+        if (raw.0 & (nsRestyleHint::eRestyle_ForceDescendants.0 | nsRestyleHint::eRestyle_Force.0)) != 0 {
+            raw.0 &= !nsRestyleHint::eRestyle_Force.0;
             hint.insert(RestyleHint::RECASCADE_SELF);
         }
 
-        if (raw.0 & eRestyle_ForceDescendants.0) != 0 {
-            raw.0 &= !eRestyle_ForceDescendants.0;
+        if (raw.0 & nsRestyleHint::eRestyle_ForceDescendants.0) != 0 {
+            raw.0 &= !nsRestyleHint::eRestyle_ForceDescendants.0;
             hint.insert(RestyleHint::RECASCADE_DESCENDANTS);
         }
 
         hint.insert(RestyleHint::from_bits_truncate(raw.0 as u8));
 
         hint
     }
 }
@@ -243,25 +236,25 @@ malloc_size_of_is_0!(RestyleHint);
 pub fn assert_restyle_hints_match() {
     use crate::gecko_bindings::structs;
 
     macro_rules! check_restyle_hints {
         ( $( $a:ident => $b:path),*, ) => {
             if cfg!(debug_assertions) {
                 let mut replacements = RestyleHint::replacements();
                 $(
-                    assert_eq!(structs::$a.0 as usize, $b.bits() as usize, stringify!($b));
+                    assert_eq!(structs::nsRestyleHint::$a.0 as usize, $b.bits() as usize, stringify!($b));
                     replacements.remove($b);
                 )*
                 assert_eq!(replacements, RestyleHint::empty(),
                            "all RestyleHint replacement bits should have an \
                             assertion");
             }
         }
     }
 
     check_restyle_hints! {
-        nsRestyleHint_eRestyle_CSSTransitions => RestyleHint::RESTYLE_CSS_TRANSITIONS,
-        nsRestyleHint_eRestyle_CSSAnimations => RestyleHint::RESTYLE_CSS_ANIMATIONS,
-        nsRestyleHint_eRestyle_StyleAttribute => RestyleHint::RESTYLE_STYLE_ATTRIBUTE,
-        nsRestyleHint_eRestyle_StyleAttribute_Animations => RestyleHint::RESTYLE_SMIL,
+        eRestyle_CSSTransitions => RestyleHint::RESTYLE_CSS_TRANSITIONS,
+        eRestyle_CSSAnimations => RestyleHint::RESTYLE_CSS_ANIMATIONS,
+        eRestyle_StyleAttribute => RestyleHint::RESTYLE_STYLE_ATTRIBUTE,
+        eRestyle_StyleAttribute_Animations => RestyleHint::RESTYLE_SMIL,
     }
 }
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -34,17 +34,16 @@ use crate::gecko_bindings::bindings::Gec
 use crate::gecko_bindings::bindings::Gecko_SetListStyleImageNone;
 use crate::gecko_bindings::bindings::Gecko_SetListStyleImageImageValue;
 use crate::gecko_bindings::bindings::Gecko_SetNullImageValue;
 use crate::gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
 use crate::gecko_bindings::bindings::RawGeckoPresContextBorrowed;
 use crate::gecko_bindings::structs;
 use crate::gecko_bindings::structs::nsCSSPropertyID;
 use crate::gecko_bindings::structs::mozilla::CSSPseudoElementType;
-use crate::gecko_bindings::structs::mozilla::CSSPseudoElementType_InheritingAnonBox;
 use crate::gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
 use crate::gecko_bindings::sugar::refptr::RefPtr;
 use crate::gecko::values::convert_nscolor_to_rgba;
 use crate::gecko::values::convert_rgba_to_nscolor;
 use crate::gecko::values::GeckoStyleCoordConvertible;
 use crate::gecko::values::round_border_to_device_pixels;
 use crate::logical_geometry::WritingMode;
 use crate::media_queries::Device;
@@ -133,17 +132,17 @@ impl ComputedValues {
     #[inline]
     fn get_pseudo_type(&self) -> CSSPseudoElementType {
         self.0.mPseudoType
     }
 
     #[inline]
     pub fn is_anon_box(&self) -> bool {
         let our_type = self.get_pseudo_type();
-        return our_type == CSSPseudoElementType_InheritingAnonBox ||
+        return our_type == CSSPseudoElementType::InheritingAnonBox ||
                our_type == CSSPseudoElementType::NonInheritingAnonBox;
     }
 
     /// Returns true if the display property is changed from 'none' to others.
     pub fn is_display_property_changed_from_none(
         &self,
         old_values: Option<<&ComputedValues>
     ) -> bool {
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -143,19 +143,16 @@ use style::gecko_bindings::structs::Call
 use style::gecko_bindings::structs::CompositeOperation;
 use style::gecko_bindings::structs::ComputedStyleStrong;
 use style::gecko_bindings::structs::DeclarationBlockMutationClosure;
 use style::gecko_bindings::structs::IterationCompositeOperation;
 use style::gecko_bindings::structs::Loader;
 use style::gecko_bindings::structs::LoaderReusableStyleSheets;
 use style::gecko_bindings::structs::MallocSizeOf as GeckoMallocSizeOf;
 use style::gecko_bindings::structs::OriginFlags;
-use style::gecko_bindings::structs::OriginFlags_Author;
-use style::gecko_bindings::structs::OriginFlags_User;
-use style::gecko_bindings::structs::OriginFlags_UserAgent;
 use style::gecko_bindings::structs::PropertyValuePair;
 use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
 use style::gecko_bindings::structs::RawServoFontFaceRule;
 use style::gecko_bindings::structs::RawServoSelectorList;
 use style::gecko_bindings::structs::RawServoSourceSizeList;
 use style::gecko_bindings::structs::RawServoStyleRule;
 use style::gecko_bindings::structs::SeenPtrs;
 use style::gecko_bindings::structs::ServoElementSnapshotTable;
@@ -1759,23 +1756,26 @@ pub extern "C" fn Servo_StyleSheet_SizeO
         None,
     );
     StylesheetContents::as_arc(&sheet).size_of(&guard, &mut ops)
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSheet_GetOrigin(sheet: RawServoStyleSheetContentsBorrowed) -> u8 {
     let origin = match StylesheetContents::as_arc(&sheet).origin {
-        Origin::UserAgent => OriginFlags_UserAgent,
-        Origin::User => OriginFlags_User,
-        Origin::Author => OriginFlags_Author,
+        Origin::UserAgent => OriginFlags::UserAgent,
+        Origin::User => OriginFlags::User,
+        Origin::Author => OriginFlags::Author,
     };
     // We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
     // work as return values with the Linux 32-bit ABI at the moment because
-    // they wrap the value in a struct, so for now just unwrap it.
+    // they wrap the value in a struct (and bindgen doesn't have support for
+    // repr(transparent), so for now just unwrap it.
+    //
+    // See https://github.com/rust-lang/rust-bindgen/issues/1474
     origin.0
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_StyleSheet_GetSourceMapURL(
     sheet: RawServoStyleSheetContentsBorrowed,
     result: *mut nsAString,
 ) {