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 with unknown variable in closure and impl trait in type alias #82139

Closed
MForster opened this issue Feb 15, 2021 · 3 comments · Fixed by #94081
Closed

ICE with unknown variable in closure and impl trait in type alias #82139

MForster opened this issue Feb 15, 2021 · 3 comments · Fixed by #94081
Labels
A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. 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) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@MForster
Copy link

The code below produces an internal compiler error on the current nightly. The bug was already present on a ~2 weeks old nightly.

Note that while this ICE was found while writing code using #![feature(type_alias_impl_trait)], it also manifests itself when the unstable feature is turned off.

Code

trait Trait {
    type Associated;
    fn func() -> Self::Associated;
}

trait Bound {}
pub struct Struct;

impl Trait for Struct {
    type Associated = impl Bound;

    fn func() -> Self::Associated {
        Some(42).map(|_| j)
    }
}

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (5fa22fe6f 2021-02-14)
binary: rustc
commit-hash: 5fa22fe6f821ac3801d05f624b123dda25fde32c
commit-date: 2021-02-14
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

Error output

error: internal compiler error: compiler/rustc_mir/src/borrow_check/universal_regions.rs:533:26: expected defining type for `DefId(0:13 ~ bug[fad1]::{impl#0}::func::{closure#0})`: `[type error]`
  --> src/lib.rs:13:22
   |
13 |         Some(42).map(|_| j)
   |                      ^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/5fa22fe6f821ac3801d05f624b123dda25fde32c/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 (5fa22fe6f 2021-02-14) 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 [mir_borrowck] borrow-checking `<Struct as Trait>::func::{closure#0}`
#1 [type_of] computing type of `<Struct as Trait>::Associated::{opaque#0}`
end of query stack
Backtrace

thread 'rustc' panicked at 'Box<Any>', /rustc/5fa22fe6f821ac3801d05f624b123dda25fde32c/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::span_bug
   3: rustc_errors::Handler::span_bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::span_bug_fmt
   7: rustc_mir::borrow_check::universal_regions::UniversalRegions::new
   8: rustc_mir::borrow_check::nll::replace_regions_in_mir
   9: rustc_mir::borrow_check::do_mir_borrowck
  10: rustc_infer::infer::InferCtxtBuilder::enter
  11: rustc_mir::borrow_check::mir_borrowck
  12: 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
  13: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::force_query_with_job
  17: rustc_query_system::query::plumbing::get_query_impl
  18: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
  19: <rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_expr
  20: rustc_hir::intravisit::walk_expr
  21: rustc_hir::intravisit::Visitor::visit_nested_body
  22: rustc_hir::intravisit::Visitor::visit_fn
  23: rustc_hir::intravisit::walk_impl_item
  24: rustc_hir::intravisit::Visitor::visit_nested_impl_item
  25: rustc_hir::intravisit::walk_impl_item_ref
  26: rustc_hir::intravisit::walk_item
  27: rustc_typeck::collect::type_of::type_of
  28: 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
  29: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  31: rustc_data_structures::stack::ensure_sufficient_stack
  32: rustc_query_system::query::plumbing::force_query_with_job
  33: rustc_query_system::query::plumbing::get_query_impl
  34: rustc_typeck::check::check::check_item_type
  35: rustc_middle::hir::map::Map::visit_item_likes_in_module
  36: rustc_typeck::check::check::check_mod_item_types
  37: 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
  38: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  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_system::query::plumbing::ensure_query_impl
  44: rustc_session::utils::<impl rustc_session::session::Session>::time
  45: rustc_typeck::check_crate
  46: rustc_interface::passes::analysis
  47: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  48: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  49: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  50: rustc_data_structures::stack::ensure_sufficient_stack
  51: rustc_query_system::query::plumbing::force_query_with_job
  52: rustc_query_system::query::plumbing::get_query_impl
  53: rustc_interface::passes::QueryContext::enter
  54: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  55: rustc_span::with_source_map
  56: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@MForster MForster 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 Feb 15, 2021
@MForster
Copy link
Author

The bug is also present in stable rust:

rustc --version --verbose:

rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-unknown-linux-gnu
release: 1.50.0

@jyn514 jyn514 added the A-associated-items Area: Associated items such as associated types and consts. label Feb 15, 2021
@jonas-schievink jonas-schievink added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 15, 2021
@hameerabbasi
Copy link
Contributor

Bisected with cargo-bisect-rustc

********************************************************************************
Regression in nightly-2020-02-16
********************************************************************************

fetching https://static.rust-lang.org/dist/2020-02-15/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-02-15: 40 B / 40 B [===============] 100.00 % 664.77 KB/s converted 2020-02-15 to 433aae93e4ef866a1fdfefad136b32ed89acd3e7
fetching https://static.rust-lang.org/dist/2020-02-16/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-02-16: 40 B / 40 B [===============] 100.00 % 674.07 KB/s converted 2020-02-16 to 61d9231ff2604a0467987042d9ebf9ff9ea739b5
looking for regression commit between 2020-02-15 and 2020-02-16
cloning rust repository
fetching (via local git) commits from 433aae93e4ef866a1fdfefad136b32ed89acd3e7 to 61d9231ff2604a0467987042d9ebf9ff9ea739b5
opening existing repository at "rust.git"
refreshing repository
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 5 bors merge commits in the specified range
  commit[0] 2020-02-14UTC: Auto merge of #69115 - ehuss:update-books, r=Dylan-DPC
  commit[1] 2020-02-14UTC: Auto merge of #69172 - JohnTitor:rollup-6cbmwcw, r=JohnTitor
  commit[2] 2020-02-15UTC: Auto merge of #67681 - matthewjasper:infer-regions-in-borrowck, r=nikomatsakis
  commit[3] 2020-02-15UTC: Auto merge of #69182 - Dylan-DPC:rollup-ifsa9fx, r=Dylan-DPC
  commit[4] 2020-02-15UTC: Auto merge of #69168 - brainlock:test-textrel-regression, r=Mark-Simulacrum,tmandry
ERROR: no commits between 433aae93e4ef866a1fdfefad136b32ed89acd3e7 and 61d9231ff2604a0467987042d9ebf9ff9ea739b5 within last 167 days

fanninpm added a commit to fanninpm/glacier that referenced this issue Feb 16, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 16, 2021
@apiraino
Copy link
Contributor

Assigning P-low as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. 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) ❄️ P-low Low priority 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.

7 participants