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

Difficulty creating &mut Trait #8248

Closed
alexcrichton opened this issue Aug 3, 2013 · 2 comments
Closed

Difficulty creating &mut Trait #8248

alexcrichton opened this issue Aug 3, 2013 · 2 comments
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 test case:

trait A {}
struct B;
impl A for B {}

fn foo(_: &mut A) {
}

fn main() {
    let mut b = B;
    foo(&mut b as &mut A);
}

fails with

foo.rs:10:8: 10:14 error: borrowed value does not live long enough
foo.rs:10     foo(&mut b as &mut A);
                  ^~~~~~
note: borrowed pointer must be valid for the static lifetime...
foo.rs:8:10: 11:1 note: ...but borrowed value is only valid for the block at 8:10
foo.rs:8 fn main() {
foo.rs:9     let mut b = B;
foo.rs:10     foo(&mut b as &mut A);
foo.rs:11 }
error: aborting due to previous error

cc @msullivan

@nikomatsakis
Copy link
Contributor

cc @nikomatsakis

@alexcrichton
Copy link
Member Author

Yay this works now!

Flagging as needstest

btw, @nikomatsakis you are awesome.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 13, 2022
Fixes rust-lang#8248

According to https://doc.rust-lang.org/cargo/reference/unstable this
seems to be the right place to set it, and it does fix the build for me.

I haven't removed the other `rustflags` because perhaps it's needed on
different cargo/rust versions?
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 13, 2022
Set binary-dep-depinfo in .cargo/config.toml

Fixes rust-lang#8248

According to https://doc.rust-lang.org/cargo/reference/unstable this
seems to be the right place to set it, and it does fix the build for me.

I haven't removed the other `rustflags` because perhaps it's needed on
different cargo/rust versions?

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
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

2 participants