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

Fix and circumvent new Rust 1.83 lints #967

Merged
merged 1 commit into from
Dec 3, 2024
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
3 changes: 1 addition & 2 deletions ash-examples/src/bin/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::default::Default;
use std::error::Error;
use std::ffi;
use std::io::Cursor;
use std::mem;
use std::mem::{align_of, size_of, size_of_val}; // TODO: Remove when bumping MSRV to 1.80
Expand Down Expand Up @@ -568,7 +567,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.create_pipeline_layout(&layout_create_info, None)
.unwrap();

let shader_entry_name = ffi::CStr::from_bytes_with_nul_unchecked(b"main\0");
let shader_entry_name = c"main";
let shader_stage_create_infos = [
vk::PipelineShaderStageCreateInfo {
module: vertex_shader_module,
Expand Down
3 changes: 1 addition & 2 deletions ash-examples/src/bin/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::default::Default;
use std::error::Error;
use std::ffi;
use std::io::Cursor;
use std::mem;
use std::mem::{align_of, size_of, size_of_val}; // TODO: Remove when bumping MSRV to 1.80
Expand Down Expand Up @@ -230,7 +229,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.create_pipeline_layout(&layout_create_info, None)
.unwrap();

let shader_entry_name = ffi::CStr::from_bytes_with_nul_unchecked(b"main\0");
let shader_entry_name = c"main";
let shader_stage_create_infos = [
vk::PipelineShaderStageCreateInfo {
module: vertex_shader_module,
Expand Down
6 changes: 2 additions & 4 deletions ash-examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ impl ExampleBase {
.build(&event_loop)
.unwrap();
let entry = Entry::linked();
let app_name = ffi::CStr::from_bytes_with_nul_unchecked(b"VulkanTriangle\0");
let app_name = c"VulkanTriangle";

let layer_names = [ffi::CStr::from_bytes_with_nul_unchecked(
b"VK_LAYER_KHRONOS_validation\0",
)];
let layer_names = [c"VK_LAYER_KHRONOS_validation"];
let layers_names_raw: Vec<*const c_char> = layer_names
.iter()
.map(|raw_name| raw_name.as_ptr())
Expand Down
2 changes: 1 addition & 1 deletion ash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub trait RawPtr<T> {
fn as_raw_ptr(&self) -> *const T;
}

impl<'r, T> RawPtr<T> for Option<&'r T> {
impl<T> RawPtr<T> for Option<&T> {
fn as_raw_ptr(&self) -> *const T {
match *self {
Some(inner) => inner,
Expand Down
1 change: 1 addition & 0 deletions ash/src/vk/definitions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::needless_lifetimes)]
use crate::vk::aliases::*;
use crate::vk::bitflags::*;
use crate::vk::constants::*;
Expand Down
12 changes: 7 additions & 5 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ fn generate_function_pointers<'a>(
.collect::<Vec<_>>();

struct CommandToParamTraits<'a>(&'a Command<'a>);
impl<'a> quote::ToTokens for CommandToParamTraits<'a> {
impl quote::ToTokens for CommandToParamTraits<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
for (param_ident, validstructs) in &self.0.parameter_validstructs {
let param_ident = param_ident.to_string();
Expand Down Expand Up @@ -1055,7 +1055,7 @@ fn generate_function_pointers<'a>(
}

struct CommandToType<'a>(&'a Command<'a>);
impl<'a> quote::ToTokens for CommandToType<'a> {
impl quote::ToTokens for CommandToType<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let type_name = &self.0.pfn_type_name;
let parameters = &self.0.parameters;
Expand All @@ -1069,7 +1069,7 @@ fn generate_function_pointers<'a>(
}

struct CommandToMember<'a>(&'a Command<'a>);
impl<'a> quote::ToTokens for CommandToMember<'a> {
impl quote::ToTokens for CommandToMember<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let type_name = &self.0.pfn_type_name;
let function_name_rust = &self.0.function_name_rust;
Expand All @@ -1078,7 +1078,7 @@ fn generate_function_pointers<'a>(
}

struct CommandToLoader<'a>(&'a Command<'a>);
impl<'a> quote::ToTokens for CommandToLoader<'a> {
impl quote::ToTokens for CommandToLoader<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let function_name_rust = &self.0.function_name_rust;
let parameters_unused = &self.0.parameters_unused;
Expand Down Expand Up @@ -1164,7 +1164,7 @@ pub struct ExtensionConstant<'a> {
pub notation: Option<&'a str>,
pub deprecated: Option<&'a str>,
}
impl<'a> ConstantExt for ExtensionConstant<'a> {
impl ConstantExt for ExtensionConstant<'_> {
fn constant(&self, _enum_name: &str) -> Constant {
self.constant.clone()
}
Expand Down Expand Up @@ -3386,6 +3386,8 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
};

let definition_code = quote! {
#![allow(clippy::needless_lifetimes)] // Omitting these correctly in the generator is complex

use core::marker::PhantomData;
use core::fmt;
use core::ffi::*;
Expand Down
Loading