Skip to content

write_mir_pretty no longer works for non local def_ids #81200

Closed

Description

@hermanventer

The expect_local call here means that write_mir_pretty no longer works for non local def_ids. The ability to print out MIR for non local functions this way is critical for the MIRAI project.

Originally posted by @hermanventer in #78407 (comment)

Activity

  1. added
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    on Jan 20, 2021
  2. RalfJung commented on Jan 20, 2021

    @RalfJung
    Member
  3. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    on Jan 20, 2021
  4. oli-obk commented on Jan 20, 2021

    @oli-obk
    Contributor

    I think what we can do is to check is_const_fn_raw for the const fn path, and use tcx.instance_mir(ty::InstanceDef::Item(def_id)) if it is not a const fn, as instance_mir already does the correct dispatching for anything that is not a const fn.

  5. 0xPoe commented on Feb 2, 2021

    @0xPoe
    Member

    Can I working on this?

  6. hermanventer commented on Feb 2, 2021

    @hermanventer
    Author

    That would be great. This is a blocker for me.

  7. oli-obk commented on Feb 2, 2021

    @oli-obk
    Contributor

    It's all yours! You can use @rustbot claim to have the bot assign it to you

  8. 0xPoe commented on Feb 2, 2021

    @0xPoe
    Member

    @rustbot claim

  9. oli-obk commented on Feb 2, 2021

    @oli-obk
    Contributor

    If you need any help, don't hesitate to ask here or ping me on zulip. I'll respond whenever I have time (which is a bit flaky this week, but you should definitely get a response once a day)

  10. removed their assignment
    on Feb 7, 2021
  11. 0xPoe commented on Feb 7, 2021

    @0xPoe
    Member

    Sorry, I haven't had time to finish it lately. Let's see if others can help.

  12. osa1 commented on Feb 9, 2021

    @osa1
    Contributor

    Do we have a reproducer for this issue? I have some idea of what needs to be done here, but I don't know how to check if it really works.

  13. hermanventer commented on Feb 9, 2021

    @hermanventer
    Author

    The only way I know of how to do this is to write something that uses the compiler driver, see for example: https://github.com/rust-lang/rustc-dev-guide/tree/master/examples. That seems like quite a lot of trouble to go to. More ideal would be some kind of unit test, but I have no idea of how that may be accomplished.

    Perhaps the easiest way to do an ad hoc test would be to build MIRAI with the latest nightly (I'd have to put up a branch that has been ported to it) and then run its tests.

  14. hermanventer commented on Feb 9, 2021

    @hermanventer
    Author

    I've uploaded a draft PR to facebookexperimental/MIRAI#754. If you build that with a recent nightly and then run cargo test, you should see failures. If your fix is good, then all tests should pass.

  15. osa1 commented on Feb 10, 2021

    @osa1
    Contributor

    Thanks @hermanventer, that's very helpful. I was able to run the tests successfully using the master branch, but if I use my stage 1 build with your branch some of the tests fail, and the backtraces include write_mir_pretty so I'm guessing those failing tests are reproducers for this issue.

  16. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 11, 2021
  17. added a commit that references this issue on Feb 14, 2021
    2efde8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-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