Skip to content

ICE: clippy: cannot relate region: ReErased, -Wclippy::needless_pass_by_value #107147

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

Closed
matthiaskrgr opened this issue Jan 21, 2023 · 5 comments · Fixed by rust-lang/rust-clippy#10328
Assignees
Labels
A-clippy Area: Clippy I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

Code: tests/ui/associated-type-bounds/enum-bounds.rs

// run-pass

#![feature(associated_type_bounds)]
#![allow(dead_code)]

trait Tr1 { type As1; }
trait Tr2 { type As2; }

impl Tr1 for &str { type As1 = bool; }
impl Tr2 for bool { type As2 = u8; }

enum _En7<'a, 'b, T> // `<T::As1 as Tr2>::As2: 'a` is implied.
where
    T: Tr1<As1: Tr2>,
{
    V0(&'a T),
    V1(&'b <T::As1 as Tr2>::As2),
}

fn _make_en7<'a, 'b, T>(x: _En7<'a, 'b, T>)
where
    T: Tr1<As1: Tr2>,
{
    match x {
        _En7::V0(x) => {
            let _: &'a T = &x;
        },
        _ => {},
    }
}

fn main() {}

exec: clippy-driver enum-bounds.rs -Wclippy::needless_pass_by_value

This crashes since 94a300b cc @compiler-errors

backtrace:

error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:203:17: cannot relate region: ReErased

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/compiler/rustc_errors/src/lib.rs:1609:9
stack backtrace:
   0:     0x7f8b91b653ca - std::backtrace_rs::backtrace::libunwind::trace::h2ca2e0eba5cfe8d9
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8b91b653ca - std::backtrace_rs::backtrace::trace_unsynchronized::h98bd949b8b0b35d4
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8b91b653ca - std::sys_common::backtrace::_print_fmt::hed7d87ad527ea338
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8b91b653ca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h574062ba946b9368
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8b91bc867e - core::fmt::write::h77be6e6d2f1c648a
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/core/src/fmt/mod.rs:1213:17
   5:     0x7f8b91b55b15 - std::io::Write::write_fmt::he75a05bbfafcedff
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/io/mod.rs:1682:15
   6:     0x7f8b91b65195 - std::sys_common::backtrace::_print::hf835dc8d93029605
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8b91b65195 - std::sys_common::backtrace::print::h69c58f82a106c19a
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f8b91b67f5f - std::panicking::default_hook::{{closure}}::h6a8b639b2d2d78cb
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/panicking.rs:267:22
   9:     0x7f8b91b67c9b - std::panicking::default_hook::h5c4555cd2fc1f2a2
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/panicking.rs:286:9
  10:     0x560d54d9f170 - clippy_driver[965cec86cb767e44]::ICE_HOOK::{closure#0}::{closure#0}
  11:     0x7f8b91b6879a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbd2046e382430105
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/alloc/src/boxed.rs:2002:9
  12:     0x7f8b91b6879a - std::panicking::rust_panic_with_hook::h5032b74b3a6755cc
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/panicking.rs:692:13
  13:     0x7f8b953ce151 - std[e5194df39356a98b]::panicking::begin_panic::<rustc_errors[9a263acecc8f02b5]::ExplicitBug>::{closure#0}
  14:     0x7f8b953cada6 - std[e5194df39356a98b]::sys_common::backtrace::__rust_end_short_backtrace::<std[e5194df39356a98b]::panicking::begin_panic<rustc_errors[9a263acecc8f02b5]::ExplicitBug>::{closure#0}, !>
  15:     0x7f8b9542fb76 - std[e5194df39356a98b]::panicking::begin_panic::<rustc_errors[9a263acecc8f02b5]::ExplicitBug>
  16:     0x7f8b953e7c06 - std[e5194df39356a98b]::panic::panic_any::<rustc_errors[9a263acecc8f02b5]::ExplicitBug>
  17:     0x7f8b953e58e6 - <rustc_errors[9a263acecc8f02b5]::HandlerInner>::bug::<&alloc[b4a1ac6178dd424a]::string::String>
  18:     0x7f8b953e4720 - <rustc_errors[9a263acecc8f02b5]::Handler>::bug::<&alloc[b4a1ac6178dd424a]::string::String>
  19:     0x7f8b953f491b - rustc_middle[356745a150da3aac]::util::bug::opt_span_bug_fmt::<rustc_span[2d977aba4a48af86]::span_encoding::Span>::{closure#0}
  20:     0x7f8b953f1cba - rustc_middle[356745a150da3aac]::ty::context::tls::with_opt::<rustc_middle[356745a150da3aac]::util::bug::opt_span_bug_fmt<rustc_span[2d977aba4a48af86]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f8b953f1c8a - rustc_middle[356745a150da3aac]::ty::context::tls::with_context_opt::<rustc_middle[356745a150da3aac]::ty::context::tls::with_opt<rustc_middle[356745a150da3aac]::util::bug::opt_span_bug_fmt<rustc_span[2d977aba4a48af86]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f8b953f4866 - rustc_middle[356745a150da3aac]::util::bug::opt_span_bug_fmt::<rustc_span[2d977aba4a48af86]::span_encoding::Span>
  23:     0x7f8b93171953 - rustc_middle[356745a150da3aac]::util::bug::bug_fmt
  24:     0x7f8b93a1dbf5 - <rustc_infer[8fc7a53e61725adb]::infer::lexical_region_resolve::LexicalResolver>::lub_empty
  25:     0x7f8b93a1d990 - <rustc_infer[8fc7a53e61725adb]::infer::lexical_region_resolve::LexicalResolver>::expand_node
  26:     0x7f8b93a1a029 - rustc_infer[8fc7a53e61725adb]::infer::lexical_region_resolve::resolve
  27:     0x7f8b93a191e8 - <rustc_infer[8fc7a53e61725adb]::infer::InferCtxt>::resolve_regions
  28:     0x7f8b93c8343b - rustc_trait_selection[49386bab22c0fb1d]::traits::misc::type_allowed_to_implement_copy
  29:     0x560d5503e9c0 - <clippy_utils[51b63d5ba4e51333]::diagnostics::span_lint_and_then<rustc_lint[ab8d78263ddfc922]::context::LateContext, rustc_span[2d977aba4a48af86]::span_encoding::Span, <clippy_lints[5b11773baa9bac1c]::needless_pass_by_value::NeedlessPassByValue as rustc_lint[ab8d78263ddfc922]::passes::LateLintPass>::check_fn::{closure#6}>::{closure#0} as core[749018e742f43565]::ops::function::FnOnce<(&mut rustc_errors[9a263acecc8f02b5]::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once::{shim:vtable#0}
  30:     0x560d55027f14 - rustc_middle[356745a150da3aac]::lint::struct_lint_level::struct_lint_level_impl::<&str>
  31:     0x560d54ea800e - <rustc_middle[356745a150da3aac]::ty::context::TyCtxt>::struct_span_lint_hir::<rustc_span[2d977aba4a48af86]::span_encoding::Span, &str, clippy_utils[51b63d5ba4e51333]::diagnostics::span_lint_and_then<rustc_lint[ab8d78263ddfc922]::context::LateContext, rustc_span[2d977aba4a48af86]::span_encoding::Span, <clippy_lints[5b11773baa9bac1c]::needless_pass_by_value::NeedlessPassByValue as rustc_lint[ab8d78263ddfc922]::passes::LateLintPass>::check_fn::{closure#6}>::{closure#0}>
  32:     0x560d550577d6 - <clippy_lints[5b11773baa9bac1c]::needless_pass_by_value::NeedlessPassByValue as rustc_lint[ab8d78263ddfc922]::passes::LateLintPass>::check_fn
  33:     0x7f8b95298fdf - <rustc_lint[ab8d78263ddfc922]::late::RuntimeCombinedLateLintPass as rustc_lint[ab8d78263ddfc922]::passes::LateLintPass>::check_fn
  34:     0x7f8b9522610b - <rustc_lint[ab8d78263ddfc922]::late::LateContextAndPass<rustc_lint[ab8d78263ddfc922]::late::RuntimeCombinedLateLintPass> as rustc_hir[71d429f827444320]::intravisit::Visitor>::visit_fn
  35:     0x7f8b951fd2fd - rustc_hir[71d429f827444320]::intravisit::walk_item::<rustc_lint[ab8d78263ddfc922]::late::LateContextAndPass<rustc_lint[ab8d78263ddfc922]::late::RuntimeCombinedLateLintPass>>
  36:     0x7f8b95226663 - <rustc_lint[ab8d78263ddfc922]::late::LateContextAndPass<rustc_lint[ab8d78263ddfc922]::late::RuntimeCombinedLateLintPass> as rustc_hir[71d429f827444320]::intravisit::Visitor>::visit_nested_item
  37:     0x7f8b951fcb48 - rustc_hir[71d429f827444320]::intravisit::walk_mod::<rustc_lint[ab8d78263ddfc922]::late::LateContextAndPass<rustc_lint[ab8d78263ddfc922]::late::RuntimeCombinedLateLintPass>>
  38:     0x7f8b94450db3 - rustc_lint[ab8d78263ddfc922]::late::late_lint_crate::<rustc_lint[ab8d78263ddfc922]::BuiltinCombinedLateLintPass>
  39:     0x7f8b94450022 - <rustc_session[4fc2ae9e63ee7171]::session::Session>::time::<(), rustc_lint[ab8d78263ddfc922]::late::check_crate<rustc_lint[ab8d78263ddfc922]::BuiltinCombinedLateLintPass, rustc_interface[e0418be0553a28c9]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}::{closure#0}>
  40:     0x7f8b944ba8c2 - <rustc_session[4fc2ae9e63ee7171]::session::Session>::time::<(), rustc_interface[e0418be0553a28c9]::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}>
  41:     0x7f8b9452937f - <core[749018e742f43565]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[e0418be0553a28c9]::passes::analysis::{closure#5}::{closure#1}> as core[749018e742f43565]::ops::function::FnOnce<()>>::call_once
  42:     0x7f8b93406428 - <rustc_session[4fc2ae9e63ee7171]::session::Session>::time::<(), rustc_interface[e0418be0553a28c9]::passes::analysis::{closure#5}>
  43:     0x7f8b93402eb6 - rustc_interface[e0418be0553a28c9]::passes::analysis
  44:     0x7f8b945c836e - rustc_query_system[9c3bda3f04ae13c3]::query::plumbing::try_execute_query::<rustc_query_impl[1f0746acf769e1f5]::queries::analysis, rustc_query_impl[1f0746acf769e1f5]::plumbing::QueryCtxt>
  45:     0x7f8b9485193a - <rustc_query_impl[1f0746acf769e1f5]::Queries as rustc_middle[356745a150da3aac]::ty::query::QueryEngine>::analysis
  46:     0x7f8b940e7d40 - <rustc_interface[e0418be0553a28c9]::passes::QueryContext>::enter::<rustc_driver[a3a58aad692ded1b]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>
  47:     0x7f8b940e6b41 - <rustc_interface[e0418be0553a28c9]::interface::Compiler>::enter::<rustc_driver[a3a58aad692ded1b]::run_compiler::{closure#1}::{closure#2}, core[749018e742f43565]::result::Result<core[749018e742f43565]::option::Option<rustc_interface[e0418be0553a28c9]::queries::Linker>, rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>
  48:     0x7f8b940e4c14 - rustc_span[2d977aba4a48af86]::with_source_map::<core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>, rustc_interface[e0418be0553a28c9]::interface::run_compiler<core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>, rustc_driver[a3a58aad692ded1b]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  49:     0x7f8b940e4724 - <scoped_tls[964654d9bfefaa53]::ScopedKey<rustc_span[2d977aba4a48af86]::SessionGlobals>>::set::<rustc_interface[e0418be0553a28c9]::interface::run_compiler<core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>, rustc_driver[a3a58aad692ded1b]::run_compiler::{closure#1}>::{closure#0}, core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>
  50:     0x7f8b940e3e22 - std[e5194df39356a98b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e0418be0553a28c9]::util::run_in_thread_pool_with_globals<rustc_interface[e0418be0553a28c9]::interface::run_compiler<core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>, rustc_driver[a3a58aad692ded1b]::run_compiler::{closure#1}>::{closure#0}, core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>
  51:     0x7f8b940e3bca - <<std[e5194df39356a98b]::thread::Builder>::spawn_unchecked_<rustc_interface[e0418be0553a28c9]::util::run_in_thread_pool_with_globals<rustc_interface[e0418be0553a28c9]::interface::run_compiler<core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>, rustc_driver[a3a58aad692ded1b]::run_compiler::{closure#1}>::{closure#0}, core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[749018e742f43565]::result::Result<(), rustc_errors[9a263acecc8f02b5]::ErrorGuaranteed>>::{closure#1} as core[749018e742f43565]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:     0x7f8b91b72bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1faedbb3aa636d41
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/alloc/src/boxed.rs:1988:9
  53:     0x7f8b91b72bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h671735cb50e79975
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/alloc/src/boxed.rs:1988:9
  54:     0x7f8b91b72bd3 - std::sys::unix::thread::Thread::new::thread_start::hb5bc489c52ec14fd
                               at /rustc/0726909f6d219951ba15ac2f65656eff96bb1867/library/std/src/sys/unix/thread.rs:108:17
  55:     0x7f8b9181c8fd - <unknown>
  56:     0x7f8b9189ea60 - <unknown>
  57:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.68 (0726909 2023-01-21)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-clippy Area: Clippy labels Jan 21, 2023
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Jan 21, 2023

Smaller repro that doesn't require any features
./tests/ui/chalkify/lower_env2.rs

trait Foo { }

struct S<'a, T: ?Sized> where T: Foo {
    data: &'a T,
}

fn bar<T: Foo>(_x: S<'_, T>) { // note that we have an implicit `T: Sized` bound
}

fn main() {
}

./tests/ui/issues/issue-13703.rs

pub struct Foo<'a, 'b: 'a> { foo: &'a &'b isize }
pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<&   &   ()>) { let _y = x.foo; }
fn main() {}

@compiler-errors compiler-errors self-assigned this Jan 24, 2023
@matthiaskrgr
Copy link
Member Author

Any updates? 🙃

@compiler-errors
Copy link
Member

I'll fix this today

@rustbot claim

@compiler-errors
Copy link
Member

Minimized:

struct Foo<'a>(&'a [(); 100]);

fn test(x: Foo<'_>) {}

fn main() {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
3 participants