liana/contrib/guix/patches/gui/iced_default_enum.patch
Antoine Poinsot 3906a1b5bc
guix: reproducible builds of the GUI
The GUI is using an insane MSRV so i had to patch my way through in
order to be able to build some dependencies.
2022-12-13 14:50:56 +01:00

460 lines
10 KiB
Diff

commit f71bc71bf6724a1c5e2a3246dd8bd0a90fcf0e15
Author: Antoine Poinsot <darosior@protonmail.com>
Date: Thu Dec 1 15:38:32 2022 +0100
Do not use, or special-case them, unstable features as of 1.60.0
This is in order to make the GUI MSRV effectively 1.60.0.
Default derivation on enums is removed.
Usage of bool_to_option is removed.
Generic associated types is unfortunately special cased as enabled. This
forces use to set RUSTC_BOOTSTRAP=1 in the Guix container...
diff --git a/iced_glow/src/lib.rs b/iced_glow/src/lib.rs
index e3690a69..b5b9cc38 100644
--- a/iced_glow/src/lib.rs
+++ b/iced_glow/src/lib.rs
@@ -20,6 +20,7 @@
#![forbid(rust_2018_idioms)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
+#![feature(generic_associated_types)]
pub use glow;
diff --git a/iced_graphics/src/lib.rs b/iced_graphics/src/lib.rs
index d39dd90c..876b478f 100644
--- a/iced_graphics/src/lib.rs
+++ b/iced_graphics/src/lib.rs
@@ -21,6 +21,7 @@
#![forbid(rust_2018_idioms)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
+#![feature(generic_associated_types)]
mod antialiasing;
mod error;
mod primitive;
diff --git a/iced_native/src/program/state.rs b/iced_native/src/program/state.rs
index 8ae1cacb..25a3028b 100644
--- a/iced_native/src/program/state.rs
+++ b/iced_native/src/program/state.rs
@@ -120,7 +120,11 @@ where
.iter()
.zip(event_statuses)
.filter_map(|(event, status)| {
- matches!(status, event::Status::Ignored).then_some(event)
+ if matches!(status, event::Status::Ignored) {
+ Some(event)
+ } else {
+ None
+ }
})
.cloned()
.collect();
diff --git a/iced_style/src/theme.rs b/iced_style/src/theme.rs
index d7ebb827..224a04fc 100644
--- a/iced_style/src/theme.rs
+++ b/iced_style/src/theme.rs
@@ -25,10 +25,9 @@ use iced_core::{Background, Color, Vector};
use std::rc::Rc;
/// A built-in theme.
-#[derive(Debug, Clone, PartialEq, Default)]
+#[derive(Debug, Clone, PartialEq)]
pub enum Theme {
/// The built-in light variant.
- #[default]
Light,
/// The built-in dark variant.
Dark,
@@ -61,6 +60,12 @@ impl Theme {
}
}
+impl Default for Theme {
+ fn default() -> Self {
+ Self::Light
+ }
+}
+
/// A [`Theme`] with a customized [`Palette`].
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Custom {
@@ -79,15 +84,19 @@ impl Custom {
}
/// The style of an application.
-#[derive(Default)]
pub enum Application {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn application::StyleSheet<Style = Theme>>),
}
+impl Default for Application {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl application::StyleSheet for Theme {
type Style = Application;
@@ -119,10 +128,11 @@ impl From<fn(&Theme) -> application::Appearance> for Application {
}
/// The style of a button.
-#[derive(Default)]
+/*
+ * Button
+ */
pub enum Button {
/// The primary style.
- #[default]
Primary,
/// The secondary style.
Secondary,
@@ -138,6 +148,12 @@ pub enum Button {
Custom(Box<dyn button::StyleSheet<Style = Theme>>),
}
+impl Default for Button {
+ fn default() -> Self {
+ Self::Primary
+ }
+}
+
impl button::StyleSheet for Theme {
type Style = Button;
@@ -227,10 +243,11 @@ impl button::StyleSheet for Theme {
}
/// The style of a checkbox.
-#[derive(Default)]
+/*
+ * Checkbox
+ */
pub enum Checkbox {
/// The primary style.
- #[default]
Primary,
/// The secondary style.
Secondary,
@@ -242,6 +259,12 @@ pub enum Checkbox {
Custom(Box<dyn checkbox::StyleSheet<Style = Theme>>),
}
+impl Default for Checkbox {
+ fn default() -> Self {
+ Self::Primary
+ }
+}
+
impl checkbox::StyleSheet for Theme {
type Style = Checkbox;
@@ -339,10 +362,11 @@ fn checkbox_appearance(
}
/// The style of a container.
-#[derive(Default)]
+/*
+ * Container
+ */
pub enum Container {
/// No style.
- #[default]
Transparent,
/// A simple box.
Box,
@@ -350,6 +374,12 @@ pub enum Container {
Custom(Box<dyn container::StyleSheet<Style = Theme>>),
}
+impl Default for Container {
+ fn default() -> Self {
+ Self::Transparent
+ }
+}
+
impl From<fn(&Theme) -> container::Appearance> for Container {
fn from(f: fn(&Theme) -> container::Appearance) -> Self {
Self::Custom(Box::new(f))
@@ -387,15 +417,19 @@ impl container::StyleSheet for fn(&Theme) -> container::Appearance {
}
/// The style of a slider.
-#[derive(Default)]
pub enum Slider {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn slider::StyleSheet<Style = Theme>>),
}
+impl Default for Slider {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl slider::StyleSheet for Theme {
type Style = Slider;
@@ -468,15 +502,20 @@ impl slider::StyleSheet for Theme {
}
/// The style of a menu.
-#[derive(Clone, Default)]
+#[derive(Clone)]
pub enum Menu {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Rc<dyn menu::StyleSheet<Style = Theme>>),
}
+impl Default for Menu {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl menu::StyleSheet for Theme {
type Style = Menu;
@@ -510,10 +549,9 @@ impl From<PickList> for Menu {
}
/// The style of a pick list.
-#[derive(Clone, Default)]
+#[derive(Clone)]
pub enum PickList {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(
@@ -522,6 +560,12 @@ pub enum PickList {
),
}
+impl Default for PickList {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl pick_list::StyleSheet for Theme {
type Style = PickList;
@@ -565,15 +609,19 @@ impl pick_list::StyleSheet for Theme {
}
/// The style of a radio button.
-#[derive(Default)]
pub enum Radio {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn radio::StyleSheet<Style = Theme>>),
}
+impl Default for Radio {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl radio::StyleSheet for Theme {
type Style = Radio;
@@ -620,15 +668,19 @@ impl radio::StyleSheet for Theme {
}
/// The style of a toggler.
-#[derive(Default)]
pub enum Toggler {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn toggler::StyleSheet<Style = Theme>>),
}
+impl Default for Toggler {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl toggler::StyleSheet for Theme {
type Style = Toggler;
@@ -687,15 +739,19 @@ impl toggler::StyleSheet for Theme {
}
/// The style of a pane grid.
-#[derive(Default)]
pub enum PaneGrid {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn pane_grid::StyleSheet<Style = Theme>>),
}
+impl Default for PaneGrid {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl pane_grid::StyleSheet for Theme {
type Style = PaneGrid;
@@ -729,10 +785,11 @@ impl pane_grid::StyleSheet for Theme {
}
/// The style of a progress bar.
-#[derive(Default)]
+/*
+ * Progress Bar
+ */
pub enum ProgressBar {
/// The primary style.
- #[default]
Primary,
/// The success style.
Success,
@@ -742,6 +799,12 @@ pub enum ProgressBar {
Custom(Box<dyn progress_bar::StyleSheet<Style = Theme>>),
}
+impl Default for ProgressBar {
+ fn default() -> Self {
+ Self::Primary
+ }
+}
+
impl From<fn(&Theme) -> progress_bar::Appearance> for ProgressBar {
fn from(f: fn(&Theme) -> progress_bar::Appearance) -> Self {
Self::Custom(Box::new(f))
@@ -782,15 +845,22 @@ impl progress_bar::StyleSheet for fn(&Theme) -> progress_bar::Appearance {
}
/// The style of a rule.
-#[derive(Default)]
+/*
+ * Rule
+ */
pub enum Rule {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn rule::StyleSheet<Style = Theme>>),
}
+impl Default for Rule {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl From<fn(&Theme) -> rule::Appearance> for Rule {
fn from(f: fn(&Theme) -> rule::Appearance) -> Self {
Self::Custom(Box::new(f))
@@ -824,15 +894,19 @@ impl rule::StyleSheet for fn(&Theme) -> rule::Appearance {
}
/// The style of a scrollable.
-#[derive(Default)]
pub enum Scrollable {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn scrollable::StyleSheet<Style = Theme>>),
}
+impl Default for Scrollable {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl scrollable::StyleSheet for Theme {
type Style = Scrollable;
@@ -889,15 +963,23 @@ impl scrollable::StyleSheet for Theme {
}
/// The style of text.
-#[derive(Clone, Copy, Default)]
+/*
+ * Text
+ */
+#[derive(Clone, Copy)]
pub enum Text {
/// The default style.
- #[default]
Default,
/// Colored text.
Color(Color),
}
+impl Default for Text {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl From<Color> for Text {
fn from(color: Color) -> Self {
Text::Color(color)
@@ -916,15 +998,19 @@ impl text::StyleSheet for Theme {
}
/// The style of a text input.
-#[derive(Default)]
pub enum TextInput {
/// The default style.
- #[default]
Default,
/// A custom style.
Custom(Box<dyn text_input::StyleSheet<Style = Theme>>),
}
+impl Default for TextInput {
+ fn default() -> Self {
+ Self::Default
+ }
+}
+
impl text_input::StyleSheet for Theme {
type Style = TextInput;
diff --git a/iced_wgpu/src/lib.rs b/iced_wgpu/src/lib.rs
index dcb699e8..5b3cda57 100644
--- a/iced_wgpu/src/lib.rs
+++ b/iced_wgpu/src/lib.rs
@@ -37,6 +37,7 @@
#![forbid(rust_2018_idioms)]
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
+#![feature(generic_associated_types)]
pub mod settings;
pub mod triangle;