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

broken MIR in DefId ... #97706

Closed
ilyvion opened this issue Jun 3, 2022 · 5 comments
Closed

broken MIR in DefId ... #97706

ilyvion opened this issue Jun 3, 2022 · 5 comments
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ilyvion
Copy link

ilyvion commented Jun 3, 2022

This could be a duplicate bug, but I don't know have the know how to tell if it is (I found issues with similar but not identical error output, and I figured it's better to report and risk a duplicate than to risk leaving it unreported.

Code

pub fn compose(
    f1: impl FnOnce(f64) -> f64 + Clone,
    f2: impl FnOnce(f64) -> f64 + Clone,
) -> impl FnOnce(f64) -> f64 + Clone {
    move |x| f1(f2(x))
}

pub fn double(f: impl FnOnce(f64) -> f64 + Clone) -> impl FnOnce(f64) -> f64 + Clone {
    compose(f.clone(), f)
}


fn repeat_helper(f: impl FnOnce(f64) -> f64 + Clone, res: impl FnOnce(f64) -> f64 + Clone, times: usize) -> impl FnOnce(f64) -> f64 + Clone {
    if times == 1 {
        return res;
    }
    repeat_helper(f.clone(), compose(f, res), times - 1)
}

pub fn repeat(f: impl FnOnce(f64) -> f64 + Clone, times: usize) -> impl FnOnce(f64) -> f64 + Clone {
    repeat_helper(f.clone(), f, times)
}

(Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=1bb970cfa0b428638ff8fd94551bc3a6)

Meta

rustc --version --verbose:

Bug appears on all of 1.61.0, 1.62.0-beta.3 and 1.63.0-nightly (2022-06-02 e71440575c930dcecac2)

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:11 ~ playground[b1a6]::repeat_helper) (Terminator { source_info: SourceInfo { span: src/lib.rs:17:5: 17:57 (#0), scope: scope[0] }, kind: _0 = repeat_helper::<impl FnOnce(f64) -> f64 + Clone, impl (FnOnce(f64)-> f64) + Clone>(move _8, move _10, move _13) -> [return: bb6, unwind: bb10] }): call dest mismatch (impl (FnOnce(f64)-> f64) + std::clone::Clone <- impl (FnOnce(f64)-> f64) + std::clone::Clone): NoSolution
  --> src/lib.rs:17:55
   |
17 |     repeat_helper(f.clone(), compose(f, res), times - 1)
   |                                                       ^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1564:21
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1369:13
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   3: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   4: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   6: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   7: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@ilyvion ilyvion added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 3, 2022
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Jun 3, 2022
@matthiaskrgr
Copy link
Member

ICE since f132bcf

searched toolchains 9c06e1ba47e1077725a950e0b5d1870a89c8b536 through c5cf08d37b85f953b132951e868df5b924250fdc


********************************************************************************
Regression in f132bcf3bdf6d3ff9be7d02e8d0088b99007cd5e
********************************************************************************

==================================================================================
= Please file this regression report on the rust-lang/rust GitHub repository     =
=        New issue: https://github.com/rust-lang/rust/issues/new                 =
=     Known issues: https://github.com/rust-lang/rust/issues                     =
= Copy and paste the text below into the issue report thread.  Thanks!           =
==================================================================================

@SparrowLii
Copy link
Member

Tried to minimize it:

pub trait T {}

pub fn foo(a: impl T, b: impl T, times: usize) -> impl T {
    if times == 1 {
        return a;
    }
    foo(b, a, times - 1)
}

@SparrowLii
Copy link
Member

It may be fixed by #100092

@JohnTitor
Copy link
Member

Triage: As @SparrowLii said, this is fixed by #100092, I'm not sure if the regression tests in that PR cover this case so marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Aug 31, 2022
@JohnTitor
Copy link
Member

Triage: Closing as the tests added in the above PR seem to cover this case as well.

@JohnTitor JohnTitor removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants