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

Unconstrained lifetimes allowed with member_constraints/type_alias_impl_trait #74761

Closed
samlich opened this issue Jul 25, 2020 · 1 comment · Fixed by #77345
Closed

Unconstrained lifetimes allowed with member_constraints/type_alias_impl_trait #74761

samlich opened this issue Jul 25, 2020 · 1 comment · Fixed by #77345
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. F-member_constraints `#[feature(member_constraints)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@samlich
Copy link
Contributor

samlich commented Jul 25, 2020

Code

#![feature(member_constraints)]
#![feature(type_alias_impl_trait)]

pub trait A {
  type B;
  fn f(&self) -> Self::B;
}
impl<'a, 'b> A for () {
  type B = impl core::fmt::Debug;

  fn f(&self) -> Self::B {}
}

fn main() {}

Playground

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (5ef299eb9 2020-07-24) running on x86_64-unknown-linux-gnu

Error output

   Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'assertion failed: self.universal_regions.is_universal_region(shorter)', src/librustc_mir/borrow_check/type_check/free_region_relations.rs:377:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I had first seen:

thread 'rustc' panicked at 'assertion failed: self.universal_regions.is_universal_region(longer)', src/librustc_mir/borrow_check/type_check/free_region_relations.rs:379:9

Removing the second lifetime (impl<'a> A for () {) gives the correct error,

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
 --> src/main.rs:8:6
  |
8 | impl<'a> A for () {
  |      ^^ unconstrained lifetime parameter

Additionally, disabling either type_alias_impl_trait or member_constraints still panics (and prompts to enable those features), except in stable where it prompts to enable the features, but does not panic.

Perhaps similar to #57200

Backtrace

Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'assertion failed: self.universal_regions.is_universal_region(shorter)', src/librustc_mir/borrow_check/type_check/free_region_relations.rs:377:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1117
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1508
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:217
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:530
  12: std::panicking::begin_panic
  13: <rustc_mir::borrow_check::type_check::free_region_relations::UniversalRegionRelations as rustc_infer::infer::free_regions::FreeRegionRelations>::sub_free_regions
  14: rustc_infer::infer::InferCtxt::commit_if_ok
  15: rustc_mir::borrow_check::type_check::TypeChecker::eq_opaque_type_and_type
  16: rustc_mir::borrow_check::type_check::type_check
  17: rustc_mir::borrow_check::nll::compute_regions
  18: rustc_mir::borrow_check::do_mir_borrowck
  19: rustc_infer::infer::InferCtxtBuilder::enter
  20: rustc_mir::borrow_check::mir_borrowck
  21: core::ops::function::FnOnce::call_once
  22: 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
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
  27: rustc_hir::intravisit::walk_impl_item_ref
  28: rustc_hir::intravisit::walk_item
  29: rustc_typeck::collect::type_of::type_of
  30: 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
  31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  32: rustc_data_structures::stack::ensure_sufficient_stack
  33: rustc_query_system::query::plumbing::get_query_impl
  34: rustc_query_system::query::plumbing::ensure_query_impl
  35: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  36: rustc_middle::hir::map::Map::visit_item_likes_in_module
  37: rustc_typeck::collect::collect_mod_item_types
  38: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_mod_item_types>::compute
  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::get_query_impl
  42: rustc_query_system::query::plumbing::ensure_query_impl
  43: rustc_session::session::Session::track_errors
  44: rustc_typeck::check_crate
  45: rustc_interface::passes::analysis
  46: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  47: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  48: rustc_data_structures::stack::ensure_sufficient_stack
  49: rustc_query_system::query::plumbing::get_query_impl
  50: rustc_middle::ty::context::tls::enter_global
  51: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  52: rustc_span::with_source_map
  53: rustc_interface::interface::create_compiler_and_run
  54: 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.47.0-nightly (5ef299eb9 2020-07-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `<() as A>::f`
#1 [type_of] computing type of `<() as A>::B::{{opaque}}#0`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`.

To learn more, run the command again with --verbose.

@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 Jul 25, 2020
@jonas-schievink jonas-schievink added F-member_constraints `#[feature(member_constraints)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 25, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 3, 2020
@JohnTitor
Copy link
Member

The ICE is fixed in the latest nightly, marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 29, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 30, 2020
…as-schievink

Rollup of 12 pull requests

Successful merges:

 - rust-lang#77037 (more tiny clippy cleanups)
 - rust-lang#77233 (BTreeMap: keep an eye out on the size of the main components)
 - rust-lang#77280 (Ensure that all LLVM components requested by tests are available on CI)
 - rust-lang#77284 (library: Forward compiler-builtins "mem" feature)
 - rust-lang#77296 (liveness: Use Option::None to represent absent live nodes)
 - rust-lang#77322 (Add unstable book docs for `-Zunsound-mir-opts`)
 - rust-lang#77328 (Use `rtassert!` instead of `assert!` from the child process after fork() in std::sys::unix::process::Command::spawn())
 - rust-lang#77331 (Add test for async/await combined with const-generics.)
 - rust-lang#77338 (Fix typo in alloc vec comment)
 - rust-lang#77340 (Alloc vec use imported path)
 - rust-lang#77345 (Add test for issue rust-lang#74761)
 - rust-lang#77348 (Update books)

Failed merges:

r? `@ghost`
@bors bors closed this as completed in 4202c60 Sep 30, 2020
@oli-obk oli-obk moved this from Todo to Done in type alias impl trait stabilization Sep 9, 2022
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. F-member_constraints `#[feature(member_constraints)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

4 participants