gluon-lang / gluon

A static, type inferred and embeddable language written in Rust.
https://gluon-lang.org
MIT License
3.16k stars 145 forks source link

Support rust 1.70.0 #951

Closed chenrui333 closed 7 months ago

chenrui333 commented 1 year ago

While upgrading rust to 1.70.0, we found that fselect has some build issue with it, see the following build failure

thread 'rustc' panicked at 'assertion failed: !ty.needs_infer()', compiler/rustc_trait_selection/src/traits/outlives_bounds.rs:58:9
stack backtrace:
   0:        0x10bb01036 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha3ddc6c8acb3b41e
   1:        0x10bb8c52b - core::fmt::write::h55c7a1bdd8f56455
   2:        0x10bb1a6bc - std::io::Write::write_fmt::h27af5145c0d40b32
   3:        0x10bb00e0a - std::sys_common::backtrace::print::h5fb8c00455f3b585
   4:        0x10bb15aa0 - std::panicking::default_hook::{{closure}}::h8f62dbf924c4ee4e
   5:        0x10bb15781 - std::panicking::default_hook::h350871482efd0a0d
   Compiling clap v2.33.3
   6:        0x113da293a - rustc_driver_impl[d9a313b8f925679e]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10bb162d3 - std::panicking::rust_panic_with_hook::hbc178a4b1ac3e911
   8:        0x10bb013c3 - std::panicking::begin_panic_handler::{{closure}}::hb0394ed0e9da6eaf
   9:        0x10bb01139 - std::sys_common::backtrace::__rust_end_short_backtrace::h8199c578d0b9b873
  10:        0x10bb15ced - _rust_begin_unwind
  11:        0x10bbc8043 - core::panicking::panic_fmt::h335afe54074b123c
  12:        0x10bbc80d7 - core::panicking::panic::h679db5d92a389689
  13:        0x1178f2d9a - <rustc_infer[32fb341d6e0a7b88]::infer::InferCtxt as rustc_trait_selection[a2fd7c4595118da]::traits::outlives_bounds::InferCtxtExt>::implied_outlives_bounds
  14:        0x115dfe356 - <rustc_infer[32fb341d6e0a7b88]::infer::outlives::env::OutlivesEnvironment>::with_bounds::<core[ef37f52debf101b8]::iter::adapters::flatten::FlatMap<indexmap[51f5518122247f91]::set::IntoIter<rustc_middle[93ef92fd333526bb]::ty::Ty>, alloc[11e576ea4f8e2b32]::vec::Vec<rustc_middle[93ef92fd333526bb]::traits::query::OutlivesBound>, <rustc_infer[32fb341d6e0a7b88]::infer::InferCtxt as rustc_trait_selection[a2fd7c4595118da]::traits::outlives_bounds::InferCtxtExt>::implied_bounds_tys::{closure#0}>>
  15:        0x115f28d6a - rustc_hir_analysis[1729db833033aa34]::check::wfcheck::check_well_formed
  16:        0x116bf1f34 - rustc_query_system[4b66a84e20c37a48]::query::plumbing::try_execute_query::<rustc_query_impl[319187f9801461b0]::queries::check_well_formed, rustc_query_impl[319187f9801461b0]::plumbing::QueryCtxt>
  17:        0x116ec97d1 - <rustc_query_impl[319187f9801461b0]::Queries as rustc_middle[93ef92fd333526bb]::ty::query::QueryEngine>::check_well_formed
  18:        0x115f1687b - rustc_data_structures[74d12b3b3d632927]::sync::par_for_each_in::<&[rustc_hir[23ec9f3d33e21551]::hir::ItemId], <rustc_middle[93ef92fd333526bb]::hir::ModuleItems>::par_items<rustc_hir_analysis[1729db833033aa34]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
  19:        0x115f2ebb3 - rustc_hir_analysis[1729db833033aa34]::check::wfcheck::check_mod_type_wf
  20:        0x116bf16d6 - rustc_query_system[4b66a84e20c37a48]::query::plumbing::try_execute_query::<rustc_query_impl[319187f9801461b0]::queries::check_mod_type_wf, rustc_query_impl[319187f9801461b0]::plumbing::QueryCtxt>

  21:        0x116ebd3c1 - <rustc_query_impl[319187f9801461b0]::Queries as rustc_middle[93ef92fd333526bb]::ty::query::QueryEngine>::check_mod_type_wf
  22:        0x115f1696b - rustc_data_structures[74d12b3b3d632927]::sync::par_for_each_in::<&[rustc_hir[23ec9f3d33e21551]::hir_id::OwnerId], <rustc_middle[93ef92fd333526bb]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[1729db833033aa34]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  23:        0x115e7bf00 - <rustc_session[a38a80932245d098]::session::Session>::track_errors::<rustc_hir_analysis[1729db833033aa34]::check_crate::{closure#5}, ()>
  24:        0x115e2a864 - rustc_hir_analysis[1729db833033aa34]::check_crate
  25:        0x113eec81e - rustc_interface[22224ac49478d313]::passes::analysis
  26:        0x116c58be2 - rustc_query_system[4b66a84e20c37a48]::query::plumbing::try_execute_query::<rustc_query_impl[319187f9801461b0]::queries::analysis, rustc_query_impl[319187f9801461b0]::plumbing::QueryCtxt>
  27:        0x116eb1c79 - <rustc_query_impl[319187f9801461b0]::Queries as rustc_middle[93ef92fd333526bb]::ty::query::QueryEngine>::analysis
  28:        0x113df23a3 - <std[c074a63446a24828]::thread::local::LocalKey<core[ef37f52debf101b8]::cell::Cell<*const ()>>>::with::<rustc_middle[93ef92fd333526bb]::ty::context::tls::enter_context<<rustc_middle[93ef92fd333526bb]::ty::context::GlobalCtxt>::enter<rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>
  29:        0x113db7b64 - <rustc_interface[22224ac49478d313]::queries::QueryResult<&rustc_middle[93ef92fd333526bb]::ty::context::GlobalCtxt>>::enter::<core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>, rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  30:        0x113df9140 - <rustc_interface[22224ac49478d313]::interface::Compiler>::enter::<rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}::{closure#2}, core[ef37f52debf101b8]::result::Result<core[ef37f52debf101b8]::option::Option<rustc_interface[22224ac49478d313]::queries::Linker>, rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>
  31:        0x113da9189 - rustc_span[948e26923f0f38ec]::set_source_map::<core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>, rustc_interface[22224ac49478d313]::interface::run_compiler<core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>, rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  32:        0x113db8957 - <scoped_tls[f39a6905dcd445c5]::ScopedKey<rustc_span[948e26923f0f38ec]::SessionGlobals>>::set::<rustc_interface[22224ac49478d313]::interface::run_compiler<core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>, rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}>::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>
  33:        0x113dae2c3 - std[c074a63446a24828]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[22224ac49478d313]::util::run_in_thread_pool_with_globals<rustc_interface[22224ac49478d313]::interface::run_compiler<core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>, rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}>::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>
  34:        0x113dae7e5 - <<std[c074a63446a24828]::thread::Builder>::spawn_unchecked_<rustc_interface[22224ac49478d313]::util::run_in_thread_pool_with_globals<rustc_interface[22224ac49478d313]::interface::run_compiler<core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>, rustc_driver_impl[d9a313b8f925679e]::run_compiler::{closure#1}>::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef37f52debf101b8]::result::Result<(), rustc_span[948e26923f0f38ec]::ErrorGuaranteed>>::{closure#1} as core[ef37f52debf101b8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:        0x10bb02539 - std::sys::unix::thread::Thread::new::thread_start::h406ab92c130eec6c
  36:     0x7ff8136761d3 - __pthread_start

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

full build log, https://github.com/Homebrew/homebrew-core/actions/runs/5164912796/jobs/9305636134 some regression test log in here as well, https://github.com/chenrui333/github-action-test/actions/runs/5269091593/jobs/9526714893

frehberg commented 1 year ago

master build error with rustc 1.69.0 (84c898d65 2023-04-16)

   Compiling gluon v0.18.1 (.../3rdpary/gluon)
   Compiling gluon_parser v0.18.0 (.../3rdpary/gluon/parser)
error[E0106]: missing lifetime specifier
   --> src/query.rs:808:57
    |
808 | pub(crate) fn env(env: &(dyn Compilation + '_)) -> Env<&'_ CompilerDatabase> {
    |                        -----------------------          ^^ expected named lifetime parameter
    |
    = help: this function's return type contains a borrowed value, but the signature does not say which one of `env`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
    |
808 | pub(crate) fn env<'a>(env: &'a (dyn Compilation + 'a)) -> Env<&'a CompilerDatabase> {
    |                  ++++       ++                    ~~           ~~

For more information about this error, try `rustc --explain E0106`.
error: could not compile `gluon` due to previous error
Marwes commented 1 year ago

Reported the ICE upstream at https://github.com/rust-lang/rust/issues/112832

lockbox commented 1 year ago

in the meantime can there be a rust-toolchain file in the source tree

sheosi commented 12 months ago

FWIW, using Gluon on a project with Rust 1.71 does not compile either (though no compiler panics at least):

error[E0308]: mismatched types
    --> /home/sergio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/gluon_base-0.18.0/src/types/mod.rs:1042:24
     |
1042 | const _: [(); 8 * 6] = [(); std::mem::size_of::<Type<Symbol, ArcType>>()];
     |               -----    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an array with a fixed size of 48 elements, found one with 40 elements
     |               |
     |               help: consider specifying the actual array length: `40`
chenrui333 commented 11 months ago

any update on this thread?

frehberg commented 11 months ago

Workaround:

Sticking to the specific rust-compiler version 1.69, the code compiles

Add the following file to the project root ./rust-toolchain.toml

[toolchain]
channel = "1.69"
pillowtrucker commented 7 months ago

seems to work on current nightly ? both the gluon-repl package and the head of this repository build just fine on 1.76

Marwes commented 7 months ago

Gluon compiles on newer versions of rust again, I just forgot to close this one out