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: compiler/rustc_middle/src/ty/fold.rs:829:17: Trying to collect bound vars with a bound region: DebruijnIndex(0) BoundRegion { var: 0, kind: BrAnon(0) } #85350

Closed
chengniansun opened this issue May 15, 2021 · 7 comments
Assignees
Labels
C-bug Category: This is a bug. 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

@chengniansun
Copy link

chengniansun commented May 15, 2021

Code

impl FnMut(&Context) for 'tcx {
fn print () -> Self :: Output{ }
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (1025db84a 2021-05-14)
binary: rustc
commit-hash: 1025db84a68b948139b5adcd55da31bce32da8f3
commit-date: 2021-05-14
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

error: lifetime in trait object type must be followed by `+`
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |                          ^^^^

error[E0407]: method `print` is not a member of trait `FnMut`
 --> mutant.rs:2:1
  |
2 | fn print () -> Self :: Output{ }
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FnMut`

error[E0412]: cannot find type `Context` in this scope
 --> mutant.rs:1:13
  |
1 | impl FnMut(&Context) for 'tcx {
  |             ^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::task::Context;
  |

warning: trait objects without an explicit `dyn` are deprecated
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |                          ^^^^ help: use `dyn`: `dyn 'tcx`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

error[E0601]: `main` function not found in crate `mutant`
 --> mutant.rs:1:1
  |
1 | / impl FnMut(&Context) for 'tcx {
2 | | fn print () -> Self :: Output{ }
3 | | }
  | |_^ consider adding a `main` function to `mutant.rs`

error[E0224]: at least one trait is required for an object type
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |                          ^^^^

error[E0261]: use of undeclared lifetime name `'tcx`
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |     -                    ^^^^ undeclared lifetime
  |     |
  |     help: consider introducing lifetime `'tcx` here: `<'tcx>`
  |
  = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0229]: associated type bindings are not allowed here
 --> mutant.rs:1:6
  |
1 | impl FnMut(&Context) for 'tcx {
  |      ^^^^^^^^^^^^^^^ associated type not allowed here

error: internal compiler error: compiler/rustc_middle/src/ty/fold.rs:829:17: Trying to collect bound vars with a bound region: DebruijnIndex(0) BoundRegion { var: 0, kind: BrAnon(0) }

thread 'rustc' panicked at 'Box<Any>', /rustc/1025db84a68b948139b5adcd55da31bce32da8f3/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.54.0-nightly (1025db84a 2021-05-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `<impl at mutant.rs:1:1: 3:2>::print`
#1 [collect_mod_item_types] collecting item types in top-level module
end of query stack
error: aborting due to 8 previous errors; 1 warning emitted

Some errors have detailed explanations: E0224, E0229, E0261, E0407, E0412, E0601.
For more information about an error, try `rustc --explain E0224`.
Backtrace

error: lifetime in trait object type must be followed by `+`
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |                          ^^^^

error[E0407]: method `print` is not a member of trait `FnMut`
 --> mutant.rs:2:1
  |
2 | fn print () -> Self :: Output{ }
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FnMut`

error[E0412]: cannot find type `Context` in this scope
 --> mutant.rs:1:13
  |
1 | impl FnMut(&Context) for 'tcx {
  |             ^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::task::Context;
  |

warning: trait objects without an explicit `dyn` are deprecated
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |                          ^^^^ help: use `dyn`: `dyn 'tcx`
  |
  = note: `#[warn(bare_trait_objects)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
  = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

error[E0601]: `main` function not found in crate `mutant`
 --> mutant.rs:1:1
  |
1 | / impl FnMut(&Context) for 'tcx {
2 | | fn print () -> Self :: Output{ }
3 | | }
  | |_^ consider adding a `main` function to `mutant.rs`

error[E0224]: at least one trait is required for an object type
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |                          ^^^^

error[E0261]: use of undeclared lifetime name `'tcx`
 --> mutant.rs:1:26
  |
1 | impl FnMut(&Context) for 'tcx {
  |     -                    ^^^^ undeclared lifetime
  |     |
  |     help: consider introducing lifetime `'tcx` here: `<'tcx>`
  |
  = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0229]: associated type bindings are not allowed here
 --> mutant.rs:1:6
  |
1 | impl FnMut(&Context) for 'tcx {
  |      ^^^^^^^^^^^^^^^ associated type not allowed here

error: internal compiler error: compiler/rustc_middle/src/ty/fold.rs:829:17: Trying to collect bound vars with a bound region: DebruijnIndex(0) BoundRegion { var: 0, kind: BrAnon(0) }

thread 'rustc' panicked at 'Box<Any>', /rustc/1025db84a68b948139b5adcd55da31bce32da8f3/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_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_visit_with
   8: <rustc_middle::ty::fold::BoundVarsCollector as rustc_middle::ty::fold::TypeVisitor>::visit_ty
   9: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_visit_with
  10: <rustc_middle::ty::fold::BoundVarsCollector as rustc_middle::ty::fold::TypeVisitor>::visit_ty
  11: rustc_middle::ty::sty::Binder<T>::bind
  12: <dyn rustc_typeck::astconv::AstConv>::associated_path_to_ty
  13: <dyn rustc_typeck::astconv::AstConv>::ast_ty_to_ty_inner
  14: <dyn rustc_typeck::astconv::AstConv>::ty_of_fn
  15: rustc_typeck::collect::fn_sig
  16: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::fn_sig>::compute
  17: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  18: rustc_data_structures::stack::ensure_sufficient_stack
  19: rustc_query_system::query::plumbing::force_query_with_job
  20: rustc_query_system::query::plumbing::get_query_impl
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::fn_sig
  22: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_impl_item
  23: rustc_middle::hir::map::Map::visit_item_likes_in_module
  24: rustc_typeck::collect::collect_mod_item_types
  25: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  26: rustc_query_system::query::plumbing::force_query_with_job
  27: rustc_query_system::query::plumbing::get_query_impl
  28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_mod_item_types
  29: rustc_session::session::Session::track_errors
  30: rustc_typeck::check_crate
  31: rustc_interface::passes::analysis
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_data_structures::stack::ensure_sufficient_stack
  34: rustc_query_system::query::plumbing::force_query_with_job
  35: rustc_query_system::query::plumbing::get_query_impl
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  37: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  38: rustc_span::with_source_map
  39: rustc_interface::interface::create_compiler_and_run
  40: scoped_tls::ScopedKey<T>::set
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.54.0-nightly (1025db84a 2021-05-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `<impl at mutant.rs:1:1: 3:2>::print`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 8 previous errors; 1 warning emitted

Some errors have detailed explanations: E0224, E0229, E0261, E0407, E0412, E0601.
For more information about an error, try `rustc --explain E0224`.

@chengniansun chengniansun 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 May 15, 2021
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 15, 2021
@jackh726
Copy link
Member

I imagine this is fairly easy to fix, but can't look into it right now. If someone is interested, ping me here or on Zulip.

@jackh726 jackh726 added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label May 16, 2021
@LeSeulArtichaut LeSeulArtichaut added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label May 16, 2021
@ABouttefeux
Copy link
Contributor

@rustbot claim

@apiraino
Copy link
Contributor

apiraino commented May 19, 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 May 19, 2021
@LeSeulArtichaut LeSeulArtichaut added this to the 1.53.0 milestone May 19, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Jun 11, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jun 12, 2021
@LeSeulArtichaut LeSeulArtichaut 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 Jun 22, 2021
@Alexendoo
Copy link
Member

No longer ICEs since #86795

@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 Jul 4, 2021
@jackh726
Copy link
Member

jackh726 commented Jul 4, 2021

Uh actually this is a problem that I didn't realize.

The debug_assert in Binder::dummy should be an assert.

@JohnTitor do you have the time to open a PR for this? I imagine we'll at the very least see a perf regression. But we might also see test failures or, in cases like this, new issues.

Another alternative that @nikomatsakis and I discussed would be to add a -Zvalidate-binders option that enables the ValidateBoundVars assertions, but if this is too costly, then it's also a good candidate to go under that.

@jackh726
Copy link
Member

jackh726 commented Jul 4, 2021

Going to not mark this as not needs-test, because this shouldn't be passing.

@jackh726 jackh726 removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 4, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 4, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 5, 2021
…=jackh726

Convert `debug_assert!` to `assert!` in `Binder::dummy`

This is needed for rust-lang#85350 not to be passed.
r? `@jackh726`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2022
Return err instead of ICE

Having `escaping_bound_vars` results in ICE when trying to create `ty::Binder::dummy`, to avoid it we return err like the line above. I think this requires a more sophisticated fix, I would love to investigate if mentorship is available 🤓

Fixes rust-lang#95023 and rust-lang#85350
@Alexendoo
Copy link
Member

Fixed by #95085, for real this time I hope 😄

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-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