diff --git a/Source/buildimplementationrust.go b/Source/buildimplementationrust.go index 2963aa4f..dd29bb66 100644 --- a/Source/buildimplementationrust.go +++ b/Source/buildimplementationrust.go @@ -315,16 +315,21 @@ func writeRustTraitFn(method ComponentDefinitionMethod, w LanguageWriter, hasSel return err } RustParam := RustParams[0] + paramName := RustParam.ParamName + if hasImpl && !hasImplParent { + // For stubed out methods avoid warning about unued parameters + paramName = "_" + RustParam.ParamName + } if param.ParamPass != "return" { if parameterString == "" { - parameterString += fmt.Sprintf("%s : %s", RustParam.ParamName, RustParam.ParamType) + parameterString += fmt.Sprintf("%s : %s", paramName, RustParam.ParamType) } else { - parameterString += fmt.Sprintf(", %s : %s", RustParam.ParamName, RustParam.ParamType) + parameterString += fmt.Sprintf(", %s : %s", paramName, RustParam.ParamType) } if parameterNames == "" { - parameterNames += RustParam.ParamName + parameterNames += paramName } else { - parameterNames += fmt.Sprintf(", %s", RustParam.ParamName) + parameterNames += fmt.Sprintf(", %s", paramName) } } else { returnType = RustParam.ParamType @@ -557,6 +562,7 @@ func buildRustHandle(component ComponentDefinition, w LanguageWriter, InterfaceM w.Writeln("") w.Writeln("use %s::*;", InterfaceMod) w.Writeln("") + w.Writeln("#[allow(dead_code)]") w.Writeln("impl HandleImpl {") w.AddIndentationLevel(1) for i := 0; i < len(component.Classes); i++ { @@ -660,6 +666,7 @@ func writeRustMethodWrapper(method ComponentDefinitionMethod, optclass *Componen } } } + w.Writeln("#[no_mangle]") w.Writeln("pub fn %s%s(%s) -> i32 {", cprefix, strings.ToLower(method.MethodName), parameterString) w.AddIndentationLevel(1) // Convert self parameter if non global diff --git a/Source/languagerust.go b/Source/languagerust.go index 94e83c6b..1c3dbefe 100644 --- a/Source/languagerust.go +++ b/Source/languagerust.go @@ -53,10 +53,15 @@ func writeRustBaseTypeDefinitions(componentdefinition ComponentDefinition, w Lan w.Writeln(" Version definition for %s", NameSpace) w.Writeln("**************************************************************************************************************************/") w.Writeln("") + w.Writeln("#[allow(dead_code)]") w.Writeln("pub const %s_VERSION_MAJOR : usize = %d;", strings.ToUpper(NameSpace), majorVersion(componentdefinition.Version)) + w.Writeln("#[allow(dead_code)]") w.Writeln("pub const %s_VERSION_MINOR : usize = %d;", strings.ToUpper(NameSpace), minorVersion(componentdefinition.Version)) + w.Writeln("#[allow(dead_code)]") w.Writeln("pub const %s_VERSION_MICRO : usize= %d;", strings.ToUpper(NameSpace), microVersion(componentdefinition.Version)) + w.Writeln("#[allow(dead_code)]") w.Writeln("pub const %s_VERSION_PRERELEASEINFO : &str = \"%s\";", strings.ToUpper(NameSpace), preReleaseInfo(componentdefinition.Version)) + w.Writeln("#[allow(dead_code)]") w.Writeln("pub const %s_VERSION_BUILDINFO : &str = \"%s\";", strings.ToUpper(NameSpace), buildInfo(componentdefinition.Version)) w.Writeln("") @@ -67,9 +72,11 @@ func writeRustBaseTypeDefinitions(componentdefinition ComponentDefinition, w Lan w.Writeln(" Error constants for %s", NameSpace) w.Writeln("**************************************************************************************************************************/") w.Writeln("") + w.Writeln("#[allow(dead_code)]") w.Writeln("pub const %s_SUCCESS : i32 = 0;", strings.ToUpper(NameSpace)) for i := 0; i < len(componentdefinition.Errors.Errors); i++ { errorcode := componentdefinition.Errors.Errors[i] + w.Writeln("#[allow(dead_code)]") if errorcode.Description != "" { w.Writeln("pub const %s_ERROR_%s : i32 = %d; /** %s */", strings.ToUpper(NameSpace), errorcode.Name, errorcode.Code, errorcode.Description) } else { @@ -85,6 +92,8 @@ func writeRustBaseTypeDefinitions(componentdefinition ComponentDefinition, w Lan w.Writeln("**************************************************************************************************************************/") w.Writeln("") w.Writeln("// Enum of all traits - this acts as a handle as we pass trait pointers through the interface") + w.Writeln("") + w.Writeln("#[allow(dead_code)]") w.Writeln("pub enum HandleImpl {") w.AddIndentationLevel(1) for i := 0; i < len(componentdefinition.Classes); i++ { @@ -101,7 +110,7 @@ func writeRustBaseTypeDefinitions(componentdefinition ComponentDefinition, w Lan w.Writeln("pub type Handle = *mut HandleImpl;") for i := 0; i < len(componentdefinition.Classes); i++ { class := componentdefinition.Classes[i] - w.Writeln("pub type %sHandle = *mut HandleImpl;", class.ClassName) + w.Writeln("pub type %sHandle =Handle;", class.ClassName) } if len(componentdefinition.Enums) > 0 {