Skip to content

ICE when using lifetime arguments explicitly in late bound lifetime parameters #72278

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
fschutt opened this issue May 16, 2020 · 7 comments · Fixed by #72441
Closed

ICE when using lifetime arguments explicitly in late bound lifetime parameters #72278

fschutt opened this issue May 16, 2020 · 7 comments · Fixed by #72441
Labels
A-type-system Area: Type system C-bug Category: This is a bug. 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.

Comments

@fschutt
Copy link
Contributor

fschutt commented May 16, 2020

Code

Ignore the purpose of the code (it was to create a C-API compatible Box that can be used to and from C) - playground

pub struct RefAny { }

impl RefAny {
    pub fn downcast_mut<'a, U: 'static>(&'a mut self) -> Option<&'a mut U> {
        unsafe { self.downcast_mut_unchecked::<'a, U>() } // <- panic here in lifetime resolution
    }

    unsafe fn downcast_mut_unchecked<'a, U>(&'a mut self) -> Option<&'a mut U> {
        None
    }
}

Meta

rustc --version --verbose:

rustc 1.43.1 (8d69840ab 2020-05-04) running on x86_64-unknown-linux-gnu

Error output

   Compiling playground v0.0.1 (/playground)
warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
  --> src/main.rs:78:52
   |
78 |             unsafe { self.downcast_mut_unchecked::<'a, U>() }
   |                                                    ^^
...
82 |     unsafe fn downcast_mut_unchecked<'a, U>(&'a mut self) -> Option<&'a mut U> {
   |                                      -- the late bound lifetime parameter is introduced here
   |
   = note: `#[warn(late_bound_lifetime_arguments)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>

error: internal compiler error: src/librustc_typeck/check/mod.rs:3314: no type for node HirId { owner: DefIndex(31), local_id: 5 }: type U (hir_id=HirId { owner: DefIndex(31), local_id: 5 }) in fcx 0x7f8e2c3f06e0

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:875:9
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.43.1 (8d69840ab 2020-05-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -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 [typeck_tables_of] type-checking `RefAny::downcast_mut`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `playground`.
Backtrace

error: internal compiler error: src/librustc_typeck/check/mod.rs:3314: no type for node HirId { owner: DefIndex(31), local_id: 5 }: type U (hir_id=HirId { owner: DefIndex(31), local_id: 5 }) in fcx 0x7fe1f35f06e0

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:875:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.heygears.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.heygears.com-1ecc6299db9ec823/backtrace-0.3.44/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:1063
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   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:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc_typeck::check::FnCtxt::node_ty
  21: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_ty
  22: rustc_hir::intravisit::walk_generic_args
  23: rustc_hir::intravisit::walk_expr
  24: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  25: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  26: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  27: rustc_hir::intravisit::walk_expr
  28: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  29: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  30: rustc_typeck::check::writeback::<impl rustc_typeck::check::FnCtxt>::resolve_type_vars_in_body
  31: rustc::ty::context::GlobalCtxt::enter_local
  32: rustc_typeck::check::typeck_tables_of
  33: rustc::ty::query::__query_compute::typeck_tables_of
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  38: rustc_typeck::check::typeck_item_bodies
  39: rustc::ty::query::__query_compute::typeck_item_bodies
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  42: rustc_typeck::check_crate
  43: rustc_interface::passes::analysis
  44: rustc::ty::query::__query_compute::analysis
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc::ty::context::tls::enter_global
  48: rustc_interface::interface::run_compiler_in_existing_thread_pool
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@fschutt fschutt 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 16, 2020
@fschutt
Copy link
Contributor Author

fschutt commented May 16, 2020

It doesn't panic when the <'a, U> is removed:

changing:

unsafe { self.downcast_mut_unchecked::<'a, U>() }

to:

unsafe { self.downcast_mut_unchecked() }

@jonas-schievink jonas-schievink added A-type-system Area: Type system I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 16, 2020
@csmoe
Copy link
Member

csmoe commented May 17, 2020

related to #42868 cc @petrochenkov

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 17, 2020
@hellow554
Copy link
Contributor

"simplified"

struct S;

impl S {
    fn func<'a, U>(&'a self) -> U {
        todo!()
    }
}

fn crash<'a, U>() -> U {
    S.func::<'a, U>()
}

@spastorino
Copy link
Member

This starts ICEing in 1.43.0, so it's a stable to stable regression.

@spastorino spastorino added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label May 19, 2020
@spastorino
Copy link
Member

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

@spastorino spastorino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 19, 2020
@doctorn
Copy link
Contributor

doctorn commented May 21, 2020

I think I have a fix for this (will open a PR when I've run the test bench - just updating LLVM)

@doctorn
Copy link
Contributor

doctorn commented May 21, 2020

PR is up: #72441

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system C-bug Category: This is a bug. 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.

7 participants