Skip to content

Commit a4e606b

Browse files
committed
codegen: Simplify method implementations.
1 parent 7aed4ba commit a4e606b

10 files changed

+17
-25
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,11 +1821,7 @@ impl MethodCodegen for Method {
18211821
exprs[0] = quote_expr!(ctx.ext_cx(), &mut __bindgen_tmp);
18221822
} else if !self.is_static() {
18231823
assert!(!exprs.is_empty());
1824-
exprs[0] = if self.is_const() {
1825-
quote_expr!(ctx.ext_cx(), &*self)
1826-
} else {
1827-
quote_expr!(ctx.ext_cx(), &mut *self)
1828-
};
1824+
exprs[0] = quote_expr!(ctx.ext_cx(), self);
18291825
};
18301826

18311827
let call = aster::expr::ExprBuilder::new()

tests/expectations/tests/bitfield-method-same-name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ impl Foo {
5454
}
5555
#[inline]
5656
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_schar {
57-
Foo_type(&mut *self)
57+
Foo_type(self)
5858
}
5959
#[inline]
6060
pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_schar) {
61-
Foo_set_type_(&mut *self, c)
61+
Foo_set_type_(self, c)
6262
}
6363
#[inline]
6464
pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_schar) {
65-
Foo_set_type(&mut *self, c)
65+
Foo_set_type(self, c)
6666
}
6767
}

tests/expectations/tests/class.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ impl Clone for RealAbstractionWithTonsOfMethods {
283283
}
284284
impl RealAbstractionWithTonsOfMethods {
285285
#[inline]
286-
pub unsafe fn bar(&self) { RealAbstractionWithTonsOfMethods_bar(&*self) }
286+
pub unsafe fn bar(&self) { RealAbstractionWithTonsOfMethods_bar(self) }
287287
#[inline]
288288
pub unsafe fn bar1(&mut self) {
289-
RealAbstractionWithTonsOfMethods_bar1(&mut *self)
289+
RealAbstractionWithTonsOfMethods_bar1(self)
290290
}
291291
#[inline]
292292
pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) {
293-
RealAbstractionWithTonsOfMethods_bar2(&mut *self, foo)
293+
RealAbstractionWithTonsOfMethods_bar2(self, foo)
294294
}
295295
#[inline]
296296
pub unsafe fn sta() { RealAbstractionWithTonsOfMethods_sta() }

tests/expectations/tests/class_with_typedef.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ impl Default for C {
7070
}
7171
impl C {
7272
#[inline]
73-
pub unsafe fn method(&mut self, c: C_MyInt) { C_method(&mut *self, c) }
73+
pub unsafe fn method(&mut self, c: C_MyInt) { C_method(self, c) }
7474
#[inline]
7575
pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) {
76-
C_methodRef(&mut *self, c)
76+
C_methodRef(self, c)
7777
}
7878
#[inline]
7979
pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) {
80-
C_complexMethodRef(&mut *self, c)
80+
C_complexMethodRef(self, c)
8181
}
8282
#[inline]
8383
pub unsafe fn anotherMethod(&mut self, c: AnotherInt) {
84-
C_anotherMethod(&mut *self, c)
84+
C_anotherMethod(self, c)
8585
}
8686
}
8787
#[repr(C)]

tests/expectations/tests/gen-destructors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ extern "C" {
2727
}
2828
impl Foo {
2929
#[inline]
30-
pub unsafe fn destruct(&mut self) { Foo_Foo_destructor(&mut *self) }
30+
pub unsafe fn destruct(&mut self) { Foo_Foo_destructor(self) }
3131
}

tests/expectations/tests/issue-410.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub mod root {
3434
impl Value {
3535
#[inline]
3636
pub unsafe fn a(&mut self, arg1: root::JSWhyMagic) {
37-
Value_a(&mut *self, arg1)
37+
Value_a(self, arg1)
3838
}
3939
}
4040
}

tests/expectations/tests/method-mangling.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ impl Clone for Foo {
2525
}
2626
impl Foo {
2727
#[inline]
28-
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int {
29-
Foo_type(&mut *self)
30-
}
28+
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int { Foo_type(self) }
3129
}

tests/expectations/tests/namespace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub mod root {
5858
#[inline]
5959
pub unsafe fn lets_hope_this_works(&mut self)
6060
-> ::std::os::raw::c_int {
61-
A_lets_hope_this_works(&mut *self)
61+
A_lets_hope_this_works(self)
6262
}
6363
}
6464
}

tests/expectations/tests/public-dtor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ extern "C" {
2222
}
2323
impl cv_String {
2424
#[inline]
25-
pub unsafe fn destruct(&mut self) {
26-
cv_String_String_destructor(&mut *self)
27-
}
25+
pub unsafe fn destruct(&mut self) { cv_String_String_destructor(self) }
2826
}

tests/expectations/tests/union_dtor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ extern "C" {
5959
impl UnionWithDtor {
6060
#[inline]
6161
pub unsafe fn destruct(&mut self) {
62-
UnionWithDtor_UnionWithDtor_destructor(&mut *self)
62+
UnionWithDtor_UnionWithDtor_destructor(self)
6363
}
6464
}

0 commit comments

Comments
 (0)