Fix anyhow's glob imports (#391)

This commit is contained in:
Pedro Burgos 2022-02-03 20:37:00 +01:00 committed by GitHub
parent bf7f49848d
commit ee07598a03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 53 additions and 32 deletions

View file

@ -7,6 +7,7 @@ use crate::{
state::scope_graph::{ScopeGraph, ScopeGraphEvent, ScopeIndex}, state::scope_graph::{ScopeGraph, ScopeGraphEvent, ScopeIndex},
EwwPaths, *, EwwPaths, *,
}; };
use anyhow::anyhow;
use eww_shared_util::VarName; use eww_shared_util::VarName;
use itertools::Itertools; use itertools::Itertools;
use simplexpr::dynval::DynVal; use simplexpr::dynval::DynVal;

View file

@ -2,7 +2,7 @@
//! Currently, this only means handling application exit by providing a global //! Currently, this only means handling application exit by providing a global
//! `recv_exit()` function which can be awaited to receive an event in case of application termination. //! `recv_exit()` function which can be awaited to receive an event in case of application termination.
use anyhow::*; use anyhow::{Context, Result};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use tokio::sync::broadcast; use tokio::sync::broadcast;

View file

@ -5,7 +5,7 @@ use crate::{
opts::{self, ActionClientOnly}, opts::{self, ActionClientOnly},
EwwPaths, EwwPaths,
}; };
use anyhow::*; use anyhow::{Context, Result};
use std::{ use std::{
io::{Read, Write}, io::{Read, Write},
os::unix::net::UnixStream, os::unix::net::UnixStream,
@ -24,7 +24,6 @@ pub fn handle_client_only_action(paths: &EwwPaths, action: ActionClientOnly) ->
Ok(()) Ok(())
} }
/// Connect to the daemon and send the given request. /// Connect to the daemon and send the given request.
/// Returns the response from the daemon, or None if the daemon did not provide any useful response. An Ok(None) response does _not_ indicate failure. /// Returns the response from the daemon, or None if the daemon did not provide any useful response. An Ok(None) response does _not_ indicate failure.
pub fn do_server_call(stream: &mut UnixStream, action: &opts::ActionWithServer) -> Result<Option<DaemonResponse>> { pub fn do_server_call(stream: &mut UnixStream, action: &opts::ActionWithServer) -> Result<Option<DaemonResponse>> {

View file

@ -1,4 +1,4 @@
use anyhow::*; use anyhow::{bail, Context, Result};
use eww_shared_util::VarName; use eww_shared_util::VarName;
use std::{collections::HashMap, path::Path}; use std::{collections::HashMap, path::Path};
use yuck::config::{ use yuck::config::{

View file

@ -1,6 +1,6 @@
use std::process::Command; use std::process::Command;
use anyhow::*; use anyhow::{anyhow, bail, Context, Result};
use codespan_reporting::diagnostic::Severity; use codespan_reporting::diagnostic::Severity;
use eww_shared_util::{Span, VarName}; use eww_shared_util::{Span, VarName};
use simplexpr::dynval::DynVal; use simplexpr::dynval::DynVal;

View file

@ -1,5 +1,5 @@
use crate::util::IterAverage; use crate::util::IterAverage;
use anyhow::*; use anyhow::{Context, Result};
use itertools::Itertools; use itertools::Itertools;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::{fs::read_to_string, sync::Mutex}; use std::{fs::read_to_string, sync::Mutex};

View file

@ -0,0 +1 @@

View file

@ -1,4 +1,4 @@
use anyhow::*; use anyhow::{Context, Result};
use itertools::Itertools; use itertools::Itertools;
use crate::error_handling_ctx; use crate::error_handling_ctx;

View file

@ -13,7 +13,10 @@ mod platform {
mod platform { mod platform {
use gdk; use gdk;
use gtk::prelude::*; use gtk::prelude::*;
use yuck::config::{window_definition::{WindowStacking, WindowDefinition}, window_geometry::AnchorAlignment}; use yuck::config::{
window_definition::{WindowDefinition, WindowStacking},
window_geometry::AnchorAlignment,
};
pub fn initialize_window(window_def: &WindowDefinition, monitor: gdk::Rectangle) -> Option<gtk::Window> { pub fn initialize_window(window_def: &WindowDefinition, monitor: gdk::Rectangle) -> Option<gtk::Window> {
let window = gtk::Window::new(gtk::WindowType::Toplevel); let window = gtk::Window::new(gtk::WindowType::Toplevel);
@ -89,7 +92,7 @@ mod platform {
#[cfg(feature = "x11")] #[cfg(feature = "x11")]
mod platform { mod platform {
use anyhow::*; use anyhow::{Context, Result};
use gdkx11; use gdkx11;
use gtk::{self, prelude::*}; use gtk::{self, prelude::*};
use x11rb::protocol::xproto::ConnectionExt; use x11rb::protocol::xproto::ConnectionExt;

View file

@ -1,5 +1,5 @@
use crate::{app, opts}; use crate::{app, opts};
use anyhow::*; use anyhow::{Context, Result};
use std::time::Duration; use std::time::Duration;
use tokio::{ use tokio::{
io::{AsyncReadExt, AsyncWriteExt}, io::{AsyncReadExt, AsyncWriteExt},

View file

@ -13,7 +13,7 @@ extern crate gtk;
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
extern crate gtk_layer_shell as gtk_layer_shell; extern crate gtk_layer_shell as gtk_layer_shell;
use anyhow::*; use anyhow::{bail, Context, Result};
use daemon_response::{DaemonResponse, DaemonResponseReceiver}; use daemon_response::{DaemonResponse, DaemonResponseReceiver};
use opts::ActionWithServer; use opts::ActionWithServer;
use std::{ use std::{

View file

@ -1,4 +1,4 @@
use anyhow::*; use anyhow::{Context, Result};
use eww_shared_util::VarName; use eww_shared_util::VarName;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use simplexpr::dynval::DynVal; use simplexpr::dynval::DynVal;

View file

@ -4,7 +4,7 @@ use crate::{
app, app,
config::{create_script_var_failed_warn, script_var}, config::{create_script_var_failed_warn, script_var},
}; };
use anyhow::*; use anyhow::{anyhow, Result};
use app::DaemonCommand; use app::DaemonCommand;
use eww_shared_util::VarName; use eww_shared_util::VarName;

View file

@ -4,9 +4,16 @@ use crate::{
state::scope_graph::ScopeGraph, state::scope_graph::ScopeGraph,
util, EwwPaths, util, EwwPaths,
}; };
use anyhow::*; use anyhow::{Context, Result};
use std::{cell::RefCell, collections::{HashMap, HashSet}, os::unix::io::AsRawFd, path::Path, rc::Rc, sync::{atomic::Ordering, Arc}}; use std::{
cell::RefCell,
collections::{HashMap, HashSet},
os::unix::io::AsRawFd,
path::Path,
rc::Rc,
sync::{atomic::Ordering, Arc},
};
use tokio::sync::mpsc::*; use tokio::sync::mpsc::*;
pub fn initialize_server(paths: EwwPaths, action: Option<DaemonCommand>, should_daemonize: bool) -> Result<ForkResult> { pub fn initialize_server(paths: EwwPaths, action: Option<DaemonCommand>, should_daemonize: bool) -> Result<ForkResult> {

View file

@ -1,4 +1,4 @@
use anyhow::*; use anyhow::{bail, Result};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
/// A map that represents a structure of a 1-n relationship with edges that contain data. /// A map that represents a structure of a 1-n relationship with edges that contain data.
@ -83,7 +83,11 @@ impl<I: Copy + std::hash::Hash + std::cmp::Eq + std::fmt::Debug, T> OneToNElemen
); );
} }
} else { } else {
bail!("parent_to_child stored mapping from {:?} to {:?}, which was not found in child_to_parent", parent, child); bail!(
"parent_to_child stored mapping from {:?} to {:?}, which was not found in child_to_parent",
parent,
child
);
} }
} }
} }
@ -109,7 +113,6 @@ mod test {
assert_eq!(map.get_parent_of(4), None); assert_eq!(map.get_parent_of(4), None);
assert_eq!(map.get_parent_of(5), Some(4)); assert_eq!(map.get_parent_of(5), Some(4));
assert_eq!(map.get_children_of(4), HashSet::from_iter(vec![3, 5])); assert_eq!(map.get_children_of(4), HashSet::from_iter(vec![3, 5]));
assert_eq!(map.get_children_of(3), HashSet::from_iter(vec![2])); assert_eq!(map.get_children_of(3), HashSet::from_iter(vec![2]));
assert_eq!(map.get_children_of(2), HashSet::from_iter(vec![1])); assert_eq!(map.get_children_of(2), HashSet::from_iter(vec![1]));
@ -135,6 +138,5 @@ mod test {
assert_eq!(map.get_children_of(3), HashSet::from_iter(vec![2])); assert_eq!(map.get_children_of(3), HashSet::from_iter(vec![2]));
assert_eq!(map.get_children_of(2), HashSet::from_iter(vec![1])); assert_eq!(map.get_children_of(2), HashSet::from_iter(vec![1]));
assert_eq!(map.get_children_of(1), HashSet::new()); assert_eq!(map.get_children_of(1), HashSet::new());
} }
} }

View file

@ -3,7 +3,7 @@ use std::{
rc::Rc, rc::Rc,
}; };
use anyhow::*; use anyhow::{anyhow, bail, Context, Result};
use eww_shared_util::{AttrName, VarName}; use eww_shared_util::{AttrName, VarName};
use simplexpr::{dynval::DynVal, SimplExpr}; use simplexpr::{dynval::DynVal, SimplExpr};
use tokio::sync::mpsc::UnboundedSender; use tokio::sync::mpsc::UnboundedSender;

View file

@ -1,8 +1,7 @@
use anyhow::*; use anyhow::{anyhow, Context, Result};
use std::fmt::Write;
use extend::ext; use extend::ext;
use itertools::Itertools; use itertools::Itertools;
use std::path::Path; use std::{fmt::Write, path::Path};
#[macro_export] #[macro_export]
macro_rules! try_logging_errors { macro_rules! try_logging_errors {
@ -160,10 +159,13 @@ pub fn unindent(text: &str) -> String {
// take all the lines of our text and skip over the first empty ones // take all the lines of our text and skip over the first empty ones
let lines = text.lines().skip_while(|x| *x == ""); let lines = text.lines().skip_while(|x| *x == "");
// find the smallest indentation // find the smallest indentation
let min = lines.clone().fold(None, |min, line| { let min = lines
let min = min.unwrap_or(usize::MAX); .clone()
Some(min.min(line.chars().take(min).take_while(|&c| c == ' ').count())) .fold(None, |min, line| {
}).unwrap_or(0); let min = min.unwrap_or(usize::MAX);
Some(min.min(line.chars().take(min).take_while(|&c| c == ' ').count()))
})
.unwrap_or(0);
let mut result = String::new(); let mut result = String::new();
for i in lines { for i in lines {

View file

@ -1,4 +1,4 @@
use anyhow::*; use anyhow::{Context, Result};
use codespan_reporting::diagnostic::Severity; use codespan_reporting::diagnostic::Severity;
use eww_shared_util::AttrName; use eww_shared_util::AttrName;
use gdk::prelude::Cast; use gdk::prelude::Cast;

View file

@ -1,9 +1,13 @@
#![allow(clippy::option_map_unit_fn)] #![allow(clippy::option_map_unit_fn)]
use super::{build_widget::BuilderArgs, circular_progressbar::*, run_command}; use super::{build_widget::BuilderArgs, circular_progressbar::*, run_command};
use crate::{ use crate::{
def_widget, enum_parse, error::DiagError, error_handling_ctx, util::{list_difference, unindent}, widgets::build_widget::build_gtk_widget, def_widget, enum_parse,
error::DiagError,
error_handling_ctx,
util::{list_difference, unindent},
widgets::build_widget::build_gtk_widget,
}; };
use anyhow::*; use anyhow::{anyhow, Context, Result};
use codespan_reporting::diagnostic::Severity; use codespan_reporting::diagnostic::Severity;
use eww_shared_util::Spanned; use eww_shared_util::Spanned;
use gdk::NotifyType; use gdk::NotifyType;

View file

@ -135,7 +135,9 @@ impl SimplExpr {
} }
FunctionCall(_, _, args) => args.iter().flat_map(|a| a.var_refs_with_span()).collect(), FunctionCall(_, _, args) => args.iter().flat_map(|a| a.var_refs_with_span()).collect(),
JsonArray(_, values) => values.iter().flat_map(|v| v.var_refs_with_span()).collect(), JsonArray(_, values) => values.iter().flat_map(|v| v.var_refs_with_span()).collect(),
JsonObject(_, entries) => entries.iter().flat_map(|(k, v)| k.var_refs_with_span().into_iter().chain(v.var_refs_with_span())).collect(), JsonObject(_, entries) => {
entries.iter().flat_map(|(k, v)| k.var_refs_with_span().into_iter().chain(v.var_refs_with_span())).collect()
}
} }
} }

View file

@ -1,6 +1,6 @@
use std::str::FromStr; use std::str::FromStr;
use anyhow::*; use anyhow::{anyhow, Result};
use crate::{ use crate::{
enum_parse, enum_parse,