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: None in shadow.rs #8748

Closed
matthiaskrgr opened this issue Apr 25, 2022 · 5 comments
Closed

ICE: None in shadow.rs #8748

matthiaskrgr opened this issue Apr 25, 2022 · 5 comments
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 25, 2022

Summary

fn main() {
    let _ = [0; {
        let x = 1;
        if let Some(x) = Some(1) { x } else { 1 }
    }];
}

Version

rustc 1.62.0-nightly (18f314e70 2022-04-24)
binary: rustc
commit-hash: 18f314e7027fe7084aaab8620c624a0d7bd29e70
commit-date: 2022-04-24
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

Error output

Backtrace

warning: unused variable: `x`
--> cb66bc75309b63447612744c4a239e29380f01e0.rs:5:13
|
5 |         let x = 1;
|             ^ help: if this is intentional, prefix it with an underscore: `_x`
|
= note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/clippy/clippy_lints/src/shadow.rs:163:51
stack backtrace:
 0:     0x7f5e4fe9defd - std::backtrace_rs::backtrace::libunwind::trace::h939d3743a8b21a10
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
 1:     0x7f5e4fe9defd - std::backtrace_rs::backtrace::trace_unsynchronized::ha4a90ff774c16a42
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7f5e4fe9defd - std::sys_common::backtrace::_print_fmt::h91737d9294627e79
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/sys_common/backtrace.rs:66:5
 3:     0x7f5e4fe9defd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h10fe8bd9ff48e1b2
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/sys_common/backtrace.rs:45:22
 4:     0x7f5e4fef9c7c - core::fmt::write::h2f1ffef1b8b3ecdb
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/core/src/fmt/mod.rs:1194:17
 5:     0x7f5e4fe8f5f1 - std::io::Write::write_fmt::ha677b091a1b8cd93
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/io/mod.rs:1655:15
 6:     0x7f5e4fea0c15 - std::sys_common::backtrace::_print::h5ea24d25e5051738
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/sys_common/backtrace.rs:48:5
 7:     0x7f5e4fea0c15 - std::sys_common::backtrace::print::h5321ac51bc2d07aa
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/sys_common/backtrace.rs:35:9
 8:     0x7f5e4fea0c15 - std::panicking::default_hook::{{closure}}::h227bbb1b5187ba3a
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/panicking.rs:295:22
 9:     0x7f5e4fea0889 - std::panicking::default_hook::he030e42f064b493d
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/panicking.rs:314:9
10:     0x5646c8f26740 - clippy_driver[2836e1d8a3164605]::ICE_HOOK::{closure#0}::{closure#0}
11:     0x7f5e4fea13e6 - std::panicking::rust_panic_with_hook::h3cf1e389ae2148cd
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/panicking.rs:702:17
12:     0x7f5e4fea11a9 - std::panicking::begin_panic_handler::{{closure}}::h0a5f32b79c6e3a95
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/panicking.rs:586:13
13:     0x7f5e4fe9e3b4 - std::sys_common::backtrace::__rust_end_short_backtrace::h6d640bca5165509c
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/sys_common/backtrace.rs:138:18
14:     0x7f5e4fea0f19 - rust_begin_unwind
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/panicking.rs:584:5
15:     0x7f5e4fe66213 - core::panicking::panic_fmt::h1c34501c4b8544a1
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/core/src/panicking.rs:142:14
16:     0x7f5e4fe660dd - core::panicking::panic::h0b2eafa98acfd26f
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/core/src/panicking.rs:48:5
17:     0x5646c8f93bf3 - <clippy_lints[b0bf1e50092dbf8d]::shadow::Shadow as rustc_lint[e31bc90e03ba5811]::passes::LateLintPass>::check_pat
18:     0x7f5e514ccb04 - <rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects as rustc_lint[e31bc90e03ba5811]::passes::LateLintPass>::check_pat
19:     0x7f5e507ac86a - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_pat
20:     0x7f5e507af7b2 - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_pat::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
21:     0x7f5e507ae5ce - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_let_expr::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
22:     0x7f5e507abf8b - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_expr
23:     0x7f5e507af9ce - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_expr::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
24:     0x7f5e507abf8b - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_expr
25:     0x7f5e507ac0f9 - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_block
26:     0x7f5e507abf8b - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_expr
27:     0x7f5e507ac4a4 - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_nested_body
28:     0x7f5e507abf8b - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_expr
29:     0x7f5e507ae07b - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_local::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
30:     0x7f5e507ac17b - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_local
31:     0x7f5e507adfa7 - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_block::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
32:     0x7f5e507ac0f9 - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_block
33:     0x7f5e507abf8b - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_expr
34:     0x7f5e507ac4a4 - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_nested_body
35:     0x7f5e507ac6f5 - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_fn
36:     0x7f5e507afd83 - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_item::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
37:     0x7f5e507ad2b4 - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_nested_item
38:     0x7f5e507af5a7 - rustc_hir[2af9a4742c4c2e28]::intravisit::walk_mod::<rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>>
39:     0x7f5e507ac81c - <rustc_lint[e31bc90e03ba5811]::late::LateContextAndPass<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects> as rustc_hir[2af9a4742c4c2e28]::intravisit::Visitor>::visit_mod
40:     0x7f5e507aacfe - rustc_lint[e31bc90e03ba5811]::late::late_lint_pass_crate::<rustc_lint[e31bc90e03ba5811]::late::LateLintPassObjects>
41:     0x7f5e51995371 - rustc_lint[e31bc90e03ba5811]::late::late_lint_crate::<rustc_lint[e31bc90e03ba5811]::BuiltinCombinedLateLintPass>
42:     0x7f5e52721a56 - rustc_data_structures[aac45c5228699a3f]::sync::join::<rustc_lint[e31bc90e03ba5811]::late::check_crate<rustc_lint[e31bc90e03ba5811]::BuiltinCombinedLateLintPass, rustc_interface[2bcbc0074c3d12f8]::passes::analysis::{closure#5}::{closure#0}::{closure#2}::{closure#0}::{closure#0}>::{closure#0}, rustc_lint[e31bc90e03ba5811]::late::check_crate<rustc_lint[e31bc90e03ba5811]::BuiltinCombinedLateLintPass, rustc_interface[2bcbc0074c3d12f8]::passes::analysis::{closure#5}::{closure#0}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}, (), ()>
43:     0x7f5e5271f890 - <rustc_session[5031ba600ca320a6]::session::Session>::time::<(), rustc_interface[2bcbc0074c3d12f8]::passes::analysis::{closure#5}::{closure#0}::{closure#2}::{closure#0}>
44:     0x7f5e52739d5d - <core[2e8b3e7717192d8]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[2bcbc0074c3d12f8]::passes::analysis::{closure#5}::{closure#0}> as core[2e8b3e7717192d8]::ops::function::FnOnce<()>>::call_once
45:     0x7f5e52721268 - <rustc_session[5031ba600ca320a6]::session::Session>::time::<(), rustc_interface[2bcbc0074c3d12f8]::passes::analysis::{closure#5}>
46:     0x7f5e5271cefc - rustc_interface[2bcbc0074c3d12f8]::passes::analysis
47:     0x7f5e52be09c4 - rustc_query_system[e57d0b2d85dc560a]::query::plumbing::try_execute_query::<rustc_query_impl[1512d41c813fb0ae]::plumbing::QueryCtxt, rustc_query_system[e57d0b2d85dc560a]::query::caches::DefaultCache<(), core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>>
48:     0x7f5e52c217de - rustc_query_system[e57d0b2d85dc560a]::query::plumbing::get_query::<rustc_query_impl[1512d41c813fb0ae]::queries::analysis, rustc_query_impl[1512d41c813fb0ae]::plumbing::QueryCtxt>
49:     0x7f5e526f88c7 - <rustc_interface[2bcbc0074c3d12f8]::passes::QueryContext>::enter::<rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>
50:     0x7f5e526e3508 - <rustc_interface[2bcbc0074c3d12f8]::interface::Compiler>::enter::<rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}::{closure#2}, core[2e8b3e7717192d8]::result::Result<core[2e8b3e7717192d8]::option::Option<rustc_interface[2bcbc0074c3d12f8]::queries::Linker>, rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>
51:     0x7f5e5270ce4f - rustc_span[40d501108594b357]::with_source_map::<core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>, rustc_interface[2bcbc0074c3d12f8]::interface::create_compiler_and_run<core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>, rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}>::{closure#1}>
52:     0x7f5e526e4174 - rustc_interface[2bcbc0074c3d12f8]::interface::create_compiler_and_run::<core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>, rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}>
53:     0x7f5e526e0a11 - <scoped_tls[3e1d08058305613c]::ScopedKey<rustc_span[40d501108594b357]::SessionGlobals>>::set::<rustc_interface[2bcbc0074c3d12f8]::interface::run_compiler<core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>, rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}>::{closure#0}, core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>
54:     0x7f5e526f9fbf - std[3626c7d336dcad5f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2bcbc0074c3d12f8]::util::run_in_thread_pool_with_globals<rustc_interface[2bcbc0074c3d12f8]::interface::run_compiler<core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>, rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}>::{closure#0}, core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>::{closure#0}, core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>
55:     0x7f5e526fa0f9 - <<std[3626c7d336dcad5f]::thread::Builder>::spawn_unchecked_<rustc_interface[2bcbc0074c3d12f8]::util::run_in_thread_pool_with_globals<rustc_interface[2bcbc0074c3d12f8]::interface::run_compiler<core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>, rustc_driver[53a0486c6d04b84b]::run_compiler::{closure#1}>::{closure#0}, core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>::{closure#0}, core[2e8b3e7717192d8]::result::Result<(), rustc_errors[cc710da0c834f823]::ErrorGuaranteed>>::{closure#1} as core[2e8b3e7717192d8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
56:     0x7f5e4feab333 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5f4d59ae47de3c76
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/alloc/src/boxed.rs:1866:9
57:     0x7f5e4feab333 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc3d73b574ff0f9d5
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/alloc/src/boxed.rs:1866:9
58:     0x7f5e4feab333 - std::sys::unix::thread::Thread::new::thread_start::h7164ed46a21eef8d
                             at /rustc/18f314e7027fe7084aaab8620c624a0d7bd29e70/library/std/src/sys/unix/thread.rs:108:17
59:     0x7f5e4fc835c2 - start_thread
60:     0x7f5e4fd08584 - __clone
61:                0x0 - <unknown>

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-clippy/issues/new

note: Clippy version: clippy 0.1.62 (18f314e 2022-04-24)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
warning: 1 warning emitted

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 25, 2022
@b-ncMN
Copy link
Contributor

b-ncMN commented May 13, 2022

I want to take a look at this
Does anyone know if this has a fix to it already ?

@llogiq
Copy link
Contributor

llogiq commented May 14, 2022

I'm on mobile right now, but you can check if the shadow tests or the ice tests contain the above or a similar example (in the latter case, check the issue number). If no, you could at least make a PR to add the missing test, and perhaps a fix if the test fails.

@matthiaskrgr
Copy link
Member Author

Nope, not fixed yet, all yours, if you want 😉

@b-ncMN
Copy link
Contributor

b-ncMN commented May 14, 2022

@rustbot claim

@b-ncMN
Copy link
Contributor

b-ncMN commented May 16, 2022

Is there another way to reproduce than building rustc entirely to stage2 with the clippy component ?
I will probably need to edit rustc code and do some debugging so, nvm

I've been unable to have a clippy component successfully built with my rust custom toolchain :

error: 'cargo-clippy' is not installed for the toolchain 'test'
note: this is a custom toolchain, which cannot use `rustup component add`
help: if you built this toolchain from source, and used `rustup toolchain link`, then you may be able to build the component with `x.py`

even though my config specifies the clippy tool

# Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
changelog-seen = 2
[build]
extended = true
tools = ["clippy"]

b-ncMN added a commit to b-ncMN/rust-clippy that referenced this issue May 29, 2022
@b-ncMN b-ncMN mentioned this issue May 29, 2022
b-ncMN added a commit to b-ncMN/rust-clippy that referenced this issue May 29, 2022
b-ncMN added a commit to b-ncMN/rust-clippy that referenced this issue May 29, 2022
b-ncMN added a commit to b-ncMN/rust-clippy that referenced this issue May 30, 2022
bors added a commit that referenced this issue May 31, 2022
Fix #8748

Thank you for making Clippy better!

changelog: Fix ICE #8748 in shadow.rs
@bors bors closed this as completed in 0a7f19b May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants