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

[MIR] missing autoref in overloaded deref #31466

Closed
arielb1 opened this issue Feb 7, 2016 · 0 comments
Closed

[MIR] missing autoref in overloaded deref #31466

arielb1 opened this issue Feb 7, 2016 · 0 comments
Assignees
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html

Comments

@arielb1
Copy link
Contributor

arielb1 commented Feb 7, 2016

#![feature(rustc_attrs)]

struct DerefEx;

impl std::ops::Deref for DerefEx {
    type Target = u32;
    fn deref(&self) -> &u32 { loop {} }
}

#[rustc_mir]
fn funky(s: &'static DerefEx) -> &'static u32 {
    s
}

fn main() {}

Generated MIR:

fn(arg0: &DerefEx) -> &u32 {
    let var0: &DerefEx; // s
    let mut tmp0: &u32;
    let mut tmp1: DerefEx;
    let mut tmp2: ();

    bb0: {
        var0 = arg0;
        tmp1 = (*var0); // <- BUG this deref should be a reborrow
        tmp0 = core::ops::Deref::deref(tmp1) -> bb2;
    }

    bb1: {
        return;
    }

    bb2: {
        return = &(*tmp0);
        goto -> bb1;
    }
}

cc @nikomatsakis @nagisa

@arielb1 arielb1 self-assigned this Feb 7, 2016
@nagisa nagisa added the A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Feb 7, 2016
@bors bors closed this as completed in 350b50d Feb 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
Projects
None yet
Development

No branches or pull requests

2 participants