Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using &mut Trait requires mut local variable #8398

Closed
alexcrichton opened this issue Aug 8, 2013 · 1 comment
Closed

Using &mut Trait requires mut local variable #8398

alexcrichton opened this issue Aug 8, 2013 · 1 comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@alexcrichton
Copy link
Member

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

@alexcrichton
Copy link
Member Author

Yay, this works now!

Flagging as needstest

flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 10, 2022
Add lint `transmute_undefined_repr`

Partially implements rust-lang#3999 and rust-lang#546

This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted.

changelog: Add lint `transmute_undefined_repr`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

1 participant