-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Description
enum foo = { mut bar: baz };
enum baz = @quux_;
class quux_ { let mut baz: option<baz>;
new(baz: option<baz>) { self.baz = baz; } }
impl quuux for foo {
fn frob() {
really_impure(self.bar);
}
}
fn really_impure(bar: baz) {
bar.baz = none;
}
fn main() {}
This gets the error message:
/Users/tchevalier/rust/src/test/run-pass/borrowck-newtype.rs:11:22: 11:30 error: illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
/Users/tchevalier/rust/src/test/run-pass/borrowck-newtype.rs:11 really_impure(self.bar);
^~~~~~~~
/Users/tchevalier/rust/src/test/run-pass/borrowck-newtype.rs:11:8: 11:21 note: impure due to access to impure function
/Users/tchevalier/rust/src/test/run-pass/borrowck-newtype.rs:11 really_impure(self.bar);
I think it should be legal, since baz
is operationally a boxed type.
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type system