diff --git a/gcc/rust/typecheck/rust-tyty-cmp.h b/gcc/rust/typecheck/rust-tyty-cmp.h index 436bde9a2954..684c41abc2f8 100644 --- a/gcc/rust/typecheck/rust-tyty-cmp.h +++ b/gcc/rust/typecheck/rust-tyty-cmp.h @@ -1240,7 +1240,7 @@ class PointerCmp : public BaseCmp : 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 000000000000..6727f34336f3 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-1031.rs @@ -0,0 +1,16 @@ +extern "rust-intrinsic" { + pub fn offset(dst: *const T, offset: isize) -> *const T; +} + +#[lang = "const_ptr"] +impl *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) } + } +}