Skip to content

Using &mut Trait requires mut local variable #8398

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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