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 elided lifetimes suggestion: !suggestion.is_empty() #91763

Closed
dtolnay opened this issue Dec 10, 2021 · 4 comments · Fixed by #91764
Closed

ICE in elided lifetimes suggestion: !suggestion.is_empty() #91763

dtolnay opened this issue Dec 10, 2021 · 4 comments · Fixed by #91764
Assignees
Labels
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-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 10, 2021

# Cargo.toml

[package]
name = "repro"
version = "0.0.0"
edition = "2018"
publish = false

[lib]
proc-macro = true
// src/main.rs

#![deny(elided_lifetimes_in_paths)]

#[repro::repro]
fn f() -> Ptr<Thing>;

fn main() {}
// src/lib.rs

use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
use std::iter::FromIterator;

#[proc_macro_attribute]
pub fn repro(_args: TokenStream, input: TokenStream) -> TokenStream {
    let call_site = Span::call_site();
    let span = input.into_iter().nth(8).unwrap().span();

    //fn f(_: &::std::fmt::Formatter) {}
    TokenStream::from_iter([
        TokenTree::Ident(Ident::new("fn", call_site)),
        TokenTree::Ident(Ident::new("f", call_site)),
        TokenTree::Group(Group::new(
            Delimiter::Parenthesis,
            TokenStream::from_iter([
                TokenTree::Ident(Ident::new("_", call_site)),
                TokenTree::Punct(punct(':', Spacing::Alone, call_site)),
                TokenTree::Punct(punct('&', Spacing::Alone, call_site)),
                TokenTree::Punct(punct(':', Spacing::Joint, span)),
                TokenTree::Punct(punct(':', Spacing::Alone, span)),
                TokenTree::Ident(Ident::new("std", span)),
                TokenTree::Punct(punct(':', Spacing::Joint, span)),
                TokenTree::Punct(punct(':', Spacing::Alone, span)),
                TokenTree::Ident(Ident::new("fmt", span)),
                TokenTree::Punct(punct(':', Spacing::Joint, span)),
                TokenTree::Punct(punct(':', Spacing::Alone, span)),
                TokenTree::Ident(Ident::new("Formatter", span)),
            ]),
        )),
        TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
    ])
}

fn punct(ch: char, spacing: Spacing, span: Span) -> Punct {
    let mut punct = Punct::new(ch, spacing);
    punct.set_span(span);
    punct
}

cargo +nightly-2021-12-02 check (this is what I would expect)

error: hidden lifetime parameters in types are deprecated
 --> src/main.rs:4:20
  |
4 | fn f() -> Ptr<Thing>;
  |                    ^- help: indicate the anonymous lifetime: `<'_>`
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(elided_lifetimes_in_paths)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `repro` due to previous error

cargo +nightly-2021-12-03 check

thread 'rustc' panicked at 'assertion failed: !suggestion.is_empty()', compiler/rustc_errors/src/diagnostic.rs:342:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.59.0-nightly (acbe4443c 2021-12-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolve_lifetimes] resolving lifetimes
#1 [named_region_map] looking up a named region
end of query stack
error: could not compile `repro`
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/acbe4443cc4c9695c0b74a7b64b60333c990a400/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/acbe4443cc4c9695c0b74a7b64b60333c990a400/library/core/src/panicking.rs:107:14
   2: core::panicking::panic
             at /rustc/acbe4443cc4c9695c0b74a7b64b60333c990a400/library/core/src/panicking.rs:48:5
   3: <rustc_errors::diagnostic::Diagnostic>::multipart_suggestion_with_style
   4: <rustc_errors::diagnostic_builder::DiagnosticBuilder>::multipart_suggestion_verbose
   5: <rustc_resolve::late::lifetimes::LifetimeContext>::add_missing_lifetime_specifiers_label
   6: <<rustc_resolve::late::lifetimes::LifetimeContext>::report_elided_lifetime_in_ty::{closure#3} as core::ops::function::FnOnce<(rustc_middle::lint::LintDiagnosticBuilder,)>>::call_once::{shim:vtable#0}
   7: rustc_middle::lint::struct_lint_level::struct_lint_level_impl
   8: <rustc_middle::ty::context::TyCtxt>::struct_span_lint_hir::<alloc::vec::Vec<rustc_span::span_encoding::Span>, <rustc_resolve::late::lifetimes::LifetimeContext>::report_elided_lifetime_in_ty::{closure#3}>
   9: <rustc_resolve::late::lifetimes::LifetimeContext>::resolve_elided_lifetimes
  10: <rustc_resolve::late::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_path
  11: <rustc_resolve::late::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_ty
  12: <rustc_resolve::late::lifetimes::LifetimeContext>::visit_fn_like_elision
  13: <rustc_resolve::late::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_fn
  14: rustc_hir::intravisit::walk_item::<rustc_resolve::late::lifetimes::LifetimeContext>
  15: <rustc_resolve::late::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_item
  16: rustc_resolve::late::lifetimes::resolve_lifetimes
  17: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, rustc_middle::middle::resolve_lifetime::ResolveLifetimes>
  18: rustc_data_structures::stack::ensure_sufficient_stack::<(rustc_middle::middle::resolve_lifetime::ResolveLifetimes, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, rustc_middle::middle::resolve_lifetime::ResolveLifetimes>::{closure#3}>
  19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::ArenaCache<rustc_span::def_id::LocalDefId, rustc_middle::middle::resolve_lifetime::ResolveLifetimes>>
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_lifetimes
  21: rustc_resolve::late::lifetimes::resolve_lifetimes_for
  22: <rustc_resolve::late::lifetimes::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  23: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, core::option::Option<&std::collections::hash::map::HashMap<rustc_hir::hir_id::ItemLocalId, rustc_middle::middle::resolve_lifetime::Region, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>
  24: rustc_data_structures::stack::ensure_sufficient_stack::<(core::option::Option<&std::collections::hash::map::HashMap<rustc_hir::hir_id::ItemLocalId, rustc_middle::middle::resolve_lifetime::Region, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, core::option::Option<&std::collections::hash::map::HashMap<rustc_hir::hir_id::ItemLocalId, rustc_middle::middle::resolve_lifetime::Region, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>::{closure#3}>
  25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, core::option::Option<&std::collections::hash::map::HashMap<rustc_hir::hir_id::ItemLocalId, rustc_middle::middle::resolve_lifetime::Region, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>>
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::named_region_map
  27: <rustc_middle::ty::context::TyCtxt>::named_region
  28: rustc_hir::intravisit::walk_ty::<rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector>
  29: rustc_hir::intravisit::walk_fn_decl::<rustc_typeck::collect::has_late_bound_regions::LateBoundRegionsDetector>
  30: rustc_typeck::collect::generics_of
  31: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId, rustc_middle::ty::generics::Generics>
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::generics_of
  33: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  34: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_hir::intravisit::DeepVisitor<rustc_typeck::collect::CollectItemTypesVisitor>>
  35: rustc_typeck::collect::collect_mod_item_types
  36: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, ()>
  37: rustc_data_structures::stack::ensure_sufficient_stack::<((), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, ()>::{closure#3}>
  38: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  39: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::collect_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  40: <rustc_middle::hir::map::Map>::for_each_module::<rustc_typeck::check_crate::{closure#0}::{closure#0}::{closure#0}>
  41: <rustc_session::session::Session>::track_errors::<rustc_typeck::check_crate::{closure#0}, ()>
  42: rustc_typeck::check_crate
  43: rustc_interface::passes::analysis
  44: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
  45: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  46: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  47: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  48: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  49: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  50: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  51: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.59.0-nightly (acbe4443c 2021-12-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolve_lifetimes] resolving lifetimes
#1 [named_region_map] looking up a named region
#2 [generics_of] computing generics of `f`
#3 [collect_mod_item_types] collecting item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack

@dtolnay dtolnay added 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. C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Dec 10, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 10, 2021
@dtolnay
Copy link
Member Author

dtolnay commented Dec 10, 2021

This bisects to #90446@cjgillot @jackh726


regressed nightly: nightly-2021-12-03
searched commit range: 48a5999...acbe444
regressed commit: 76938d6

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc 2021-11-08 --end 2021-12-10 --regress ice -- check 

@matthiaskrgr
Copy link
Member

There was an issue with similar ICE that has been fixed recently #91461
Does this problem still repro with latest nightly rustc 1.59.0-nightly (0b42deacc 2021-12-09) ?

@dtolnay
Copy link
Member Author

dtolnay commented Dec 10, 2021

Yes this one still reproduces as of that nightly, which contains #91634.

@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-nightly Performance or correctness regression from stable to nightly. 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.

5 participants