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: casting &str to *const str will cast twice #30612

Closed
nagisa opened this issue Dec 29, 2015 · 5 comments
Closed

Mir: casting &str to *const str will cast twice #30612

nagisa opened this issue Dec 29, 2015 · 5 comments
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html

Comments

@nagisa
Copy link
Member

nagisa commented Dec 29, 2015

#[rustc_mir(graphviz="foo.gv")]
fn mir(){
    "hello" as *const str;
}

will result in

foo

Note the repeated cast to *const str.

@arielb1
Copy link
Contributor

arielb1 commented Dec 29, 2015

This is semi-expected. One of the casts is a coercion and the other is the identity cast. We shouldn't however be emitting Misc instructions for identity casts.

@steveklabnik steveklabnik added the A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Dec 31, 2015
@pczarn
Copy link
Contributor

pczarn commented Jan 27, 2016

What kind of instruction should be emitted for identity casts?

@arielb1
Copy link
Contributor

arielb1 commented Feb 11, 2016

We should not be emitting any instructions for an identity cast. I think that this could be best done in a post-processing pass.

@eddyb
Copy link
Member

eddyb commented Mar 10, 2016

I believe my "mir: Ignore noop casts (e.g. when as used for coercion)." commit from #32080 fixes this.

@nagisa
Copy link
Member Author

nagisa commented Apr 20, 2016

Seems to be fixed indeed.

@nagisa nagisa closed this as completed Apr 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

5 participants