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 in rustc_infer error reporting on elided lifetime in extern signature #80468

Closed
dtolnay opened this issue Dec 29, 2020 · 2 comments · Fixed by #80548
Closed

ICE in rustc_infer error reporting on elided lifetime in extern signature #80468

dtolnay opened this issue Dec 29, 2020 · 2 comments · Fixed by #80548
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. 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

@dtolnay
Copy link
Member

dtolnay commented Dec 29, 2020

Repro:

pub trait Trait {}

#[repr(transparent)]
pub struct Wrapper<T: Trait>(T);

#[repr(transparent)]
pub struct Ref<'a>(&'a u8);

impl Trait for Ref {}

extern "C" {
    pub fn repro(_: Wrapper<Ref>);
}

As of current nightly:

$ RUST_BACKTRACE=1 rustc +nightly-2020-12-29 src/lib.rs --crate-type lib
thread 'rustc' panicked at 'internal error: entered unreachable code', compiler/rustc_infer/src/infer/error_reporting/mod.rs:156:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2987785df3d46d5ff144a5c67fbb8f5cca798d78/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2987785df3d46d5ff144a5c67fbb8f5cca798d78/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/2987785df3d46d5ff144a5c67fbb8f5cca798d78/library/core/src/panicking.rs:50:5
   3: rustc_infer::infer::error_reporting::msg_span_from_free_region
   4: rustc_infer::infer::error_reporting::note_and_explain_region
   5: rustc_infer::infer::error_reporting::note::<impl rustc_infer::infer::InferCtxt>::report_concrete_failure
   6: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::report_region_errors
   7: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
   8: rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_item
   9: rustc_infer::infer::InferCtxtBuilder::enter
  10: rustc_typeck::check::wfcheck::check_item_well_formed
  11: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_item_well_formed>::compute
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::get_query_impl
  15: rustc_query_system::query::plumbing::ensure_query_impl
  16: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::itemlikevisit::ParItemLikeVisitor>::visit_item
  17: rustc_data_structures::sync::par_for_each_in
  18: rustc_hir::hir::Crate::par_visit_all_item_likes
  19: rustc_session::session::Session::track_errors
  20: rustc_typeck::check_crate
  21: rustc_interface::passes::analysis
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_interface::passes::QueryContext::enter
  27: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  28: rustc_span::with_source_map
  29: rustc_interface::interface::create_compiler_and_run

note: rustc 1.51.0-nightly (2987785df 2020-12-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_item_well_formed] checking that `` is well-formed
#1 [analysis] running analysis passes on this crate
end of query stack

This is the unreachable line:

The same crash reproduces back to 1.47.0. Older stable compilers do not crash:

$ RUST_BACKTRACE=1 rustc +1.46.0 src/lib.rs --crate-type lib
error[E0726]: implicit elided lifetime not allowed here
 --> src/lib.rs:9:16
  |
9 | impl Trait for Ref {}
  |                ^^^- help: indicate the anonymous lifetime: `<'_>`
@dtolnay dtolnay added A-diagnostics Area: Messages for errors, warnings, and lints 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. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. C-bug Category: This is a bug. labels Dec 29, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 29, 2020
@dtolnay
Copy link
Member Author

dtolnay commented Dec 29, 2020

Bisect:

#!/bin/bash
rustc src/lib.rs --crate-type lib 2>&1 | not grep unreachable

#cargo-bisect-rustc --script=./bisect.sh --without-cargo --start=2020-07-10 --end=2020-08-27

searched nightlies: from nightly-2020-07-10 to nightly-2020-08-27
regressed nightly: nightly-2020-07-22
searched commits: from f9a3086 to 8ad7bc3
regressed commit: 734233d (#74569)

Mentioning @davidtwco @lcnr because #73323 appears the most relevant.

@rylev
Copy link
Member

rylev commented Dec 30, 2020

@rylev rylev added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 30, 2020
@bors bors closed this as completed in 33806d2 Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. 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.

3 participants