-
Notifications
You must be signed in to change notification settings - Fork 13.4k
"unsafe" on methods doesn't work #3080
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This might be related to #2587. |
Latest head solved this with throwing error case |
I just tried compiling this program with the latest incoming, and it still compiled successfully. @vertexclique, did you say you got an error with this test program? |
Still wrong as of b60a0be (no error message) |
Can this be closed? I have a working example of unsafe fn foo() methods. |
Indeed, I am wondering the same thing as kud1ing. I quickly hacked up an example program that uses unsafe features, and it seems to compile and run properly. (I've included the example at the end of this comment.) I do not know enough about how traits and methods are implemented, especially in the case of dynamic dispatch in object types, to say that we currently support unsafe methods; all I can see is that we do not obviously fail to support them. :) So I won't close this ticket immediately, but I'd like someone else on the team to consider doing so (or provide me with a pointer to something saying why we do not and/or can not support unsafe methods). unsafe fn f(x:*int) -> int {
let p = x as int;
let q = p + 8; // danger: assumes sizeof(int*) in a vec is 8 !
let y = q as *int;
*y
}
trait x { unsafe fn uwith(&self, x:*int) -> int; }
impl x for () {
unsafe fn uwith(&self, x:*int) -> int { 3+f(x) }
}
impl x for @() {
unsafe fn uwith(&self, x:*int) -> int { 13+f(x) }
}
impl x for @int {
unsafe fn uwith(&self, x:*int) -> int { 23+f(x) }
}
fn main() {
let obju = ();
let objo = @();
let obji = @3;
let vec = [0,7,1000];
io::print(fmt!("%?\n", obju.uwith(&vec[0])));
io::print(fmt!("%?\n", objo.uwith(&vec[0])));
io::print(fmt!("%?\n", obji.uwith(&vec[0])));
} |
(either way, this is not a 0.6 milestone issue.) |
In case it is not clear: I was able to compile and run the code from the comment above. I had meant for this to demonstrate that |
More examples in #6331 |
This is fixed. |
Format macro calls with item-like arguments
This is a follow-up to rust-lang#3063 that turns off that MIR pass while compiling `std` as well to ensure any bugs of the same nature in `std` are captured by Kani. Resolves rust-lang#3079
This compiles, and shouldn't:
The text was updated successfully, but these errors were encountered: