gccrs
gccrs copied to clipboard
Add check for `#[repr(transparent)]` on `#[derive(CoercePointee)]` items
This built-in derive is only allowed on structs that are marked as #[repr(transparent)]
Hi Cohen, I've worked on this issue and #4916. I'm currently struck in trying to test the system. Can you guide me with that. It would get me up to speed with the testing of the system as well.
This is file, I'm using for testing.
#![feature(no_core)]
#![feature(lang_items)]
#![feature(rustc_attrs)]
#![no_core]
#[lang = "sized"]
pub trait Sized {}
#[derive(CoercePointee)]
// { dg-error "can only be derived on .struct.s with .#.\[repr\(transparent\)\]." "" { target *-*-* } .+1 }
struct Bad<T: ?Sized> {
ptr: *const T,
}
#[derive(CoercePointee)]
#[repr(transparent)]
struct Good<T: ?Sized> {
ptr: *const T,
}
I get the error:
FAIL: rust/compile/derive-coercepointee.rs (test for excess errors)
Excess errors:
/home/wesley/projects/oss/rust-gcc/gccrs/gcc/testsuite/rust/compile/derive-coercepointee.rs:28:10: error: could not resolve trait 'CoercePointee'
/home/wesley/projects/oss/rust-gcc/gccrs/gcc/testsuite/rust/compile/derive-coercepointee.rs:34:10: error: could not resolve trait 'CoercePointee'
I did some digging in the system and understood the parsing of lang item. There's no CoercePointee as of yet.