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

assertion failed: !value.has_escaping_bound_vars() with trait A where for<'a> Self: 'a{} #88586

Closed
mixal-iirec opened this issue Sep 2, 2021 · 6 comments · Fixed by #91308
Closed
Labels
C-bug Category: This is a bug. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@mixal-iirec
Copy link

Code

trait A where
    for<'a> Self: 'a,
{
}

Meta

Stable (1.54.0) works correctly(?) (E0311 the parameter type `Self` may not live long enough with nonsensical help consider adding an explicit lifetime bound `Self: 'a` ).

rustc --version --verbose:

rustc 1.56.0-nightly (50171c310 2021-09-01)
binary: rustc
commit-hash: 50171c310cd15e1b2d3723766ce64e2e4d6696fc
commit-date: 2021-09-01
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/compiler/rustc_middle/src/ty/sty.rs:971:9
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.56.0-nightly (50171c310 2021-09-01) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [super_predicates_that_define_assoc_type] computing the super traits of `A`
#1 [super_predicates_of] computing the super predicates of `A`
end of query stack
Backtrace

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/compiler/rustc_middle/src/ty/sty.rs:971:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/library/core/src/panicking.rs:101:14
   2: core::panicking::panic
             at /rustc/50171c310cd15e1b2d3723766ce64e2e4d6696fc/library/core/src/panicking.rs:50:5
   3: rustc_typeck::collect::predicates_from_bound
   4: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::next
   5: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   6: rustc_typeck::collect::super_predicates_that_define_assoc_type
   7: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   8: rustc_data_structures::stack::ensure_sufficient_stack
   9: rustc_query_system::query::plumbing::get_query_impl
  10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::super_predicates_that_define_assoc_type
  11: rustc_typeck::collect::super_predicates_of
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_query_system::query::plumbing::force_query_with_job
  14: rustc_query_system::query::plumbing::get_query_impl
  15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::super_predicates_of
  16: rustc_typeck::collect::convert_item
  17: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  18: rustc_typeck::collect::collect_mod_item_types
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_query_system::query::plumbing::force_query_with_job
  22: rustc_query_system::query::plumbing::get_query_impl
  23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_mod_item_types
  24: rustc_session::session::Session::track_errors
  25: rustc_typeck::check_crate
  26: rustc_interface::passes::analysis
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  28: rustc_data_structures::stack::ensure_sufficient_stack
  29: rustc_query_system::query::plumbing::force_query_with_job
  30: rustc_query_system::query::plumbing::get_query_impl
  31: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  32: rustc_interface::passes::QueryContext::enter
  33: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  34: rustc_span::with_source_map
  35: 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.56.0-nightly (50171c310 2021-09-01) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [super_predicates_that_define_assoc_type] computing the super traits of `A`
#1 [super_predicates_of] computing the super predicates of `A`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack

@mixal-iirec mixal-iirec 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 Sep 2, 2021
@jackh726 jackh726 added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Sep 2, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Sep 2, 2021
@camelid camelid added this to the 1.55.0 milestone Sep 2, 2021
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Sep 5, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Sep 5, 2021
@apiraino
Copy link
Contributor

apiraino commented Sep 8, 2021

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 8, 2021
@Alexendoo
Copy link
Member

No longer ICEs since #88061

@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 Sep 9, 2021
@jackh726
Copy link
Member

jackh726 commented Sep 9, 2021

Wait really? Neat.

@JohnTitor JohnTitor removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 21, 2021
@JohnTitor
Copy link
Member

This triggers another ICE with debug_assertions as described in #89803.

The relevant part is:

if cfg!(debug_assertions) {
let mut validator = ValidateBoundVars::new(vars);
value.visit_with(&mut validator);
}

And bound_vars is prepared here:

astconv.add_bounds(
param_ty,
std::array::IntoIter::new([bound]),
&mut bounds,
ty::List::empty(),
);

So if I understand correctly, since it's empty, it won't pass the assertion, and validating it doesn't make sense here currently. @jackh726 could we just remove the validation or should we have something in bound_vars?

@JohnTitor JohnTitor added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Oct 21, 2021
@jackh726
Copy link
Member

I very briefly looked at this a few days ago.

We most certainly should be validating here; this is precisely the case that we want to catch. The problem really comes down to

hir::GenericBound::Outlives(lifetime) => {
let region = self.ast_region_to_region(lifetime, None);
bounds
.region_bounds
.push((ty::Binder::bind_with_vars(region, bound_vars), lifetime.span));
}

I think the correct fix here is to just make GenericBound::Outlives have a Binder<Lifetime>. I'm definitely willing to mentor someone here, but don't have time currently to work on this.

@jackh726 jackh726 added E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels Nov 14, 2021
@BGR360
Copy link
Contributor

BGR360 commented Nov 27, 2021

I'd like to take a stab at this. @jackh726 I started a thread on zulip to track mentoring questions. You've given a very good starting point so I'll start reading code to see if it doesn't just click.

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-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

9 participants