From 1525769c6cf191b6f899ff5064627882e911ce90 Mon Sep 17 00:00:00 2001 From: Daniel Reiter Horn Date: Mon, 24 Aug 2020 01:15:40 -0700 Subject: [PATCH 1/3] revert undefined behavior introduction (recommended by clippy?) --- src/sdl2/rect.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl2/rect.rs b/src/sdl2/rect.rs index 5ad6c4b4..ba31db69 100644 --- a/src/sdl2/rect.rs +++ b/src/sdl2/rect.rs @@ -739,7 +739,7 @@ impl Point { slice.as_ptr() as *const sys::SDL_Point } - pub fn raw(self) -> *const sys::SDL_Point { + pub fn raw(&self) -> *const sys::SDL_Point { &self.raw } From eaa01c597e08f08962b47a862dfdc2b5a0f63b5d Mon Sep 17 00:00:00 2001 From: Daniel Reiter Horn Date: Mon, 24 Aug 2020 15:23:31 -0700 Subject: [PATCH 2/3] suppress dangerous clippy hints until https://github.com/rust-lang/rust-clippy/issues/3992 is resolved --- src/sdl2/macros.rs | 3 +++ src/sdl2/rect.rs | 7 ++++++- src/sdl2/render.rs | 15 +++++++++++++++ src/sdl2/rwops.rs | 3 +++ src/sdl2/surface.rs | 3 +++ src/sdl2/ttf/font.rs | 3 +++ src/sdl2/video.rs | 3 +++ 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/sdl2/macros.rs b/src/sdl2/macros.rs index 4ceaa804..41100950 100644 --- a/src/sdl2/macros.rs +++ b/src/sdl2/macros.rs @@ -3,6 +3,9 @@ macro_rules! impl_raw_accessors( $( impl $t { #[inline] + // can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub const unsafe fn raw(&self) -> $raw { self.raw } } )+ diff --git a/src/sdl2/rect.rs b/src/sdl2/rect.rs index ba31db69..1d963893 100644 --- a/src/sdl2/rect.rs +++ b/src/sdl2/rect.rs @@ -391,6 +391,9 @@ impl Rect { } /// Returns the underlying C Rect. + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *const sys::SDL_Rect { &self.raw } @@ -738,7 +741,9 @@ impl Point { pub fn raw_slice(slice: &[Point]) -> *const sys::SDL_Point { slice.as_ptr() as *const sys::SDL_Point } - + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *const sys::SDL_Point { &self.raw } diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index 3b1f94be..7792f306 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -219,6 +219,9 @@ impl RendererContext { } /// Gets the raw pointer to the SDL_Renderer + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Renderer { self.raw } @@ -784,6 +787,9 @@ fn ll_create_texture(context: *mut sys::SDL_Renderer, /// Texture-creating methods for the renderer impl TextureCreator { + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Renderer { self.context.raw() } @@ -922,6 +928,9 @@ impl TextureCreator { /// Drawing methods impl Canvas { + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Renderer { self.context.raw() } @@ -2148,6 +2157,9 @@ impl<'r> Texture<'r> { } #[inline] + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub const fn raw(&self) -> *mut sys::SDL_Texture { self.raw } @@ -2328,6 +2340,9 @@ impl<> Texture<> { } #[inline] + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub const fn raw(&self) -> *mut sys::SDL_Texture { self.raw } diff --git a/src/sdl2/rwops.rs b/src/sdl2/rwops.rs index de752f84..ec81feed 100644 --- a/src/sdl2/rwops.rs +++ b/src/sdl2/rwops.rs @@ -16,6 +16,9 @@ pub struct RWops<'a> { } impl<'a> RWops<'a> { + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub unsafe fn raw(&self) -> *mut sys::SDL_RWops { self.raw } pub unsafe fn from_ll<'b>(raw: *mut sys::SDL_RWops) -> RWops<'b> { diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 91eabd66..6258fd3d 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -281,6 +281,9 @@ impl SurfaceRef { } #[inline] + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Surface { self as *const SurfaceRef as *mut SurfaceRef as *mut () as *mut sys::SDL_Surface } diff --git a/src/sdl2/ttf/font.rs b/src/sdl2/ttf/font.rs index 14aa5681..0df75d1b 100644 --- a/src/sdl2/ttf/font.rs +++ b/src/sdl2/ttf/font.rs @@ -301,6 +301,9 @@ pub fn internal_load_font_at_index<'ttf,P: AsRef>(path: P, index: u32, pts impl<'ttf,'r> Font<'ttf,'r> { /// Returns the underlying C font object. + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] unsafe fn raw(&self) -> *mut ttf::TTF_Font { self.raw } diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index a389b62d..5836f99d 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -1075,6 +1075,9 @@ impl From for CanvasBuilder { impl Window { #[inline] + // this can prevent introducing UB until + // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Window { self.context.raw } #[inline] From 9d1851b7dfa53168d22c5c17ca941088e9ab4b34 Mon Sep 17 00:00:00 2001 From: Daniel Reiter Horn Date: Mon, 24 Aug 2020 15:33:15 -0700 Subject: [PATCH 3/3] reference the latest clippy issue --- src/sdl2/macros.rs | 2 +- src/sdl2/rect.rs | 4 ++-- src/sdl2/render.rs | 10 +++++----- src/sdl2/rwops.rs | 2 +- src/sdl2/surface.rs | 2 +- src/sdl2/ttf/font.rs | 2 +- src/sdl2/video.rs | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sdl2/macros.rs b/src/sdl2/macros.rs index 41100950..4041aaae 100644 --- a/src/sdl2/macros.rs +++ b/src/sdl2/macros.rs @@ -4,7 +4,7 @@ macro_rules! impl_raw_accessors( impl $t { #[inline] // can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub const unsafe fn raw(&self) -> $raw { self.raw } } diff --git a/src/sdl2/rect.rs b/src/sdl2/rect.rs index 1d963893..e1803af6 100644 --- a/src/sdl2/rect.rs +++ b/src/sdl2/rect.rs @@ -392,7 +392,7 @@ impl Rect { /// Returns the underlying C Rect. // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *const sys::SDL_Rect { &self.raw @@ -742,7 +742,7 @@ impl Point { slice.as_ptr() as *const sys::SDL_Point } // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *const sys::SDL_Point { &self.raw diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index 7792f306..349b1822 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -220,7 +220,7 @@ impl RendererContext { /// Gets the raw pointer to the SDL_Renderer // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Renderer { self.raw @@ -788,7 +788,7 @@ fn ll_create_texture(context: *mut sys::SDL_Renderer, /// Texture-creating methods for the renderer impl TextureCreator { // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Renderer { self.context.raw() @@ -929,7 +929,7 @@ impl TextureCreator { /// Drawing methods impl Canvas { // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Renderer { self.context.raw() @@ -2158,7 +2158,7 @@ impl<'r> Texture<'r> { #[inline] // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub const fn raw(&self) -> *mut sys::SDL_Texture { self.raw @@ -2341,7 +2341,7 @@ impl<> Texture<> { #[inline] // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub const fn raw(&self) -> *mut sys::SDL_Texture { self.raw diff --git a/src/sdl2/rwops.rs b/src/sdl2/rwops.rs index ec81feed..c5d8cb03 100644 --- a/src/sdl2/rwops.rs +++ b/src/sdl2/rwops.rs @@ -17,7 +17,7 @@ pub struct RWops<'a> { impl<'a> RWops<'a> { // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub unsafe fn raw(&self) -> *mut sys::SDL_RWops { self.raw } diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 6258fd3d..6eca4395 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -282,7 +282,7 @@ impl SurfaceRef { #[inline] // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Surface { self as *const SurfaceRef as *mut SurfaceRef as *mut () as *mut sys::SDL_Surface diff --git a/src/sdl2/ttf/font.rs b/src/sdl2/ttf/font.rs index 0df75d1b..03c67a4f 100644 --- a/src/sdl2/ttf/font.rs +++ b/src/sdl2/ttf/font.rs @@ -302,7 +302,7 @@ pub fn internal_load_font_at_index<'ttf,P: AsRef>(path: P, index: u32, pts impl<'ttf,'r> Font<'ttf,'r> { /// Returns the underlying C font object. // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] unsafe fn raw(&self) -> *mut ttf::TTF_Font { self.raw diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index 5836f99d..0b9f2090 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -1076,7 +1076,7 @@ impl From for CanvasBuilder { impl Window { #[inline] // this can prevent introducing UB until - // https://github.com/rust-lang/rust-clippy/issues/3992 is fixed + // https://github.com/rust-lang/rust-clippy/issues/5953 is fixed #[allow(clippy::trivially_copy_pass_by_ref)] pub fn raw(&self) -> *mut sys::SDL_Window { self.context.raw }