From 6c0025439e2d93c186e4859e474ce4f67aaec0d2 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 19 Feb 2021 12:51:07 -0500 Subject: [PATCH] [bindings] Correctly use access string in to-Rust container conv `from_c_conversion_container_new_var` should use var_access when it wishes to access the variable being converted, not `var_name`, but in a few cases it did not. Note that this has no impact on the generated bindings as of this commit. --- c-bindings-gen/src/types.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index f7d1e7fa..0c570bff 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1004,8 +1004,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { match full_path { "Result" if !is_ref => { Some(("match ", - vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_name)), - ("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_name))], + vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_access)), + ("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_access))], ")}")) }, "Vec"|"Slice" if !is_ref => { @@ -1018,9 +1018,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { if let Some(syn::Type::Path(p)) = single_contained { if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) { if is_ref { - return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_name))], ").clone()) }")) + return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_access))], ").clone()) }")) } else { - return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_name))], ") }")); + return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_access))], ") }")); } } } -- 2.30.2