Skip to content

Using &mut Trait requires mut local variable #8398

Closed
@alexcrichton

Description

@alexcrichton

This code:

use std::rt::io;

fn foo(a: &mut io::Writer) {
    a.write([])
}

fn main(){}

Yields this error:

foo.rs:4:4: 4:5 error: cannot borrow immutable argument as mutable
foo.rs:4     a.write([])
             ^
error: aborting due to previous error

Which doesn't make sense to me because a shouldn't have to be mutable because it's already a pointer to a mutable thing (which is what io::Writer wants)

cc @msullivan

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions