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 with clippy::undocumented_unsafe_blocks #7868

Closed
dylni opened this issue Oct 23, 2021 · 4 comments · Fixed by #7891
Closed

ICE with clippy::undocumented_unsafe_blocks #7868

dylni opened this issue Oct 23, 2021 · 4 comments · Fixed by #7891
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@dylni
Copy link

dylni commented Oct 23, 2021

Code

main.rs:

#![warn(clippy::undocumented_unsafe_blocks)]

mod zero;

fn main() {}

zero.rs:

fn zero() {
    unsafe { 0 };
}

Meta

Rust version (rustc -v):

rustc 1.58.0-nightly (514b38779 2021-10-22)

Error output

thread 'rustc' panicked at 'byte index 36 is out of bounds of `fn zero() {
    unsafe { 0 };
}
`', src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs:149:23
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-clippy/issues/new

note: Clippy version: clippy 0.1.58 (514b387 2021-10-22)

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

 0: rust_begin_unwind
           at /rustc/514b3877956dc594823106b66c164f8cdbc8b3da/library/std/src/panicking.rs:495:5
 1: core::panicking::panic_fmt
           at /rustc/514b3877956dc594823106b66c164f8cdbc8b3da/library/core/src/panicking.rs:107:14
 2: core::str::slice_error_fail
 3: clippy_lints::undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::block_has_safety_comment
 4: <clippy_lints::undocumented_unsafe_blocks::UndocumentedUnsafeBlocks as rustc_lint::passes::LateLintPass>::check_block
 5: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_block
 6: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_block
 7: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_expr
 8: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_stmt
 9: rustc_hir::intravisit::walk_block
10: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_block
11: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_expr
12: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_nested_body
13: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_fn
14: rustc_hir::intravisit::walk_item
15: rustc_hir::intravisit::Visitor::visit_nested_item
16: rustc_hir::intravisit::walk_mod
17: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_mod
18: rustc_hir::intravisit::Visitor::visit_nested_item
19: rustc_hir::intravisit::walk_mod
20: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_mod
21: rustc_middle::hir::map::Map::walk_toplevel_module
22: rustc_lint::late::late_lint_pass_crate
23: rustc_session::utils::<impl rustc_session::session::Session>::time
24: rustc_session::utils::<impl rustc_session::session::Session>::time
25: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
26: rustc_session::utils::<impl rustc_session::session::Session>::time
27: rustc_interface::passes::analysis
28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
29: rustc_data_structures::stack::ensure_sufficient_stack
30: rustc_query_system::query::plumbing::try_execute_query
31: rustc_query_system::query::plumbing::get_query
32: rustc_interface::passes::QueryContext::enter
33: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
34: rustc_span::with_source_map
35: scoped_tls::ScopedKey<T>::set

@dylni dylni added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Oct 23, 2021
@bors bors closed this as completed in 7788af9 Oct 28, 2021
@calebzulawski
Copy link
Member

I'm still getting this error when I use clippy on portable-simd after enabling this lint (https://github.com/rust-lang/portable-simd)

@giraffate
Copy link
Contributor

This fix has just been synced to rustc at rust-lang/rust#90564, so you may not get the latest one yet.

@calebzulawski
Copy link
Member

calebzulawski commented Nov 5, 2021

Whoops--you are right. I actually built from source, but I was accidentally using the wrong toolchain (not the rust-toolchain override). Though I did find a new ICE with this lint, which I can report in a new issue...

@calebzulawski
Copy link
Member

Opened #7934

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

Successfully merging a pull request may close this issue.

3 participants