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

ICE: NLL region is not an ReVar: ReEarlyBound(0, 'a) with type_alias_impl_trait and particular type parameter bounds #78561

Closed
samlich opened this issue Oct 30, 2020 · 3 comments · Fixed by #90115
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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

@samlich
Copy link
Contributor

samlich commented Oct 30, 2020

Code

Playground stable: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=56aa005452055e07bce498e36cbad72b
Playground nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7e80ca3b1ec7abe08f60c41aff91f060

Somewhat similar to #78450
Edit: Actually, it's identical except this is with two lifetimes.
Edit 2: And this one crashes stable, while the other does not.

#![feature(type_alias_impl_trait, member_constraints)]

pub trait Trait {
    type A;

    fn f() -> Self::A;
}

pub trait Tr2<'a, 'b> {}

pub struct A<T>(T);
pub trait Tr {
    type B;
}

impl<'a, 'b, T: Tr<B = dyn Tr2<'a, 'b>>> Trait for A<T> {
    type A = impl core::fmt::Debug;

    fn f() -> Self::A {}
}

Also crashes without enabling features, and complains that

error: ambiguous lifetime bound in `impl Trait`
  --> src/lib.rs:18:14
   |
18 |     type A = impl core::fmt::Debug;
   |              ^^^^^^^^^^^^^^^^^^^^^ neither `'a` nor `'b` outlives the other
   |
   = help: add #![feature(member_constraints)] to the crate attributes to enable

However, constraining 'b: 'a removes this error, but not the crash. Two lifetimes are required for the crash.

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (6bdae9edd 2020-10-29)
binary: rustc
commit-hash: 6bdae9edd0cc099daa6038bca469dc09b6fc078a
commit-date: 2020-10-29
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Also crashes on Rust Playground with stable rustc 1.47.0 (18bf6b4f0 2020-10-07) running on x86_64-unknown-linux-gnu

Error output

     Running `rustc --crate-name revar --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=e78049d190dc1b43 -C extra-filename=-e78049d190dc1b43 --out-dir /home/s/.cargo_target/debug/deps -C incremental=/home/s/.cargo_target/debug/incremental -L dependency=/home/s/.cargo_target/debug/deps -C link-arg=-fuse-ld=lld`
error: internal compiler error: compiler/rustc_mir/src/borrow_check/nll.rs:444:54: region is not an ReVar: ReEarlyBound(0, 'a)

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
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.49.0-nightly (6bdae9edd 2020-10-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C link-arg=-fuse-ld=lld --crate-type lib

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `<A<T> as Trait>::f`
#1 [type_of] computing type of `<A<T> as Trait>::A::{opaque#0}`
end of query stack
error: aborting due to previous error

error: could not compile `revar`

Caused by:
  process didn't exit successfully: `rustc --crate-name revar --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=e78049d190dc1b43 -C extra-filename=-e78049d190dc1b43 --out-dir /home/s/.cargo_target/debug/deps -C incremental=/home/s/.cargo_target/debug/incremental -L dependency=/home/s/.cargo_target/debug/deps -C link-arg=-fuse-ld=lld` (exit code: 101)
Backtrace

stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: <rustc_mir::borrow_check::type_check::free_region_relations::UniversalRegionRelations as rustc_infer::infer::free_regions::FreeRegionRelations>::sub_free_regions
   9: rustc_infer::infer::InferCtxt::commit_if_ok
  10: <rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp<F,G> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
  11: rustc_mir::borrow_check::type_check::TypeChecker::eq_opaque_type_and_type
  12: rustc_mir::borrow_check::type_check::type_check
  13: rustc_mir::borrow_check::nll::compute_regions
  14: rustc_mir::borrow_check::do_mir_borrowck
  15: rustc_infer::infer::InferCtxtBuilder::enter
  16: rustc_mir::borrow_check::mir_borrowck
  17: core::ops::function::FnOnce::call_once
  18: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  19: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  21: rustc_data_structures::stack::ensure_sufficient_stack
  22: rustc_query_system::query::plumbing::get_query_impl
  23: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
  24: rustc_hir::intravisit::walk_impl_item_ref
  25: rustc_hir::intravisit::walk_item
  26: rustc_typeck::collect::type_of::type_of
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::type_of>::compute
  28: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::get_query_impl
  32: rustc_typeck::check::check::check_item_type
  33: rustc_middle::hir::map::Map::visit_item_likes_in_module
  34: rustc_typeck::check::check::check_mod_item_types
  35: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute
  36: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_data_structures::stack::ensure_sufficient_stack
  39: rustc_query_system::query::plumbing::get_query_impl
  40: rustc_query_system::query::plumbing::ensure_query_impl
  41: rustc_session::utils::<impl rustc_session::session::Session>::time
  42: rustc_typeck::check_crate
  43: rustc_interface::passes::analysis
  44: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  45: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  46: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  47: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  48: rustc_query_system::query::plumbing::get_query_impl
  49: rustc_interface::passes::QueryContext::enter
  50: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  51: rustc_span::with_source_map
  52: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@samlich samlich 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 Oct 30, 2020
@jonas-schievink jonas-schievink added the F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` label Oct 30, 2020
@camelid
Copy link
Member

camelid commented Oct 30, 2020

rustbot added a commit to rustbot/glacier that referenced this issue Oct 30, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 12, 2020
@matthiaskrgr
Copy link
Member

Seems related to 08e2d46

@Alexendoo
Copy link
Member

No longer ICEs since #89229

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 20, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 21, 2021
Add test for issue rust-lang#78561

Adds test for and closes rust-lang#78561 which previously crashed compiler.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 21, 2021
Add test for issue rust-lang#78561

Adds test for and closes rust-lang#78561 which previously crashed compiler.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 22, 2021
Add test for issue rust-lang#78561

Adds test for and closes rust-lang#78561 which previously crashed compiler.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 22, 2021
Add test for issue rust-lang#78561

Adds test for and closes rust-lang#78561 which previously crashed compiler.
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 22, 2021
Rollup of 14 pull requests

Successful merges:

 - rust-lang#87537 (Clarify undefined behaviour in binary heap, btree and hashset docs)
 - rust-lang#88624 (Stabilize feature `saturating_div` for rust 1.58.0)
 - rust-lang#89257 (Give better error for `macro_rules name`)
 - rust-lang#89665 (Ensure that pushing empty path works as before on verbatim paths)
 - rust-lang#89895 (Don't mark for loop iter expression as desugared)
 - rust-lang#89922 (Update E0637 description to mention `&` w/o an explicit lifetime name)
 - rust-lang#89944 (Change `Duration::[try_]from_secs_{f32, f64}` underflow error)
 - rust-lang#89991 (rustc_ast: Turn `MutVisitor::token_visiting_enabled` into a constant)
 - rust-lang#90028 (Reject closures in patterns)
 - rust-lang#90069 (Fix const qualification when executed after promotion)
 - rust-lang#90078 (Add a regression test for issue-83479)
 - rust-lang#90114 (Add some tests for const_generics_defaults)
 - rust-lang#90115 (Add test for issue rust-lang#78561)
 - rust-lang#90129 (triagebot: Treat `I-*nominated` like `I-nominated`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in a741f68 Oct 22, 2021
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. 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.

6 participants