Skip to content

Panic when compiling gluon on 1.46 #75313

Description

@nukeop

I created an empty hello world project with Cargo, added the "gluon" library to it, then tried to compile.
I understand this is something more than just an incompatibility between the nightly compiler and the library.
Does not occur on stable.

Code

There's no code, I added gluon = "0.16.1" to Cargo.toml of an empty project.

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (6c8927b0c 2020-07-26)
binary: rustc
commit-hash: 6c8927b0cf80ceee19386026cf9d7fd4fd9d486f
commit-date: 2020-07-26
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:814 ~ gluon[bf1c]::std_lib[0]::regex[0]::load[0]), const_param_did: None }) (end of phase Optimized) at bb26[20]:            
encountered `Assign` statement with incompatible types:                                                                                                                                                          
left-hand side has type: fn(&std_lib::regex::Regex, &str) -> std::option::Option<vm::api::Collect<impl std::iter::Iterator>>                                                                                     
right-hand side has type: for<'r, 's> fn(&'r std_lib::regex::Regex, &'s str) -> std::option::Option<vm::api::Collect<impl std::iter::Iterator>>                                                                  
  --> /home/jcd/.cargo/registry/src/github.com-1ecc6299db9ec823/gluon-0.16.1/src/std_lib/regex.rs:90:39                                                                                                          
   |                                                                                                                                                                                                             
90 |             captures => primitive!(2, std::regex::prim::captures),                                                                                                                                          
   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                            
   |                                                                                                                                                                                                             
   = note: delayed at src/librustc_mir/transform/validate.rs:140:36                                                                                                                                              
                                                                                                                                                                                                                 
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:2715 ~ gluon[bf1c]::std_lib[0]::regex[0]::load[0]::wrapper[3]), const_param_did: None }) (end of phase Optimized) at bb0[0]: 
encountered `Assign` statement with incompatible types:                                                                                                                                                          
left-hand side has type: fn(&std_lib::regex::Regex, &str) -> std::option::Option<vm::api::Collect<impl std::iter::Iterator>>                                                                                     
right-hand side has type: for<'r, 's> fn(&'r std_lib::regex::Regex, &'s str) -> std::option::Option<vm::api::Collect<impl std::iter::Iterator>>                                                                  
  --> /home/jcd/.cargo/registry/src/github.com-1ecc6299db9ec823/gluon-0.16.1/src/std_lib/regex.rs:90:39                                                                                                          
   |                                                                                                                                                                                                             
90 |             captures => primitive!(2, std::regex::prim::captures),                                                                                                                                          
   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                                                
   = note: delayed at src/librustc_mir/transform/validate.rs:140:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:366:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.47.0-nightly (6c8927b0c 2020-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: could not compile `gluon`.

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 8, 2020
  2. added
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Aug 9, 2020
  3. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 9, 2020
  4. Aaron1011 commented on Aug 9, 2020

    @Aaron1011
    Contributor

    It looks like the bound regions are preventing us from normalizing an opaque type, leading us to conclude that the LHS and RHS types are not actually equal.

  5. added
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    on Aug 9, 2020
  6. jonas-schievink commented on Aug 9, 2020

    @jonas-schievink
    Contributor
  7. RalfJung commented on Aug 9, 2020

    @RalfJung
    Member

    Well I thought our subtyping check would catch such things? Cc @eddyb

    It would be great to get a minimal testcase out of this.

  8. RalfJung commented on Aug 9, 2020

    @RalfJung
    Member

    I thought something like this could be used to reproduce the problem, but so far I could not get it to ICE:

    struct Regex;
    
    fn nested(x: (for<'r, 's> fn(&'r Regex, &'s str), String)) -> (fn(&Regex, &str), String) {
        x
    }
    
    fn main() {
        nested((|_x, _y| (), String::new()));
    }
  9. eddyb commented on Aug 9, 2020

    @eddyb
    Contributor

    It looks like the bound regions are preventing us from normalizing an opaque type, leading us to conclude that the LHS and RHS types are not actually equal.

    @RalfJung You're missing the impl Iterator from the original. Here's a short repro:

    fn iter_slice<'a, T>(xs: &'a [T]) -> impl Iterator<Item = &'a T> {
        xs.iter()
    }
    
    fn main() {
        iter_slice::<()> as fn(_) -> _;
    }

    For the record, the thing of note about primitive!(2, std::regex::prim::captures) is that it casts (twice, even, presumably accounting for the two errors), the function to primitive_cast!(2) (which is just fn(_, _) -> _)

    The function is gluon's std::regex::prim::captures, with the signature:

    fn captures<'a>(
        re: &Regex,
        text: &'a str,
    ) -> Option<Collect<impl Iterator<Item = Option<Match<'a>>>>>
  10. RalfJung commented on Aug 9, 2020

    @RalfJung
    Member

    You're missing the impl Iterator from the original. Here's a short repro:

    Nice, a repro! So return-position impl-trait is crucial here. (We don't really need a bisect as we know that this got introduced by checking that MIR assignments are properly typed, so removing that label as well.)

    Any proposal for how this could be handled? I don't even understand why it doesn't work, I thought we are deleting all the lifetimes, but clearly not enough of them.^^
    Would moving back to a "type fold" (instead of this relator thing we are currently doing) help?

  11. removed
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Aug 9, 2020
  12. 24 remaining items

  13. RalfJung commented on Aug 13, 2020

    @RalfJung
    Member

    Reopening as the problem remains on beta.

    @lcnr can you do a backport?

  14. spastorino commented on Aug 13, 2020

    @spastorino
    Member

    @RalfJung #75443 is already beta-nominated, still this can be left open until we do the actual backport.

  15. RalfJung commented on Aug 13, 2020

    @RalfJung
    Member

    Oh I thought the beta PR would get nominated?
    Clearly I do not know the process. Feel free to close again if that's the process. :)

  16. Mark-Simulacrum commented on Aug 13, 2020

    @Mark-Simulacrum
    Member

    Hm, when you say "beta PR" -- is there a dedicated PR intended for beta backport? Or is #75443 slated for beta backport? Whichever PR's commits should be cherry-picked onto beta should get nominated.

  17. RalfJung commented on Aug 13, 2020

    @RalfJung
    Member

    Oh gosh now I confused everyone.^^
    What I thought would happen is that someone cherry-picks #75443 onto the beta branch, opens that PR, and then marks it as nominated for the team to discuss. But best to ignore me as I clearly have no idea how you are doing backports.^^

  18. spastorino commented on Aug 13, 2020

    @spastorino
    Member

    @RalfJung the way it works is ... a PR that was made against master is labelled with beta-nominated requesting a backport for beta or stable-nominated requesting a backport for stable. During the following compiler weekly meeting members vote if the request should be accepted or rejected. If it is accepted a label beta-accepted or stable-accepted is added and at that point @Mark-Simulacrum ports that PR to the corresponding beta/stable branch. If it request is declined the beta-nominated or stable-nominated label is removed leaving the backport without effect.

  19. teor2345 commented on Aug 19, 2020

    @teor2345
    Member

    We experienced a minor regression with the fix in PR #75443, but there are known workarounds.

    The fix caused new "reached the type-length limit" compiler errors in our project. In our particular case, we didn't need the tracing::instrument spans that were creating the large types, so we deleted them (see ZcashFoundation/zebra#923).

    This is a known issue in tracing tokio-rs/tracing#616 - they increase the type-length limit as a workaround.

    It's also a known issue in rustc (#54540). I added the bisect-rustc regression report to that issue as #54540 (comment).

  20. emilyalbini commented on Aug 21, 2020

    @emilyalbini
    Member

    The fix seems to have been backported to beta. Can we close this?

  21. RalfJung commented on Aug 21, 2020

    @RalfJung
    Member

    What's the link to the beta PR?

    Yes I think it can be closed then.

  22. emilyalbini commented on Aug 21, 2020

    @emilyalbini
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions