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

Nightly error: internal compiler error: src/librustc_middle/ich/impls_ty.rs:94: StableHasher: unexpected region '_#10r #72595

Closed
benbromhead opened this issue May 26, 2020 · 1 comment

Comments

@benbromhead
Copy link

I tried this code (using cargo test to run the test):

use std::error::Error;
use async_trait::async_trait;

#[async_trait]
pub trait Transform2: Send + Sync {
    async fn transform(&self) -> Result<(), Box<dyn Error>>;
    fn get_name(&self) -> &'static str;
}

pub struct Printer {}

impl Printer {
    pub fn new() -> Printer {
        Printer{}
    }
}

#[async_trait]
impl Transform2 for Printer {
    async fn transform(&self) -> Result<(), Box<dyn Error>> {
        unimplemented!()
    }
    fn get_name(&self) -> &'static str {
        unimplemented!()
    }
}

#[tokio::test(threaded_scheduler)]
async fn test_compiler_script() -> Result<(), Box<dyn Error>> {
    let transforms: Vec<dyn Transform2> = vec![Printer::new()];

    return Ok(())
}

From my cargo.toml:

[dependencies]
async-trait = "0.1.30"
tokio = { version = "0.2.20", features = ["full", "macros"] }

I expected to see this happen:

This code should not compile and should produce some errors along the following (as it does on stable):

error[E0277]: the size for values of type `dyn Transform2` cannot be known at compilation time
  --> src/main.rs:30:21
   |
30 |     let transforms: Vec<dyn Transform2> = vec![Printer::new()];
   |                     ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `std::marker::Sized` is not implemented for `dyn Transform2`
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
   = note: required by `std::vec::Vec`
... [TRUNCATED for brevity]...

Instead, this happened:
error: internal compiler error: src/librustc_middle/ich/impls_ty.rs:94: StableHasher: unexpected region '_#10r
The rust compiler throws an internal error and panics.

Meta

rustc --version --verbose: rustc 1.45.0-nightly (46e85b432 2020-05-24) binary: rustc commit-hash: 46e85b4328fe18492894093c1092dfe509df4370 commit-date: 2020-05-24 host: x86_64-apple-darwin release: 1.45.0-nightly LLVM version: 10.0

Backtrace:

./.cargo/bin/cargo test --color=always --no-run --package dummy --bin dummy test_compiler_script -- --exact
   Compiling dummy v0.1.0 (.../CLionProjects/dummy)
error: internal compiler error: src/librustc_middle/ich/impls_ty.rs:94: StableHasher: unexpected region '_#10r

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: rustc_errors::HandlerInner::bug
   9: rustc_errors::Handler::bug
  10: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc_middle::ty::context::tls::with_opt::{{closure}}
  12: rustc_middle::ty::context::tls::with_opt
  13: rustc_middle::util::bug::opt_span_bug_fmt
  14: rustc_middle::util::bug::bug_fmt
  15: rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::RegionKind>::hash_stable
  16: <T as rustc_query_system::dep_graph::dep_node::DepNodeParams<Ctxt>>::to_fingerprint
  17: rustc_query_system::query::plumbing::get_query_impl
  18: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::suggest_await_before_try
  19: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
  20: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  21: rustc_typeck::check::FnCtxt::resolve_vars_with_obligations
  22: rustc_typeck::check::FnCtxt::structurally_resolved_type
  23: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  24: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  26: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_coercable_to_type
  27: rustc_typeck::check::FnCtxt::check_decl_local
  28: rustc_typeck::check::FnCtxt::check_stmt
  29: rustc_typeck::check::FnCtxt::check_block_with_expected
  30: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  31: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  32: rustc_typeck::check::FnCtxt::check_block_with_expected
  33: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  34: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  35: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  36: rustc_typeck::check::check_fn
  37: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  38: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  39: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  40: rustc_typeck::check::FnCtxt::check_argument_types
  41: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
  42: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  43: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  44: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  45: rustc_typeck::check::FnCtxt::check_argument_types
  46: rustc_typeck::check::FnCtxt::check_method_argument_types
  47: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  48: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  49: rustc_typeck::check::FnCtxt::check_block_with_expected
  50: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  51: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  52: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  53: rustc_typeck::check::check_fn
  54: rustc_middle::ty::context::GlobalCtxt::enter_local
  55: rustc_typeck::check::typeck_tables_of
  56: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_tables_of>::compute
  57: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  58: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  59: rustc_query_system::query::plumbing::get_query_impl
  60: rustc_typeck::check::typeck_tables_of
  61: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_tables_of>::compute
  62: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  63: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  64: rustc_query_system::query::plumbing::get_query_impl
  65: rustc_query_system::query::plumbing::ensure_query_impl
  66: rustc_typeck::check::typeck_item_bodies
  67: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  68: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  69: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  70: rustc_query_system::query::plumbing::get_query_impl
  71: rustc_typeck::check_crate
  72: rustc_interface::passes::analysis
  73: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  74: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  75: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  76: rustc_query_system::query::plumbing::get_query_impl
  77: rustc_middle::ty::context::tls::enter_global
  78: rustc_interface::interface::run_compiler_in_existing_thread_pool
  79: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-nightly (46e85b432 2020-05-24) running on x86_64-apple-darwin

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:
#0 [typeck_tables_of] type-checking `test_compiler_script`
#1 [typeck_tables_of] type-checking `test_compiler_script::{{closure}}#0`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `dummy`.

@csmoe
Copy link
Member

csmoe commented May 26, 2020

Duplicate of #72442

@csmoe csmoe closed this as completed May 26, 2020
@csmoe csmoe marked this as a duplicate of #72442 May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants