Fix clippy warnings
This commit is contained in:
parent
6069ee1239
commit
20c6c2d463
29
build.rs
29
build.rs
|
@ -19,8 +19,8 @@ use version_check::{Channel, Date, Version};
|
|||
/// Specifies the minimum nightly version needed to compile pyo3.
|
||||
/// Keep this synced up with the travis ci config,
|
||||
/// But note that this is the rustc version which can be lower than the nightly version
|
||||
const MIN_DATE: &'static str = "2019-07-18";
|
||||
const MIN_VERSION: &'static str = "1.37.0-nightly";
|
||||
const MIN_DATE: &str = "2019-07-18";
|
||||
const MIN_VERSION: &str = "1.37.0-nightly";
|
||||
//const PYTHON_INTERPRETER: &'static str = "python3";
|
||||
|
||||
lazy_static! {
|
||||
|
@ -85,7 +85,7 @@ impl fmt::Display for PythonVersion {
|
|||
|
||||
const PY3_MIN_MINOR: u8 = 5;
|
||||
|
||||
const CFG_KEY: &'static str = "py_sys_config";
|
||||
const CFG_KEY: &str = "py_sys_config";
|
||||
|
||||
/// A list of python interpreter compile-time preprocessor defines that
|
||||
/// we will pick up and pass to rustc via --cfg=py_sys_config={varname};
|
||||
|
@ -100,7 +100,7 @@ const CFG_KEY: &'static str = "py_sys_config";
|
|||
/// (hrm, this is sort of re-implementing what distutils does, except
|
||||
/// by passing command line args instead of referring to a python.h)
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
static SYSCONFIG_FLAGS: [&'static str; 7] = [
|
||||
static SYSCONFIG_FLAGS: [&str; 7] = [
|
||||
"Py_USING_UNICODE",
|
||||
"Py_UNICODE_WIDE",
|
||||
"WITH_THREAD",
|
||||
|
@ -110,7 +110,7 @@ static SYSCONFIG_FLAGS: [&'static str; 7] = [
|
|||
"COUNT_ALLOCS",
|
||||
];
|
||||
|
||||
static SYSCONFIG_VALUES: [&'static str; 1] = [
|
||||
static SYSCONFIG_VALUES: [&str; 1] = [
|
||||
// cfg doesn't support flags with values, just bools - so flags
|
||||
// below are translated into bools as {varname}_{val}
|
||||
//
|
||||
|
@ -188,7 +188,7 @@ fn load_cross_compile_info() -> Result<(InterpreterConfig, HashMap<String, Strin
|
|||
let shared = match config_map
|
||||
.get("Py_ENABLE_SHARED")
|
||||
.map(|x| x.as_str())
|
||||
.ok_or("Py_ENABLE_SHARED is not defined".to_string())?
|
||||
.ok_or_else(|| "Py_ENABLE_SHARED is not defined".to_string())?
|
||||
{
|
||||
"1" | "true" | "True" => true,
|
||||
"0" | "false" | "False" => false,
|
||||
|
@ -279,7 +279,7 @@ fn get_config_vars(_: &str) -> Result<HashMap<String, String>, String> {
|
|||
}
|
||||
|
||||
fn is_value(key: &str) -> bool {
|
||||
SYSCONFIG_VALUES.iter().find(|x| **x == key).is_some()
|
||||
SYSCONFIG_VALUES.iter().any(|x| *x == key)
|
||||
}
|
||||
|
||||
fn cfg_line_for_var(key: &str, val: &str) -> Option<String> {
|
||||
|
@ -321,7 +321,7 @@ fn run_python_script(interpreter: &str, script: &str) -> Result<String, String>
|
|||
};
|
||||
|
||||
if !out.status.success() {
|
||||
return Err(format!("python script failed"));
|
||||
return Err("python script failed".to_string());
|
||||
}
|
||||
|
||||
Ok(String::from_utf8(out.stdout).unwrap())
|
||||
|
@ -451,7 +451,7 @@ fn find_interpreter_and_get_config() -> Result<(InterpreterConfig, HashMap<Strin
|
|||
));
|
||||
}
|
||||
|
||||
Err(format!("No python interpreter found"))
|
||||
Err("No python interpreter found".to_string())
|
||||
}
|
||||
|
||||
/// Extract compilation vars from the specified interpreter.
|
||||
|
@ -513,7 +513,7 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<String, String> {
|
|||
|
||||
if interpreter_config.version.implementation == PythonInterpreterKind::PyPy {
|
||||
println!("cargo:rustc-cfg=PyPy");
|
||||
flags += format!("CFG_PyPy").as_ref();
|
||||
flags += "CFG_PyPy";
|
||||
};
|
||||
|
||||
if interpreter_config.version.major == 2 {
|
||||
|
@ -533,7 +533,7 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<String, String> {
|
|||
}
|
||||
println!("cargo:rustc-cfg=Py_3");
|
||||
|
||||
return Ok(flags);
|
||||
Ok(flags)
|
||||
}
|
||||
|
||||
fn check_rustc_version() {
|
||||
|
@ -603,9 +603,8 @@ fn main() -> Result<(), String> {
|
|||
}
|
||||
|
||||
for (key, val) in &config_map {
|
||||
match cfg_line_for_var(key, val) {
|
||||
Some(line) => println!("{}", line),
|
||||
None => (),
|
||||
if let Some(line) = cfg_line_for_var(key, val) {
|
||||
println!("{}", line)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -634,7 +633,7 @@ fn main() -> Result<(), String> {
|
|||
|
||||
println!(
|
||||
"cargo:python_flags={}",
|
||||
if flags.len() > 0 {
|
||||
if !flags.is_empty() {
|
||||
&flags[..flags.len() - 1]
|
||||
} else {
|
||||
""
|
||||
|
|
|
@ -23,7 +23,6 @@ use crate::ffi;
|
|||
use crate::types::PyAny;
|
||||
use crate::AsPyPointer;
|
||||
use crate::Python;
|
||||
use libc;
|
||||
use std::ffi::CStr;
|
||||
use std::os::raw;
|
||||
use std::pin::Pin;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![feature(specialization)]
|
||||
#![allow(clippy::missing_safety_doc)] // FIXME (#698)
|
||||
|
||||
//! Rust bindings to the Python interpreter.
|
||||
//!
|
||||
|
|
Loading…
Reference in New Issue