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

Different version in dev-dependencies and dependencies seems to cause a crash #83950

Closed
Deisss opened this issue Apr 6, 2021 · 1 comment · Fixed by #105208
Closed

Different version in dev-dependencies and dependencies seems to cause a crash #83950

Deisss opened this issue Apr 6, 2021 · 1 comment · Fixed by #105208
Labels
A-resolve Area: Path resolution 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.

Comments

@Deisss
Copy link

Deisss commented Apr 6, 2021

Code

First, feel free to close or something, it just said to report a bug but I'm not sure it should be reported...

The bug appears after changing Cargo.toml:

[dependencies]
actix-web = "4.0.0-beta.4"
actix-service = "2.0.0-beta.5"

(...)

[dev-dependencies]
actix-http = "2.2.0"
actix-rt = "2.2.0"

Failing to compile, but "working", and this is the one breaking it:

[dependencies]
actix-web = "4.0.0-beta.4"
actix-service = "2.0.0-beta.5"

(...)

[dev-dependencies]
actix-service = "1.0.6"
actix-http = "2.2.0"
actix-rt = "2.2.0"

The add of mismatched actix-service in dev-deps cause the crash, the code hasn't changed in between (and was not compiling before and after of course so not sure it has any use).

Here is the code just in case, but like said, wasn't compiling anyway:

#[cfg(test)]
mod tests {
    use super::*;
    use actix_web::test;
    use actix_service::Service;
    use actix_http::Request;

    pub async fn unit_test_main() -> impl Service<Request> {
        let _guard = logger::create_basic_logger_std_out_std_err(None);

        // Parsing configuration
        let settings = Settings::new();
        if settings.is_err() {
            crit!("Wrong configuration: {:?}", settings.as_ref().err());
        }
        let config = settings.unwrap();
        let port = config.port.clone();
        let pool = create_config_from_settings(&config).create_pool(NoTls).unwrap();

        let p = WebData {
            config,
            pool
        };

        test::init_service(
            App::new()
                .data(p.clone())
                .service(
                    web::resource("/convert")
                        .route(web::post().to(convert::convert))
                )
        ).await
    }
}

Meta

rustc --version --verbose:

rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-pc-windows-msvc
release: 1.50.0

Error output

thread 'rustc' panicked at 'compiler\rustc_resolve\src\imports.rs:904:25: inconsistent resolution for an import', /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b\compiler\rustc_middle\src\util\bug.rs:34:26
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.50.0 (cb75ad5db 2021-02-10) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native

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

Backtrace

<backtrace>

@Deisss Deisss 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 Apr 6, 2021
@jyn514 jyn514 added the A-resolve Area: Path resolution label Apr 6, 2021
@hmunozb
Copy link

hmunozb commented Jun 23, 2021

I was about to post my own issue but I guess I'll throw my ring in the hat here. I encountered essentially the same problem and I reduced it to a more lightweight minimal example. A diamond dependency in the test build with a different version of the dependency in [dev-dependencies] appears to cause the issue.


Code

// src/lib.rs
// This file as-is results in an ICE

use simba;  //Comment this line results in "error: cannot determine resolution for the import"

#[cfg(test)]
mod tests {
    use approx; // Comment this line and the test completes successfully.

    #[test]
    fn simple_test(){
        use alga; // Comment this line and the test completes successfully.
        println!("Goodbye, world!");
    }
}
# Cargo.toml
[package]
name = "icy_project"
version = "0.1.0"
edition = "2018"

[dependencies]
approx="0.5.0"
simba="0.5.1"
# If you change to simba version 0.4, (which dependends on approx 0.4)
# then the test compilation ends with "error: cannot determine resolution for the import"

[dev-dependencies]
approx = "0.3.2"
alga = "0.9.3"

Meta

rustc --version --verbose:

rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-apple-darwin
release: 1.52.1
LLVM version: 12.0.0

Error output

This is the error that would occur in the circumstance that the first [dependency] is not used. If either the first [dev-dependency] or the offending mismatched dependency is not used, then the test is successful.

error: cannot determine resolution for the import
 --> src/lib.rs:8:9
  |
8 |     use approx; // Comment this line and the test completes successfully.
  |         ^^^^^^
  |
  = note: import resolution is stuck, try simplifying other imports

Otherwise, the compiler panics on the above project.

Backtrace

thread 'rustc' panicked at 'compiler/rustc_resolve/src/imports.rs:1056:33: inconsistent resolution for an import', /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   3: rustc_middle::ty::context::tls::with_opt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::span_bug_fmt
   7: rustc_resolve::imports::ImportResolver::finalize_import::{{closure}}
   8: rustc_resolve::imports::ImportResolver::finalize_import
   9: rustc_resolve::imports::ImportResolver::finalize_imports
  10: rustc_session::utils::<impl rustc_session::session::Session>::time
  11: rustc_resolve::Resolver::resolve_crate
  12: rustc_interface::passes::configure_and_expand_inner
  13: rustc_interface::passes::configure_and_expand::{{closure}}
  14: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  15: rustc_interface::passes::configure_and_expand
  16: rustc_interface::queries::Queries::expansion
  17: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  18: rustc_span::with_source_map
  19: rustc_interface::interface::create_compiler_and_run
  20: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants