Skip to content

ICE: compiler/rustc_typeck/src/variance/constraints.rs:332:17: unexpected type encountered in variance inference: FreshTy(0) #82927

Closed
@chengniansun

Description

Code

trait SendEqAlias<T> = PartialEq;
struct Foo;
struct Bar<T>(SendEqAlias<T>);

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (8f349be27 2021-03-08)
binary: rustc
commit-hash: 8f349be27815d43d462a32faeb270a22a68486b6
commit-date: 2021-03-08
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Error output

error[E0658]: trait aliases are experimental
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | trait SendEqAlias<T> = PartialEq;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
  = help: add `#![feature(trait_alias)]` to the crate attributes to enable

warning: trait objects without an explicit `dyn` are deprecated
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:15
  |
3 | struct Bar<T>(SendEqAlias<T>);
  |               ^^^^^^^^^^^^^^ help: use `dyn`: `dyn SendEqAlias<T>`
  |
  = note: `#[warn(bare_trait_objects)]` on by default

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | / trait SendEqAlias<T> = PartialEq;
2 | | struct Foo;
3 | | struct Bar<T>(SendEqAlias<T>);
  | |______________________________^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error: internal compiler error: compiler/rustc_typeck/src/variance/constraints.rs:332:17: unexpected type encountered in variance inference: FreshTy(0)

thread 'rustc' panicked at 'Box<Any>', /rustc/8f349be27815d43d462a32faeb270a22a68486b6/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.52.0-nightly (8f349be27 2021-03-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [crate_variances] computing the variances for items in this crate
#1 [variances_of] computing the variances of `Foo`
end of query stack

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)
Backtrace

error[E0658]: trait aliases are experimental
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | trait SendEqAlias<T> = PartialEq;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
  = help: add `#![feature(trait_alias)]` to the crate attributes to enable

warning: trait objects without an explicit `dyn` are deprecated
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:15
  |
3 | struct Bar<T>(SendEqAlias<T>);
  |               ^^^^^^^^^^^^^^ help: use `dyn`: `dyn SendEqAlias<T>`
  |
  = note: `#[warn(bare_trait_objects)]` on by default

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | / trait SendEqAlias<T> = PartialEq;
2 | | struct Foo;
3 | | struct Bar<T>(SendEqAlias<T>);
  | |______________________________^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error: internal compiler error: compiler/rustc_typeck/src/variance/constraints.rs:332:17: unexpected type encountered in variance inference: FreshTy(0)

thread 'rustc' panicked at 'Box<Any>', /rustc/8f349be27815d43d462a32faeb270a22a68486b6/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_typeck::variance::constraints::ConstraintContext::add_constraints_from_ty
   8: rustc_typeck::variance::constraints::ConstraintContext::add_constraints_from_invariant_substs
   9: rustc_typeck::variance::constraints::ConstraintContext::add_constraints_from_ty
  10: rustc_typeck::variance::constraints::ConstraintContext::visit_node_helper
  11: <rustc_typeck::variance::constraints::ConstraintContext as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  12: rustc_hir::hir::Crate::visit_all_item_likes
  13: rustc_typeck::variance::constraints::add_constraints_from_crate
  14: rustc_typeck::variance::crate_variances
  15: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::crate_variances>::compute
  16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  17: rustc_data_structures::stack::ensure_sufficient_stack
  18: rustc_query_system::query::plumbing::force_query_with_job
  19: rustc_query_system::query::plumbing::get_query_impl
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::crate_variances
  21: rustc_typeck::variance::variances_of
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::variances_of
  27: rustc_typeck::check::wfcheck::check_variances_for_type_defn
  28: rustc_typeck::check::wfcheck::check_item_well_formed
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_query_system::query::plumbing::force_query_with_job
  31: rustc_query_system::query::plumbing::get_query_impl
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_item_well_formed
  33: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::intravisit::Visitor>::visit_item
  34: rustc_data_structures::sync::par_for_each_in
  35: rustc_hir::hir::Crate::par_visit_all_item_likes
  36: rustc_session::session::Session::track_errors
  37: rustc_typeck::check_crate
  38: rustc_interface::passes::analysis
  39: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  40: rustc_data_structures::stack::ensure_sufficient_stack
  41: rustc_query_system::query::plumbing::force_query_with_job
  42: rustc_query_system::query::plumbing::get_query_impl
  43: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  44: rustc_interface::passes::QueryContext::enter
  45: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  46: rustc_span::with_source_map
  47: rustc_interface::interface::create_compiler_and_run
  48: rustc_span::with_session_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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.52.0-nightly (8f349be27 2021-03-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [crate_variances] computing the variances for items in this crate
#1 [variances_of] computing the variances of `Foo`
#2 [check_item_well_formed] checking that `Foo` is well-formed
#3 [analysis] running analysis passes on this crate
end of query stack

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

Metadata

Assignees

No one assigned

    Labels

    A-varianceArea: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions