Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'failure' in favor of 'anyhow' #21

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ keywords = ["llvm"]
categories = ["development-tools::build-utils", "external-ffi-bindings"]
repository = "https://github.com/aya-rs/rustc-llvm-proxy"
readme = "README.md"
edition = "2018"
edition = "2021"

[dependencies]
libloading = "0.8.0"
anyhow = "1.0.72"
lazy_static = "1.0"
failure = "0.1"
libc = "0.2"
libloading = "0.8.0"
llvm-sys = { version = "160", features = [
"no-llvm-linking",
"disable-alltargets-init",
] }

[build-dependencies]
anyhow = "1.0.72"
cargo_metadata = "0.17.0"
failure = "0.1"
prettyplease = "0.2.10"
quote = "1.0.29"
syn = { version = "2.0.26", features = ["full"] }
17 changes: 6 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ extern crate cargo_metadata;
extern crate quote;
extern crate syn;

#[macro_use]
extern crate failure;

fn main() {
let out_dir = std::env::var_os("OUT_DIR").unwrap();

Expand All @@ -26,8 +23,8 @@ fn main() {
}

mod llvm {
use anyhow::{format_err, Context as _, Error};
use cargo_metadata::{MetadataCommand, Package, Target};
use failure::{Error, ResultExt as _};
use quote::{format_ident, quote};
use std::{
collections::{
Expand Down Expand Up @@ -101,14 +98,14 @@ mod llvm {
// The module is in another file (or directory).
let fs_path = if directory
.try_exists()
.with_context(|_: &io::Error| directory.display().to_string())?
.with_context(|| directory.display().to_string())?
{
directory.join("mod.rs")
} else {
directory.with_extension("rs")
};
self.generate_file(&fs_path, mod_path.as_slice())
.with_context(|_: &Error| fs_path.display().to_string())
.with_context(|| fs_path.display().to_string())
.map_err(Into::into)
}
Some((_, items)) => {
Expand All @@ -117,9 +114,7 @@ mod llvm {
match item {
syn::Item::Mod(m) => {
self.generate_mod(&directory, mod_path.as_slice(), m)
.with_context(|_: &Error| {
quote! { #(#mod_path)::* }.to_string()
})?;
.with_context(|| quote! { #(#mod_path)::* }.to_string())?;
}
syn::Item::Type(..) => {}
item => {
Expand All @@ -137,8 +132,8 @@ mod llvm {
fs_path: &Path,
mod_path: &[syn::Ident],
) -> Result<(), Error> {
let content = fs::read_to_string(fs_path)
.with_context(|_: &io::Error| fs_path.display().to_string())?;
let content =
fs::read_to_string(fs_path).with_context(|| fs_path.display().to_string())?;
let syn::File {
shebang: _,
attrs: _,
Expand Down
14 changes: 2 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,14 @@
//! extern crate aya_rustc_llvm_proxy;
//! ```

#[macro_use]
extern crate lazy_static;

#[macro_use]
extern crate failure;

extern crate libc;
extern crate libloading as lib;
extern crate llvm_sys;

use lib::Library;
use libloading::Library;

mod path;
use path::find_lib_path;

pub mod init;

lazy_static! {
lazy_static::lazy_static! {
static ref SHARED_LIB: Library = {
let lib_path = match find_lib_path() {
Ok(path) => path,
Expand Down
5 changes: 2 additions & 3 deletions src/path.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use anyhow::{bail, Result};
use std::env;
use std::fs::read_dir;
use std::path::{Path, PathBuf};
use std::process::Command;

use failure::Error;

pub fn find_lib_path() -> Result<PathBuf, Error> {
pub fn find_lib_path() -> Result<PathBuf> {
let directories = collect_possible_directories();

if directories.is_empty() {
Expand Down