Skip to content

ICE bootstrapping rustc with NLL enabled #48071

Closed

Description

@nikomatsakis

When I try to bootstrap rustc with NLL enabled, I get an odd ICE compiling libsyntax_ext:

error: internal compiler error: broken MIR in NodeId(16117) (_368 = move _369): bad assignment (for<'cx, 'r, 's> fn(&'cx mut syntax::ext::base::ExtCtxt<'r>, syntax_pos::Span, &'s [syntax::tokenstream::To\
kenTree]) -> std::boxed::Box<syntax::ext::base::MacResult + 'cx> = for<'r, 's, 't0> fn(&'r mut syntax::ext::base::ExtCtxt<'s>, syntax_pos::Span, &'t0 [syntax::tokenstream::TokenTree]) -> std::boxed::Box<\
syntax::ext::base::MacResult>): RegionsOverlyPolymorphic(BrNamed(crate11:DefIndex(1:1012), 'cx), '_#729r)
   --> src/libsyntax_ext/lib.rs:65:44
    |
65  |                           expander: Box::new($f as MacroExpanderFn),
    |                                              ^^^^^^^^^^^^^^^^^^^^^
...
92  | /     register! {
93  | |         line: expand_line,
94  | |         __rust_unstable_column: expand_column_gated,
95  | |         column: expand_column,
...   |
112 | |         compile_error: compile_error::expand_compile_error,
113 | |     }
    | |_____- in this macro invocation

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-NLLArea: Non-lexical lifetimes (NLL)
    on Feb 8, 2018
  2. Aaron1011 commented on Feb 10, 2018

    @Aaron1011
    Contributor

    I'd like to work on this.

  3. nikomatsakis commented on Feb 14, 2018

    @nikomatsakis
    ContributorAuthor

    @Aaron1011 any progress? want me to take a look at all?

  4. Aaron1011 commented on Feb 14, 2018

    @Aaron1011
    Contributor

    @nikomatsakis: I haven't yet been able to reproduce this, due to #48129 stopping compilation. I'll try to work around that issue locally, and see if I can reproduce + investigate the original issue.

  5. Aaron1011 commented on Feb 15, 2018

    @Aaron1011
    Contributor

    @nikomatsakis: I ran across another issue while trying to reach the ICE: #48224

  6. Aaron1011 commented on Feb 15, 2018

    @Aaron1011
    Contributor

    @nikomatsakis: Until the intermediate issues are resolved, I don't think I'll be able to reproduce this.

  7. nikomatsakis commented on Feb 21, 2018

    @nikomatsakis
    ContributorAuthor

    @Aaron1011 this branch #48372 clears the way

  8. nikomatsakis commented on Feb 21, 2018

    @nikomatsakis
    ContributorAuthor

    Hmm, but on that branch I am now encountering the AddAssign problems I guess. So we're still blocked on #48129

  9. nikomatsakis commented on Feb 21, 2018

    @nikomatsakis
    ContributorAuthor

    Actually, the issue-48071 branch on my repo reproduces the problem. You have to build like so:

    RUSTFLAGS_STAGE_NOT_0='-Znll -Zborrowck=mir -Ztwo-phase-borrows' ./x.py build --stage 2 
    
  10. nikomatsakis commented on Feb 21, 2018

    @nikomatsakis
    ContributorAuthor

    Error that I get is (lightly edited):

    error: internal compiler error: broken MIR in NodeId(16117) (_368 = move _369): bad assignment (
    
    for<'cx, 'r, 's> fn(&'cx mut syntax::ext::base::ExtCtxt<'r>, syntax_pos::Span, &'s [syntax::tokenstream::TokenTree]) -> std::boxed::Box<syntax::ext::base::MacResult + 'cx>
    for<'r, 's, 't0> fn(&'r mut syntax::ext::base::ExtCtxt<'s>, syntax_pos::Span, &'t0 [syntax::tokenstream::TokenTree]) -> std::boxed::Box<syntax::ext::base::MacResult>): 
    
    RegionsOverlyPolymorphic(BrNamed(crate11:DefIndex(1:1012), 'cx), '_#729r)
    

    Removing explicit paths:

    for<'cx, 'r, 's> fn(&'cx mut ExtCtxt<'r>, Span, &'s [TokenTree]) -> Box<MacResult + 'cx>
    for<'r, 's, 't0> fn(&'r mut ExtCtxt<'s>, Span, &'t0 [TokenTree]) -> Box<MacResult>)
    

    The problem seems to be the return type.

  11. nikomatsakis commented on Feb 21, 2018

    @nikomatsakis
    ContributorAuthor

    Minimized:

    #![allow(warnings)]
    #![feature(dyn_trait)]
    #![feature(nll)]
    
    trait Foo {
        fn foo(&self) { }
    }
    
    impl Foo for () {
    }
    
    type MakeFooFn = for<'a> fn(&'a u8) -> Box<dyn Foo + 'a>;
    
    fn make_foo(x: &u8) -> Box<dyn Foo + 'static> {
        Box::new(())
    }
    
    fn main() {
        let x: MakeFooFn = make_foo as MakeFooFn;
    }
  12. nikomatsakis commented on Feb 21, 2018

    @nikomatsakis
    ContributorAuthor

    I think the problem is that there is a missing coercion of sorts, or else that this code in the NLL type checker is too strict:

    CastKind::ReifyFnPointer => {
    let fn_sig = op.ty(mir, tcx).fn_sig(tcx);
    // The type that we see in the fcx is like
    // `foo::<'a, 'b>`, where `foo` is the path to a
    // function definition. When we extract the
    // signature, it comes from the `fn_sig` query,
    // and hence may contain unnormalized results.
    let fn_sig = self.normalize(&fn_sig, location);
    let ty_fn_ptr_from = tcx.mk_fn_ptr(fn_sig);
    if let Err(terr) = self.eq_types(ty_fn_ptr_from, ty, location.at_self()) {
    span_mirbug!(
    self,
    rvalue,
    "equating {:?} with {:?} yields {:?}",
    ty_fn_ptr_from,
    ty,
    terr
    );
    }
    }

    In particular, it constructs the "reified" form of the fn pointer in ty_fn_ptr_from and then requires that the target type be equal to that. But in this case, the target type is a subtype of that.

  13. 10 remaining items

  14. nikomatsakis commented on Jun 29, 2018

    @nikomatsakis
    ContributorAuthor

    Hmm. I'm going to mark this as high priority because it blocks bootstrap. I think it's a bit tricky to fix. While bike riding recently though I had some ideas here -- I realized that we could probably write a custom bit of subtyping code used only (initially) by the MIR type checker. The hope would be that this is faster than canonicalizing etc. This code could use a universe-based check. This would sidestep the limitations of our existing subtyping algorithm which are biting us here. It would also help eliminate a blocker for chalk integration later. I may take a stab at this.

  15. self-assigned this
    on Jun 29, 2018
  16. added
    NLL-completeWorking towards the "valid code works" goal
    and removed on Jul 6, 2018
  17. nikomatsakis commented on Jul 17, 2018

    @nikomatsakis
    ContributorAuthor

    OK, my branch is now working and passing tests. I want to clean it up some and perhaps try to improve its performance though.

  18. pnkfelix commented on Jul 24, 2018

    @pnkfelix
    Contributor

    visited for triage. this should be fixed via PR #52488 (which is WIP but hopefully will be ready soon).

  19. added 5 commits that reference this issue on Jul 25, 2018
    da353ad
    4311afc
    73f817a
    bfbf837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.NLL-completeWorking towards the "valid code works" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions