Skip to content

Commit b7f6937

Browse files
Merge pull request #841 from jf2048/cairo-warnings
cairo: fix some misc warnings
2 parents aa75187 + ea7eb69 commit b7f6937

File tree

3 files changed

+70
-76
lines changed

3 files changed

+70
-76
lines changed

cairo/src/device.rs

Lines changed: 67 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -201,101 +201,95 @@ impl Device {
201201
#[cfg(any(feature = "xlib", feature = "xcb", feature = "dox"))]
202202
#[doc(alias = "cairo_xlib_device_debug_cap_xrender_version")]
203203
#[doc(alias = "cairo_xcb_device_debug_cap_xrender_version")]
204-
pub fn debug_cap_xrender_version(&self, major_version: i32, minor_version: i32) {
205-
unsafe {
206-
match self.type_() {
207-
DeviceType::Xlib => {
208-
#[cfg(feature = "xlib")]
209-
{
210-
ffi::cairo_xlib_device_debug_cap_xrender_version(
211-
self.to_raw_none(),
212-
major_version,
213-
minor_version,
214-
)
215-
}
216-
#[cfg(not(feature = "xlib"))]
217-
{
218-
panic!("you need to enable \"xlib\" feature")
219-
}
204+
pub fn debug_cap_xrender_version(&self, _major_version: i32, _minor_version: i32) {
205+
match self.type_() {
206+
DeviceType::Xlib => {
207+
#[cfg(feature = "xlib")]
208+
unsafe {
209+
ffi::cairo_xlib_device_debug_cap_xrender_version(
210+
self.to_raw_none(),
211+
_major_version,
212+
_minor_version,
213+
)
214+
}
215+
#[cfg(not(feature = "xlib"))]
216+
{
217+
panic!("you need to enable \"xlib\" feature")
218+
}
219+
}
220+
DeviceType::Xcb => {
221+
#[cfg(feature = "xcb")]
222+
unsafe {
223+
ffi::cairo_xcb_device_debug_cap_xrender_version(
224+
self.to_raw_none(),
225+
_major_version,
226+
_minor_version,
227+
)
220228
}
221-
DeviceType::Xcb => {
222-
#[cfg(feature = "xcb")]
223-
{
224-
ffi::cairo_xcb_device_debug_cap_xrender_version(
225-
self.to_raw_none(),
226-
major_version,
227-
minor_version,
228-
)
229-
}
230-
#[cfg(not(feature = "xcb"))]
231-
{
232-
panic!("you need to enable \"xcb\" feature")
233-
}
229+
#[cfg(not(feature = "xcb"))]
230+
{
231+
panic!("you need to enable \"xcb\" feature")
234232
}
235-
d => panic!("invalid device type: {}", d),
236233
}
234+
d => panic!("invalid device type: {}", d),
237235
}
238236
}
239237

240238
#[cfg(any(feature = "xlib", feature = "xcb", feature = "dox"))]
241239
#[doc(alias = "cairo_xlib_device_debug_get_precision")]
242240
#[doc(alias = "cairo_xcb_device_debug_get_precision")]
243241
pub fn debug_get_precision(&self) -> i32 {
244-
unsafe {
245-
match self.type_() {
246-
DeviceType::Xlib => {
247-
#[cfg(feature = "xlib")]
248-
{
249-
ffi::cairo_xlib_device_debug_get_precision(self.to_raw_none())
250-
}
251-
#[cfg(not(feature = "xlib"))]
252-
{
253-
panic!("you need to enable \"xlib\" feature")
254-
}
242+
match self.type_() {
243+
DeviceType::Xlib => {
244+
#[cfg(feature = "xlib")]
245+
unsafe {
246+
ffi::cairo_xlib_device_debug_get_precision(self.to_raw_none())
247+
}
248+
#[cfg(not(feature = "xlib"))]
249+
{
250+
panic!("you need to enable \"xlib\" feature")
255251
}
256-
DeviceType::Xcb => {
257-
#[cfg(feature = "xcb")]
258-
{
259-
ffi::cairo_xcb_device_debug_get_precision(self.to_raw_none())
260-
}
261-
#[cfg(not(feature = "xcb"))]
262-
{
263-
panic!("you need to enable \"xcb\" feature")
264-
}
252+
}
253+
DeviceType::Xcb => {
254+
#[cfg(feature = "xcb")]
255+
unsafe {
256+
ffi::cairo_xcb_device_debug_get_precision(self.to_raw_none())
257+
}
258+
#[cfg(not(feature = "xcb"))]
259+
{
260+
panic!("you need to enable \"xcb\" feature")
265261
}
266-
d => panic!("invalid device type: {}", d),
267262
}
263+
d => panic!("invalid device type: {}", d),
268264
}
269265
}
270266

271267
#[cfg(any(feature = "xlib", feature = "xcb", feature = "dox"))]
272268
#[doc(alias = "cairo_xlib_device_debug_set_precision")]
273269
#[doc(alias = "cairo_xcb_device_debug_set_precision")]
274-
pub fn debug_set_precision(&self, precision: i32) {
275-
unsafe {
276-
match self.type_() {
277-
DeviceType::Xlib => {
278-
#[cfg(feature = "xlib")]
279-
{
280-
ffi::cairo_xlib_device_debug_set_precision(self.to_raw_none(), precision)
281-
}
282-
#[cfg(not(feature = "xlib"))]
283-
{
284-
panic!("you need to enable \"xlib\" feature")
285-
}
270+
pub fn debug_set_precision(&self, _precision: i32) {
271+
match self.type_() {
272+
DeviceType::Xlib => {
273+
#[cfg(feature = "xlib")]
274+
unsafe {
275+
ffi::cairo_xlib_device_debug_set_precision(self.to_raw_none(), _precision)
276+
}
277+
#[cfg(not(feature = "xlib"))]
278+
{
279+
panic!("you need to enable \"xlib\" feature")
280+
}
281+
}
282+
DeviceType::Xcb => {
283+
#[cfg(feature = "xcb")]
284+
unsafe {
285+
ffi::cairo_xcb_device_debug_set_precision(self.to_raw_none(), _precision)
286286
}
287-
DeviceType::Xcb => {
288-
#[cfg(feature = "xcb")]
289-
{
290-
ffi::cairo_xcb_device_debug_set_precision(self.to_raw_none(), precision)
291-
}
292-
#[cfg(not(feature = "xcb"))]
293-
{
294-
panic!("you need to enable \"xcb\" feature")
295-
}
287+
#[cfg(not(feature = "xcb"))]
288+
{
289+
panic!("you need to enable \"xcb\" feature")
296290
}
297-
d => panic!("invalid device type: {}", d),
298291
}
292+
d => panic!("invalid device type: {}", d),
299293
}
300294
}
301295

cairo/src/enums.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ impl fmt::Display for MeshCorner {
19761976
}
19771977

19781978
#[cfg(any(feature = "freetype", feature = "dox"))]
1979-
#[derive(Clone, PartialEq, PartialOrd, Debug, Copy)]
1979+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Copy)]
19801980
#[non_exhaustive]
19811981
#[doc(alias = "cairo_ft_synthesize_t")]
19821982
pub enum FtSynthesize {
@@ -2028,7 +2028,7 @@ impl fmt::Display for FtSynthesize {
20282028
}
20292029

20302030
#[cfg(any(feature = "script", feature = "dox"))]
2031-
#[derive(Clone, PartialEq, PartialOrd, Debug, Copy)]
2031+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Copy)]
20322032
#[non_exhaustive]
20332033
#[doc(alias = "cairo_script_mode_t")]
20342034
pub enum ScriptMode {

cairo/src/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ extern "C" fn write_callback<W: io::Write + 'static>(
222222
{
223223
// Safety: `write_callback<W>` was instantiated in `Surface::_for_stream`
224224
// with a W parameter consistent with the box that was unsized to `Box<dyn Any>`.
225-
let stream = unsafe { stream.downcast_mut_unchecked::<W>() };
225+
let stream = unsafe { AnyExt::downcast_mut_unchecked::<W>(&mut **stream) };
226226
// Safety: this is the callback contract from cairo’s API
227227
let data = unsafe {
228228
if data.is_null() || length == 0 {

0 commit comments

Comments
 (0)