Skip to content

MIR-based borrow checker complains about rogue elves ("mut elf") when used with arbitrary self types #51578

Closed
@shepmaster

Description

@shepmaster

1.28.0-nightly (2018-06-13 5205ae8)

#![feature(nll, arbitrary_self_types)]

use std::rc::Rc;

struct Combine(u8);

impl Combine {
    fn poll(self: Rc<Self>) {
        drop(self);
        self.0 = 42;
    }
}

fn main() {}
error[E0594]: cannot assign to immutable item
  --> src/main.rs:10:9
   |
10 |         self.0 = 42;
   |         ----^^^^^^^
   |         |
   |         cannot assign through `&`-reference
   |         help: consider changing this to be a mutable reference: `&mut elf`

Unsurprisingly, &mut elf does not help the code compile.

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions