Skip to content

Cannot declare unsafe impl functions #1807

Closed
@erickt

Description

@erickt

I would expect that interfaces and implementations would support declaring a function as unsafe but it doesn't seem to work:

impl foo for [u8] {
    unsafe fn from_bytes() -> str { str::unsafe::from_bytes(self) }
}

fn main() {}

Errors out with this:

test.rs:2:4: 2:10 error: expecting fn, found unsafe
test.rs:2     unsafe fn from_bytes() -> str {
               ^~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions