Skip to content

Commit 6e385d2

Browse files
committed
Fix bad copy-paste in can equal interface for pointer types
When we perform method resolution we check if the self arguments can be matched. Here the bug was that pointer types had a bad vistitor and only could ever match reference types which is wrong and was a copy paste error. Fixes #1031
1 parent bb234b0 commit 6e385d2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

gcc/rust/typecheck/rust-tyty-cmp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ class PointerCmp : public BaseCmp
12401240
: BaseCmp (base, emit_errors), base (base)
12411241
{}
12421242

1243-
void visit (const ReferenceType &type) override
1243+
void visit (const PointerType &type) override
12441244
{
12451245
auto base_type = base->get_base ();
12461246
auto other_base_type = type.get_base ();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
extern "rust-intrinsic" {
2+
pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
3+
}
4+
5+
#[lang = "const_ptr"]
6+
impl<T> *const T {
7+
pub const unsafe fn offset(self, count: isize) -> *const T {
8+
// { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
9+
unsafe { offset(self, count) }
10+
}
11+
12+
pub const unsafe fn add(self, count: usize) -> Self {
13+
// { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
14+
unsafe { self.offset(count as isize) }
15+
}
16+
}

0 commit comments

Comments
 (0)