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

Nightly clippies #1184

Merged
merged 3 commits into from
Nov 3, 2022
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
2 changes: 1 addition & 1 deletion demo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

fn main() -> miette::Result<()> {
let path = std::path::PathBuf::from("src");
let mut b = autocxx_build::Builder::new("src/main.rs", &[&path]).build()?;
let mut b = autocxx_build::Builder::new("src/main.rs", [&path]).build()?;
b.flag_if_supported("-std=c++14").compile("autocxx-demo");

println!("cargo:rerun-if-changed=src/main.rs");
Expand Down
2 changes: 1 addition & 1 deletion engine/src/conversion/analysis/fun/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ impl<'a> FnAnalyzer<'a> {
let cpp_wrapper = if wrapper_function_needed {
// Generate a new layer of C++ code to wrap/unwrap parameters
// and return values into/out of std::unique_ptrs.
let cpp_construction_ident = make_ident(&effective_cpp_name);
let cpp_construction_ident = make_ident(effective_cpp_name);
let joiner = if cxxbridge_name.to_string().ends_with('_') {
""
} else {
Expand Down
4 changes: 2 additions & 2 deletions engine/src/conversion/codegen_rs/fun_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'a> FnGenerator<'a> {
let mut ptr_arg_name = None;
let mut ret_type: Cow<'a, _> = ret_type
.map(Cow::Owned)
.unwrap_or(Cow::Borrowed(self.ret_type));
.unwrap_or_else(|| Cow::Borrowed(self.ret_type));
let mut any_conversion_requires_unsafe = false;
let mut variable_counter = 0usize;
for pd in self.param_details {
Expand Down Expand Up @@ -444,7 +444,7 @@ impl<'a> FnGenerator<'a> {
let ret_type: ReturnType = parse_quote! { -> impl autocxx::moveit::new::New<Output=Self> };
let (lifetime_tokens, wrapper_params, ret_type, call_body) =
self.common_parts(true, &None, Some(ret_type));
let rust_name = make_ident(&self.rust_name);
let rust_name = make_ident(self.rust_name);
let doc_attrs = self.doc_attrs;
let unsafety = self.unsafety.wrapper_token();
let ty = impl_block_type_name.get_final_ident();
Expand Down
22 changes: 14 additions & 8 deletions engine/src/conversion/convert_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ struct PhantomSanitized;
/// This is used to generate suitable rustdoc in the output codegen so that
/// the errors can be revealed in rust-analyzer-based IDEs, etc.
#[derive(Clone)]
pub(crate) struct ErrorContext(ErrorContextType, PhantomSanitized);
pub(crate) struct ErrorContext(Box<ErrorContextType>, PhantomSanitized);

/// All idents in this structure are guaranteed to be something we can safely codegen for.
#[derive(Clone)]
Expand All @@ -205,8 +205,11 @@ pub(crate) enum ErrorContextType {
impl ErrorContext {
pub(crate) fn new_for_item(id: Ident) -> Self {
match Self::sanitize_error_ident(&id) {
None => Self(ErrorContextType::Item(id), PhantomSanitized),
Some(sanitized) => Self(ErrorContextType::SanitizedItem(sanitized), PhantomSanitized),
None => Self(Box::new(ErrorContextType::Item(id)), PhantomSanitized),
Some(sanitized) => Self(
Box::new(ErrorContextType::SanitizedItem(sanitized)),
PhantomSanitized,
),
}
}

Expand All @@ -216,14 +219,17 @@ impl ErrorContext {
// an impl block.
match Self::sanitize_error_ident(&self_ty) {
None => Self(
ErrorContextType::Method {
Box::new(ErrorContextType::Method {
self_ty,
method: Self::sanitize_error_ident(&method).unwrap_or(method),
},
}),
PhantomSanitized,
),
Some(_) => Self(
ErrorContextType::SanitizedItem(make_ident(format!("{}_{}", self_ty, method))),
Box::new(ErrorContextType::SanitizedItem(make_ident(format!(
"{}_{}",
self_ty, method
)))),
PhantomSanitized,
),
}
Expand All @@ -245,13 +251,13 @@ impl ErrorContext {
}

pub(crate) fn into_type(self) -> ErrorContextType {
self.0
*self.0
}
}

impl std::fmt::Display for ErrorContext {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.0 {
match &*self.0 {
ErrorContextType::Item(id) | ErrorContextType::SanitizedItem(id) => write!(f, "{}", id),
ErrorContextType::Method { self_ty, method } => write!(f, "{}::{}", self_ty, method),
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ pub fn do_run_test_manual(
let rs_path = write_rust_to_file(&rust_code);

info!("Path is {:?}", tdir.path());
let builder = Builder::<TestBuilderContext>::new(&rs_path, &[tdir.path()])
let builder = Builder::<TestBuilderContext>::new(&rs_path, [tdir.path()])
.custom_gendir(target_dir.clone());
let builder = if let Some(builder_modifier) = &builder_modifier {
builder_modifier.modify_autocxx_builder(builder)
Expand Down
4 changes: 2 additions & 2 deletions tools/reduce/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ fn create_interestingness_test(
file.write_all(content.as_bytes())?;
}

let mut perms = std::fs::metadata(&test_path)?.permissions();
let mut perms = std::fs::metadata(test_path)?.permissions();
perms.set_mode(0o700);
std::fs::set_permissions(&test_path, perms)?;
std::fs::set_permissions(test_path, perms)?;
Ok(())
}

Expand Down