Skip to content

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

Closed

Description

@dtolnay

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: `<'_>`

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    C-bugCategory: This is a bug.
    on Dec 29, 2020
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Dec 29, 2020
  3. dtolnay commented on Dec 29, 2020

    @dtolnay
    MemberAuthor

    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.

  4. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Dec 30, 2020
  5. added a commit that references this issue on Dec 31, 2020
    33806d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions