aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-03-17 09:44:46 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-03-17 09:51:39 +0000
commit6e385d2f257c5cba10e569bd540bdfa9f91960d2 (patch)
tree21a6cb15c6e07550a3ad851f5b7aea42527a70d7
parentbb234b080a5be332bbe67d9920a65959124088e7 (diff)
downloadgcc-6e385d2f257c5cba10e569bd540bdfa9f91960d2.zip
gcc-6e385d2f257c5cba10e569bd540bdfa9f91960d2.tar.gz
gcc-6e385d2f257c5cba10e569bd540bdfa9f91960d2.tar.bz2
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
-rw-r--r--gcc/rust/typecheck/rust-tyty-cmp.h2
-rw-r--r--gcc/testsuite/rust/compile/issue-1031.rs16
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-cmp.h b/gcc/rust/typecheck/rust-tyty-cmp.h
index 436bde9..684c41a 100644
--- a/gcc/rust/typecheck/rust-tyty-cmp.h
+++ b/gcc/rust/typecheck/rust-tyty-cmp.h
@@ -1240,7 +1240,7 @@ public:
: BaseCmp (base, emit_errors), base (base)
{}
- void visit (const ReferenceType &type) override
+ void visit (const PointerType &type) override
{
auto base_type = base->get_base ();
auto other_base_type = type.get_base ();
diff --git a/gcc/testsuite/rust/compile/issue-1031.rs b/gcc/testsuite/rust/compile/issue-1031.rs
new file mode 100644
index 0000000..6727f34
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-1031.rs
@@ -0,0 +1,16 @@
+extern "rust-intrinsic" {
+ pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
+}
+
+#[lang = "const_ptr"]
+impl<T> *const T {
+ pub const unsafe fn offset(self, count: isize) -> *const T {
+ // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
+ unsafe { offset(self, count) }
+ }
+
+ pub const unsafe fn add(self, count: usize) -> Self {
+ // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
+ unsafe { self.offset(count as isize) }
+ }
+}