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

rustc panic after failing to resolve trait fn return lifetime #48963

Closed
scowcron opened this issue Mar 12, 2018 · 2 comments
Closed

rustc panic after failing to resolve trait fn return lifetime #48963

scowcron opened this issue Mar 12, 2018 · 2 comments
Labels
A-traits Area: Trait system 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.

Comments

@scowcron
Copy link

I have no idea if what I'm trying to do is even reasonable, but the compiler crash should probably be addressed.

I tried this code:

trait Broken<'a> {
    const LEN: usize;
    fn buf() -> &'a [u8; Broken::LEN];
    fn buf_mut() -> &'a mut [u8; Broken::LEN];
}

I expected to see this happen:

The same failure, but without a panic. Note that rustc does not panic when only one of the two methods is provided, although it still cannot resolve the lifetime.

What I hoped would happen:

The const value would be interpreted by the compiler and the impl would need to return a slice of size Broken::LEN

Instead, this happened:

rustc panicked.

Meta

rustc --version --verbose:

rustc 1.26.0-nightly (2789b067d 2018-03-06)
binary: rustc
commit-hash: 2789b067da2ac921b86199bde21dd231ace1da39
commit-date: 2018-03-06
host: x86_64-unknown-linux-gnu
release: 1.26.0-nightly
LLVM version: 6.0

Backtrace:

     Running `rustc --crate-name broken src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=d3500dba229a2885 -C extra-filename=-d3500dba229a2885 --out-dir /path/to/broken/target/debug/deps -C incremental=/path/to/broken/target/debug/incremental -L dependency=/path/to/broken/target/debug/deps`
error[E0283]: type annotations required: cannot resolve `_: Broken<'_>`
 --> src/lib.rs:3:26
  |
3 |     fn buf() -> &'a [u8; Broken::A];
  |                          ^^^^^^^^^
  |
note: required by `Broken::A`
 --> src/lib.rs:2:5
  |
2 |     const A: usize;
  |     ^^^^^^^^^^^^^^^

error: internal compiler error: librustc/traits/trans/mod.rs:62: Encountered ambiguity selecting `Binder(<[type error] as Broken>)` during trans, presuming due to overflow

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:535:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:207
   3: std::panicking::default_hook
             at libstd/panicking.rs:223
   4: core::ops::function::Fn::call
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:403
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: <std::thread::local::LocalKey<T>>::try_with
  11: <std::thread::local::LocalKey<T>>::with
  12: rustc::ty::context::tls::with
  13: rustc::ty::context::tls::with_opt
  14: rustc::session::opt_span_bug_fmt
  15: rustc::session::bug_fmt
  16: rustc::traits::trans::trans_fulfill_obligation
  17: rustc::dep_graph::graph::DepGraph::with_task_impl
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::trans_fulfill_obligation<'tcx>>::force
  19: rustc::ty::maps::<impl rustc::ty::maps::queries::trans_fulfill_obligation<'tcx>>::try_get
  20: rustc::ty::maps::TyCtxtAt::trans_fulfill_obligation
  21: rustc::ty::instance::Instance::resolve
  22: rustc_const_eval::eval::lookup_const_by_id
  23: rustc_mir::interpret::const_eval::const_eval_provider
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::force
  26: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  27: rustc::ty::maps::TyCtxtAt::const_eval
  28: rustc_const_eval::eval::eval_const_expr_partial
  29: rustc_const_eval::eval::ConstContext::eval
  30: rustc_mir::interpret::const_eval::const_eval_provider
  31: rustc::dep_graph::graph::DepGraph::with_task_impl
  32: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::force
  33: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  34: rustc::ty::maps::TyCtxtAt::const_eval
  35: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
  36: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  37: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  38: rustc::ty::fold::TypeFoldable::fold_with
  39: rustc::infer::InferCtxt::partially_normalize_associated_types_in
  40: rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor::check_associated_item
  41: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_trait_item
  42: rustc_typeck::check_crate::{{closure}}
  43: rustc_typeck::check_crate
  44: rustc::ty::context::TyCtxt::create_and_enter
  45: rustc_driver::driver::compile_input
  46: rustc_driver::run_compiler
If you want more information on this error, try using "rustc --explain E0283"

@scowcron
Copy link
Author

What I was trying to do doesn't work anyway (#44168).

@estebank estebank added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 13, 2018
@XAMPPRocky XAMPPRocky added A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 14, 2018
@dtolnay
Copy link
Member

dtolnay commented Aug 13, 2018

Closing as a duplicate of #48027.

@dtolnay dtolnay closed this as completed Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system 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.
Projects
None yet
Development

No branches or pull requests

4 participants