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

compiler error on cargo test #79948

Closed
gilesbradshaw opened this issue Dec 11, 2020 · 4 comments
Closed

compiler error on cargo test #79948

gilesbradshaw opened this issue Dec 11, 2020 · 4 comments
Labels
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

@gilesbradshaw
Copy link

It says you'd appreciate report ...

I am 99% sure this code was compiling - but now

Code

use std::fs;
use std::error::Error;

pub fn run(config: Config) -> Result<(), Box<dyn Error>>{
   
  let contents = fs::read_to_string(config.filename)?;
  
  println!("With text:\n{}", contents);
  Ok(())
}

pub struct Config {
  pub query: String,
  pub filename: String
}

impl Config {
  pub fn new(args: &[String]) -> Result<Config, &'static str> {
      if args.len() < 3 {
          return Err("u need s args");
      }
      let query = args[1].clone();
      let filename = args[2].clone();
      Ok(
          Config {
              query,
              filename,
          }
      )
  }   
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_config() {
      if let Ok(config) = Config::new(&[String::from(""), String::from("search"), String::from("file"),]) {
        assert_eq!(config.query, "search", "its search");
        
      }
    }
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (1700ca07c 2020-12-08)
binary: rustc
commit-hash: 1700ca07c6dd7becff85678409a5df6ad4cf4f47
commit-date: 2020-12-08
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

$ RUST_BACKTRACE=1 cargo test
   Compiling minigrep v0.1.0 (/home/giles/rust/minigrep)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/ty/query/mod.rs:235:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1700ca07c6dd7becff85678409a5df6ad4cf4f47/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/1700ca07c6dd7becff85678409a5df6ad4cf4f47/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/1700ca07c6dd7becff85678409a5df6ad4cf4f47/library/core/src/panicking.rs:50:5
   3: rustc_middle::ty::query::try_load_from_on_disk_cache
   4: rustc_query_system::dep_graph::graph::DepGraph<K>::exec_cache_promotions
   5: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   6: rustc_incremental::persist::save::save_in
   7: rustc_data_structures::sync::join
   8: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   9: rustc_incremental::persist::save::save_dep_graph
  10: rustc_codegen_ssa::base::finalize_tcx
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::QueryContext::enter
  14: rustc_interface::queries::Queries::ongoing_codegen
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: rustc_interface::interface::create_compiler_and_run
  18: 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

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-nightly (1700ca07c 2020-12-08) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: could not compile `minigrep`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Backtrace

<backtrace>

@gilesbradshaw gilesbradshaw 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 Dec 11, 2020
@camelid
Copy link
Member

camelid commented Dec 11, 2020

Appears to be a duplicate of #79661. Can you please try with the latest nightly and let me know if it works? If it does not, you may need to wait for the one after that.

@gilesbradshaw
Copy link
Author

actually I have "fixed" it by deleting target directory - now it compiles fine..
If I get it again i will also try and fix by updating and report back ..

@camelid
Copy link
Member

camelid commented Dec 11, 2020

Yes, this is an incremental compilation bug, which means that deleting the target directory will at least temporarily fix the problem. Updating your version should actually fix it though.

@camelid camelid closed this as completed Dec 11, 2020
@gilesbradshaw
Copy link
Author

yeap it happened again - fixed with upgrade

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. 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

2 participants